commit | author | age
|
4e17e6
|
1 |
<?php |
T |
2 |
|
|
3 |
/* |
|
4 |
+-----------------------------------------------------------------------+ |
|
5 |
| program/steps/settings/edit_identity.inc | |
|
6 |
| | |
|
7 |
| This file is part of the RoundCube Webmail client | |
f11541
|
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 |
|
a55606
|
22 |
$OUTPUT->set_pagetitle(rcube_label('identities')); |
A |
23 |
|
f645ce
|
24 |
if (($_GET['_iid'] || $_POST['_iid']) && $RCMAIL->action=='edit-identity') { |
fba1f5
|
25 |
$IDENTITY_RECORD = $USER->get_identity(get_input_value('_iid', RCUBE_INPUT_GPC)); |
4e17e6
|
26 |
|
T |
27 |
if (is_array($IDENTITY_RECORD)) |
f11541
|
28 |
$OUTPUT->set_env('iid', $IDENTITY_RECORD['identity_id']); |
f645ce
|
29 |
} |
T |
30 |
else if (!$RCMAIL->config->get('multiple_identities', true)) { |
|
31 |
$OUTPUT->show_message('opnotpermitted', 'error'); |
|
32 |
// go to identities page |
|
33 |
rcmail_overwrite_action('identities'); |
|
34 |
return; |
|
35 |
} |
4e17e6
|
36 |
|
740e9e
|
37 |
$OUTPUT->include_script('list.js'); |
T |
38 |
|
4e17e6
|
39 |
|
T |
40 |
function rcube_identity_form($attrib) |
|
41 |
{ |
197601
|
42 |
global $IDENTITY_RECORD, $RCMAIL, $OUTPUT; |
a0109c
|
43 |
|
197601
|
44 |
$tinylang = substr($_SESSION['language'], 0, 2); |
33bb98
|
45 |
if (!file_exists('program/js/tiny_mce/langs/'.$tinylang.'.js')) |
A |
46 |
{ |
|
47 |
$tinylang = 'en'; |
|
48 |
} |
|
49 |
|
|
50 |
$OUTPUT->include_script('tiny_mce/tiny_mce.js'); |
d9344f
|
51 |
$OUTPUT->add_script("tinyMCE.init({ mode : 'textareas'," . |
S |
52 |
"editor_selector : 'mce_editor'," . |
a0109c
|
53 |
"apply_source_formatting : true," . |
140d6e
|
54 |
"language : '$tinylang'," . |
5ec619
|
55 |
"content_css : '\$__skin_path' + '/editor_content.css'," . |
a0109c
|
56 |
"theme : 'advanced'," . |
S |
57 |
"theme_advanced_toolbar_location : 'top'," . |
|
58 |
"theme_advanced_toolbar_align : 'left'," . |
106d05
|
59 |
"theme_advanced_buttons1 : 'bold,italic,underline,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,separator,outdent,indent,charmap,hr,link,unlink,code,forecolor'," . |
A |
60 |
"theme_advanced_buttons2 : ',fontselect,fontsizeselect'," . |
491a6e
|
61 |
"theme_advanced_buttons3 : '',". |
A |
62 |
"gecko_spellcheck : true });"); |
4e17e6
|
63 |
|
197601
|
64 |
if (!$IDENTITY_RECORD && $RCMAIL->action != 'add-identity') |
4e17e6
|
65 |
return rcube_label('notfound'); |
T |
66 |
|
10a699
|
67 |
// add some labels to client |
3bd94b
|
68 |
$OUTPUT->add_label('noemailwarning', 'nonamewarning', 'converting'); |
10a699
|
69 |
|
106d05
|
70 |
$i_size = !empty($attrib['size']) ? $attrib['size'] : 40; |
A |
71 |
$t_rows = !empty($attrib['textarearows']) ? $attrib['textarearows'] : 6; |
|
72 |
$t_cols = !empty($attrib['textareacols']) ? $attrib['textareacols'] : 40; |
10a699
|
73 |
|
4e17e6
|
74 |
list($form_start, $form_end) = get_form_tags($attrib, 'save-identity', array('name' => '_iid', 'value' => $IDENTITY_RECORD['identity_id'])); |
T |
75 |
unset($attrib['form']); |
|
76 |
|
|
77 |
|
|
78 |
// list of available cols |
106d05
|
79 |
$a_show_cols = array('name' => array('type' => 'text', 'size' => $i_size), |
A |
80 |
'email' => array('type' => 'text', 'size' => $i_size), |
|
81 |
'organization' => array('type' => 'text', 'size' => $i_size), |
|
82 |
'reply-to' => array('type' => 'text', 'label' => 'reply-to', 'size' => $i_size), |
|
83 |
'bcc' => array('type' => 'text', 'size' => $i_size), |
|
84 |
'signature' => array('type' => 'textarea', 'size' => $t_cols, 'rows' => $t_rows), |
d9344f
|
85 |
'html_signature'=>array('type' => 'checkbox', 'label' => 'htmlsignature', 'onclick' => 'return rcmail.toggle_editor(this, \'rcmfd_signature\');'), |
1cded8
|
86 |
'standard' => array('type' => 'checkbox', 'label' => 'setdefault')); |
4e17e6
|
87 |
|
T |
88 |
|
|
89 |
// a specific part is requested |
|
90 |
if ($attrib['part']) |
|
91 |
{ |
|
92 |
$colprop = $a_show_cols[$attrib['part']]; |
|
93 |
if (is_array($colprop)) |
|
94 |
{ |
|
95 |
$out = $form_start; |
106d05
|
96 |
$out .= rcmail_get_edit_field($attrib['part'], $IDENTITY_RECORD[$attrib['part']], $attrib, $colprop['type']); |
4e17e6
|
97 |
return $out; |
T |
98 |
} |
|
99 |
else |
|
100 |
return ''; |
|
101 |
} |
|
102 |
|
|
103 |
|
|
104 |
// return the complete edit form as table |
|
105 |
$out = "$form_start<table>\n\n"; |
|
106 |
|
|
107 |
foreach ($a_show_cols as $col => $colprop) |
|
108 |
{ |
106d05
|
109 |
$colprop['id'] = 'rcmfd_'.$col; |
a0109c
|
110 |
|
S |
111 |
if ($col == 'signature') |
|
112 |
{ |
106d05
|
113 |
$colprop['spellcheck'] = true; |
d9344f
|
114 |
if ($IDENTITY_RECORD['html_signature']) |
S |
115 |
{ |
106d05
|
116 |
$colprop['class'] = 'mce_editor'; |
d9344f
|
117 |
} |
a0109c
|
118 |
} |
S |
119 |
|
4e17e6
|
120 |
$label = strlen($colprop['label']) ? $colprop['label'] : $col; |
106d05
|
121 |
$value = rcmail_get_edit_field($col, $IDENTITY_RECORD[$col], $colprop, $colprop['type']); |
4e17e6
|
122 |
|
T |
123 |
$out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n", |
106d05
|
124 |
$colprop['id'], |
2bca6e
|
125 |
Q(rcube_label($label)), |
4e17e6
|
126 |
$value); |
T |
127 |
} |
|
128 |
|
|
129 |
$out .= "\n</table>$form_end"; |
|
130 |
|
|
131 |
return $out; |
|
132 |
} |
|
133 |
|
f11541
|
134 |
$OUTPUT->add_handler('identityform', 'rcube_identity_form'); |
4e17e6
|
135 |
|
f645ce
|
136 |
$OUTPUT->set_pagetitle(rcube_label(($RCMAIL->action=='add-identity' ? 'newidentity' : 'edititem'))); |
T |
137 |
|
e58df3
|
138 |
if ($RCMAIL->action=='add-identity' && $OUTPUT->template_exists('addidentity')) |
47124c
|
139 |
$OUTPUT->send('addidentity'); |
4e17e6
|
140 |
|
47124c
|
141 |
$OUTPUT->send('editidentity'); |
5ec619
|
142 |
?> |