delete / undelete of emails now working. need cron for pop deletion
This commit is contained in:
		
							parent
							
								
									a022ae4ae3
								
							
						
					
					
						commit
						8487d68bb1
					
				|  | @ -258,6 +258,7 @@ bureau/admin/mail_localbox_edit.inc.php -text | ||||||
| bureau/admin/mail_properties.php -text | bureau/admin/mail_properties.php -text | ||||||
| bureau/admin/mail_redirection_doedit.php -text | bureau/admin/mail_redirection_doedit.php -text | ||||||
| bureau/admin/mail_redirection_edit.inc.php -text | bureau/admin/mail_redirection_edit.inc.php -text | ||||||
|  | bureau/admin/mail_undelete.php -text | ||||||
| bureau/admin/main.php -text | bureau/admin/main.php -text | ||||||
| bureau/admin/mem_admin.php -text | bureau/admin/mem_admin.php -text | ||||||
| bureau/admin/mem_chgmail.php -text | bureau/admin/mem_chgmail.php -text | ||||||
|  |  | ||||||
|  | @ -27,7 +27,7 @@ require_once("../class/config.php"); | ||||||
| 
 | 
 | ||||||
| $fields = array ( | $fields = array ( | ||||||
| 	"d"    => array ("request", "array", ""), | 	"d"    => array ("request", "array", ""), | ||||||
| 	"domain"  => array ("request", "string", ""), | 	"domain_id"  => array ("request", "integer", ""), | ||||||
| 	"confirm" => array("request", "string", "n"), | 	"confirm" => array("request", "string", "n"), | ||||||
| ); | ); | ||||||
| getFields($fields); | getFields($fields); | ||||||
|  | @ -41,16 +41,19 @@ reset($d); | ||||||
| include_once ("head.php"); | include_once ("head.php"); | ||||||
| 
 | 
 | ||||||
| if ($confirm=="y") { | if ($confirm=="y") { | ||||||
| 
 |   $error=""; | ||||||
| while (list($key,$val)=each($d)) { |   while (list($key,$val)=each($d)) { | ||||||
| 	if (!$mail->del_mail($val)) { |     $mail->delete($val); | ||||||
| 		$error.=sprintf(_("The email address <b>%s</b> does not exist!")."<br />",$val); |     $error.=$err->errstr()."<br />";  | ||||||
| 	} else { |     /* | ||||||
| 		$error.=sprintf(_("The email address <b>%s</b> has been deleted!")."<br />",$val);  |       $error.=$err->errstr()."<br />"; //sprintf(_("The email address <b>%s</b> does not exist!")."<br />",$val);
 | ||||||
| 	} |     } else { | ||||||
| } |       $error.=sprintf(_("The email address <b>%s</b> has been deleted!")."<br />",$val);  | ||||||
| include("mail_list.php"); |       } | ||||||
|  exit(); |     */ | ||||||
|  |   } | ||||||
|  |   include("mail_list.php"); | ||||||
|  |   exit(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| ?>
 | ?>
 | ||||||
|  | @ -63,13 +66,14 @@ include("mail_list.php"); | ||||||
| <form method="post" action="mail_del.php" id="main"> | <form method="post" action="mail_del.php" id="main"> | ||||||
| <p> | <p> | ||||||
| <input type="hidden" name="confirm" value="y" /> | <input type="hidden" name="confirm" value="y" /> | ||||||
| <input type="hidden" name="domain" value="<?php echo $domain; ?>" /> | <input type="hidden" name="domain_id" value="<?php echo $domain_id; ?>" /> | ||||||
| 
 | 
 | ||||||
| <?php | <?php | ||||||
| 
 | 
 | ||||||
| while (list($key,$val)=each($d)) { | while (list($key,$val)=each($d)) { | ||||||
|  |   $m=$mail->get_details($val); | ||||||
|   echo "<input type=\"hidden\" name=\"d[]\" value=\"$val\" />";
 |   echo "<input type=\"hidden\" name=\"d[]\" value=\"$val\" />";
 | ||||||
|   echo $val."<br />"; |   echo $m["address"]."@".$m["domain"]."<br />"; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| ?>
 | ?>
 | ||||||
|  |  | ||||||
|  | @ -95,6 +95,7 @@ if (empty($mails_list)){ // If there is no mail for this domain | ||||||
| </fieldset> | </fieldset> | ||||||
| 
 | 
 | ||||||
| <form method="post" action="mail_del.php"> | <form method="post" action="mail_del.php"> | ||||||
|  |  <input type="hidden" name="domain_id" value="<?php echo $domain_id; ?>" /> | ||||||
| <table class="tlist"> | <table class="tlist"> | ||||||
| <tr><th></th><th></th><th><?php __("Enabled");?></th><th style="text-align:right"><?php __("Address"); ?></th><th><?php __("Pop/Imap"); ?></th><th><?php __("Other recipients"); ?></th><th><?php __("Last login time"); ?></th></tr>
 | <tr><th></th><th></th><th><?php __("Enabled");?></th><th style="text-align:right"><?php __("Address"); ?></th><th><?php __("Pop/Imap"); ?></th><th><?php __("Other recipients"); ?></th><th><?php __("Last login time"); ?></th></tr>
 | ||||||
| <?php | <?php | ||||||
|  | @ -102,16 +103,22 @@ if (empty($mails_list)){ // If there is no mail for this domain | ||||||
| $col=1; $i=0; | $col=1; $i=0; | ||||||
| //listing of every mail of the current domain.
 | //listing of every mail of the current domain.
 | ||||||
| while (list($key,$val)=each($mails_list)){ | while (list($key,$val)=each($mails_list)){ | ||||||
| 	$col=3-$col; |   $col=3-$col; $grey=""; | ||||||
| 	?>
 | 	?>
 | ||||||
| 	<tr class="lst<?php echo $col; ?>"> | 	<tr class="lst<?php echo $col; ?>"> | ||||||
| 	  <?php if (!$val["type"]) { ?>
 | 	   <?php if ($val["mail_action"]=="DELETING") { $grey="grey"; ?>
 | ||||||
|         <td align="center"> | 	  <td colspan="3"><?php __("Deleting..."); ?></td>
 | ||||||
| 	    <input class="inc" type="checkbox" id="del_<?php echo $i; ?>" name="d[]\" value="<?php ehe($val["address"]."@".$val["domain"]); ?>" />
 | 	  <?php } else if ($val["mail_action"]=="DELETE") { $grey="grey"; ?>
 | ||||||
|  | 	  <td></td> | ||||||
|  | 	  <td><div class="ina"><a href="mail_undelete.php?search=<?php ehe($search); ?>&offset=<?php ehe($offset); ?>&count=<?php ehe($count); ?>&domain_id=<?php ehe($domain_id);  ?>&mail_id=<?php echo $val["id"] ?>"><img src="images/undelete.png" alt="<?php __("Undelete"); ?>" /><?php __("Undelete"); ?></a></div></td>
 | ||||||
|  | 	  <td><img src="images/check_no.png" alt="<?php __("Disabled"); ?>" /></td>	   | ||||||
|  | 	  <?php } else if (!$val["type"]) { ?>
 | ||||||
|  |           <td align="center"> | ||||||
|  | 	    <input class="inc" type="checkbox" id="del_<?php echo $i; ?>" name="d[]" value="<?php ehe($val["id"]); ?>" /> | ||||||
| 	</td> | 	</td> | ||||||
| 	<td> | 	<td class="<?php echo $grey; ?>"> | ||||||
| 	  <div class="ina"><a href="mail_properties.php?mail_id=<?php echo $val["id"] ?>"><img src="images/edit.png" alt="<?php __("Edit"); ?>" /><?php __("Edit"); ?></a></div></td>
 | 	  <div class="ina"><a href="mail_properties.php?mail_id=<?php echo $val["id"] ?>"><img src="images/edit.png" alt="<?php __("Edit"); ?>" /><?php __("Edit"); ?></a></div></td>
 | ||||||
| 	<td><?php if ($val["enabled"] ) { ?>
 | 	<td class="<?php echo $grey; ?>"><?php if ($val["enabled"] ) { ?>
 | ||||||
| 			<img src="images/check_ok.png" alt="<?php __("Enabled"); ?>" /> | 			<img src="images/check_ok.png" alt="<?php __("Enabled"); ?>" /> | ||||||
| 		<?php } else { ?>
 | 		<?php } else { ?>
 | ||||||
| 			<img src="images/check_no.png" alt="<?php __("Disabled"); ?>" /> | 			<img src="images/check_no.png" alt="<?php __("Disabled"); ?>" /> | ||||||
|  | @ -120,14 +127,14 @@ while (list($key,$val)=each($mails_list)){ | ||||||
| 	<?php } else { ?>
 | 	<?php } else { ?>
 | ||||||
| 	<td colspan="3"></td> | 	<td colspan="3"></td> | ||||||
| 	<?php } ?>
 | 	<?php } ?>
 | ||||||
| 	<td 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="2"><?php echo $val["typedata"]; ?></td>
 | ||||||
| 	<?php } else { ?>
 | 	<?php } else { ?>
 | ||||||
| 	<td><?php if ($val["islocal"]) echo format_size($val["used"])."/".format_size($val["quota"]); else __("No"); ?></td>
 | 	<td class="<?php echo $grey; ?>"><?php if ($val["islocal"]) echo format_size($val["used"])."/".format_size($val["quota"]); else __("No"); ?></td>
 | ||||||
| 	<td><?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 } ?>
 | 	<?php } ?>
 | ||||||
|         <td><?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>
 | ||||||
| 	</tr> | 	</tr> | ||||||
|  |  | ||||||
|  | @ -0,0 +1,36 @@ | ||||||
|  | <?php | ||||||
|  | /* | ||||||
|  |  ---------------------------------------------------------------------- | ||||||
|  |  AlternC - Web Hosting System | ||||||
|  |  Copyright (C) 2000-2012 by the AlternC Development Team. | ||||||
|  |  https://alternc.org/ | ||||||
|  |  ---------------------------------------------------------------------- | ||||||
|  |  LICENSE | ||||||
|  | 
 | ||||||
|  |  This program is free software; you can redistribute it and/or | ||||||
|  |  modify it under the terms of the GNU General Public License (GPL) | ||||||
|  |  as published by the Free Software Foundation; either version 2 | ||||||
|  |  of the License, or (at your option) any later version. | ||||||
|  | 
 | ||||||
|  |  This program is distributed in the hope that it will be useful, | ||||||
|  |  but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
|  |  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||||
|  |  GNU General Public License for more details. | ||||||
|  | 
 | ||||||
|  |  To read the license please visit http://www.gnu.org/copyleft/gpl.html | ||||||
|  |  ---------------------------------------------------------------------- | ||||||
|  |  Purpose of file: undelete one mailbox | ||||||
|  |  ---------------------------------------------------------------------- | ||||||
|  | */ | ||||||
|  | require_once("../class/config.php"); | ||||||
|  | 
 | ||||||
|  | $fields = array ( | ||||||
|  | 	"mail_id"    => array ("request", "integer", ""), | ||||||
|  | ); | ||||||
|  | getFields($fields); | ||||||
|  | 
 | ||||||
|  | $mail->undelete($mail_id); | ||||||
|  | $error=$err->errstr(); | ||||||
|  | 
 | ||||||
|  | include("mail_list.php"); | ||||||
|  | 
 | ||||||
|  | @ -461,3 +461,6 @@ input#dir, input#sub_local { | ||||||
|     padding-top: 6px; |     padding-top: 6px; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | .grey { | ||||||
|  |     color: #999; | ||||||
|  | } | ||||||
|  | @ -1181,6 +1181,32 @@ class m_dom { | ||||||
|       return false; |       return false; | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |   /* ----------------------------------------------------------------- */ | ||||||
|  |   /** | ||||||
|  |    * Returns the id of a domain for the current user, from it's domain name | ||||||
|  |    * @param $domain string the domain name to search for | ||||||
|  |    * @return integer the domain id, or false with an error raised. | ||||||
|  |    */ | ||||||
|  |   function get_domain_byname($domain) { | ||||||
|  |     global $db,$err,$cuid; | ||||||
|  |     $domain=trim($domain); | ||||||
|  |     $db->query("SELECT id FROM domaines WHERE domaine='".addslashes($domain)."' AND compte=$cuid;"); | ||||||
|  |     if ($db->next_record()) { | ||||||
|  |       $id=$db->f("id"); | ||||||
|  |       if (!$id) { | ||||||
|  | 	$err->raise("dom",_("This domain is not installed in your account")); | ||||||
|  | 	return false; | ||||||
|  |       } else { | ||||||
|  | 	return $id; | ||||||
|  |       } | ||||||
|  |     } else { | ||||||
|  |       $err->raise("dom",_("This domain is not installed in your account")); | ||||||
|  |       return false; | ||||||
|  |     } | ||||||
|  |   } | ||||||
|    |    | ||||||
| 
 | 
 | ||||||
|   /* ----------------------------------------------------------------- */ |   /* ----------------------------------------------------------------- */ | ||||||
|  |  | ||||||
|  | @ -118,7 +118,7 @@ class m_mail { | ||||||
|     $db->next_record(); |     $db->next_record(); | ||||||
|     $this->total=$db->f("total"); |     $this->total=$db->f("total"); | ||||||
| 
 | 
 | ||||||
|     $db->query("SELECT a.id, a.address, a.password, a.enabled, d.domaine AS domain, m.quota*1024*1024 AS quota, m.bytes AS used, NOT ISNULL(m.id) AS islocal, a.type, r.recipients, m.lastlogin  
 |     $db->query("SELECT a.id, a.address, a.password, a.`enabled`, a.mail_action, d.domaine AS domain, m.quota*1024*1024 AS quota, m.bytes AS used, NOT ISNULL(m.id) AS islocal, a.type, r.recipients, m.lastlogin  
 | ||||||
|          FROM (address a LEFT JOIN mailbox m ON m.address_id=a.id) LEFT JOIN recipient r ON r.address_id=a.id, domaines d  |          FROM (address a LEFT JOIN mailbox m ON m.address_id=a.id) LEFT JOIN recipient r ON r.address_id=a.id, domaines d  | ||||||
|          WHERE $where AND d.id=a.domain_id  |          WHERE $where AND d.id=a.domain_id  | ||||||
|          LIMIT $offset,$count;");
 |          LIMIT $offset,$count;");
 | ||||||
|  | @ -142,7 +142,7 @@ class m_mail { | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|   /* ----------------------------------------------------------------- */ |   /* ----------------------------------------------------------------- */ | ||||||
|   /** Function used to insert a new mail into de the db |   /** Function used to insert a new mail into the db | ||||||
|    * should be used by the web interface, not by third-party programs. |    * should be used by the web interface, not by third-party programs. | ||||||
|    * |    * | ||||||
|    * This function calls the hook "hooks_mail_cancreate" |    * This function calls the hook "hooks_mail_cancreate" | ||||||
|  | @ -155,7 +155,7 @@ class m_mail { | ||||||
|    * or false if an error occured ($err is filled accordingly) |    * or false if an error occured ($err is filled accordingly) | ||||||
|    */  |    */  | ||||||
|   function create($dom_id, $mail){ |   function create($dom_id, $mail){ | ||||||
|     global $err,$db,$cuid,$quota,$dom; |     global $err,$db,$cuid,$quota,$dom,$hooks; | ||||||
|     $err->log("mail","create"); |     $err->log("mail","create"); | ||||||
| 
 | 
 | ||||||
|     // Validate the domain id
 |     // Validate the domain id
 | ||||||
|  | @ -203,13 +203,13 @@ class m_mail { | ||||||
|   * @return array a hashtable with all the informations for that email |   * @return array a hashtable with all the informations for that email | ||||||
|   */ |   */ | ||||||
|   function get_details($mail_id) { |   function get_details($mail_id) { | ||||||
|     global $db, $err, $cuid; |     global $db, $err, $cuid, $hooks; | ||||||
|     $err->log("mail","get_details"); |     $err->log("mail","get_details"); | ||||||
| 
 | 
 | ||||||
|     $mail_id=intval($mail_id); |     $mail_id=intval($mail_id); | ||||||
| 
 | 
 | ||||||
|     // We fetch all the informations for that email: these will fill the hastable : 
 |     // We fetch all the informations for that email: these will fill the hastable : 
 | ||||||
|     $db->query("SELECT a.address, a.password, a.enabled, d.domaine AS domain, m.quota, m.bytes/1024/1024 AS used, NOT ISNULL(m.id) AS islocal, a.type  
 |     $db->query("SELECT a.address, a.password, a.`enabled`, d.domaine AS domain, m.quota, m.bytes/1024/1024 AS used, NOT ISNULL(m.id) AS islocal, a.type  
 | ||||||
|          FROM address a LEFT JOIN mailbox m ON m.address_id=a.id, domaines d WHERE a.id=$mail_id AND d.id=a.domain_id;");
 |          FROM address a LEFT JOIN mailbox m ON m.address_id=a.id, domaines d WHERE a.id=$mail_id AND d.id=a.domain_id;");
 | ||||||
|     if (! $db->next_record()) return false; |     if (! $db->next_record()) return false; | ||||||
|     $details=$db->Record; |     $details=$db->Record; | ||||||
|  | @ -222,8 +222,132 @@ class m_mail { | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |   /* ----------------------------------------------------------------- */ | ||||||
|  |   /** Check if an email is mine ... | ||||||
|  |    * | ||||||
|  |    * @param $mail_id integer the number of the email to check | ||||||
|  |    * @return string the complete email address if that's mine, false if not | ||||||
|  |    * ($err is filled accordingly) | ||||||
|  |    */  | ||||||
|  |   function is_it_my_mail($mail_id){ | ||||||
|  |     global $err,$db,$cuid; | ||||||
|  |     $mail_id=intval($mail_id); | ||||||
|  |     $db->query("SELECT concat(a.address,'@',d.domaine) AS email FROM address a, domaines d WHERE d.id=a.domain_id AND a.id=$mail_id AND d.compte=$cuid;"); | ||||||
|  |     if ($db->next_record()) { | ||||||
|  |       return $db->f("email"); | ||||||
|  |     } else { | ||||||
|  |       $err->raise("mail",_("This email is not yours, you can't change anything on it")); | ||||||
|  |       return false; | ||||||
|  |     } | ||||||
|  |   } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |   /* ----------------------------------------------------------------- */ | ||||||
|  |   /** Function used to delete a mail from the db | ||||||
|  |    * should be used by the web interface, not by third-party programs. | ||||||
|  |    * | ||||||
|  |    * @param $mail_id integer the number of the email to delete | ||||||
|  |    * @return true if the email has been properly deleted  | ||||||
|  |    * or false if an error occured ($err is filled accordingly) | ||||||
|  |    */  | ||||||
|  |   function delete($mail_id){ | ||||||
|  |     global $err,$db,$cuid,$quota,$dom,$hooks; | ||||||
|  |     $err->log("mail","delete"); | ||||||
|  | 
 | ||||||
|  |     $mail_id=intval($mail_id); | ||||||
|  | 
 | ||||||
|  |     if (!$mail_id)  { | ||||||
|  |       $err->raise("mail",_("The email you entered is syntaxically incorrect")); | ||||||
|  |       return false; | ||||||
|  |     } | ||||||
|  |     // Validate that this email is owned by me...
 | ||||||
|  |     if (!($mail=$this->is_it_my_mail($mail_id))) { | ||||||
|  |       return false; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     // Search for that address:
 | ||||||
|  |     $db->query("SELECT a.id, a.type, a.mail_action, m.mail_action AS mailbox_action, NOT ISNULL(m.id) AS islocal FROM address a LEFT JOIN mailbox m ON m.address_id=a.id WHERE a.id='$mail_id';"); | ||||||
|  |     if (!$db->next_record()) { | ||||||
|  |       $err->raise("mail",_("The email %s does not exist, it can't be deleted"),$mail); | ||||||
|  |       return false; | ||||||
|  |     } | ||||||
|  |     if ($db->f("type")!="") { // Technically special : mailman, sympa ... 
 | ||||||
|  |       $err->raise("mail",_("The email %s is special, it can't be deleted"),$mail); | ||||||
|  |       return false; | ||||||
|  |     } | ||||||
|  |     if ($db->f("mailbox_action")!=""  || $db->f("mail_action")!="") { // will be deleted soon ...
 | ||||||
|  |       $err->raise("mail",_("The email %s is already marked for deletion, it can't be deleted"),$mail); | ||||||
|  |       return false; | ||||||
|  |     } | ||||||
|  |     $mail_id=$db->f("id"); | ||||||
|  | 
 | ||||||
|  |     if ($db->f("islocal")) { | ||||||
|  |       // If it's a pop/imap mailbox, mark it for deletion
 | ||||||
|  |       $db->query("UPDATE address SET mail_action='DELETE', enabled=0 WHERE id='$mail_id';"); | ||||||
|  |       $db->query("UPDATE mailbox SET mail_action='DELETE' WHERE address_id='$mail_id';"); | ||||||
|  |       $err->raise("mail",_("The email %s has been marked for deletion"),$mail); | ||||||
|  |     } else { | ||||||
|  |       // If it's only aliases, delete it NOW.
 | ||||||
|  |       $db->query("DELETE FROM address WHERE id='$mail_id';"); | ||||||
|  |       $db->query("DELETE FROM mailbox WHERE address_id='$mail_id';"); | ||||||
|  |       $db->query("DELETE FROM recipient WHERE address_id='$mail_id';"); | ||||||
|  |       $err->raise("mail",_("The email %s has been successfully deleted"),$mail); | ||||||
|  |     } | ||||||
|  |     return true; | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |   /* ----------------------------------------------------------------- */ | ||||||
|  |   /** Function used to undelete a pending deletion mail from the db | ||||||
|  |    * should be used by the web interface, not by third-party programs. | ||||||
|  |    * | ||||||
|  |    * @param $mail_id integer the email id | ||||||
|  |    * @return true if the email has been properly undeleted  | ||||||
|  |    * or false if an error occured ($err is filled accordingly) | ||||||
|  |    */  | ||||||
|  |   function undelete($mail_id){ | ||||||
|  |     global $err,$db,$cuid,$quota,$dom,$hooks; | ||||||
|  |     $err->log("mail","undelete"); | ||||||
|  | 
 | ||||||
|  |     $mail_id=intval($mail_id); | ||||||
|  | 
 | ||||||
|  |     if (!$mail_id)  { | ||||||
|  |       $err->raise("mail",_("The email you entered is syntaxically incorrect")); | ||||||
|  |       return false; | ||||||
|  |     } | ||||||
|  |     // Validate that this email is owned by me...
 | ||||||
|  |     if (!($mail=$this->is_it_my_mail($mail_id))) { | ||||||
|  |       return false; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     // Search for that address:
 | ||||||
|  |     $db->query("SELECT a.id, a.type, a.mail_action, m.mail_action AS mailbox_action, NOT ISNULL(m.id) AS islocal FROM address a LEFT JOIN mailbox m ON m.address_id=a.id WHERE a.id='$mail_id';"); | ||||||
|  |     if (!$db->next_record()) { | ||||||
|  |       $err->raise("mail",_("The email %s does not exist, it can't be undeleted"),$mail); | ||||||
|  |       return false; | ||||||
|  |     } | ||||||
|  |     if ($db->f("type")!="") { // Technically special : mailman, sympa ... 
 | ||||||
|  |       $err->raise("mail",_("The email %s is special, it can't be undeleted"),$mail); | ||||||
|  |       return false; | ||||||
|  |     } | ||||||
|  |     if ($db->f("mailbox_action")!="DELETE" || $db->f("mail_action")!="DELETE") { // will be deleted soon ...
 | ||||||
|  |       $err->raise("mail",_("Sorry, deletion of email %s is already in progress, or not marked for deletion, it can't be undeleted"),$mail); | ||||||
|  |       return false; | ||||||
|  |     } | ||||||
|  |     $mail_id=$db->f("id"); | ||||||
|  | 
 | ||||||
|  |     if ($db->f("islocal")) { | ||||||
|  |       // If it's a pop/imap mailbox, mark it for deletion
 | ||||||
|  |       $db->query("UPDATE address SET mail_action='', `enabled`=1 WHERE id='$mail_id';"); | ||||||
|  |       $db->query("UPDATE mailbox SET mail_action='' WHERE address_id='$mail_id';"); | ||||||
|  |       $err->raise("mail",_("The email %s has been undeleted"),$mail); | ||||||
|  |       return true; | ||||||
|  |     } else { | ||||||
|  |       $err->raise("mail",_("-- Program Error -- The email %s can't be undeleted"),$mail); | ||||||
|  |       return false; | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @ -322,7 +446,7 @@ class m_mail { | ||||||
|   function enable($mail_id){ |   function enable($mail_id){ | ||||||
|     global $db,$err; |     global $db,$err; | ||||||
|     $err->log("mail","enable"); |     $err->log("mail","enable"); | ||||||
|     if( !$db->query("UPDATE address SET enabled=1 where id=$mail_id;"))return false; |     if( !$db->query("UPDATE address SET `enabled`=1 where id=$mail_id;"))return false; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @ -333,7 +457,7 @@ class m_mail { | ||||||
|   function disable($mail_id){ |   function disable($mail_id){ | ||||||
|     global $db,$err; |     global $db,$err; | ||||||
|     $err->log("mail","enable"); |     $err->log("mail","enable"); | ||||||
|     if( !$db->query("UPDATE address SET enabled=0 where id=$mail_id;")) return false; |     if( !$db->query("UPDATE address SET `enabled`=0 where id=$mail_id;")) return false; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -6,8 +6,8 @@ | ||||||
| msgid "" | msgid "" | ||||||
| msgstr "" | msgstr "" | ||||||
| "Project-Id-Version: AlternC-awstats module 2.0\n" | "Project-Id-Version: AlternC-awstats module 2.0\n" | ||||||
| "Report-Msgid-Bugs-To: benjamin@alternc.org\n" | "Report-Msgid-Bugs-To: alternc@packages.debian.org\n" | ||||||
| "POT-Creation-Date: 2007-08-22 17:38+0200\n" | "POT-Creation-Date: 2012-08-21 12:36+0200\n" | ||||||
| "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" | ||||||
| "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||||||
| "Language-Team: LANGUAGE <LL@li.org>\n" | "Language-Team: LANGUAGE <LL@li.org>\n" | ||||||
|  |  | ||||||
|  | @ -14,8 +14,8 @@ | ||||||
| msgid "" | msgid "" | ||||||
| msgstr "" | msgstr "" | ||||||
| "Project-Id-Version: 0.3.1\n" | "Project-Id-Version: 0.3.1\n" | ||||||
| "Report-Msgid-Bugs-To: benjamin@alternc.org\n" | "Report-Msgid-Bugs-To: alternc@packages.debian.org\n" | ||||||
| "POT-Creation-Date: 2007-08-22 17:38+0200\n" | "POT-Creation-Date: 2012-08-21 12:36+0200\n" | ||||||
| "PO-Revision-Date: 2005-05-15 18:24+0200\n" | "PO-Revision-Date: 2005-05-15 18:24+0200\n" | ||||||
| "Last-Translator: Benjamin Sonntag <benjamin@altercn.org>\n" | "Last-Translator: Benjamin Sonntag <benjamin@altercn.org>\n" | ||||||
| "Language-Team: french <dev@alternc.org>\n" | "Language-Team: french <dev@alternc.org>\n" | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 Benjamin Sonntag
						Benjamin Sonntag