commit | author | age
|
4e17e6
|
1 |
<?php |
T |
2 |
|
|
3 |
/* |
|
4 |
+-----------------------------------------------------------------------+ |
|
5 |
| program/steps/addressbook/edit.inc | |
|
6 |
| | |
e019f2
|
7 |
| This file is part of the Roundcube Webmail client | |
A |
8 |
| Copyright (C) 2005-2007, Roundcube Dev. - Switzerland | |
30233b
|
9 |
| Licensed under the GNU GPL | |
4e17e6
|
10 |
| | |
T |
11 |
| PURPOSE: | |
|
12 |
| Show edit form for a contact entry or to add a new one | |
|
13 |
| | |
|
14 |
+-----------------------------------------------------------------------+ |
|
15 |
| Author: Thomas Bruederli <roundcube@gmail.com> | |
|
16 |
+-----------------------------------------------------------------------+ |
|
17 |
|
|
18 |
$Id$ |
|
19 |
|
|
20 |
*/ |
|
21 |
|
|
22 |
|
f11541
|
23 |
if (($cid = get_input_value('_cid', RCUBE_INPUT_GPC)) && ($record = $CONTACTS->get_record($cid, true))) |
a79417
|
24 |
$OUTPUT->set_env('cid', $record['ID']); |
10a699
|
25 |
|
f11541
|
26 |
// adding not allowed here |
a79417
|
27 |
if ($CONTACTS->readonly) { |
A |
28 |
$OUTPUT->show_message('sourceisreadonly'); |
|
29 |
rcmail_overwrite_action('show'); |
|
30 |
return; |
f11541
|
31 |
} |
a79417
|
32 |
|
4e17e6
|
33 |
|
T |
34 |
function rcmail_contact_editform($attrib) |
f11541
|
35 |
{ |
a79417
|
36 |
global $RCMAIL, $CONTACTS, $OUTPUT; |
4e17e6
|
37 |
|
a79417
|
38 |
// check if we have a valid result |
A |
39 |
if ($RCMAIL->action != 'add' |
|
40 |
&& !(($result = $CONTACTS->get_result()) && ($record = $result->first())) |
|
41 |
) { |
|
42 |
$OUTPUT->show_message('contactnotfound'); |
|
43 |
return false; |
|
44 |
} |
4e17e6
|
45 |
|
a79417
|
46 |
// add some labels to client |
A |
47 |
$OUTPUT->add_label('noemailwarning', 'nonamewarning'); |
10a699
|
48 |
|
a79417
|
49 |
$i_size = !empty($attrib['size']) ? $attrib['size'] : 40; |
A |
50 |
$t_rows = !empty($attrib['textarearows']) ? $attrib['textarearows'] : 6; |
|
51 |
$t_cols = !empty($attrib['textareacols']) ? $attrib['textareacols'] : 40; |
4e17e6
|
52 |
|
a79417
|
53 |
$form = array( |
A |
54 |
'info' => array( |
|
55 |
'name' => rcube_label('contactproperties'), |
|
56 |
'content' => array( |
|
57 |
'name' => array('type' => 'text', 'size' => $i_size), |
|
58 |
'firstname' => array('type' => 'text', 'size' => $i_size), |
|
59 |
'surname' => array('type' => 'text', 'size' => $i_size), |
|
60 |
'email' => array('type' => 'text', 'size' => $i_size), |
|
61 |
), |
|
62 |
), |
|
63 |
); |
4e17e6
|
64 |
|
T |
65 |
|
a79417
|
66 |
list($form_start, $form_end) = get_form_tags($attrib); |
A |
67 |
unset($attrib['form']); |
4e17e6
|
68 |
|
a79417
|
69 |
// return the complete address edit form as table |
A |
70 |
$out = rcmail_contact_form($form, $record); |
4e17e6
|
71 |
|
a79417
|
72 |
return $form_start . $out . $form_end; |
f11541
|
73 |
} |
4e17e6
|
74 |
|
T |
75 |
|
|
76 |
// similar function as in /steps/settings/edit_identity.inc |
|
77 |
function get_form_tags($attrib) |
57f0c8
|
78 |
{ |
a79417
|
79 |
global $CONTACTS, $EDIT_FORM, $RCMAIL; |
4e17e6
|
80 |
|
a79417
|
81 |
$form_start = $form_end = ''; |
83ba22
|
82 |
|
a79417
|
83 |
if (empty($EDIT_FORM)) { |
A |
84 |
$hiddenfields = new html_hiddenfield(array( |
|
85 |
'name' => '_source', 'value' => get_input_value('_source', RCUBE_INPUT_GPC))); |
|
86 |
$hiddenfields->add(array('name' => '_gid', 'value' => $CONTACTS->group_id)); |
83ba22
|
87 |
|
a79417
|
88 |
if (($result = $CONTACTS->get_result()) && ($record = $result->first())) |
A |
89 |
$hiddenfields->add(array('name' => '_cid', 'value' => $record['ID'])); |
83ba22
|
90 |
|
a79417
|
91 |
$form_start = $RCMAIL->output->request_form(array( |
A |
92 |
'name' => "form", 'method' => "post", |
|
93 |
'task' => $RCMAIL->task, 'action' => 'save', |
|
94 |
'request' => 'save.'.intval($record['ID']), |
|
95 |
'noclose' => true) + $attrib, $hiddenfields->show()); |
|
96 |
$form_end = !strlen($attrib['form']) ? '</form>' : ''; |
57f0c8
|
97 |
|
a79417
|
98 |
$EDIT_FORM = !empty($attrib['form']) ? $attrib['form'] : 'form'; |
A |
99 |
$RCMAIL->output->add_gui_object('editform', $EDIT_FORM); |
|
100 |
} |
4e17e6
|
101 |
|
a79417
|
102 |
return array($form_start, $form_end); |
57f0c8
|
103 |
} |
4e17e6
|
104 |
|
T |
105 |
|
a79417
|
106 |
$OUTPUT->add_handler('contacteditform', 'rcmail_contact_editform'); |
4e17e6
|
107 |
|
83ba22
|
108 |
if (!$CONTACTS->get_result() && $OUTPUT->template_exists('contactadd')) |
A |
109 |
$OUTPUT->send('contactadd'); |
4e17e6
|
110 |
|
T |
111 |
// this will be executed if no template for addcontact exists |
83ba22
|
112 |
$OUTPUT->send('contactedit'); |