Adding mail class listing functionnality to show "system mail" (mailman etc..)
This commit is contained in:
parent
3cd65a99d6
commit
0037b747ad
|
@ -29,6 +29,7 @@ include_once("head.php");
|
||||||
$fields = array (
|
$fields = array (
|
||||||
"mail_arg" => array ("request", "integer", ""), // from mail_add.php in case of error
|
"mail_arg" => array ("request", "integer", ""), // from mail_add.php in case of error
|
||||||
"domain_id" => array ("request", "integer", ""),
|
"domain_id" => array ("request", "integer", ""),
|
||||||
|
"show_systemmails" => array ("request", "integer", ""),
|
||||||
"search" => array ("request", "string", ""),
|
"search" => array ("request", "string", ""),
|
||||||
"offset" => array ("request", "integer", 0),
|
"offset" => array ("request", "integer", 0),
|
||||||
"count" => array ("request", "integer", 50),
|
"count" => array ("request", "integer", 50),
|
||||||
|
@ -46,7 +47,7 @@ if(!$domain_id ) {
|
||||||
$fatal=false;
|
$fatal=false;
|
||||||
|
|
||||||
if ($domain=$dom->get_domain_byid($domain_id)) {
|
if ($domain=$dom->get_domain_byid($domain_id)) {
|
||||||
if(!($mails_list = $mail->enum_domain_mails($domain_id,$search,$offset,$count))) {
|
if(!($mails_list = $mail->enum_domain_mails($domain_id,$search,$offset,$count,$show_systemmails))) {
|
||||||
$error=$err->errstr();
|
$error=$err->errstr();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -54,7 +55,6 @@ if ($domain=$dom->get_domain_byid($domain_id)) {
|
||||||
$fatal=true;
|
$fatal=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($fatal) {
|
if ($fatal) {
|
||||||
echo "<div class=\"error\">$error</div>";
|
echo "<div class=\"error\">$error</div>";
|
||||||
} else {
|
} else {
|
||||||
|
@ -92,10 +92,14 @@ if (isset($error) && !empty($error)) {
|
||||||
<input type="hidden" name="domain_id" value="<?php echo $domain_id; ?>" />
|
<input type="hidden" name="domain_id" value="<?php echo $domain_id; ?>" />
|
||||||
<input type="hidden" name="offset" value="0" />
|
<input type="hidden" name="offset" value="0" />
|
||||||
<span class="int intleft"><img alt="<?php __("Search"); ?>" title="<?php __("Search"); ?>" src="/images/search.png" style="vertical-align: middle"/> </span><input type="text" name="search" value="<?php ehe($search); ?>" size="20" maxlength="64" class="int intright" />
|
<span class="int intleft"><img alt="<?php __("Search"); ?>" title="<?php __("Search"); ?>" src="/images/search.png" style="vertical-align: middle"/> </span><input type="text" name="search" value="<?php ehe($search); ?>" size="20" maxlength="64" class="int intright" />
|
||||||
</form>
|
|
||||||
</td><td>
|
</td><td>
|
||||||
<?php pager($offset,$count,$mail->total,"mail_list.php?domain_id=".$domain_id."&count=".$count."&search=".urlencode($search)."&offset=%%offset%%"); ?>
|
<?php pager($offset,$count,$mail->total,"mail_list.php?domain_id=".$domain_id."&count=".$count."&search=".urlencode($search)."&offset=%%offset%%"); ?>
|
||||||
</td><td style="text-align:right">
|
</td>
|
||||||
|
<td style="text-align:center">
|
||||||
|
<input type="checkbox" id="show_systemmails" name="show_systemmails" <?php if($show_systemmails) {echo "checked";}?> value="1"><label for="show_systemmails" onclick="document.form['formlist1'].submit();"><?php __("Show system emails");?></label>
|
||||||
|
</td>
|
||||||
|
</form>
|
||||||
|
<td style="text-align:right">
|
||||||
<form method="get" name="formlist2" id="formlist2" action="mail_list.php">
|
<form method="get" name="formlist2" id="formlist2" action="mail_list.php">
|
||||||
<input type="hidden" name="domain_id" value="<?php echo $domain_id; ?>" />
|
<input type="hidden" name="domain_id" value="<?php echo $domain_id; ?>" />
|
||||||
<input type="hidden" name="offset" value="0" />
|
<input type="hidden" name="offset" value="0" />
|
||||||
|
@ -138,14 +142,14 @@ while (list($key,$val)=each($mails_list)){
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<td class="<?php echo $grey; ?>" style="text-align:right"><?php echo $val["address"]."@".$domain ?></td>
|
<td class="<?php echo $grey; ?>" style="text-align:right"><?php echo $val["address"]."@".$domain ?></td>
|
||||||
<?php if ($val["type"]) { ?>
|
<?php if ($val["type"]) { ?>
|
||||||
<td colspan="2"><?php echo $val["typedata"]; ?></td>
|
<td colspan="3"><?php echo $val["typedata"]; ?></td>
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
<td class="<?php echo $grey; ?>"><?php if ($val["islocal"]) echo format_size($val["used"])."/".format_size($val["quotabytes"]); else __("No"); ?></td>
|
<td class="<?php echo $grey; ?>"><?php if ($val["islocal"]) echo format_size($val["used"])."/".format_size($val["quotabytes"]); else __("No"); ?></td>
|
||||||
<td class="<?php echo $grey; ?>"><?php echo $val["recipients"]; /* TODO : if >60chars, use "..." + js close/open */ ?></td>
|
<td class="<?php echo $grey; ?>"><?php echo $val["recipients"]; /* TODO : if >60chars, use "..." + js close/open */ ?></td>
|
||||||
<?php } ?>
|
|
||||||
<td class="<?php echo $grey; ?>"><?php if ($val["islocal"]) {
|
<td class="<?php echo $grey; ?>"><?php if ($val["islocal"]) {
|
||||||
if (date("Y-m-d")==substr($val["lastlogin"],0,10)) echo substr($val["lastlogin"],11,5); else if (substr($val["lastlogin"],0,10)=="0000-00-00") __("Never"); else echo format_date(_('%3$d-%2$d-%1$d'),$val["lastlogin"]);
|
if (date("Y-m-d")==substr($val["lastlogin"],0,10)) echo substr($val["lastlogin"],11,5); else if (substr($val["lastlogin"],0,10)=="0000-00-00") __("Never"); else echo format_date(_('%3$d-%2$d-%1$d'),$val["lastlogin"]);
|
||||||
} ?></td>
|
} ?></td>
|
||||||
|
<?php } ?>
|
||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
$i++;
|
$i++;
|
||||||
|
|
|
@ -134,9 +134,10 @@ class m_mail {
|
||||||
(SELECT address.id, COUNT(*) AS mail
|
(SELECT address.id, COUNT(*) AS mail
|
||||||
FROM address
|
FROM address
|
||||||
WHERE type=''
|
WHERE type=''
|
||||||
GROUP BY address.domain_id) lol
|
GROUP BY address.domain_id) subreq
|
||||||
USING (id)
|
USING (id)
|
||||||
WHERE COMPTE={$uid}");
|
WHERE COMPTE={$uid}
|
||||||
|
order by domaines.domaine");
|
||||||
$this->enum_domains=array();
|
$this->enum_domains=array();
|
||||||
while($db->next_record()){
|
while($db->next_record()){
|
||||||
$this->enum_domains[]=$db->Record;
|
$this->enum_domains[]=$db->Record;
|
||||||
|
@ -182,7 +183,7 @@ class m_mail {
|
||||||
* @param $count integer return no more than THAT much emails. -1 for ALL. Offset is ignored then.
|
* @param $count integer return no more than THAT much emails. -1 for ALL. Offset is ignored then.
|
||||||
* @result an array of each mail hosted under the domain.
|
* @result an array of each mail hosted under the domain.
|
||||||
*/
|
*/
|
||||||
function enum_domain_mails($dom_id = null, $search="", $offset=0, $count=30){
|
function enum_domain_mails($dom_id = null, $search="", $offset=0, $count=30, $show_systemmails=false){
|
||||||
global $db,$err,$cuid,$hooks;
|
global $db,$err,$cuid,$hooks;
|
||||||
$err->log("mail","enum_domains_mail");
|
$err->log("mail","enum_domains_mail");
|
||||||
|
|
||||||
|
@ -190,6 +191,7 @@ class m_mail {
|
||||||
|
|
||||||
$where="a.domain_id=$dom_id";
|
$where="a.domain_id=$dom_id";
|
||||||
if ($search) $where.=" AND (a.address LIKE '%".addslashes($search)."%' OR r.recipients LIKE '%".addslashes($search)."%')";
|
if ($search) $where.=" AND (a.address LIKE '%".addslashes($search)."%' OR r.recipients LIKE '%".addslashes($search)."%')";
|
||||||
|
if (!$show_systemmails) $where.=" AND type='' ";
|
||||||
$db->query("SELECT count(a.id) AS total FROM address a LEFT JOIN recipient r ON r.address_id=a.id WHERE $where;");
|
$db->query("SELECT count(a.id) AS total FROM address a LEFT JOIN recipient r ON r.address_id=a.id WHERE $where;");
|
||||||
$db->next_record();
|
$db->next_record();
|
||||||
$this->total=$db->f("total");
|
$this->total=$db->f("total");
|
||||||
|
|
Loading…
Reference in New Issue