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 938 2007-12-10 15:27:19Z thomasb $
22 $a_save_cols = array('name', 'email', 'organization', 'reply-to', 'bcc', 'standard', 'signature', 'html_signature');
23 $a_html_cols = array('signature');
24 $a_boolean_cols = array('standard', 'html_signature');
25 $updated = $default_id = false;
28 if (empty($_POST['_name']) || empty($_POST['_email']))
30 $OUTPUT->show_message('formincomplete', 'warning');
31 rcmail_overwrite_action('edit-identitiy');
37 foreach ($a_save_cols as $col)
40 if (isset($_POST[$fname]))
41 $save_data[$col] = get_input_value($fname, RCUBE_INPUT_POST, in_array($col, $a_html_cols));
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)
49 if (!isset($_POST[$fname]))
54 // update an existing contact
57 if ($updated = $USER->update_identity(get_input_value('_iid', RCUBE_INPUT_POST), $save_data))
59 $OUTPUT->show_message('successfullysaved', 'confirmation');
61 if (!empty($_POST['_standard']))
62 $default_id = get_input_value('_iid', RCUBE_INPUT_POST);
64 if ($_POST['_framed'])
66 // update the changed col in list
70 else if ($DB->is_error())
73 $OUTPUT->show_message('errorsaving', 'error');
74 rcmail_overwrite_action('edit-identitiy');
79 // insert a new contact
82 if ($insert_id = $USER->insert_identity($save_data))
84 $_GET['_iid'] = $insert_id;
86 if (!empty($_POST['_standard']))
87 $default_id = $insert_id;
89 if ($_POST['_framed'])
91 // add contact row or jump to the page where it should appear
98 $OUTPUT->show_message('errorsaving', 'error');
99 rcmail_overwrite_action('edit-identity');
105 // mark all other identities as 'not-default'
107 $USER->set_default($default_id);
110 rcmail_overwrite_action($_framed ? 'edit-identity' : 'identities');