]> git.donarmstrong.com Git - roundcube.git/blob - program/steps/settings/edit_identity.inc
Imported Upstream version 0.2~alpha
[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 1412 2008-05-21 07:45:54Z alec $
19
20 */
21
22 $OUTPUT->set_pagetitle(rcube_label('identities'));
23
24 if (($_GET['_iid'] || $_POST['_iid']) && $RCMAIL->action=='edit-identity')
25   {
26   $IDENTITY_RECORD = $USER->get_identity(get_input_value('_iid', RCUBE_INPUT_GPC));
27   
28   if (is_array($IDENTITY_RECORD))
29     $OUTPUT->set_env('iid', $IDENTITY_RECORD['identity_id']);
30   }
31
32
33 $OUTPUT->include_script('list.js');
34
35
36 function rcube_identity_form($attrib)
37   {
38   global $IDENTITY_RECORD, $RCMAIL, $OUTPUT;
39
40   $tinylang = substr($_SESSION['language'], 0, 2);
41   if (!file_exists('program/js/tiny_mce/langs/'.$tinylang.'.js'))
42     {
43       $tinylang = 'en';
44     }
45
46   $OUTPUT->include_script('tiny_mce/tiny_mce.js');
47   $OUTPUT->add_script("tinyMCE.init({ mode : 'textareas'," .
48                                     "editor_selector : 'mce_editor'," .
49                                     "apply_source_formatting : true," .
50                                     "language : '$tinylang'," .
51                                     "content_css : '\$__skin_path' + '/editor_content.css'," .
52                                     "theme : 'advanced'," .
53                                     "theme_advanced_toolbar_location : 'top'," .
54                                     "theme_advanced_toolbar_align : 'left'," .
55                                     "theme_advanced_buttons1 : 'bold,italic,underline,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,separator,outdent,indent,charmap,hr'," .
56                                     "theme_advanced_buttons2 : 'link,unlink,code,forecolor,fontselect,fontsizeselect'," .
57                                     "theme_advanced_buttons3 : '' });");
58
59   if (!$IDENTITY_RECORD && $RCMAIL->action != 'add-identity')
60     return rcube_label('notfound');
61
62   // add some labels to client
63   rcube_add_label('noemailwarning', 'nonamewarning');
64
65
66   list($form_start, $form_end) = get_form_tags($attrib, 'save-identity', array('name' => '_iid', 'value' => $IDENTITY_RECORD['identity_id']));
67   unset($attrib['form']);
68
69
70   // list of available cols
71   $a_show_cols = array('name'         => array('type' => 'text'),
72                        'email'        => array('type' => 'text'),
73                        'organization' => array('type' => 'text'),
74                        'reply-to'     => array('type' => 'text', 'label' => 'replyto'),
75                        'bcc'          => array('type' => 'text'),
76                        'signature'        => array('type' => 'textarea', 'size' => "40", 'rows' => "6"),
77                        'html_signature'=>array('type' => 'checkbox', 'label' => 'htmlsignature', 'onclick' => 'return rcmail.toggle_editor(this, \'rcmfd_signature\');'),
78                        'standard'     => array('type' => 'checkbox', 'label' => 'setdefault'));
79
80
81   // a specific part is requested
82   if ($attrib['part'])
83     {
84     $colprop = $a_show_cols[$attrib['part']];
85     if (is_array($colprop))
86       {
87       $out = $form_start;
88       $out .= rcmail_get_edit_field($attrib['part'], $IDENTITY_RECORD[$attrib['part']], $attrib + array('size' => 30), $colprop['type']); 
89       return $out;
90       }
91     else
92       return '';
93     }
94
95
96   // return the complete edit form as table
97   $out = "$form_start<table>\n\n";
98
99   foreach ($a_show_cols as $col => $colprop)
100     {
101     $attrib['id'] = 'rcmfd_'.$col;
102
103     if (strlen($colprop['onclick']))
104       $attrib['onclick'] = $colprop['onclick'];
105     else
106       unset($attrib['onclick']);
107
108     if ($col == 'signature')
109       {
110       $attrib['size'] = $colprop['size'];
111       $attrib['rows'] = $colprop['rows'];
112       if ($IDENTITY_RECORD['html_signature'])
113         {
114         $attrib['class'] = "mce_editor";
115         }
116       }
117     else
118       {
119       $attrib['size'] = 40;
120       unset($attrib['rows']);
121       }
122
123     $label = strlen($colprop['label']) ? $colprop['label'] : $col;
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'],
128                     Q(rcube_label($label)),
129                     $value);
130     }
131
132   $out .= "\n</table>$form_end";
133
134   return $out;  
135   }
136
137 $OUTPUT->add_handler('identityform', 'rcube_identity_form');
138
139 if ($RCMAIL->action=='add-identity' && template_exists('addidentity'))
140   $OUTPUT->send('addidentity');
141
142 $OUTPUT->send('editidentity');
143 ?>