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 (
|
||||
"mail_arg" => array ("request", "integer", ""), // from mail_add.php in case of error
|
||||
"domain_id" => array ("request", "integer", ""),
|
||||
"show_systemmails" => array ("request", "integer", ""),
|
||||
"search" => array ("request", "string", ""),
|
||||
"offset" => array ("request", "integer", 0),
|
||||
"count" => array ("request", "integer", 50),
|
||||
|
@ -46,7 +47,7 @@ if(!$domain_id ) {
|
|||
$fatal=false;
|
||||
|
||||
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();
|
||||
}
|
||||
} else {
|
||||
|
@ -54,7 +55,6 @@ if ($domain=$dom->get_domain_byid($domain_id)) {
|
|||
$fatal=true;
|
||||
}
|
||||
|
||||
|
||||
if ($fatal) {
|
||||
echo "<div class=\"error\">$error</div>";
|
||||
} 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="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" />
|
||||
</form>
|
||||
</td><td>
|
||||
<?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">
|
||||
<input type="hidden" name="domain_id" value="<?php echo $domain_id; ?>" />
|
||||
<input type="hidden" name="offset" value="0" />
|
||||
|
@ -138,14 +142,14 @@ while (list($key,$val)=each($mails_list)){
|
|||
<?php } ?>
|
||||
<td class="<?php echo $grey; ?>" style="text-align:right"><?php echo $val["address"]."@".$domain ?></td>
|
||||
<?php if ($val["type"]) { ?>
|
||||
<td colspan="2"><?php echo $val["typedata"]; ?></td>
|
||||
<td colspan="3"><?php echo $val["typedata"]; ?></td>
|
||||
<?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 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"]);
|
||||
} ?></td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
<?php
|
||||
$i++;
|
||||
|
|
|
@ -131,12 +131,13 @@ class m_mail {
|
|||
$db->query("SELECT domaines.id,domaines.domaine, IFNULL(mail, 0) as nb_mail
|
||||
FROM domaines
|
||||
LEFT JOIN
|
||||
(SELECT address.id, COUNT(*) AS mail
|
||||
FROM address
|
||||
WHERE type=''
|
||||
GROUP BY address.domain_id) lol
|
||||
USING (id)
|
||||
WHERE COMPTE={$uid}");
|
||||
(SELECT address.id, COUNT(*) AS mail
|
||||
FROM address
|
||||
WHERE type=''
|
||||
GROUP BY address.domain_id) subreq
|
||||
USING (id)
|
||||
WHERE COMPTE={$uid}
|
||||
order by domaines.domaine");
|
||||
$this->enum_domains=array();
|
||||
while($db->next_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.
|
||||
* @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;
|
||||
$err->log("mail","enum_domains_mail");
|
||||
|
||||
|
@ -190,6 +191,7 @@ class m_mail {
|
|||
|
||||
$where="a.domain_id=$dom_id";
|
||||
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->next_record();
|
||||
$this->total=$db->f("total");
|
||||
|
@ -206,8 +208,8 @@ class m_mail {
|
|||
$details=$db->Record;
|
||||
// if necessary, fill the typedata with data from hooks ...
|
||||
if ($details["type"]) {
|
||||
$result=$hooks->invoke("hook_mail_get_details",array($details["id"])); // Will fill typedata if necessary
|
||||
$details["typedata"]=implode("<br />",$result);
|
||||
$result=$hooks->invoke("hook_mail_get_details",array($details["id"])); // Will fill typedata if necessary
|
||||
$details["typedata"]=implode("<br />",$result);
|
||||
}
|
||||
$res[]=$details;
|
||||
} while ($db->next_record());
|
||||
|
|
Loading…
Reference in New Issue