commit | author | age
|
4e17e6
|
1 |
<?php |
T |
2 |
|
|
3 |
/* |
|
4 |
+-----------------------------------------------------------------------+ |
|
5 |
| program/steps/settings/save_identity.inc | |
|
6 |
| | |
|
7 |
| This file is part of the RoundCube Webmail client | |
6ec91f
|
8 |
| Copyright (C) 2005-2007, RoundCube Dev. - Switzerland | |
30233b
|
9 |
| Licensed under the GNU GPL | |
4e17e6
|
10 |
| | |
T |
11 |
| PURPOSE: | |
|
12 |
| Save an identity record or to add a new one | |
|
13 |
| | |
|
14 |
+-----------------------------------------------------------------------+ |
|
15 |
| Author: Thomas Bruederli <roundcube@gmail.com> | |
|
16 |
+-----------------------------------------------------------------------+ |
|
17 |
|
|
18 |
$Id$ |
|
19 |
|
|
20 |
*/ |
|
21 |
|
a0109c
|
22 |
$a_save_cols = array('name', 'email', 'organization', 'reply-to', 'bcc', 'standard', 'signature', 'html_signature'); |
ea7c46
|
23 |
$a_html_cols = array('signature'); |
a0109c
|
24 |
$a_boolean_cols = array('standard', 'html_signature'); |
6ec91f
|
25 |
$updated = $default_id = false; |
4e17e6
|
26 |
|
10a699
|
27 |
// check input |
T |
28 |
if (empty($_POST['_name']) || empty($_POST['_email'])) |
|
29 |
{ |
f11541
|
30 |
$OUTPUT->show_message('formincomplete', 'warning'); |
10a699
|
31 |
rcmail_overwrite_action('edit-identitiy'); |
T |
32 |
return; |
|
33 |
} |
|
34 |
|
|
35 |
|
fba1f5
|
36 |
$save_data = array(); |
T |
37 |
foreach ($a_save_cols as $col) |
|
38 |
{ |
|
39 |
$fname = '_'.$col; |
|
40 |
if (isset($_POST[$fname])) |
|
41 |
$save_data[$col] = get_input_value($fname, RCUBE_INPUT_POST, in_array($col, $a_html_cols)); |
|
42 |
} |
|
43 |
|
|
44 |
// set "off" values for checkboxes that were not checked, and therefore |
|
45 |
// not included in the POST body. |
|
46 |
foreach ($a_boolean_cols as $col) |
|
47 |
{ |
|
48 |
$fname = '_' . $col; |
|
49 |
if (!isset($_POST[$fname])) |
|
50 |
$save_data[$col] = 0; |
|
51 |
} |
|
52 |
|
|
53 |
|
4e17e6
|
54 |
// update an existing contact |
T |
55 |
if ($_POST['_iid']) |
fba1f5
|
56 |
{ |
T |
57 |
if ($updated = $USER->update_identity(get_input_value('_iid', RCUBE_INPUT_POST), $save_data)) |
4e17e6
|
58 |
{ |
f11541
|
59 |
$OUTPUT->show_message('successfullysaved', 'confirmation'); |
6ec91f
|
60 |
|
ea206d
|
61 |
if (!empty($_POST['_standard'])) |
6ec91f
|
62 |
$default_id = get_input_value('_iid', RCUBE_INPUT_POST); |
4e17e6
|
63 |
|
T |
64 |
if ($_POST['_framed']) |
fba1f5
|
65 |
{ |
4e17e6
|
66 |
// update the changed col in list |
T |
67 |
// ... |
|
68 |
} |
fba1f5
|
69 |
} |
ad57b3
|
70 |
else if ($DB->is_error()) |
fba1f5
|
71 |
{ |
4e17e6
|
72 |
// show error message |
f11541
|
73 |
$OUTPUT->show_message('errorsaving', 'error'); |
10a699
|
74 |
rcmail_overwrite_action('edit-identitiy'); |
6ec91f
|
75 |
return; |
4e17e6
|
76 |
} |
fba1f5
|
77 |
} |
4e17e6
|
78 |
|
T |
79 |
// insert a new contact |
|
80 |
else |
fba1f5
|
81 |
{ |
T |
82 |
if ($insert_id = $USER->insert_identity($save_data)) |
4e17e6
|
83 |
{ |
T |
84 |
$_GET['_iid'] = $insert_id; |
|
85 |
|
6ec91f
|
86 |
if (!empty($_POST['_standard'])) |
T |
87 |
$default_id = $insert_id; |
|
88 |
|
4e17e6
|
89 |
if ($_POST['_framed']) |
fba1f5
|
90 |
{ |
4e17e6
|
91 |
// add contact row or jump to the page where it should appear |
T |
92 |
// .... |
|
93 |
} |
fba1f5
|
94 |
} |
4e17e6
|
95 |
else |
fba1f5
|
96 |
{ |
4e17e6
|
97 |
// show error message |
f11541
|
98 |
$OUTPUT->show_message('errorsaving', 'error'); |
853b2e
|
99 |
rcmail_overwrite_action('edit-identity'); |
6ec91f
|
100 |
return; |
4e17e6
|
101 |
} |
fba1f5
|
102 |
} |
4e17e6
|
103 |
|
T |
104 |
|
6ec91f
|
105 |
// mark all other identities as 'not-default' |
T |
106 |
if ($default_id) |
fba1f5
|
107 |
$USER->set_default($default_id); |
6ec91f
|
108 |
|
4e17e6
|
109 |
// go to next step |
f11541
|
110 |
rcmail_overwrite_action($_framed ? 'edit-identity' : 'identities'); |
4e17e6
|
111 |
|
T |
112 |
?> |