svncommit
2006-10-22 5c52d06844779efbf4034663f5e68db10619b367
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                     |
8  | Copyright (C) 2005, 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
22 if (($_GET['_iid'] || $_POST['_iid']) && $_action=='edit-identity')
23   {
d7cb77 24   $DB->query("SELECT * FROM ".get_table_name('identities')."
S 25               WHERE  identity_id=?
26               AND    user_id=?
1cded8 27               AND    del<>1",
89406f 28               get_input_value('_iid', RCUBE_INPUT_GPC),
d7cb77 29               $_SESSION['user_id']);
4e17e6 30   
T 31   $IDENTITY_RECORD = $DB->fetch_assoc();
32   
33   if (is_array($IDENTITY_RECORD))
34     $OUTPUT->add_script(sprintf("%s.set_env('iid', '%s');", $JS_OBJECT_NAME, $IDENTITY_RECORD['identity_id']));
35     
36   $PAGE_TITLE = rcube_label('edititem');
37   }
38 else
39   $PAGE_TITLE = rcube_label('newitem');
40
41
42
43 function rcube_identity_form($attrib)
44   {
a0109c 45   global $IDENTITY_RECORD, $JS_OBJECT_NAME, $OUTPUT;
S 46
47   $OUTPUT->include_script('tiny_mce/tiny_mce_src.js');
48   $OUTPUT->add_script("tinyMCE.init({ mode : 'specific_textareas'," .
49                                     "apply_source_formatting : true," .
5ec619 50                                     "content_css : '\$__skin_path' + '/editor_content.css'," .
S 51                                     "popups_css : '\$__skin_path' + '/editor_popups.css'," .
52                                     "editor_css : '\$__skin_path' + '/editor_ui.css'," .
a0109c 53                                     "theme : 'advanced'," .
S 54                                     "theme_advanced_toolbar_location : 'top'," .
55                                     "theme_advanced_toolbar_align : 'left'," .
56                                     "theme_advanced_buttons1 : 'bold,italic,underline,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,separator,outdent,indent,charmap,hr'," .
57                                     "theme_advanced_buttons2 : 'link,unlink,forecolor,fontselect,fontsizeselect'," .
58                                     "theme_advanced_buttons3 : '' });");
4e17e6 59
T 60   if (!$IDENTITY_RECORD && $GLOBALS['_action']!='add-identity')
61     return rcube_label('notfound');
62
10a699 63   // add some labels to client
T 64   rcube_add_label('noemailwarning');
65   rcube_add_label('nonamewarning');
66
67
4e17e6 68   list($form_start, $form_end) = get_form_tags($attrib, 'save-identity', array('name' => '_iid', 'value' => $IDENTITY_RECORD['identity_id']));
T 69   unset($attrib['form']);
70
71
72   // list of available cols
73   $a_show_cols = array('name'         => array('type' => 'text'),
74                        'email'        => array('type' => 'text'),
75                        'organization' => array('type' => 'text'),
76                        'reply-to'     => array('type' => 'text', 'label' => 'replyto'),
77                        'bcc'          => array('type' => 'text'),
a0109c 78                        'signature'      => array('type' => 'textarea', 'size' => "40", 'rows' => "6"),
S 79                        'html_signature'=>array('type' => 'checkbox', 'label' => 'htmlsignature', 'onclick' => 'return rcmail.toggle_editor(this, \'_signature\');'),
1cded8 80                        'standard'     => array('type' => 'checkbox', 'label' => 'setdefault'));
4e17e6 81
T 82
83   // a specific part is requested
84   if ($attrib['part'])
85     {
86     $colprop = $a_show_cols[$attrib['part']];
87     if (is_array($colprop))
88       {
89       $out = $form_start;
90       $out .= rcmail_get_edit_field($attrib['part'], $IDENTITY_RECORD[$attrib['part']], $attrib, $colprop['type']); 
91       return $out;
92       }
93     else
94       return '';
95     }
96
97
98   // return the complete edit form as table
99   $out = "$form_start<table>\n\n";
100
101   foreach ($a_show_cols as $col => $colprop)
102     {
103     $attrib['id'] = 'rcmfd_'.$col;
a0109c 104
S 105     if (strlen($colprop['onclick']))
106       $attrib['onclick'] = $colprop['onclick'];
107     else
108       unset($attrib['onclick']);
109
110     if ($col == 'signature')
111       {
112       $attrib['size'] = $colprop['size'];
113       $attrib['rows'] = $colprop['rows'];
114       $attrib['mce_editable'] = $IDENTITY_RECORD['html_signature'] ? "true" : "false";
115       }
116     else
117       {
118       unset($attrib['size']);
119       unset($attrib['rows']);
120       unset($attrib['mce_editable']);
121       }
122
4e17e6 123     $label = strlen($colprop['label']) ? $colprop['label'] : $col;
T 124     $value = rcmail_get_edit_field($col, $IDENTITY_RECORD[$col], $attrib, $colprop['type']);
125
126     $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
127                     $attrib['id'],
1038d5 128                     rep_specialchars_output(rcube_label($label)),
4e17e6 129                     $value);
T 130     }
131
132   $out .= "\n</table>$form_end";
133
134   return $out;  
135   }
136
137
138
139 if ($_action=='add-identity' && template_exists('addidentity'))
140   parse_template('addidentity');
141
142 parse_template('editidentity');
5ec619 143 ?>