diff options
author | alecpl <alec@alec.pl> | 2008-10-24 07:57:21 +0000 |
---|---|---|
committer | alecpl <alec@alec.pl> | 2008-10-24 07:57:21 +0000 |
commit | ec01712a998b35d48be3daaf272779fdbc63cd74 (patch) | |
tree | 397846eede8b3d52e55dcc33563b0bc47b0a2913 /program/steps | |
parent | d1a8d0f4c21136c9adc7efa02e3a37772bea222f (diff) |
- Added option 'identities_level', removed 'multiple_identities'
- Allow deleting identities when multiple_identities=false (#1485435)
Diffstat (limited to 'program/steps')
-rw-r--r-- | program/steps/settings/edit_identity.inc | 30 | ||||
-rw-r--r-- | program/steps/settings/func.inc | 19 | ||||
-rw-r--r-- | program/steps/settings/identities.inc | 3 | ||||
-rw-r--r-- | program/steps/settings/save_identity.inc | 17 |
4 files changed, 55 insertions, 14 deletions
diff --git a/program/steps/settings/edit_identity.inc b/program/steps/settings/edit_identity.inc index 5cad6bec8..78b204576 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 1b28d3b17..6f378fd0e 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 fded6c151..e480f367e 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 e19a3317b..b34575dce 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 +?> |