Alternc  latest
Alternc logiel libre pour l'hébergement
mail_doedit.php
Go to the documentation of this file.
1 <?php
2 /*
3  ----------------------------------------------------------------------
4  LICENSE
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public License (GPL)
8  as published by the Free Software Foundation; either version 2
9  of the License, or (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  To read the license please visit http://www.gnu.org/copyleft/gpl.html
17  ----------------------------------------------------------------------
18 */
19 
20 /**
21  * edit an email account settings
22  *
23  * @copyright AlternC-Team 2000-2017 https://alternc.com/
24  */
25 
26 require_once("../class/config.php");
27 
28 $fields = array (
29  "mail_id" =>array ("post","integer",""),
30  "new_account" =>array ("post","integer",""),
31  "pass" => array ("post","string",""),
32  "passconf" => array("post","string",""),
33  "quotamb" => array("post","integer",0),
34  "enabled" => array("post","boolean",true),
35  "islocal" => array("post","boolean",true),
36  "recipients" => array("post","string",""),
37  );
38 
40 
41 $isedit=true; // if we go back to edit, it will know ;)
42 
43 // We check that email first ... so that we can compare its status with our ...
44 if (!$res=$mail->get_details($mail_id)) {
45  include("mail_list.php");
46  exit();
47 } else {
48 
49 
50  /*
51  * checking the password
52  */
53  if($pass != $passconf){
54  $msg->raise("ERROR", "mail", _("Passwords do not match"));
55  include ("mail_edit.php");
56  exit();
57  } else {
58  $canbeempty = ($islocal != 1 || ($islocal == 1 && !$new_account))?true:false;
59  if ($new_account || !empty($pass) || $islocal != 1) {
60  if ($islocal != 1)
61  $pass = "";
62 
63  if (!$mail->set_passwd($mail_id,$pass,$canbeempty)) { /* SET THE PASSWORD */
64  include ("mail_edit.php");
65  exit();
66  }
67  } else if (!$new_account && empty($pass) && $islocal == 1 && $res['password'] == "") {
68  if (!$mail->set_passwd($mail_id,$pass, false)) { /* SET THE PASSWORD */
69  include ("mail_edit.php");
70  exit();
71  }
72  }
73  }
74 
75 
76  /*
77  * now the enable/disable status
78  */
79  if ($res["enabled"] && !$enabled) {
80  if (!$mail->disable($mail_id)) { /* DISABLE */
81  include ("mail_edit.php");
82  exit();
83  }
84  }
85  if (!$res["enabled"] && $enabled) {
86  if (!$mail->enable($mail_id)) { /* ENABLE */
87  include ("mail_edit.php");
88  exit();
89  }
90  }
91 
92 
93  /*
94  * now the islocal + quota + recipients
95  */
96  if (!$mail->set_details($mail_id,$islocal,$quotamb,$recipients)) { /* SET OTHERS */
97  include ("mail_edit.php");
98  exit();
99  }
100 
101 
102  /*
103  * Other elements by hooks
104  */
105  $rh=$hooks->invoke("mail_edit_post",array($mail_id));
106  if (in_array(false,$rh,true)) {
107  include ("mail_edit.php");
108  exit();
109  } else {
110  foreach($rh as $h) if ($h) $msg->raise("ERROR", "mail", $h);
111  }
112 
113 }
114 
115 if ($new_account)
116  $msg->raise("INFO", "mail", _("Your email has been created successfully"));
117 else
118  $msg->raise("INFO", "mail", _("Your email has been edited successfully"));
119 
120 $_REQUEST["domain_id"]=$dom->get_domain_byname($res["domain"]);
121 include("mail_list.php");
122 
exit
Definition: adm_doadd.php:70
$hooks
Definition: bootstrap.php:74
$msg
Definition: bootstrap.php:75
$res
Definition: index.php:111
getFields($fields, $requestOnly=false)
Get the Fields of the posted form from $_REQUEST or POST or GET and check their type.
Definition: functions.php:688
$recipients
Definition: mail_add.php:50
$new_account
Definition: mail_doadd.php:37
$mail_id
$_REQUEST["domain_id"]
$isedit
Definition: mail_doedit.php:41
$fields
edit an email account settings
Definition: mail_doedit.php:28
$quotamb
Definition: mail_edit.php:46
$dom
Definition: whois_test.php:10