| | |
| | | * (Settings -> Password tab) |
| | | * |
| | | * @version 1.1 |
| | | * @author Aleksander 'A.L.E.C' Machniak |
| | | * @author Aleksander 'A.L.E.C' Machniak <alec@alec.pl> |
| | | * @editor Daniel Black |
| | | * |
| | | * Configuration Items (config/main.inc.php): |
| | |
| | | $rcmail->output->add_label('password'); |
| | | $this->register_action('plugin.password', array($this, 'password_init')); |
| | | $this->register_action('plugin.password-save', array($this, 'password_save')); |
| | | $this->register_handler('plugin.body', array($this, 'password_form')); |
| | | $this->include_script('password.js'); |
| | | } |
| | | |
| | | function password_init() |
| | | { |
| | | $this->add_texts('localization/'); |
| | | rcmail::get_instance()->output->send('plugin'); |
| | | $this->register_handler('plugin.body', array($this, 'password_form')); |
| | | |
| | | $rcmail = rcmail::get_instance(); |
| | | $rcmail->output->set_pagetitle($this->gettext('changepasswd')); |
| | | $rcmail->output->send('plugin'); |
| | | } |
| | | |
| | | function password_save() |
| | | { |
| | | $rcmail = rcmail::get_instance(); |
| | | |
| | | $confirm = $rcmail->config->get('password_confirm_current'); |
| | | $this->add_texts('localization/'); |
| | | $this->register_handler('plugin.body', array($this, 'password_form')); |
| | | $rcmail->output->set_pagetitle($this->gettext('changepasswd')); |
| | | |
| | | $confirm = $rcmail->config->get('password_confirm_current'); |
| | | |
| | | if (($confirm && !isset($_POST['_curpasswd'])) || !isset($_POST['_newpasswd'])) |
| | | $rcmail->output->command('display_message', $this->gettext('nopassword'), 'error'); |
| | |
| | | $curpwd = get_input_value('_curpasswd', RCUBE_INPUT_POST); |
| | | $newpwd = get_input_value('_newpasswd', RCUBE_INPUT_POST); |
| | | |
| | | if ($confirm && $_SESSION['password'] != $rcmail->encrypt_passwd($curpwd)) |
| | | if ($confirm && $rcmail->decrypt($_SESSION['password']) != $curpwd) |
| | | $rcmail->output->command('display_message', $this->gettext('passwordincorrect'), 'error'); |
| | | else if (!($res = $this->_save($curpwd,$newpwd))) { |
| | | $rcmail->output->command('display_message', $this->gettext('successfullysaved'), 'confirmation'); |
| | | $_SESSION['password'] = $rcmail->encrypt_passwd($newpwd); |
| | | $_SESSION['password'] = $rcmail->encrypt($newpwd); |
| | | } else |
| | | $rcmail->output->command('display_message', $res, 'error'); |
| | | } |
| | | |
| | | rcmail_overwrite_action('plugin.password'); |
| | | rcmail::get_instance()->output->send('plugin'); |
| | | $rcmail->output->send('plugin'); |
| | | } |
| | | |
| | | function password_form() |
| | |
| | | $rcmail->output->add_label( |
| | | 'password.nopassword', |
| | | 'password.nocurpassword', |
| | | 'password.passwordinconsistency', |
| | | 'password.changepasswd' |
| | | 'password.passwordinconsistency' |
| | | ); |
| | | // $rcmail->output->set_pagetitle($this->gettext('changepasswd')); |
| | | |
| | | $rcmail->output->set_env('product_name', $rcmail->config->get('product_name')); |
| | | |
| | | // allow the following attributes to be added to the <table> tag |
| | |
| | | // return the complete edit form as table |
| | | $out = '<table' . $attrib_str . ">\n\n"; |
| | | |
| | | $a_show_cols = array('newpasswd' => array('type' => 'text'), |
| | | 'confpasswd' => array('type' => 'text')); |
| | | |
| | | if ($confirm) { |
| | | $a_show_cols['curpasswd'] = array('type' => 'text'); |
| | | // show current password selection |
| | | $field_id = 'curpasswd'; |
| | | $input_newpasswd = new html_passwordfield(array('name' => '_curpasswd', 'id' => $field_id, 'size' => 20)); |
| | | $input_newpasswd = new html_passwordfield(array('name' => '_curpasswd', 'id' => $field_id, |
| | | 'size' => 20, 'autocomplete' => 'off')); |
| | | |
| | | $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n", |
| | | $field_id, |
| | |
| | | |
| | | // show new password selection |
| | | $field_id = 'newpasswd'; |
| | | $input_newpasswd = new html_passwordfield(array('name' => '_newpasswd', 'id' => $field_id, 'size' => 20)); |
| | | $input_newpasswd = new html_passwordfield(array('name' => '_newpasswd', 'id' => $field_id, |
| | | 'size' => 20, 'autocomplete' => 'off')); |
| | | |
| | | $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n", |
| | | $field_id, |
| | |
| | | |
| | | // show confirm password selection |
| | | $field_id = 'confpasswd'; |
| | | $input_confpasswd = new html_passwordfield(array('name' => '_confpasswd', 'id' => $field_id, 'size' => 20)); |
| | | $input_confpasswd = new html_passwordfield(array('name' => '_confpasswd', 'id' => $field_id, |
| | | 'size' => 20, 'autocomplete' => 'off')); |
| | | |
| | | $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n", |
| | | $field_id, |