From f645ce169e11339d45cbc0b5b4cf6154346fd4c7 Mon Sep 17 00:00:00 2001 From: thomascube <thomas@roundcube.net> Date: Mon, 15 Sep 2008 10:53:57 -0400 Subject: [PATCH] Redesign of the identities settings + add config option to disable multiple identities --- program/localization/de_DE/messages.inc | 1 skins/default/templates/editidentity.html | 10 +- CHANGELOG | 5 + program/localization/de_CH/messages.inc | 1 program/steps/settings/save_identity.inc | 4 config/main.inc.php.dist | 3 program/steps/settings/edit_identity.inc | 14 ++- /dev/null | 36 --------- program/steps/settings/delete_identity.inc | 17 ++- skins/default/settings.css | 45 +++++++++- program/localization/en_US/messages.inc | 1 program/steps/settings/func.inc | 3 program/include/rcube_template.php | 50 +++++++----- program/js/app.js | 6 + skins/default/templates/identities.html | 10 ++ 15 files changed, 123 insertions(+), 83 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 6d3a3cf..e185a5e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,11 @@ CHANGELOG RoundCube Webmail --------------------------- +2008/09/15 (thomasb) +---------- +- Redesign of the identities settings (#1484042) +- Add config option to disable creation/deletion of identities (#1484498) + 2008/09/15 (alec) ---------- - Added 'sendmail_delay' option to restrict messages sending interval (#1484491) diff --git a/config/main.inc.php.dist b/config/main.inc.php.dist index ffa2d06..5475c61 100644 --- a/config/main.inc.php.dist +++ b/config/main.inc.php.dist @@ -298,6 +298,9 @@ // 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; + // try to load host-specific configuration // see http://trac.roundcube.net/wiki/Howto_Config for more details $rcmail_config['include_host_config'] = false; diff --git a/program/include/rcube_template.php b/program/include/rcube_template.php index 4441b0a..98e29e7 100755 --- a/program/include/rcube_template.php +++ b/program/include/rcube_template.php @@ -106,6 +106,28 @@ $this->pagetitle = $title; } + + /** + * Getter for the current page title + * + * @return string The page title + */ + public function get_pagetitle() + { + if (!empty($this->pagetitle)) { + $title = $this->pagetitle; + } + else if ($this->env['task'] == 'login') { + $title = rcube_label(array('name' => 'welcome', 'vars' => array('product' => $this->config['product_name']))); + } + else { + $title = ucfirst($this->env['task']); + } + + return $title; + } + + /** * Set skin */ @@ -357,13 +379,7 @@ implode(',', $args) ); } - // add command to set page title - if ($this->ajax_call && !empty($this->pagetitle)) { - $out .= sprintf( - "this.set_pagetitle('%s');\n", - JQ((!empty($this->config['product_name']) ? $this->config['product_name'].' :: ' : '') . $this->pagetitle) - ); - } + return $out; } @@ -455,13 +471,13 @@ $condition = preg_replace( array( '/session:([a-z0-9_]+)/i', - '/config:([a-z0-9_]+)/i', + '/config:([a-z0-9_]+)(:([a-z0-9_]+))?/i', '/env:([a-z0-9_]+)/i', '/request:([a-z0-9_]+)/ie' ), array( "\$_SESSION['\\1']", - "\$this->config['\\1']", + "\$this->app->config->get('\\1',get_boolean('\\3'))", "\$this->env['\\1']", "get_input_value('\\1', RCUVE_INPUT_GPC)" ), @@ -591,20 +607,12 @@ } return $ver; } + if ($object=='steptitle') { + return Q($this->get_pagetitle()); + } if ($object=='pagetitle') { - $task = $this->env['task']; $title = !empty($this->config['product_name']) ? $this->config['product_name'].' :: ' : ''; - - if (!empty($this->pagetitle)) { - $title .= $this->pagetitle; - } - else if ($task == 'login') { - $title = rcube_label(array('name' => 'welcome', 'vars' => array('product' => $this->config['product_name']))); - } - else { - $title .= ucfirst($task); - } - + $title .= $this->get_pagetitle(); return Q($title); } break; diff --git a/program/js/app.js b/program/js/app.js index 31be5f7..83b3972 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -295,8 +295,10 @@ case 'settings': 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('edit', 'add', 'delete', 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); + } if (this.env.action=='edit-identity' || this.env.action=='add-identity') this.enable_command('save', true); diff --git a/program/localization/de_CH/messages.inc b/program/localization/de_CH/messages.inc index 201bf94..7357dc8 100644 --- a/program/localization/de_CH/messages.inc +++ b/program/localization/de_CH/messages.inc @@ -85,5 +85,6 @@ $messages['importwait'] = 'Daten werden importiert, bitte warten...'; $messages['importerror'] = 'Import fehlgeschlagen! Die hochgeladene Datei ist nicht im vCard-Format.'; $messages['importconfirm'] = '<b>Es wurden $inserted Adressen erfolgreich importiert und $skipped bestehende Einträge übersprungen</b>:<p><em>$names</em></p>'; +$messages['opnotpermitted'] = 'Operation nicht erlaubt!'; ?> diff --git a/program/localization/de_DE/messages.inc b/program/localization/de_DE/messages.inc index 36892db..646ac7d 100644 --- a/program/localization/de_DE/messages.inc +++ b/program/localization/de_DE/messages.inc @@ -85,5 +85,6 @@ $messages['importwait'] = 'Daten werden importiert, bitte warten...'; $messages['importerror'] = 'Import fehlgeschlagen! Die hochgeladene Datei ist nicht im vCard-Format.'; $messages['importconfirm'] = 'Es wurden $inserted Adressen erfolgreich importiert und $skipped bestehende Einträge übersprungen:$names'; +$messages['opnotpermitted'] = 'Operation nicht erlaubt!'; ?> diff --git a/program/localization/en_US/messages.inc b/program/localization/en_US/messages.inc index 9373be8..26e107f 100644 --- a/program/localization/en_US/messages.inc +++ b/program/localization/en_US/messages.inc @@ -86,5 +86,6 @@ $messages['importwait'] = 'Importing, please wait...'; $messages['importerror'] = 'Import failed! The uploaded file is not a valid vCard file.'; $messages['importconfirm'] = '<b>Successfully imported $inserted contacts, $skipped existing entries skipped</b>:<p><em>$names</em></p>'; +$messages['opnotpermitted'] = 'Operation not permitted!'; ?> \ No newline at end of file diff --git a/program/steps/settings/delete_identity.inc b/program/steps/settings/delete_identity.inc index a5f3d44..87bac13 100644 --- a/program/steps/settings/delete_identity.inc +++ b/program/steps/settings/delete_identity.inc @@ -21,15 +21,18 @@ if (($ids = get_input_value('_iid', RCUBE_INPUT_GET)) && preg_match('/^[0-9]+(,[0-9]+)*$/', $ids)) { - - if ($USER->delete_identity($ids)) - { - $OUTPUT->show_message('deletedsuccessfully', 'confirmation'); + if ($RCMAIL->config->get('multiple_identities', true)) { + if ($USER->delete_identity($ids)) { + $OUTPUT->show_message('deletedsuccessfully', 'confirmation'); + } + else { + $OUTPUT->show_message('nodeletelastidentity', 'error'); + } } - else - { - $OUTPUT->show_message('nodeletelastidentity', 'error'); + else { + $OUTPUT->show_message('opnotpermitted', 'error'); } + // send response if ($OUTPUT->ajax_call) $OUTPUT->send(); diff --git a/program/steps/settings/edit_identity.inc b/program/steps/settings/edit_identity.inc index 46918cb..1e3fa34 100644 --- a/program/steps/settings/edit_identity.inc +++ b/program/steps/settings/edit_identity.inc @@ -21,14 +21,18 @@ $OUTPUT->set_pagetitle(rcube_label('identities')); -if (($_GET['_iid'] || $_POST['_iid']) && $RCMAIL->action=='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; +} $OUTPUT->include_script('list.js'); @@ -136,6 +140,8 @@ $OUTPUT->add_handler('identityform', 'rcube_identity_form'); +$OUTPUT->set_pagetitle(rcube_label(($RCMAIL->action=='add-identity' ? 'newidentity' : 'edititem'))); + if ($RCMAIL->action=='add-identity' && $OUTPUT->template_exists('addidentity')) $OUTPUT->send('addidentity'); diff --git a/program/steps/settings/func.inc b/program/steps/settings/func.inc index ef2befd..1b399de 100644 --- a/program/steps/settings/func.inc +++ b/program/steps/settings/func.inc @@ -301,7 +301,7 @@ $attrib['id'] = 'rcmIdentitiesList'; // define list of cols to be displayed - $a_show_cols = array('name', 'email', 'organization', 'reply-to'); + $a_show_cols = array('name', 'email'); // create XHTML table $out = rcube_table_output($attrib, $USER->list_identities(), $a_show_cols, 'identity_id'); @@ -366,6 +366,7 @@ return $skins; } +$OUTPUT->set_env('multiple_identities', $RCMAIL->config->get('multiple_identities', true)); // register UI objects $OUTPUT->add_handlers(array( diff --git a/program/steps/settings/save_identity.inc b/program/steps/settings/save_identity.inc index 1eb9a90..de2b4fc 100644 --- a/program/steps/settings/save_identity.inc +++ b/program/steps/settings/save_identity.inc @@ -77,7 +77,7 @@ } // insert a new identity record -else +else if ($RCMAIL->config->get('multiple_identities', true)) { if ($insert_id = $USER->insert_identity($save_data)) { @@ -96,6 +96,8 @@ return; } } +else + $OUTPUT->show_message('opnotpermitted', 'error'); // mark all other identities as 'not-default' diff --git a/skins/default/settings.css b/skins/default/settings.css index 9dee623..ca01b5a 100644 --- a/skins/default/settings.css +++ b/skins/default/settings.css @@ -6,12 +6,12 @@ position: absolute; top: 50px; left: 220px; - right: 60px; + right: 40px; height: 22px; border-bottom: 1px solid #999999; white-space: nowrap; /* css hack for IE */ - width: expression((parseInt(document.documentElement.clientWidth)-280)+'px'); + width: expression((parseInt(document.documentElement.clientWidth)-260)+'px'); } span.tablink, @@ -87,16 +87,42 @@ background-color: #FFFFA6; } +#identities-list +{ + bottom: 60px; + width: 420px; + border: 1px solid #999999; +} + +#listbuttons +{ + position: absolute; + left: 20px; + bottom: 18px; +} + #identities-table { - width: 600px; - border: 1px solid #999999; + width: 420px; + table-layout: fixed; background-color: #F9F9F9; } #identities-table tbody td { cursor: default; + overflow: hidden; + text-overflow: ellipsis; +} + +#identities-table thead td.name +{ + width: 55%; +} + +#identities-table thead td.email +{ + width: 45%; } #identity-frame @@ -108,9 +134,16 @@ #identity-details { - margin-top: 30px; - width: 600px; + position: absolute; + top: 95px; + left: 450px; + right: 40px; + bottom: 60px; border: 1px solid #999999; + overflow: auto; + /* css hack for IE */ + width: expression((parseInt(document.documentElement.clientWidth)-490)+'px'); + height: expression((parseInt(document.documentElement.clientHeight)-160)+'px'); } #identity-details table td.title diff --git a/skins/default/templates/addidentity.html b/skins/default/templates/addidentity.html deleted file mode 100644 index 8162d1c..0000000 --- a/skins/default/templates/addidentity.html +++ /dev/null @@ -1,36 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml"> -<head> -<title><roundcube:object name="pagetitle" /></title> -<roundcube:include file="/includes/links.html" /> -<link rel="stylesheet" type="text/css" href="/settings.css" /> -</head> -<body> - -<roundcube:include file="/includes/taskbar.html" /> -<roundcube:include file="/includes/header.html" /> -<roundcube:include file="/includes/settingstabs.html" /> - - -<div id="identities-list"> -<roundcube:object name="identitiesList" id="identities-table" class="records-table" cellspacing="0" summary="Identities list" editIcon="" /> - -<p><roundcube:button command="add" type="input" label="newidentity" class="button" /></p> - -<div id="identity-details"> -<div id="identity-title"><roundcube:label name="newidentity" /></div> - -<div style="padding:15px;"> -<roundcube:object name="identityform" size="40" /> - -<p><br /> -<roundcube:button command="save" type="input" class="button" label="save" /> -</p> -</div> -</div> -</div> - -<roundcube:include file="/includes/settingscripts.html" /> - -</body> -</html> diff --git a/skins/default/templates/editidentity.html b/skins/default/templates/editidentity.html index 94c70e6..8744655 100644 --- a/skins/default/templates/editidentity.html +++ b/skins/default/templates/editidentity.html @@ -14,20 +14,22 @@ <div id="identities-list"> <roundcube:object name="identitiesList" id="identities-table" class="records-table" cellspacing="0" summary="Identities list" editIcon="" /> +</div> -<p><roundcube:button command="add" type="input" label="newidentity" class="button" /></p> +<p id="listbuttons"> +<roundcube:button command="add" type="input" label="newidentity" class="button" condition="config:multiple_identities:true" /> +</p> <div id="identity-details"> -<div id="identity-title"><roundcube:label name="edititem" /></div> +<div id="identity-title"><roundcube:object name="steptitle" /></div> <div style="padding:15px;"> <roundcube:object name="identityform" size="40" /> <p><br /> -<roundcube:button command="delete" type="input" class="button" label="delete" /> +<roundcube:button command="delete" type="input" class="button" label="delete" condition="env:action=='edit-identity'&&config:multiple_identities:true" style="margin-right:0.5em" /> <roundcube:button command="save" type="input" class="button mainaction" label="save" /> </p> -</div> </div> </div> diff --git a/skins/default/templates/identities.html b/skins/default/templates/identities.html index f9f3436..1dc42d0 100644 --- a/skins/default/templates/identities.html +++ b/skins/default/templates/identities.html @@ -13,8 +13,16 @@ <div id="identities-list"> <roundcube:object name="identitiesList" id="identities-table" class="records-table" cellspacing="0" summary="Identities list" editIcon="" /> +</div> -<p><roundcube:button command="add" type="input" label="newidentity" class="button" /></p> +<p id="listbuttons"> +<roundcube:button command="add" type="input" label="newidentity" class="button" condition="config:multiple_identities:true" /> +</p> + +<div id="identity-details"> + <div style="margin:10px auto; text-align:center"> + <img src="/images/rcube_watermark.png" width="245" height="245" alt="RoundCube" /> + </div> </div> <roundcube:include file="/includes/settingscripts.html" /> -- Gitblit v1.9.1