MailboxHandler.php:

- add _field_password():
  - compare password / password2 field (error message will be displayed 
    at password2 field)
  - autogenerate password if enabled in config and $new
  - display password on $new if enabled in config or autogenerated

This means MailboxHandler now has all needed features to replace 
create-mailbox.php :-)


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1432 a1433add-5e2c-0410-b055-b7f2511e0802
pull/2/head
Christian Boltz 11 years ago
parent 47b0ebdec5
commit 13f89e339b

@ -303,6 +303,27 @@ class MailboxHandler extends PFAHandler {
return true;
}
/**
* - compare password / password2 field (error message will be displayed at password2 field)
* - autogenerate password if enabled in config and $new
* - display password on $new if enabled in config or autogenerated
*/
protected function _field_password($field, $val) {
if (!$this->_field_password2($field, $val)) return false;
if ($this->new && Config::read('generate_password') == 'YES' && $val == '') {
# auto-generate new password
unset ($this->errormsg[$field]); # remove "password too short" error message
$val = generate_password();
$this->values[$field] = $val; # we are doing this "behind the back" of set()
$this->infomsg[] = "Password: $val"; # TODO: make translateable
return false; # to avoid that set() overwrites $this->values[$field]
} elseif ($this->new && Config::read('show_password') == 'YES') {
$this->infomsg[] = "Password: $val"; # TODO: make translateable
}
}
/**
* compare password / password2 field
* error message will be displayed at the password2 field
@ -311,9 +332,6 @@ class MailboxHandler extends PFAHandler {
return $this->compare_password_fields('password', 'password2');
}
# TODO: generate password if $new, no password specified and $CONF['generate_password'] is set
/**
* on $this->new, set localpart based on address
*/

Loading…
Cancel
Save