4 +-----------------------------------------------------------------------+
5 | program/steps/settings/save_identity.inc |
7 | This file is part of the RoundCube Webmail client |
8 | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland |
9 | Licensed under the GNU GPL |
12 | Save an identity record or to add a new one |
14 +-----------------------------------------------------------------------+
15 | Author: Thomas Bruederli <roundcube@gmail.com> |
16 +-----------------------------------------------------------------------+
18 $Id: save_identity.inc 2006 2008-10-24 07:57:21Z alec $
22 define('IDENTITIES_LEVEL', intval($RCMAIL->config->get('identities_level', 0)));
24 $a_save_cols = array('name', 'email', 'organization', 'reply-to', 'bcc', 'standard', 'signature', 'html_signature');
25 $a_html_cols = array('signature');
26 $a_boolean_cols = array('standard', 'html_signature');
27 $updated = $default_id = false;
30 if (empty($_POST['_name']) || (empty($_POST['_email']) && IDENTITIES_LEVEL != 1 && IDENTITIES_LEVEL != 3))
32 $OUTPUT->show_message('formincomplete', 'warning');
33 rcmail_overwrite_action('edit-identity');
39 foreach ($a_save_cols as $col)
42 if (isset($_POST[$fname]))
43 $save_data[$col] = get_input_value($fname, RCUBE_INPUT_POST, in_array($col, $a_html_cols));
46 // set "off" values for checkboxes that were not checked, and therefore
47 // not included in the POST body.
48 foreach ($a_boolean_cols as $col)
51 if (!isset($_POST[$fname]))
55 // unset email address if user has no rights to change it
56 if (IDENTITIES_LEVEL == 1 || IDENTITIES_LEVEL == 3)
57 unset($save_data['email']);
60 // update an existing contact
63 if ($updated = $USER->update_identity(get_input_value('_iid', RCUBE_INPUT_POST), $save_data))
65 $OUTPUT->show_message('successfullysaved', 'confirmation');
67 if (!empty($_POST['_standard']))
68 $default_id = get_input_value('_iid', RCUBE_INPUT_POST);
70 if ($_POST['_framed'])
72 // update the changed col in list
76 else if ($DB->is_error())
79 $OUTPUT->show_message('errorsaving', 'error');
80 rcmail_overwrite_action('edit-identity');
85 // insert a new identity record
86 else if (IDENTITIES_LEVEL < 2)
88 if (IDENTITIES_LEVEL == 1)
89 $save_data['email'] = rcmail_get_email();
91 if ($save_data['email'] && ($insert_id = $USER->insert_identity($save_data)))
93 $OUTPUT->show_message('successfullysaved', 'confirmation');
95 $_GET['_iid'] = $insert_id;
97 if (!empty($_POST['_standard']))
98 $default_id = $insert_id;
102 // show error message
103 $OUTPUT->show_message('errorsaving', 'error');
104 rcmail_overwrite_action('edit-identity');
109 $OUTPUT->show_message('opnotpermitted', 'error');
112 // mark all other identities as 'not-default'
114 $USER->set_default($default_id);
117 rcmail_overwrite_action('identities');