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 579 2007-05-18 13:11:22Z thomasb $
22 if (($_GET['_iid'] || $_POST['_iid']) && $_action=='edit-identity')
24 $DB->query("SELECT * FROM ".get_table_name('identities')."
28 get_input_value('_iid', RCUBE_INPUT_GPC),
29 $_SESSION['user_id']);
31 $IDENTITY_RECORD = $DB->fetch_assoc();
33 if (is_array($IDENTITY_RECORD))
34 $OUTPUT->set_env('iid', $IDENTITY_RECORD['identity_id']);
36 $OUTPUT->set_pagetitle(rcube_label('edititem'));
39 $OUTPUT->set_pagetitle(rcube_label('newitem'));
42 $OUTPUT->include_script('list.js');
45 function rcube_identity_form($attrib)
47 global $IDENTITY_RECORD, $OUTPUT;
50 $OUTPUT->include_script('tiny_mce/tiny_mce_src.js');
51 $OUTPUT->add_script("tinyMCE.init({ mode : 'specific_textareas'," .
52 "apply_source_formatting : true," .
53 "content_css : '\$__skin_path' + '/editor_content.css'," .
54 "popups_css : '\$__skin_path' + '/editor_popups.css'," .
55 "editor_css : '\$__skin_path' + '/editor_ui.css'," .
56 "theme : 'advanced'," .
57 "theme_advanced_toolbar_location : 'top'," .
58 "theme_advanced_toolbar_align : 'left'," .
59 "theme_advanced_buttons1 : 'bold,italic,underline,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,separator,outdent,indent,charmap,hr'," .
60 "theme_advanced_buttons2 : 'link,unlink,code,forecolor,fontselect,fontsizeselect'," .
61 "theme_advanced_buttons3 : '' });");
63 if (!$IDENTITY_RECORD && $GLOBALS['_action']!='add-identity')
64 return rcube_label('notfound');
66 // add some labels to client
67 rcube_add_label('noemailwarning', 'nonamewarning');
70 list($form_start, $form_end) = get_form_tags($attrib, 'save-identity', array('name' => '_iid', 'value' => $IDENTITY_RECORD['identity_id']));
71 unset($attrib['form']);
74 // list of available cols
75 $a_show_cols = array('name' => array('type' => 'text'),
76 'email' => array('type' => 'text'),
77 'organization' => array('type' => 'text'),
78 'reply-to' => array('type' => 'text', 'label' => 'replyto'),
79 'bcc' => array('type' => 'text'),
80 'signature' => array('type' => 'textarea', 'size' => "40", 'rows' => "4"),
81 // 'html_signature'=>array('type' => 'checkbox', 'label' => 'htmlsignature', 'onclick' => 'return rcmail.toggle_editor(this, \'_signature\');'),
82 'standard' => array('type' => 'checkbox', 'label' => 'setdefault'));
85 // a specific part is requested
88 $colprop = $a_show_cols[$attrib['part']];
89 if (is_array($colprop))
92 $out .= rcmail_get_edit_field($attrib['part'], $IDENTITY_RECORD[$attrib['part']], $attrib, $colprop['type']);
100 // return the complete edit form as table
101 $out = "$form_start<table>\n\n";
103 foreach ($a_show_cols as $col => $colprop)
105 $attrib['id'] = 'rcmfd_'.$col;
107 if (strlen($colprop['onclick']))
108 $attrib['onclick'] = $colprop['onclick'];
110 unset($attrib['onclick']);
112 if ($col == 'signature')
114 $attrib['size'] = $colprop['size'];
115 $attrib['rows'] = $colprop['rows'];
116 $attrib['mce_editable'] = $IDENTITY_RECORD['html_signature'] ? "true" : "false";
120 unset($attrib['size']);
121 unset($attrib['rows']);
122 unset($attrib['mce_editable']);
125 $label = strlen($colprop['label']) ? $colprop['label'] : $col;
126 $value = rcmail_get_edit_field($col, $IDENTITY_RECORD[$col], $attrib, $colprop['type']);
128 $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
130 Q(rcube_label($label)),
134 $out .= "\n</table>$form_end";
139 $OUTPUT->add_handler('identityform', 'rcube_identity_form');
141 if ($_action=='add-identity' && template_exists('addidentity'))
142 parse_template('addidentity');
144 parse_template('editidentity');