2006-04-26 12:28:53 +00:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
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
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
2017-10-11 09:58:04 +00:00
|
|
|
/**
|
|
|
|
* edit an email account settings
|
|
|
|
*
|
|
|
|
* @copyright AlternC-Team 2000-2017 https://alternc.com/
|
|
|
|
*/
|
2006-04-26 12:28:53 +00:00
|
|
|
|
2012-04-06 10:10:36 +00:00
|
|
|
require_once("../class/config.php");
|
2011-03-27 17:50:37 +00:00
|
|
|
|
|
|
|
$fields = array (
|
2016-05-23 13:03:13 +00:00
|
|
|
"mail_id" =>array ("post","integer",""),
|
2017-08-15 14:11:57 +00:00
|
|
|
"new_account" =>array ("post","integer",""),
|
2016-05-23 13:03:13 +00:00
|
|
|
"pass" => array ("post","string",""),
|
|
|
|
"passconf" => array("post","string",""),
|
|
|
|
"quotamb" => array("post","integer",0),
|
|
|
|
"enabled" => array("post","boolean",true),
|
|
|
|
"islocal" => array("post","boolean",true),
|
|
|
|
"recipients" => array("post","string",""),
|
2012-08-24 18:21:00 +00:00
|
|
|
);
|
2012-04-06 10:10:36 +00:00
|
|
|
|
2011-03-27 17:50:37 +00:00
|
|
|
getFields($fields);
|
|
|
|
|
2012-08-24 18:21:00 +00:00
|
|
|
$isedit=true; // if we go back to edit, it will know ;)
|
2011-03-27 17:50:37 +00:00
|
|
|
|
2012-08-24 18:21:00 +00:00
|
|
|
// We check that email first ... so that we can compare its status with our ...
|
|
|
|
if (!$res=$mail->get_details($mail_id)) {
|
2017-08-15 14:11:57 +00:00
|
|
|
include("mail_list.php");
|
2012-08-24 18:21:00 +00:00
|
|
|
exit();
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* checking the password
|
|
|
|
*/
|
2017-08-15 14:11:57 +00:00
|
|
|
if($pass != $passconf){
|
2017-10-06 16:04:36 +00:00
|
|
|
$msg->raise("ERROR", "mail", _("Passwords do not match"));
|
2017-08-15 14:11:57 +00:00
|
|
|
include ("mail_edit.php");
|
|
|
|
exit();
|
|
|
|
} else {
|
2017-08-17 14:38:09 +00:00
|
|
|
$canbeempty = ($islocal != 1 || ($islocal == 1 && !$new_account))?true:false;
|
2017-09-12 12:49:33 +00:00
|
|
|
if ($new_account || !empty($pass) || $islocal != 1) {
|
|
|
|
if ($islocal != 1)
|
|
|
|
$pass = "";
|
|
|
|
|
|
|
|
if (!$mail->set_passwd($mail_id,$pass,$canbeempty)) { /* SET THE PASSWORD */
|
|
|
|
include ("mail_edit.php");
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
} else if (!$new_account && empty($pass) && $islocal == 1 && $res['password'] == "") {
|
|
|
|
if (!$mail->set_passwd($mail_id,$pass, false)) { /* SET THE PASSWORD */
|
|
|
|
include ("mail_edit.php");
|
|
|
|
exit();
|
|
|
|
}
|
2017-08-15 14:11:57 +00:00
|
|
|
}
|
|
|
|
}
|
2012-08-24 18:21:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* now the enable/disable status
|
|
|
|
*/
|
|
|
|
if ($res["enabled"] && !$enabled) {
|
|
|
|
if (!$mail->disable($mail_id)) { /* DISABLE */
|
|
|
|
include ("mail_edit.php");
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!$res["enabled"] && $enabled) {
|
|
|
|
if (!$mail->enable($mail_id)) { /* ENABLE */
|
|
|
|
include ("mail_edit.php");
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* now the islocal + quota + recipients
|
|
|
|
*/
|
|
|
|
if (!$mail->set_details($mail_id,$islocal,$quotamb,$recipients)) { /* SET OTHERS */
|
|
|
|
include ("mail_edit.php");
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Other elements by hooks
|
|
|
|
*/
|
|
|
|
$rh=$hooks->invoke("mail_edit_post",array($mail_id));
|
2017-08-12 14:56:06 +00:00
|
|
|
if (in_array(false,$rh,true)) {
|
2012-08-24 18:21:00 +00:00
|
|
|
include ("mail_edit.php");
|
|
|
|
exit();
|
|
|
|
} else {
|
2017-10-06 16:04:36 +00:00
|
|
|
foreach($rh as $h) if ($h) $msg->raise("ERROR", "mail", $h);
|
2012-08-24 18:21:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-08-15 14:11:57 +00:00
|
|
|
if ($new_account)
|
2017-10-06 16:04:36 +00:00
|
|
|
$msg->raise("INFO", "mail", _("Your email has been created successfully"));
|
2017-08-15 14:11:57 +00:00
|
|
|
else
|
2017-10-06 16:04:36 +00:00
|
|
|
$msg->raise("INFO", "mail", _("Your email has been edited successfully"));
|
2012-04-06 10:10:36 +00:00
|
|
|
|
2012-08-24 18:21:00 +00:00
|
|
|
$_REQUEST["domain_id"]=$dom->get_domain_byname($res["domain"]);
|
|
|
|
include("mail_list.php");
|
2012-04-06 10:10:36 +00:00
|
|
|
|