source: github/program/steps/settings/edit_identity.inc @ 491a6e2

HEADcourier-fixdev-browser-capabilitiespdorelease-0.6release-0.7release-0.8
Last change on this file since 491a6e2 was 491a6e2, checked in by alecpl <alec@…>, 5 years ago
  • Allow and use spellcheck attribute for input/textarea fields (#1485060)
  • Property mode set to 100644
File size: 5.6 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                                    "gecko_spellcheck : true });");
63
64  if (!$IDENTITY_RECORD && $RCMAIL->action != 'add-identity')
65    return rcube_label('notfound');
66
67  // add some labels to client
68  $OUTPUT->add_label('noemailwarning', 'nonamewarning', 'converting');
69
70
71  list($form_start, $form_end) = get_form_tags($attrib, 'save-identity', array('name' => '_iid', 'value' => $IDENTITY_RECORD['identity_id']));
72  unset($attrib['form']);
73
74
75  // list of available cols
76  $a_show_cols = array('name'         => array('type' => 'text'),
77                       'email'        => array('type' => 'text'),
78                       'organization' => array('type' => 'text'),
79                       'reply-to'     => array('type' => 'text', 'label' => 'reply-to'),
80                       'bcc'          => array('type' => 'text'),
81                       'signature'        => array('type' => 'textarea', 'size' => "40", 'rows' => "6"),
82                       'html_signature'=>array('type' => 'checkbox', 'label' => 'htmlsignature', 'onclick' => 'return rcmail.toggle_editor(this, \'rcmfd_signature\');'),
83                       'standard'     => array('type' => 'checkbox', 'label' => 'setdefault'));
84
85
86  // a specific part is requested
87  if ($attrib['part'])
88    {
89    $colprop = $a_show_cols[$attrib['part']];
90    if (is_array($colprop))
91      {
92      $out = $form_start;
93      $out .= rcmail_get_edit_field($attrib['part'], $IDENTITY_RECORD[$attrib['part']], $attrib + array('size' => 30), $colprop['type']);
94      return $out;
95      }
96    else
97      return '';
98    }
99
100
101  // return the complete edit form as table
102  $out = "$form_start<table>\n\n";
103
104  foreach ($a_show_cols as $col => $colprop)
105    {
106    $attrib['id'] = 'rcmfd_'.$col;
107
108    if (strlen($colprop['onclick']))
109      $attrib['onclick'] = $colprop['onclick'];
110    else
111      unset($attrib['onclick']);
112
113    if ($col == 'signature')
114      {
115      $attrib['size'] = $colprop['size'];
116      $attrib['rows'] = $colprop['rows'];
117      $attrib['spellcheck'] = true;
118      if ($IDENTITY_RECORD['html_signature'])
119        {
120        $attrib['class'] = "mce_editor";
121        }
122      }
123    else
124      {
125      $attrib['size'] = 40;
126      unset($attrib['rows']);
127      }
128
129    $label = strlen($colprop['label']) ? $colprop['label'] : $col;
130    $value = rcmail_get_edit_field($col, $IDENTITY_RECORD[$col], $attrib, $colprop['type']);
131
132    $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
133                    $attrib['id'],
134                    Q(rcube_label($label)),
135                    $value);
136    }
137
138  $out .= "\n</table>$form_end";
139
140  return $out; 
141  }
142
143$OUTPUT->add_handler('identityform', 'rcube_identity_form');
144
145$OUTPUT->set_pagetitle(rcube_label(($RCMAIL->action=='add-identity' ? 'newidentity' : 'edititem')));
146
147if ($RCMAIL->action=='add-identity' && $OUTPUT->template_exists('addidentity'))
148  $OUTPUT->send('addidentity');
149
150$OUTPUT->send('editidentity');
151?>
Note: See TracBrowser for help on using the repository browser.