diff --git a/CHANGELOG b/CHANGELOG index e0caecfe90c..8fbff19d872 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,11 @@ CHANGELOG RoundCube Webmail --------------------------- +2008/10/24 (alec) +---------- +- Added option 'identities_level', removed 'multiple_identities' +- Allow deleting identities when multiple_identities=false (#1485435) + 2008/10/22 (alec) ---------- - Added option focus_on_new_message (#1485374) diff --git a/config/main.inc.php.dist b/config/main.inc.php.dist index f6156c1b986..8a6c2966aa3 100644 --- a/config/main.inc.php.dist +++ b/config/main.inc.php.dist @@ -285,8 +285,12 @@ $rcmail_config['address_book_type'] = 'sql'; // don't allow these settings to be overriden by the user $rcmail_config['dont_override'] = array(); -// allow users to add and delete sender identities -$rcmail_config['multiple_identities'] = true; +// Set identities access level: +// 0 - many identities with possibility to edit all params +// 1 - many identities with possibility to edit all params but not email address +// 2 - one identity with possibility to edit all params +// 3 - one identity with possibility to edit all params but not email address +$rcmail_config['identities_level'] = 0; // try to load host-specific configuration // see http://trac.roundcube.net/wiki/Howto_Config for more details diff --git a/installer/config.php b/installer/config.php index 52991242cb6..13371afac82 100644 --- a/installer/config.php +++ b/installer/config.php @@ -122,6 +122,22 @@

It is based on GoogieSpell what implies that the message content will be sent to Google in order to check the spelling.

+
identities_level
+
+ '_identities_level', 'id' => "cfgidentitieslevel")); +$input_ilevel->add('many identities with possibility to edit all params', 0); +$input_ilevel->add('many identities with possibility to edit all params but not email address', 1); +$input_ilevel->add('one identity with possibility to edit all params', 2); +$input_ilevel->add('one identity with possibility to edit all params but not email address', 3); +echo $input_ilevel->show($RCI->getprop('identities_level'), 0); + +?> +
Level of identities access
+

Defines what users can do with their identities.

+
+ diff --git a/program/include/rcmail.php b/program/include/rcmail.php index d07e03c0db0..53b4765b9fe 100644 --- a/program/include/rcmail.php +++ b/program/include/rcmail.php @@ -433,7 +433,7 @@ function login($username, $pass, $host=NULL) // lowercase username if it's an e-mail address (#1484473) if (strpos($username, '@')) - $username = strtolower($username); + $username = rc_strtolower($username); // user already registered -> overwrite username if ($user = rcube_user::query($username, $host)) diff --git a/program/js/app.js b/program/js/app.js index 6994d18930e..861c3d7cfe0 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -288,8 +288,8 @@ function rcube_webmail() this.enable_command('preferences', 'identities', 'save', 'folders', true); if (this.env.action=='identities' || this.env.action=='edit-identity' || this.env.action=='add-identity') { - this.enable_command('add', 'delete', this.env.multiple_identities); - this.enable_command('edit', true); + this.enable_command('add', this.env.identities_level < 2); + this.enable_command('delete', 'edit', true); } if (this.env.action=='edit-identity' || this.env.action=='add-identity') diff --git a/program/steps/settings/edit_identity.inc b/program/steps/settings/edit_identity.inc index 5cad6bec8ce..78b20457673 100644 --- a/program/steps/settings/edit_identity.inc +++ b/program/steps/settings/edit_identity.inc @@ -19,23 +19,27 @@ */ -$OUTPUT->set_pagetitle(rcube_label('identities')); +define('IDENTITIES_LEVEL', intval($RCMAIL->config->get('identities_level', 0))); +// edit-identity if (($_GET['_iid'] || $_POST['_iid']) && $RCMAIL->action=='edit-identity') { $IDENTITY_RECORD = $USER->get_identity(get_input_value('_iid', RCUBE_INPUT_GPC)); if (is_array($IDENTITY_RECORD)) $OUTPUT->set_env('iid', $IDENTITY_RECORD['identity_id']); } -else if (!$RCMAIL->config->get('multiple_identities', true)) { - $OUTPUT->show_message('opnotpermitted', 'error'); - // go to identities page - rcmail_overwrite_action('identities'); - return; +// add-identity +else { + if (IDENTITIES_LEVEL > 1) { + $OUTPUT->show_message('opnotpermitted', 'error'); + // go to identities page + rcmail_overwrite_action('identities'); + return; + } + else if (IDENTITIES_LEVEL == 1) + $IDENTITY_RECORD['email'] = rcmail_get_email(); } -$OUTPUT->include_script('list.js'); - function rcube_identity_form($attrib) { @@ -85,7 +89,12 @@ function rcube_identity_form($attrib) 'html_signature'=>array('type' => 'checkbox', 'label' => 'htmlsignature', 'onclick' => 'return rcmail.toggle_editor(this, \'rcmfd_signature\');'), 'standard' => array('type' => 'checkbox', 'label' => 'setdefault')); - + // disable some field according to access level + if (IDENTITIES_LEVEL == 1 || IDENTITIES_LEVEL == 3) { + $a_show_cols['email']['disabled'] = true; + $a_show_cols['email']['class'] = 'disabled'; + } + // a specific part is requested if ($attrib['part']) { @@ -131,7 +140,9 @@ function rcube_identity_form($attrib) return $out; } +$OUTPUT->include_script('list.js'); $OUTPUT->add_handler('identityform', 'rcube_identity_form'); +$OUTPUT->set_env('identities_level', IDENTITIES_LEVEL); $OUTPUT->set_pagetitle(rcube_label(($RCMAIL->action=='add-identity' ? 'newidentity' : 'edititem'))); @@ -139,4 +150,5 @@ if ($RCMAIL->action=='add-identity' && $OUTPUT->template_exists('addidentity')) $OUTPUT->send('addidentity'); $OUTPUT->send('editidentity'); + ?> diff --git a/program/steps/settings/func.inc b/program/steps/settings/func.inc index 1b28d3b1741..6f378fd0ed0 100644 --- a/program/steps/settings/func.inc +++ b/program/steps/settings/func.inc @@ -401,7 +401,24 @@ function rcmail_get_skins() return $skins; } -$OUTPUT->set_env('multiple_identities', $RCMAIL->config->get('multiple_identities', true)); + +function rcmail_get_email() + { + global $RCMAIL; + + if (strpos($RCMAIL->user->data['username'], '@')) + return $RCMAIL->user->data['username']; + else { + if ($RCMAIL->config->get('virtuser_file')) + $user_email = rcube_user::user2email($RCMAIL->user->data['username']); + + if ($user_email == '') + $user_email = sprintf('%s@%s', $RCMAIL->user->data['username'], + $RCMAIL->config->mail_domain($_SESSION['imap_host'])); + + return $user_email; + } + } // register UI objects $OUTPUT->add_handlers(array( diff --git a/program/steps/settings/identities.inc b/program/steps/settings/identities.inc index fded6c151f0..e480f367e17 100644 --- a/program/steps/settings/identities.inc +++ b/program/steps/settings/identities.inc @@ -19,6 +19,8 @@ */ +define('IDENTITIES_LEVEL', intval($RCMAIL->config->get('identities_level', 0))); + $OUTPUT->set_pagetitle(rcube_label('identities')); $OUTPUT->include_script('list.js'); @@ -40,6 +42,7 @@ function rcmail_identity_frame($attrib) } $OUTPUT->add_handler('identityframe', 'rcmail_identity_frame'); +$OUTPUT->set_env('identities_level', IDENTITIES_LEVEL); $OUTPUT->send('identities'); ?> \ No newline at end of file diff --git a/program/steps/settings/save_identity.inc b/program/steps/settings/save_identity.inc index e19a3317bc3..b34575dcebc 100644 --- a/program/steps/settings/save_identity.inc +++ b/program/steps/settings/save_identity.inc @@ -19,13 +19,15 @@ */ +define('IDENTITIES_LEVEL', intval($RCMAIL->config->get('identities_level', 0))); + $a_save_cols = array('name', 'email', 'organization', 'reply-to', 'bcc', 'standard', 'signature', 'html_signature'); $a_html_cols = array('signature'); $a_boolean_cols = array('standard', 'html_signature'); $updated = $default_id = false; // check input -if (empty($_POST['_name']) || empty($_POST['_email'])) +if (empty($_POST['_name']) || (empty($_POST['_email']) && IDENTITIES_LEVEL != 1 && IDENTITIES_LEVEL != 3)) { $OUTPUT->show_message('formincomplete', 'warning'); rcmail_overwrite_action('edit-identity'); @@ -50,6 +52,10 @@ foreach ($a_boolean_cols as $col) $save_data[$col] = 0; } +// unset email address if user has no rights to change it +if (IDENTITIES_LEVEL == 1 || IDENTITIES_LEVEL == 3) + unset($save_data['email']); + // update an existing contact if ($_POST['_iid']) @@ -77,9 +83,12 @@ if ($_POST['_iid']) } // insert a new identity record -else if ($RCMAIL->config->get('multiple_identities', true)) +else if (IDENTITIES_LEVEL < 2) { - if ($insert_id = $USER->insert_identity($save_data)) + if (IDENTITIES_LEVEL == 1) + $save_data['email'] = rcmail_get_email(); + + if ($save_data['email'] && ($insert_id = $USER->insert_identity($save_data))) { $OUTPUT->show_message('successfullysaved', 'confirmation'); @@ -107,4 +116,4 @@ if ($default_id) // go to next step rcmail_overwrite_action('identities'); -?> \ No newline at end of file +?> diff --git a/skins/default/settings.css b/skins/default/settings.css index 19f4aa8c44b..01c24bd79d6 100644 --- a/skins/default/settings.css +++ b/skins/default/settings.css @@ -161,6 +161,11 @@ span.tablink-selected a padding-right: 10px; } +input.disabled +{ + color: #999999; +} + #bottomboxes { position: absolute; diff --git a/skins/default/templates/editidentity.html b/skins/default/templates/editidentity.html index bac7579dd60..0d1f6a4ab86 100644 --- a/skins/default/templates/editidentity.html +++ b/skins/default/templates/editidentity.html @@ -17,7 +17,7 @@

- +

@@ -27,7 +27,7 @@


- +

diff --git a/skins/default/templates/identities.html b/skins/default/templates/identities.html index bb29c61e6c4..1609fbe0f31 100644 --- a/skins/default/templates/identities.html +++ b/skins/default/templates/identities.html @@ -17,7 +17,7 @@

- +