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