source: subversion/trunk/roundcubemail/program/steps/settings/edit_identity.inc @ 1796

Last change on this file since 1796 was 1796, checked in by thomasb, 5 years ago

Redesign of the identities settings + add config option to disable multiple identities

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.5 KB
Line 
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$
19
20*/
21
22$OUTPUT->set_pagetitle(rcube_label('identities'));
23
24if (($_GET['_iid'] || $_POST['_iid']) && $RCMAIL->action=='edit-identity') {
25  $IDENTITY_RECORD = $USER->get_identity(get_input_value('_iid', RCUBE_INPUT_GPC));
26 
27  if (is_array($IDENTITY_RECORD))
28    $OUTPUT->set_env('iid', $IDENTITY_RECORD['identity_id']);
29}
30else 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}
36
37$OUTPUT->include_script('list.js');
38
39
40function rcube_identity_form($attrib)
41  {
42  global $IDENTITY_RECORD, $RCMAIL, $OUTPUT;
43
44  $tinylang = substr($_SESSION['language'], 0, 2);
45  if (!file_exists('program/js/tiny_mce/langs/'.$tinylang.'.js'))
46    {
47      $tinylang = 'en';
48    }
49
50  $OUTPUT->include_script('tiny_mce/tiny_mce.js');
51  $OUTPUT->add_script("tinyMCE.init({ mode : 'textareas'," .
52                                    "editor_selector : 'mce_editor'," .
53                                    "apply_source_formatting : true," .
54                                    "language : '$tinylang'," .
55                                    "content_css : '\$__skin_path' + '/editor_content.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 : '' });");
62
63  if (!$IDENTITY_RECORD && $RCMAIL->action != 'add-identity')
64    return rcube_label('notfound');
65
66  // add some labels to client
67  $OUTPUT->add_label('noemailwarning', 'nonamewarning', 'converting');
68
69
70  list($form_start, $form_end) = get_form_tags($attrib, 'save-identity', array('name' => '_iid', 'value' => $IDENTITY_RECORD['identity_id']));
71  unset($attrib['form']);
72
73
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' => 'reply-to'),
79                       'bcc'          => array('type' => 'text'),
80                       'signature'        => array('type' => 'textarea', 'size' => "40", 'rows' => "6"),
81                       'html_signature'=>array('type' => 'checkbox', 'label' => 'htmlsignature', 'onclick' => 'return rcmail.toggle_editor(this, \'rcmfd_signature\');'),
82                       'standard'     => array('type' => 'checkbox', 'label' => 'setdefault'));
83
84
85  // a specific part is requested
86  if ($attrib['part'])
87    {
88    $colprop = $a_show_cols[$attrib['part']];
89    if (is_array($colprop))
90      {
91      $out = $form_start;
92      $out .= rcmail_get_edit_field($attrib['part'], $IDENTITY_RECORD[$attrib['part']], $attrib + array('size' => 30), $colprop['type']);
93      return $out;
94      }
95    else
96      return '';
97    }
98
99
100  // return the complete edit form as table
101  $out = "$form_start<table>\n\n";
102
103  foreach ($a_show_cols as $col => $colprop)
104    {
105    $attrib['id'] = 'rcmfd_'.$col;
106
107    if (strlen($colprop['onclick']))
108      $attrib['onclick'] = $colprop['onclick'];
109    else
110      unset($attrib['onclick']);
111
112    if ($col == 'signature')
113      {
114      $attrib['size'] = $colprop['size'];
115      $attrib['rows'] = $colprop['rows'];
116      if ($IDENTITY_RECORD['html_signature'])
117        {
118        $attrib['class'] = "mce_editor";
119        }
120      }
121    else
122      {
123      $attrib['size'] = 40;
124      unset($attrib['rows']);
125      }
126
127    $label = strlen($colprop['label']) ? $colprop['label'] : $col;
128    $value = rcmail_get_edit_field($col, $IDENTITY_RECORD[$col], $attrib, $colprop['type']);
129
130    $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
131                    $attrib['id'],
132                    Q(rcube_label($label)),
133                    $value);
134    }
135
136  $out .= "\n</table>$form_end";
137
138  return $out; 
139  }
140
141$OUTPUT->add_handler('identityform', 'rcube_identity_form');
142
143$OUTPUT->set_pagetitle(rcube_label(($RCMAIL->action=='add-identity' ? 'newidentity' : 'edititem')));
144
145if ($RCMAIL->action=='add-identity' && $OUTPUT->template_exists('addidentity'))
146  $OUTPUT->send('addidentity');
147
148$OUTPUT->send('editidentity');
149?>
Note: See TracBrowser for help on using the repository browser.