commit | author | age
|
4e17e6
|
1 |
<?php |
T |
2 |
|
|
3 |
/* |
|
4 |
+-----------------------------------------------------------------------+ |
|
5 |
| program/steps/settings/edit_identity.inc | |
|
6 |
| | |
e019f2
|
7 |
| This file is part of the Roundcube Webmail client | |
A |
8 |
| Copyright (C) 2005-2007, Roundcube Dev. - Switzerland | |
30233b
|
9 |
| Licensed under the GNU GPL | |
4e17e6
|
10 |
| | |
T |
11 |
| PURPOSE: | |
|
12 |
| Show edit form for a identity record or to add a new one | |
|
13 |
| | |
|
14 |
+-----------------------------------------------------------------------+ |
|
15 |
| Author: Thomas Bruederli <roundcube@gmail.com> | |
|
16 |
+-----------------------------------------------------------------------+ |
|
17 |
|
|
18 |
$Id$ |
|
19 |
|
|
20 |
*/ |
|
21 |
|
ec0171
|
22 |
define('IDENTITIES_LEVEL', intval($RCMAIL->config->get('identities_level', 0))); |
a55606
|
23 |
|
ec0171
|
24 |
// edit-identity |
f645ce
|
25 |
if (($_GET['_iid'] || $_POST['_iid']) && $RCMAIL->action=='edit-identity') { |
fba1f5
|
26 |
$IDENTITY_RECORD = $USER->get_identity(get_input_value('_iid', RCUBE_INPUT_GPC)); |
d11fb2
|
27 |
|
4e17e6
|
28 |
if (is_array($IDENTITY_RECORD)) |
f11541
|
29 |
$OUTPUT->set_env('iid', $IDENTITY_RECORD['identity_id']); |
7f59c0
|
30 |
else { |
A |
31 |
$OUTPUT->show_message('opnotpermitted', 'error'); |
|
32 |
// go to identities page |
|
33 |
rcmail_overwrite_action('identities'); |
|
34 |
return; |
|
35 |
} |
f645ce
|
36 |
} |
ec0171
|
37 |
// add-identity |
A |
38 |
else { |
|
39 |
if (IDENTITIES_LEVEL > 1) { |
|
40 |
$OUTPUT->show_message('opnotpermitted', 'error'); |
|
41 |
// go to identities page |
|
42 |
rcmail_overwrite_action('identities'); |
|
43 |
return; |
|
44 |
} |
|
45 |
else if (IDENTITIES_LEVEL == 1) |
82c45a
|
46 |
$IDENTITY_RECORD['email'] = $RCMAIL->user->get_username(); |
f645ce
|
47 |
} |
740e9e
|
48 |
|
4e17e6
|
49 |
|
T |
50 |
function rcube_identity_form($attrib) |
d11fb2
|
51 |
{ |
197601
|
52 |
global $IDENTITY_RECORD, $RCMAIL, $OUTPUT; |
a0109c
|
53 |
|
d11fb2
|
54 |
// Add HTML editor script(s) |
b8ae50
|
55 |
rcube_html_editor('identity'); |
4e17e6
|
56 |
|
10a699
|
57 |
// add some labels to client |
79af0b
|
58 |
$OUTPUT->add_label('noemailwarning', 'nonamewarning', 'converting', 'editorwarning'); |
10a699
|
59 |
|
106d05
|
60 |
$i_size = !empty($attrib['size']) ? $attrib['size'] : 40; |
A |
61 |
$t_rows = !empty($attrib['textarearows']) ? $attrib['textarearows'] : 6; |
|
62 |
$t_cols = !empty($attrib['textareacols']) ? $attrib['textareacols'] : 40; |
10a699
|
63 |
|
4e17e6
|
64 |
// list of available cols |
d11fb2
|
65 |
$form = array( |
A |
66 |
'addressing' => array( |
|
67 |
'name' => rcube_label('settings'), |
|
68 |
'content' => array( |
|
69 |
'name' => array('type' => 'text', 'size' => $i_size), |
|
70 |
'email' => array('type' => 'text', 'size' => $i_size), |
|
71 |
'organization' => array('type' => 'text', 'size' => $i_size), |
|
72 |
'reply-to' => array('type' => 'text', 'size' => $i_size), |
|
73 |
'bcc' => array('type' => 'text', 'size' => $i_size), |
|
74 |
'standard' => array('type' => 'checkbox', 'label' => rcube_label('setdefault')), |
|
75 |
)), |
|
76 |
'signature' => array( |
|
77 |
'name' => rcube_label('signature'), |
|
78 |
'content' => array( |
|
79 |
'signature' => array('type' => 'textarea', 'size' => $t_cols, 'rows' => $t_rows, |
|
80 |
'spellcheck' => true), |
|
81 |
'html_signature' => array('type' => 'checkbox', 'label' => rcube_label('htmlsignature'), |
|
82 |
'onclick' => 'return rcmail_toggle_editor(this, \'rcmfd_signature\');'), |
|
83 |
)) |
|
84 |
); |
|
85 |
|
|
86 |
// Enable TinyMCE editor |
|
87 |
if ($IDENTITY_RECORD['html_signature']) { |
|
88 |
$form['signature']['content']['signature']['class'] = 'mce_editor'; |
|
89 |
} |
4e17e6
|
90 |
|
ec0171
|
91 |
// disable some field according to access level |
A |
92 |
if (IDENTITIES_LEVEL == 1 || IDENTITIES_LEVEL == 3) { |
1c1e1e
|
93 |
$form['addressing']['content']['email']['disabled'] = true; |
A |
94 |
$form['addressing']['content']['email']['class'] = 'disabled'; |
ec0171
|
95 |
} |
4e17e6
|
96 |
|
e99991
|
97 |
$IDENTITY_RECORD['email'] = idn_to_utf8($IDENTITY_RECORD['email']); |
A |
98 |
$IDENTITY_RECORD['reply-to'] = idn_to_utf8($IDENTITY_RECORD['reply-to']); |
|
99 |
$IDENTITY_RECORD['bcc'] = idn_to_utf8($IDENTITY_RECORD['bcc']); |
|
100 |
|
d11fb2
|
101 |
// Allow plugins to modify identity form content |
A |
102 |
$plugin = $RCMAIL->plugins->exec_hook('identity_form', array( |
|
103 |
'form' => $form, 'record' => $IDENTITY_RECORD)); |
|
104 |
|
|
105 |
$form = $plugin['form']; |
|
106 |
$IDENTITY_RECORD = $plugin['record']; |
|
107 |
|
|
108 |
// Set form tags and hidden fields |
|
109 |
list($form_start, $form_end) = get_form_tags($attrib, 'save-identity', |
|
110 |
intval($IDENTITY_RECORD['identity_id']), |
|
111 |
array('name' => '_iid', 'value' => $IDENTITY_RECORD['identity_id'])); |
|
112 |
|
|
113 |
unset($plugin); |
|
114 |
unset($attrib['form']); |
4e17e6
|
115 |
|
T |
116 |
// return the complete edit form as table |
d11fb2
|
117 |
$out = "$form_start\n"; |
4e17e6
|
118 |
|
d11fb2
|
119 |
foreach ($form as $fieldset) { |
A |
120 |
if (empty($fieldset['content'])) |
|
121 |
continue; |
a0109c
|
122 |
|
d11fb2
|
123 |
$content = ''; |
A |
124 |
if (is_array($fieldset['content'])) { |
|
125 |
$table = new html_table(array('cols' => 2)); |
|
126 |
foreach ($fieldset['content'] as $col => $colprop) { |
|
127 |
$colprop['id'] = 'rcmfd_'.$col; |
|
128 |
|
db1a87
|
129 |
$label = !empty($colprop['label']) ? $colprop['label'] : |
T |
130 |
rcube_label(str_replace('-', '', $col)); |
d11fb2
|
131 |
$value = !empty($colprop['value']) ? $colprop['value'] : |
A |
132 |
rcmail_get_edit_field($col, $IDENTITY_RECORD[$col], $colprop, $colprop['type']); |
|
133 |
|
|
134 |
$table->add('title', sprintf('<label for="%s">%s</label>', $colprop['id'], Q($label))); |
|
135 |
$table->add(null, $value); |
a0109c
|
136 |
} |
d11fb2
|
137 |
$content = $table->show(); |
A |
138 |
} |
|
139 |
else { |
|
140 |
$content = $fieldset['content']; |
4e17e6
|
141 |
} |
T |
142 |
|
d11fb2
|
143 |
$out .= html::tag('fieldset', null, html::tag('legend', null, Q($fieldset['name'])) . $content) ."\n"; |
4e17e6
|
144 |
} |
T |
145 |
|
d11fb2
|
146 |
$out .= $form_end; |
A |
147 |
|
|
148 |
return $out; |
|
149 |
} |
|
150 |
|
ec0171
|
151 |
$OUTPUT->include_script('list.js'); |
f11541
|
152 |
$OUTPUT->add_handler('identityform', 'rcube_identity_form'); |
ec0171
|
153 |
$OUTPUT->set_env('identities_level', IDENTITIES_LEVEL); |
4e17e6
|
154 |
|
f645ce
|
155 |
$OUTPUT->set_pagetitle(rcube_label(($RCMAIL->action=='add-identity' ? 'newidentity' : 'edititem'))); |
T |
156 |
|
83ba22
|
157 |
if ($RCMAIL->action=='add-identity' && $OUTPUT->template_exists('identityadd')) |
A |
158 |
$OUTPUT->send('identityadd'); |
4e17e6
|
159 |
|
83ba22
|
160 |
$OUTPUT->send('identityedit'); |
ec0171
|
161 |
|
b25dfd
|
162 |
|