Alternc  latest
Alternc logiel libre pour l'hébergement
mail_edit.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  * Form to edit a mailbox parameters.
22  *
23  * @copyright AlternC-Team 2000-2017 https://alternc.com/
24  */
25 
26 require_once("../class/config.php");
27 include_once("head.php");
28 
29 $fields = array (
30  "mail_id" =>array ("request","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 );
39 
40 if (!$res=$mail->get_details($mail_id)) {
41  include("mail_list.php");
42  exit();
43 } else {
44 
45  foreach($res as $key=>$val) $$key=$val;
46  $quotamb=$quota;
47 
48  if ($islocal && $mailbox_action=="DELETE") $islocal=false;
49 
50  if (isset($isedit) && $isedit) getFields($fields); // we came from a POST, so let's get the request again ...
51 
52 ?>
53 <h3><?php printf(_("Editing the email %s"),$res["address"]."@".$res["domain"]); ?></h3>
54 <hr id="topbar"/>
55 <br />
56 
57 
58 <?php
59 $c=$admin->listPasswordPolicies();
60 $passwd_classcount = $c['pop']['classcount'];
61 
62 echo $msg->msg_html_all();
63 ?>
64 
65 <form action="mail_doedit.php" method="post" name="main" id="main" autocomplete="off">
66  <?php csrf_get(); ?>
67 <!-- honeypot fields -->
68 <input type="text" style="display: none" id="fakeUsername" name="fakeUsername" value="" />
69 <input type="password" style="display: none" id="fakePassword" name="fakePassword" value="" />
70 
71 <input type="hidden" name="mail_id" value="<?php ehe($mail_id); ?>" />
72 <input type="hidden" name="new_account" value="<?php echo isset($new_account)?$new_account:false;?>" />
73 <table class="tedit">
74  <tr><th colspan="2"><b><?php __("Is this email enabled?"); ?></b></th></tr>
75 
76  <tr><td style="width: 50%; text-align: justify"><?php __("You can enable or disable this email anytime. This will bounce any mail received on this address, but will not delete the stored email, or the redirections or password."); ?><br />
77 </td>
78  <td>
79  <p>
80  <input type="radio" name="enabled" id="enabled0" class="inc" value="0"<?php cbox($enabled==0); ?> /><label for="enabled0"><?php __("No (email disabled)"); ?></label>
81  <input type="radio" name="enabled" id="enabled1" class="inc" value="1"<?php cbox($enabled==1); ?> /><label for="enabled1"><?php __("Yes (email enabled)"); ?></label>
82  </p>
83  </td></tr>
84 
85  <tr><th colspan="2"><b><?php __("Is it a POP/IMAP account?"); ?></b></th></tr>
86  <tr><td style="width: 50%; text-align: justify"><?php __("POP/IMAP accounts are receiving emails in the server. To read those emails, you can use a Webmail, or a mail client such as Thunderbird. If you don't use POP/IMAP, you can configure your email to be a redirection to other existing emails. The maximum size is in megabytes, use 0 to make it infinite."); ?><br />
87 <p>&nbsp;</p>
88 <?php if ($islocal) { ?>
89 <p><?php printf(_('This mailbox is currently using %1$s / %2$s'),format_size($used),format_size($quotabytes)); ?></p>
90 <?php } ?>
91 <?php if ($mailbox_action=="DELETE") { ?>
92 <p class="alert alert-warning"><?php __("This mailbox is pending deletion. You can recover its mails by setting it to 'Yes' NOW!"); ?></p>
93 <?php } ?>
94 </td>
95  <td>
96  <p>
97  <input type="radio" name="islocal" id="islocal0" class="inc" value="0"<?php !isset($new_account)?cbox($islocal==0):""; ?> onclick="popoff()" /><label for="islocal0"><?php __("No"); ?></label>
98  <input type="radio" name="islocal" id="islocal1" class="inc" value="1"<?php !isset($new_account)?cbox($islocal==1):cbox($islocal==0); ?> onclick="popon();" /><label for="islocal1"><?php __("Yes"); ?></label>
99  </p>
100  <div id="poptbl">
101  <table class="tedit" >
102  <tr id='mail_edit_pass' style='display: none;'><td colspan='2'><a href='javascript:mail_edit_pass();'><?php __("Click here to edit the existing password");?></a></td></tr>
103  <tr id='mail_edit_pass1'><td><label for="pass"><?php __("Enter a POP/IMAP password"); ?></label></td><td><input type="password" class="int" autocomplete="off" name="pass" id="pass" value="" size="20" maxlength="32" /><?php display_div_generate_password(DEFAULT_PASS_SIZE,"#pass","#passconf",$passwd_classcount); ?></td></tr>
104  <tr id='mail_edit_pass2'><td><label for="passconf"><?php __("Confirm password"); ?></label></td><td><input type="password" class="int" autocomplete="off" name="passconf" id="passconf" value="" size="20" maxlength="32" /></td></tr>
105  <tr><td><label for="quotamb"><?php __("Maximum allowed size of this Mailbox"); ?></label></td><td><input type="text" class="int intleft" style="text-align: right" name="quotamb" id="quotamb" value="<?php ehe($quotamb); ?>" size="7" maxlength="6" /><span class="int intright"><?php __("MB"); ?></span></td></tr>
106  </table>
107  </div>
108  </td></tr>
109  <?php if ($islocal) { ?>
110 <tr id="turnoff" style="display: none;"><td colspan="2" class="alert alert-warning"><?php __("WARNING: turning POP/IMAP off will DELETE the stored messages in this email address."); ?></td></tr>
111 <?php } ?>
112  <tr><th colspan="2"><b><?php __("Is it a redirection to other email addresses?"); ?></b></th></tr>
113 
114  <tr><td style="width: 50%; text-align: justify"><label for="recipients"><?php __("If you want to send emails received on this address to other addresses, even outside this server, enter those recipients here."); ?></label></td><td>(<?php __("one recipient per line"); ?>)<br /><textarea class="int" cols="32" rows="5" name="recipients" id="recipients"><?php echo $recipients; ?></textarea></td></tr>
115 <?php
116 
117  $html=$hooks->invoke("hook_mail_edit_html",array($mail_id,$type));
118 foreach($html as $h) echo $h;
119 
120 ?>
121 <tr class="trbtn"><td colspan="2">
122  <input type="submit" class="inb ok" name="submit" value="<?php __("Change this email address"); ?>" />
123  <input type="button" class="inb cancel" name="cancel" value="<?php __("Cancel"); ?>" onclick="window.history.go(-1);"/>
124 </td></tr>
125 </table>
126 </form>
127 
128 <?php
129 }
130 ?>
131 <script type="text/javascript">
132 
133 function popoff() {
134  $('#turnoff').show();
135  $('#poptbl').addClass('grey');
136  $('#pass').attr("disabled", "disabled");
137  $('#quotamb').attr("disabled", "disabled");
138  $('#passconf').attr("disabled", "disabled");
139 }
140 function popon() {
141  $('#turnoff').hide();
142  $('#poptbl').removeClass('grey');
143  $('#pass').removeAttr("disabled");
144  $('#quotamb').removeAttr("disabled");
145  $('#passconf').removeAttr("disabled");
146 }
147 
148 function mail_edit_pass() {
149  $('#mail_edit_pass').toggle();
150  $('#mail_edit_pass1').toggle();
151  $('#mail_edit_pass2').toggle();
152 }
153 
154 </script>
155 <?php
156 if (isset($res) && !empty($res['password']) ) {
157  echo '<script type="text/javascript">mail_edit_pass();</script>';
158 } // if $islocal
159 
160 include_once("foot.php");
161 ?>
exit
Definition: adm_doadd.php:70
$hooks
Definition: bootstrap.php:74
$msg
Definition: bootstrap.php:75
$res
Definition: index.php:111
const DEFAULT_PASS_SIZE
Define constants from vars of /etc/alternc/local.sh The you can't choose where is the AlternC Panel.
Definition: config.php:81
$isedit
Definition: dom_edit.php:280
display_div_generate_password($pass_size=DEFAULT_PASS_SIZE, $fields_to_fill1="", $fields_to_fill2="", $classcount=3)
Show a button to set a random password for a password field.
Definition: functions.php:922
format_size($size, $html=0)
Definition: functions.php:430
__($str)
Definition: functions.php:404
cbox($test, $echo=true)
ECHOes checked="checked" only if the parameter is true useful for checkboxes and radio buttons.
Definition: functions.php:345
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
csrf_get($return=false)
Give a new CSRF uniq token for a form the session must be up since the CSRF is linked to the session ...
Definition: functions.php:1159
$recipients
Definition: mail_add.php:50
$new_account
Definition: mail_doadd.php:37
$mail_id
$quotamb
Definition: mail_edit.php:46
$html
Definition: mail_edit.php:117
$fields
Form to edit a mailbox parameters.
Definition: mail_edit.php:29
$c
Definition: mail_edit.php:59
$passwd_classcount
Definition: mail_edit.php:60
$val
Definition: tempovars.php:15
if(empty($_POST['key'])||empty($_POST['val'])) $key
Definition: tempovars.php:14