Skip to content

Commit

Permalink
- Added option 'identities_level', removed 'multiple_identities'
Browse files Browse the repository at this point in the history
- Allow deleting identities when multiple_identities=false (#1485435)
  • Loading branch information
alecpl committed Oct 24, 2008
1 parent d1a8d0f commit ec01712
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 22 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG
@@ -1,6 +1,11 @@
CHANGELOG RoundCube Webmail 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) 2008/10/22 (alec)
---------- ----------
- Added option focus_on_new_message (#1485374) - Added option focus_on_new_message (#1485374)
Expand Down
8 changes: 6 additions & 2 deletions config/main.inc.php.dist
Expand Up @@ -285,8 +285,12 @@ $rcmail_config['address_book_type'] = 'sql';
// don't allow these settings to be overriden by the user // don't allow these settings to be overriden by the user
$rcmail_config['dont_override'] = array(); $rcmail_config['dont_override'] = array();


// allow users to add and delete sender identities // Set identities access level:
$rcmail_config['multiple_identities'] = true; // 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 // try to load host-specific configuration
// see http://trac.roundcube.net/wiki/Howto_Config for more details // see http://trac.roundcube.net/wiki/Howto_Config for more details
Expand Down
16 changes: 16 additions & 0 deletions installer/config.php
Expand Up @@ -122,6 +122,22 @@
<p class="hint">It is based on GoogieSpell what implies that the message content will be sent to Google in order to check the spelling.</p> <p class="hint">It is based on GoogieSpell what implies that the message content will be sent to Google in order to check the spelling.</p>
</dd> </dd>


<dt class="propname">identities_level</dt>
<dd>
<?php

$input_ilevel = new html_select(array('name' => '_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);

?>
<div>Level of identities access</div>
<p class="hint">Defines what users can do with their identities.</p>
</dd>

</dl> </dl>
</fieldset> </fieldset>


Expand Down
2 changes: 1 addition & 1 deletion program/include/rcmail.php
Expand Up @@ -433,7 +433,7 @@ function login($username, $pass, $host=NULL)


// lowercase username if it's an e-mail address (#1484473) // lowercase username if it's an e-mail address (#1484473)
if (strpos($username, '@')) if (strpos($username, '@'))
$username = strtolower($username); $username = rc_strtolower($username);


// user already registered -> overwrite username // user already registered -> overwrite username
if ($user = rcube_user::query($username, $host)) if ($user = rcube_user::query($username, $host))
Expand Down
4 changes: 2 additions & 2 deletions program/js/app.js
Expand Up @@ -288,8 +288,8 @@ function rcube_webmail()
this.enable_command('preferences', 'identities', 'save', 'folders', true); this.enable_command('preferences', 'identities', 'save', 'folders', true);


if (this.env.action=='identities' || this.env.action=='edit-identity' || this.env.action=='add-identity') { 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('add', this.env.identities_level < 2);
this.enable_command('edit', true); this.enable_command('delete', 'edit', true);
} }


if (this.env.action=='edit-identity' || this.env.action=='add-identity') if (this.env.action=='edit-identity' || this.env.action=='add-identity')
Expand Down
30 changes: 21 additions & 9 deletions program/steps/settings/edit_identity.inc
Expand Up @@ -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') { if (($_GET['_iid'] || $_POST['_iid']) && $RCMAIL->action=='edit-identity') {
$IDENTITY_RECORD = $USER->get_identity(get_input_value('_iid', RCUBE_INPUT_GPC)); $IDENTITY_RECORD = $USER->get_identity(get_input_value('_iid', RCUBE_INPUT_GPC));


if (is_array($IDENTITY_RECORD)) if (is_array($IDENTITY_RECORD))
$OUTPUT->set_env('iid', $IDENTITY_RECORD['identity_id']); $OUTPUT->set_env('iid', $IDENTITY_RECORD['identity_id']);
} }
else if (!$RCMAIL->config->get('multiple_identities', true)) { // add-identity
$OUTPUT->show_message('opnotpermitted', 'error'); else {
// go to identities page if (IDENTITIES_LEVEL > 1) {
rcmail_overwrite_action('identities'); $OUTPUT->show_message('opnotpermitted', 'error');
return; // 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) function rcube_identity_form($attrib)
{ {
Expand Down Expand Up @@ -85,7 +89,12 @@ function rcube_identity_form($attrib)
'html_signature'=>array('type' => 'checkbox', 'label' => 'htmlsignature', 'onclick' => 'return rcmail.toggle_editor(this, \'rcmfd_signature\');'), 'html_signature'=>array('type' => 'checkbox', 'label' => 'htmlsignature', 'onclick' => 'return rcmail.toggle_editor(this, \'rcmfd_signature\');'),
'standard' => array('type' => 'checkbox', 'label' => 'setdefault')); '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 // a specific part is requested
if ($attrib['part']) if ($attrib['part'])
{ {
Expand Down Expand Up @@ -131,12 +140,15 @@ function rcube_identity_form($attrib)
return $out; return $out;
} }


$OUTPUT->include_script('list.js');
$OUTPUT->add_handler('identityform', 'rcube_identity_form'); $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'))); $OUTPUT->set_pagetitle(rcube_label(($RCMAIL->action=='add-identity' ? 'newidentity' : 'edititem')));


if ($RCMAIL->action=='add-identity' && $OUTPUT->template_exists('addidentity')) if ($RCMAIL->action=='add-identity' && $OUTPUT->template_exists('addidentity'))
$OUTPUT->send('addidentity'); $OUTPUT->send('addidentity');


$OUTPUT->send('editidentity'); $OUTPUT->send('editidentity');

?> ?>
19 changes: 18 additions & 1 deletion program/steps/settings/func.inc
Expand Up @@ -401,7 +401,24 @@ function rcmail_get_skins()
return $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 // register UI objects
$OUTPUT->add_handlers(array( $OUTPUT->add_handlers(array(
Expand Down
3 changes: 3 additions & 0 deletions program/steps/settings/identities.inc
Expand Up @@ -19,6 +19,8 @@
*/ */


define('IDENTITIES_LEVEL', intval($RCMAIL->config->get('identities_level', 0)));

$OUTPUT->set_pagetitle(rcube_label('identities')); $OUTPUT->set_pagetitle(rcube_label('identities'));


$OUTPUT->include_script('list.js'); $OUTPUT->include_script('list.js');
Expand All @@ -40,6 +42,7 @@ function rcmail_identity_frame($attrib)
} }


$OUTPUT->add_handler('identityframe', 'rcmail_identity_frame'); $OUTPUT->add_handler('identityframe', 'rcmail_identity_frame');
$OUTPUT->set_env('identities_level', IDENTITIES_LEVEL);


$OUTPUT->send('identities'); $OUTPUT->send('identities');
?> ?>
17 changes: 13 additions & 4 deletions program/steps/settings/save_identity.inc
Expand Up @@ -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_save_cols = array('name', 'email', 'organization', 'reply-to', 'bcc', 'standard', 'signature', 'html_signature');
$a_html_cols = array('signature'); $a_html_cols = array('signature');
$a_boolean_cols = array('standard', 'html_signature'); $a_boolean_cols = array('standard', 'html_signature');
$updated = $default_id = false; $updated = $default_id = false;


// check input // 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'); $OUTPUT->show_message('formincomplete', 'warning');
rcmail_overwrite_action('edit-identity'); rcmail_overwrite_action('edit-identity');
Expand All @@ -50,6 +52,10 @@ foreach ($a_boolean_cols as $col)
$save_data[$col] = 0; $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 // update an existing contact
if ($_POST['_iid']) if ($_POST['_iid'])
Expand Down Expand Up @@ -77,9 +83,12 @@ if ($_POST['_iid'])
} }


// insert a new identity record // 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'); $OUTPUT->show_message('successfullysaved', 'confirmation');


Expand Down Expand Up @@ -107,4 +116,4 @@ if ($default_id)
// go to next step // go to next step
rcmail_overwrite_action('identities'); rcmail_overwrite_action('identities');


?> ?>
5 changes: 5 additions & 0 deletions skins/default/settings.css
Expand Up @@ -161,6 +161,11 @@ span.tablink-selected a
padding-right: 10px; padding-right: 10px;
} }


input.disabled
{
color: #999999;
}

#bottomboxes #bottomboxes
{ {
position: absolute; position: absolute;
Expand Down
4 changes: 2 additions & 2 deletions skins/default/templates/editidentity.html
Expand Up @@ -17,7 +17,7 @@
</div> </div>


<p id="listbuttons"> <p id="listbuttons">
<roundcube:button command="add" type="input" label="newidentity" class="button" condition="config:multiple_identities:true" /> <roundcube:button command="add" type="input" label="newidentity" class="button" condition="config:identities_level:0<2" />
</p> </p>


<div id="identity-details"> <div id="identity-details">
Expand All @@ -27,7 +27,7 @@
<roundcube:object name="identityform" size="40" textareacols="60" textarearows="6" /> <roundcube:object name="identityform" size="40" textareacols="60" textarearows="6" />


<p><br /> <p><br />
<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="delete" type="input" class="button" label="delete" condition="env:action=='edit-identity'" style="margin-right:0.5em" />
<roundcube:button command="save" type="input" class="button mainaction" label="save" /> <roundcube:button command="save" type="input" class="button mainaction" label="save" />
</p> </p>
</div> </div>
Expand Down
2 changes: 1 addition & 1 deletion skins/default/templates/identities.html
Expand Up @@ -17,7 +17,7 @@
</div> </div>


<p id="listbuttons"> <p id="listbuttons">
<roundcube:button command="add" type="input" label="newidentity" class="button" condition="config:multiple_identities:true" /> <roundcube:button command="add" type="input" label="newidentity" class="button" condition="config:identities_level:0<2" />
</p> </p>


<div id="identity-details"> <div id="identity-details">
Expand Down

0 comments on commit ec01712

Please sign in to comment.