X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=plugins%2Fnew_user_dialog%2Fnew_user_dialog.php;h=9d7cbcba57e09123746522557d3dc2e29d5c5a64;hb=a2dd2e41259a5e90016efcd7d083020b95e25527;hp=4f6250f08ba7392104bc093325eac676998fed7a;hpb=b68022ca3782d5eb5a1a7ef6f8cf7abe1dc15bd6;p=roundcube.git diff --git a/plugins/new_user_dialog/new_user_dialog.php b/plugins/new_user_dialog/new_user_dialog.php index 4f6250f..9d7cbcb 100644 --- a/plugins/new_user_dialog/new_user_dialog.php +++ b/plugins/new_user_dialog/new_user_dialog.php @@ -7,24 +7,24 @@ * and sets a session flag in case it is incomplete. An overlay box will appear * on the screen until the user has reviewed/completed his identity. * - * @version 1.0 + * @version @package_version@ * @author Thomas Bruederli */ class new_user_dialog extends rcube_plugin { - public $task = 'mail'; - + public $task = 'login|mail'; + function init() { - $this->add_hook('create_identity', array($this, 'create_identity')); - + $this->add_hook('identity_create', array($this, 'create_identity')); + $this->register_action('plugin.newusersave', array($this, 'save_data')); + // register additional hooks if session flag is set if ($_SESSION['plugin.newuserdialog']) { $this->add_hook('render_page', array($this, 'render_page')); - $this->register_action('plugin.newusersave', array($this, 'save_data')); } } - + /** * Check newly created identity at first login */ @@ -41,35 +41,66 @@ class new_user_dialog extends rcube_plugin */ function render_page($p) { - if ($_SESSION['plugin.newuserdialog']) { + if ($_SESSION['plugin.newuserdialog'] && $p['template'] == 'mail') { $this->add_texts('localization'); - + $rcmail = rcmail::get_instance(); $identity = $rcmail->user->get_identity(); $identities_level = intval($rcmail->config->get('identities_level', 0)); - + // compose user-identity dialog $table = new html_table(array('cols' => 2)); - + $table->add('title', $this->gettext('name')); - $table->add(null, html::tag('input', array('type' => "text", 'name' => "_name", 'value' => $identity['name']))); + $table->add(null, html::tag('input', array( + 'type' => 'text', + 'name' => '_name', + 'value' => $identity['name'] + ))); $table->add('title', $this->gettext('email')); - $table->add(null, html::tag('input', array('type' => "text", 'name' => "_email", 'value' => $identity['email'], 'disabled' => ($identities_level == 1 || $identities_level == 3)))); - + $table->add(null, html::tag('input', array( + 'type' => 'text', + 'name' => '_email', + 'value' => rcube_idn_to_utf8($identity['email']), + 'disabled' => ($identities_level == 1 || $identities_level == 3) + ))); + + $table->add('title', $this->gettext('organization')); + $table->add(null, html::tag('input', array( + 'type' => 'text', + 'name' => '_organization', + 'value' => $identity['organization'] + ))); + + $table->add('title', $this->gettext('signature')); + $table->add(null, html::tag('textarea', array( + 'name' => '_signature', + 'rows' => '3', + ),$identity['signature'] + )); + // add overlay input box to html page - $rcmail->output->add_footer(html::div(array('id' => "newuseroverlay"), + $rcmail->output->add_footer(html::div(array('id' => 'newuseroverlay'), html::tag('form', array( 'action' => $rcmail->url('plugin.newusersave'), - 'method' => "post"), + 'method' => 'post'), html::tag('h3', null, Q($this->gettext('identitydialogtitle'))) . html::p('hint', Q($this->gettext('identitydialoghint'))) . $table->show() . - html::p(array('class' => "formbuttons"), - html::tag('input', array('type' => "submit", 'class' => "button mainaction", 'value' => $this->gettext('save')))) + html::p(array('class' => 'formbuttons'), + html::tag('input', array('type' => 'submit', + 'class' => 'button mainaction', 'value' => $this->gettext('save')))) ) )); - + + // disable keyboard events for messages list (#1486726) + $rcmail->output->add_script( + "rcmail.message_list.key_press = function(){}; + rcmail.message_list.key_down = function(){}; + $('input[name=_name]').focus(); + ", 'docready'); + $this->include_stylesheet('newuserdialog.css'); } } @@ -85,25 +116,29 @@ class new_user_dialog extends rcube_plugin $rcmail = rcmail::get_instance(); $identity = $rcmail->user->get_identity(); $identities_level = intval($rcmail->config->get('identities_level', 0)); - + $save_data = array( 'name' => get_input_value('_name', RCUBE_INPUT_POST), 'email' => get_input_value('_email', RCUBE_INPUT_POST), + 'organization' => get_input_value('_organization', RCUBE_INPUT_POST), + 'signature' => get_input_value('_signature', RCUBE_INPUT_POST), ); - + // don't let the user alter the e-mail address if disabled by config if ($identities_level == 1 || $identities_level == 3) $save_data['email'] = $identity['email']; - + else + $save_data['email'] = rcube_idn_to_ascii($save_data['email']); + // save data if not empty - if (!empty($save_data['name']) && !empty($save_data['name'])) { + if (!empty($save_data['name']) && !empty($save_data['email'])) { $rcmail->user->update_identity($identity['identity_id'], $save_data); - rcube_sess_unset('plugin.newuserdialog'); + $rcmail->session->remove('plugin.newuserdialog'); } - + $rcmail->output->redirect(''); } - + } -?> \ No newline at end of file +?>