4 +-----------------------------------------------------------------------+
5 | program/steps/settings/edit_identity.inc |
7 | This file is part of the RoundCube Webmail client |
8 | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland |
9 | Licensed under the GNU GPL |
12 | Show edit form for a identity record or to add a new one |
14 +-----------------------------------------------------------------------+
15 | Author: Thomas Bruederli <roundcube@gmail.com> |
16 +-----------------------------------------------------------------------+
18 $Id: edit_identity.inc 2755 2009-07-15 09:49:35Z thomasb $
22 define('IDENTITIES_LEVEL', intval($RCMAIL->config->get('identities_level', 0)));
25 if (($_GET['_iid'] || $_POST['_iid']) && $RCMAIL->action=='edit-identity') {
26 $IDENTITY_RECORD = $USER->get_identity(get_input_value('_iid', RCUBE_INPUT_GPC));
28 if (is_array($IDENTITY_RECORD))
29 $OUTPUT->set_env('iid', $IDENTITY_RECORD['identity_id']);
31 $OUTPUT->show_message('opnotpermitted', 'error');
32 // go to identities page
33 rcmail_overwrite_action('identities');
39 if (IDENTITIES_LEVEL > 1) {
40 $OUTPUT->show_message('opnotpermitted', 'error');
41 // go to identities page
42 rcmail_overwrite_action('identities');
45 else if (IDENTITIES_LEVEL == 1)
46 $IDENTITY_RECORD['email'] = $RCMAIL->user->get_username();
50 function rcube_identity_form($attrib)
52 global $IDENTITY_RECORD, $RCMAIL, $OUTPUT;
54 rcube_html_editor('identity');
56 // add some labels to client
57 $OUTPUT->add_label('noemailwarning', 'nonamewarning', 'converting', 'editorwarning');
59 $i_size = !empty($attrib['size']) ? $attrib['size'] : 40;
60 $t_rows = !empty($attrib['textarearows']) ? $attrib['textarearows'] : 6;
61 $t_cols = !empty($attrib['textareacols']) ? $attrib['textareacols'] : 40;
63 list($form_start, $form_end) = get_form_tags($attrib, 'save-identity', intval($IDENTITY_RECORD['identity_id']), array('name' => '_iid', 'value' => $IDENTITY_RECORD['identity_id']));
64 unset($attrib['form']);
66 // list of available cols
67 $a_show_cols = array('name' => array('type' => 'text', 'size' => $i_size),
68 'email' => array('type' => 'text', 'size' => $i_size),
69 'organization' => array('type' => 'text', 'size' => $i_size),
70 'reply-to' => array('type' => 'text', 'label' => 'reply-to', 'size' => $i_size),
71 'bcc' => array('type' => 'text', 'size' => $i_size),
72 'signature' => array('type' => 'textarea', 'size' => $t_cols, 'rows' => $t_rows),
73 'html_signature'=>array('type' => 'checkbox', 'label' => 'htmlsignature', 'onclick' => 'return rcmail_toggle_editor(this.checked, \'rcmfd_signature\');'),
74 'standard' => array('type' => 'checkbox', 'label' => 'setdefault'));
76 // disable some field according to access level
77 if (IDENTITIES_LEVEL == 1 || IDENTITIES_LEVEL == 3) {
78 $a_show_cols['email']['disabled'] = true;
79 $a_show_cols['email']['class'] = 'disabled';
82 // a specific part is requested
85 $colprop = $a_show_cols[$attrib['part']];
86 if (is_array($colprop))
89 $out .= rcmail_get_edit_field($attrib['part'], $IDENTITY_RECORD[$attrib['part']], $attrib, $colprop['type']);
97 // return the complete edit form as table
98 $out = "$form_start<table>\n\n";
100 foreach ($a_show_cols as $col => $colprop)
102 $colprop['id'] = 'rcmfd_'.$col;
104 if ($col == 'signature')
106 $colprop['spellcheck'] = true;
107 if ($IDENTITY_RECORD['html_signature'])
109 $colprop['class'] = 'mce_editor';
113 $label = strlen($colprop['label']) ? $colprop['label'] : $col;
114 $value = rcmail_get_edit_field($col, $IDENTITY_RECORD[$col], $colprop, $colprop['type']);
116 $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
118 Q(rcube_label($label)),
122 $out .= "\n</table>$form_end";
127 $OUTPUT->include_script('list.js');
128 $OUTPUT->add_handler('identityform', 'rcube_identity_form');
129 $OUTPUT->set_env('identities_level', IDENTITIES_LEVEL);
131 $OUTPUT->set_pagetitle(rcube_label(($RCMAIL->action=='add-identity' ? 'newidentity' : 'edititem')));
133 if ($RCMAIL->action=='add-identity' && $OUTPUT->template_exists('addidentity'))
134 $OUTPUT->send('addidentity');
136 $OUTPUT->send('editidentity');