Commit 20d4b3fb authored by Alan Garcia's avatar Alan Garcia
Browse files

Ajout de la notion de temporaire sur les mails

("May be broken" comme qui dirait, ya eu pas mal de patch entretemps
parent 888685bc
......@@ -195,6 +195,7 @@ bureau/admin/images/quota.png -text
bureau/admin/images/stat.png -text
bureau/admin/index.php -text
bureau/admin/js/alternc.js -text
bureau/admin/js/jquery.min.js -text
bureau/admin/js/prototype.js -text
bureau/admin/js/rico.js -text
bureau/admin/js/wz_dragdrop.js -text
......@@ -285,6 +286,7 @@ bureau/class/m_mem.php -text
bureau/class/m_mysql.php -text
bureau/class/m_quota.php -text
bureau/class/m_sta2.php -text
bureau/class/m_trash.php -text
bureau/class/mime.php -text
bureau/class/reset_stats_conf.php -text
bureau/class/variables.php -text
......
This diff is collapsed.
......@@ -33,8 +33,9 @@ include_once("head.php");
$fields = array (
"domain" => array ("request", "string", ""),
"dst_mail" => array ("request", "string", ""),
"many" => array ("request", "integer", 0),
"pop" => array ("request", "integer", 1),
"pop" => array ("request", "integer", 1),
);
getFields($fields);
......@@ -45,6 +46,10 @@ if ($error) {
echo "<p class=\"error\">$error</p>";
}
// If a dst email is indicated, it's for an alias
// So we desactivate pop by default
if (!empty($dst_mail)) $pop=0;
?>
<hr id="topbar"/>
<br />
......@@ -68,7 +73,13 @@ if ($error) {
</div>
</td></tr>
<tr><td><label for="alias"><?php __("Redirections<br />Other recipients:"); ?></label></td><td>(<?php __("one email per line"); ?>)<br /><textarea class="int" cols="32" rows="5" name="alias" id="alias"><?php echo $alias; ?></textarea></td></tr>
<tr><td><label for="alias"><?php __("Redirections<br />Other recipients:"); ?></label></td><td>(<?php __("one email per line"); ?>)<br /><textarea class="int" cols="32" rows="5" name="alias" id="alias"><?php echo $alias; echo ((empty($alias) && !empty($dst_mail))?"":"\n").$dst_mail; ?></textarea></td></tr>
<tr><td>
<?php echo __("Informations for temporary account"); ?><br/>
<span style="color: red;"><?php __("All this account information will <br/> be deleted at expiration");?></span>
</td><td>
<?php include_once("trash_dateselect.php"); ?>
</td></tr>
<tr class="trbtn"><td colspan="2">
<input type="hidden" name="many" value="<?php echo intval($many); ?>" />
<input type="submit" class="inb" name="submit" value="<?php __("Create this email address"); ?>" />
......
......@@ -28,6 +28,7 @@
----------------------------------------------------------------------
*/
require_once("../class/config.php");
$trash->getfromform();
if ($pass != $passconf) {
$error = _("Passwords do not match");
......@@ -35,7 +36,7 @@ if ($pass != $passconf) {
exit();
}
if (!$mail->add_mail($domain,$email,$pop,$pass,$alias)) {
if (!$mail->add_mail($domain,$email,$pop,$pass,$alias,$trash->expiration_date_db)) {
$error=$err->errstr();
$addok=0;
include ("mail_add.php");
......@@ -51,4 +52,4 @@ if (!$mail->add_mail($domain,$email,$pop,$pass,$alias)) {
exit();
}
?>
\ No newline at end of file
?>
......@@ -30,6 +30,8 @@
require_once("../class/config.php");
$error_edit="";
$trash=new m_trash();
$trash->getfromform();
if ($pass != $passconf) {
$error = _("Passwords do not match");
......@@ -37,7 +39,7 @@ if ($pass != $passconf) {
exit();
}
if (!$mail->put_mail_details($email,$pop,$pass,$alias)) {
if (!$mail->put_mail_details($email,$pop,$pass,$alias,$trash->expiration_date_db)) {
$error_edit=$err->errstr();
$addok=0;
include ("mail_edit.php");
......
......@@ -64,6 +64,9 @@ if ($error_edit) {
<tr><th colspan="2"><input type="hidden" name="email" value="<?php echo $email; ?>" />
<input type="hidden" name="domain" value="<?php echo $domain; ?>" />
<?php printf(_("Edit the email address <b>%s</b>"),$email); ?></th></tr>
<?php if (! is_null($res['trash_info']) && $res['trash_info']->is_trash ) { ?>
<tr><th colspan="2"><span style="color: red"><?php __("This account is a temporary account.<br/>It will be delete the "); echo $res['trash_info']->human_display(); ?></span></th></tr>
<?php } ?>
<tr><td><label for="pop"><?php __("Is it a POP/IMAP account?"); ?></label></td>
<td>
<p>
......@@ -83,6 +86,13 @@ echo "<div class=\"warningmsg\">"._("WARNING: turning POP/IMAP off will DELETE t
</td></tr>
<tr><td><label for="alias"><?php __("Redirections<br />Other recipients:"); ?></label></td><td>(<?php __("one email per line"); ?>)<br /><textarea class="int" cols="32" rows="5" name="alias" id="alias"><?php echo $alias; ?></textarea></td></tr>
<tr><td>
<?php echo __("Informations for temporary account"); ?><br/>
<span style="color: red;"><?php __("All this account information will <br/> be deleted at expiration");?></span>
</td><td>
<?php include_once("trash_dateselect.php"); ?>
</td></tr>
<tr class="trbtn"><td colspan="2">
<input type="submit" class="inb" name="submit" value="<?php __("Change this email address"); ?>" />
<input type="button" class="inb" name="cancel" value="<?php __("Cancel"); ?>" onclick="document.location='mail_list.php?domain=<?php echo urlencode($domain); ?>'"/>
......
......@@ -99,7 +99,7 @@ else{
<table class="tlist">
<tr><th colspan="2"><input type="hidden" name="domain" value="<?php echo $domain ?>"/>
<?php __("Actions"); ?></th><th><?php __("Email address"); ?></th><th><?php __("Size"); ?></th></tr>
<?php __("Actions"); ?></th><th><?php __("Email address"); ?></th><th><?php __("Size"); ?></th><th/></tr>
<?php
$col=1;
for($i=0;$i<$res["count"];$i++) {
......@@ -117,6 +117,17 @@ for($i=0;$i<$res["count"];$i++) {
} else {
echo "<td>&nbsp;</td>";
}
echo "<td>";
if (! is_null($val['expiration_date'])) {
// It's a temporary account
echo __("Manage this temporary account");
// It's a normal account
} else {
echo "<a href='mail_add.php?domain=".urlencode($domain)."&dst_mail=".urlencode($val["mail"])."'>";
echo __("Create alias");
echo "</a>";
}
echo "</td>";
echo "</tr>";
}
......
......@@ -120,7 +120,7 @@ class m_mail {
$letter = "";
else
$letter .= "%";
$db->query("SELECT mail,pop,alias FROM mail_domain WHERE mail LIKE '".addslashes($letter)."@".addslashes($dom)."' AND uid='$cuid' AND type=0;");
$db->query("SELECT mail,pop,alias,expiration_date FROM mail_domain WHERE mail LIKE '".addslashes($letter)."@".addslashes($dom)."' AND uid='$cuid' AND type=0;");
$res=array(); $i=0;
while ($db->next_record()) {
if ($db->f("pop")) {
......@@ -136,7 +136,7 @@ class m_mail {
$account=$db->f("alias");
}
$res[]=array("mail" => $db->f("mail"), "pop" => $db->f("pop"),
"alias"=>$account,"size"=>$size);
"alias"=>$account,"size"=>$size, "expiration_date"=>$db->f("expiration_date"));
$i++;
}
if ($sort==1) {
......@@ -183,19 +183,21 @@ class m_mail {
function get_mail_details($mail) {
global $err,$db,$cuid;
$err->log("mail","get_mail_details",$mail);
$db->query("SELECT mail,pop,alias FROM mail_domain WHERE mail='$mail' AND uid='$cuid';");
$db->query("SELECT mail,pop,alias,expiration_date FROM mail_domain WHERE mail='$mail' AND uid='$cuid';");
if (!$db->next_record()) {
$err->raise("mail",3,$mail);
return false;
}
$pop=$db->f("pop");
$trash_info=new m_trash();
$trash_info->set_from_db($db->f("expiration_date"));
if ($pop) {
$login=str_replace("@","_",$db->f("mail"));
$account=str_replace($login,"",$db->f("alias"));
} else {
$account=$db->f("alias");
}
return array("mail" => $mail, "login" => $login, "alias" => $account, "pop" => $pop);
return array("mail" => $mail, "login" => $login, "alias" => $account, "pop" => $pop, "trash_info"=> $trash_info);
}
......@@ -293,7 +295,7 @@ class m_mail {
* @param string $alias Liste des destinataires auxiliaires, un par ligne.
* @return boolean TRUE si l'email a bien t modifi, FALSE si une erreur s'est produite.
*/
function put_mail_details($mail,$pop,$pass,$alias) {
function put_mail_details($mail,$pop,$pass,$alias, $expiration_date=null) {
global $err,$cuid,$db,$admin;
$err->log("mail","put_mail_details",$mail);
$mail=trim(strtolower($mail)); // remove spaces also
......@@ -330,7 +332,7 @@ class m_mail {
}
}
$db->query("SELECT mail,alias,pop FROM mail_domain WHERE mail='$mail' AND uid='$cuid' AND type=0;");
$db->query("SELECT mail,alias,pop,expiration_date FROM mail_domain WHERE mail='$mail' AND uid='$cuid' AND type=0;");
if (!$db->next_record()) {
$err->raise("mail",3,$mail);
return false;
......@@ -350,7 +352,8 @@ class m_mail {
}
}
$db->query("UPDATE mail_domain SET alias='".implode("\n",$account)."', pop='$pop' WHERE mail='$mail';");
$expiration_sql = (is_null($expiration_date))?"null":"'$expiration_date'";
$db->query("UPDATE mail_domain SET alias='".implode("\n",$account)."', pop='$pop',expiration_date=$expiration_sql WHERE mail='$mail';");
if ($pop=="1" && $oldpop!=1) { /* POP Creation */
if (!$this->_createpop($email,$dom,$pass)) {
......@@ -385,7 +388,7 @@ class m_mail {
* @param string $alias Liste des alias, un par ligne
* @return boolean TRUE si le compte a bien t cr, FALSE si une erreur s'est produite.
*/
function add_mail($dom,$mail,$pop,$pass,$alias) {
function add_mail($dom,$mail,$pop,$pass,$alias, $expiration_date=null) {
global $quota,$err,$cuid,$db,$admin,$L_FQDN;
$err->log("mail","add_mail",$dom."/".$mail);
$account=array();
......@@ -450,7 +453,8 @@ class m_mail {
$err->raise("mail",8);
return false;
}
$db->query("INSERT INTO mail_domain (mail,alias,uid,pop,type) VALUES ('".$mail."@".$dom."','".implode("\n",$account)."','$cuid','$pop',0);");
$expiration_sql = (is_null($expiration_date))?"null":"'$expiration_date'";
$db->query("INSERT INTO mail_domain (mail,alias,uid,pop,type,expiration_date) VALUES ('".$mail."@".$dom."','".implode("\n",$account)."','$cuid','$pop',0, $expiration_sql);");
if ($pop=="1") {
if (!$this->_createpop($mail,$dom,$pass))
......
<?php
/*
$Id: m_trash.php,v 0.1 2010/11/17 15:51:00 fufroma Exp $
----------------------------------------------------------------------
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
----------------------------------------------------------------------
Original Author of file: Alan Garcia
Purpose of file: Manage trash class
----------------------------------------------------------------------
*/
class m_trash {
var $is_trash=false;
var $expiration_date=null;
var $expiration_date_db=null;
/* ----------------------------------------------------------------- */
/**
* Constructeur
*/
function m_trash() {
}
function set_from_db($expiration_date_db) {
$this->expiration_date_db=$expiration_date_db;
$this->expiration_date=strtotime($this->expiration_date_db);
}
function human_display() {
return strftime("%d/%m/%Y %T",$this->expiration_date);
}
function getfromform() {
$fields = array (
"trash_type_expiration" => array ("request", "string", ""),
"trash_exp_in_value" => array ("request", "string", ""),
"trash_exp_in_unit" => array ("request", "string", ""),
"trash_datepicker" => array ("request", "string", ""),
);
$champs=getFields($fields);
foreach($champs as $k=>$v) $$k = $v;
switch($trash_type_expiration) {
case "trash_at_x":
// We can use date_parse_from_format if we have php 5.3
//$this->expiration_date=date_parse_from_format("%d/%m/%Y",$trash_datepicker);
$mydate=strptime($trash_datepicker, "%d/%m/%Y");
if ($mydate){
$this->expiration_date=new DateTime("@".mktime( 0, 0, 0, $mydate['tm_mon']+1, $mydate['tm_mday']+1, 1900+$mydate['tm_year']));
} else {
$this->expiration_date=new DateTime("@".(time() + (7*24*3600)));
}
$this->is_trash=true;
break;
case "trash_in_x":
$this->is_trash=true;
switch ($trash_exp_in_unit) {
case "weeks":
$trash_unit = 7*24*3600;
break;
case "days":
$trash_unit = 24*3600;
break;
case "hours":
$trash_unit = 3600;
break;
}
$this->expiration_date= new DateTime("@".(time() + ($trash_exp_in_value*$trash_unit)) );
break;
case "no_exp":
$this->is_trash=false;
break;
default:
$this->is_trash=false;
} // switch
if (!is_null($this->expiration_date)) $this->expiration_date_db=$this->expiration_date->format('Y-m-d H:i:s');
}
}
......@@ -79,6 +79,7 @@ CREATE TABLE IF NOT EXISTS `mail_domain` (
`uid` int(10) unsigned NOT NULL default '0', # Numro de l'utilisateur (alternc)
`pop` tinyint(4) NOT NULL default '0', # Est-ce un compte pop ?
`type` tinyint(4) NOT NULL default '0', # Je ne sais plus ...
`expiration_date` DEFAULT null, # Pour les mails temporaire
PRIMARY KEY (`mail`),
KEY `uid` (`uid`),
KEY `pop` (`pop`)
......
......@@ -5,3 +5,6 @@ ALTER TABLE sub_domaines_standby ADD CONSTRAINT pk_SubDomainesStandby PRIMARY K
-- Alter table to allow use of ipv6, cname and txt in dns record
ALTER TABLE sub_domaines DROP PRIMARY KEY;
ALTER TABLE sub_domaines ADD CONSTRAINT pk_SubDomaines PRIMARY KEY (compte,domaine,sub,type);
-- Alter table mail_domain to add support of temporary mail
ALTER TABLE mail_domain ADD expiration_date datetime DEFAULT null;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment