summaryrefslogtreecommitdiff
path: root/program/steps/settings
diff options
context:
space:
mode:
Diffstat (limited to 'program/steps/settings')
-rw-r--r--program/steps/settings/delete_identity.inc55
-rw-r--r--program/steps/settings/edit_identity.inc106
-rw-r--r--program/steps/settings/func.inc194
-rw-r--r--program/steps/settings/identities.inc48
-rw-r--r--program/steps/settings/manage_folders.inc176
-rw-r--r--program/steps/settings/save_identity.inc136
-rw-r--r--program/steps/settings/save_prefs.inc59
7 files changed, 774 insertions, 0 deletions
diff --git a/program/steps/settings/delete_identity.inc b/program/steps/settings/delete_identity.inc
new file mode 100644
index 000000000..dacfc0563
--- /dev/null
+++ b/program/steps/settings/delete_identity.inc
@@ -0,0 +1,55 @@
+<?php
+
+/*
+ +-----------------------------------------------------------------------+
+ | program/steps/settings/delete_identity.inc |
+ | |
+ | This file is part of the RoundCube Webmail client |
+ | Copyright (C) 2005, RoundCube Dev. - Switzerland |
+ | All rights reserved. |
+ | |
+ | PURPOSE: |
+ | Delete the submitted identities (IIDs) from the database |
+ | |
+ +-----------------------------------------------------------------------+
+ | Author: Thomas Bruederli <roundcube@gmail.com> |
+ +-----------------------------------------------------------------------+
+
+ $Id$
+
+*/
+
+$REMOTE_REQUEST = $_GET['_remote'] ? TRUE : FALSE;
+
+if ($_GET['_iid'])
+ {
+ $DB->query(sprintf("UPDATE %s
+ SET del='1'
+ WHERE user_id=%d
+ AND identity_id IN (%s)",
+ get_table_name('identities'),
+ $_SESSION['user_id'],
+ $_GET['_iid']));
+
+ $count = $DB->affected_rows();
+ if ($count)
+ {
+ $commands = show_message('deletedsuccessfully', 'confirmation');
+ }
+
+ // send response
+ if ($REMOTE_REQUEST)
+ rcube_remote_response($commands);
+ }
+
+
+if ($REMOTE_REQUEST)
+ exit;
+
+
+// go to identities page
+$_action = 'identities';
+
+// overwrite action variable
+$OUTPUT->add_script(sprintf("\n%s.set_env('action', '%s');", $JS_OBJECT_NAME, $_action));
+?> \ No newline at end of file
diff --git a/program/steps/settings/edit_identity.inc b/program/steps/settings/edit_identity.inc
new file mode 100644
index 000000000..f4134d329
--- /dev/null
+++ b/program/steps/settings/edit_identity.inc
@@ -0,0 +1,106 @@
+<?php
+
+/*
+ +-----------------------------------------------------------------------+
+ | program/steps/settings/edit_identity.inc |
+ | |
+ | This file is part of the RoundCube Webmail client |
+ | Copyright (C) 2005, RoundCube Dev. - Switzerland |
+ | All rights reserved. |
+ | |
+ | PURPOSE: |
+ | Show edit form for a identity record or to add a new one |
+ | |
+ +-----------------------------------------------------------------------+
+ | Author: Thomas Bruederli <roundcube@gmail.com> |
+ +-----------------------------------------------------------------------+
+
+ $Id$
+
+*/
+
+if (($_GET['_iid'] || $_POST['_iid']) && $_action=='edit-identity')
+ {
+ $id = $_POST['_iid'] ? $_POST['_iid'] : $_GET['_iid'];
+ $DB->query(sprintf("SELECT * FROM %s
+ WHERE identity_id=%d
+ AND user_id=%d
+ AND del!='1'",
+ get_table_name('identities'),
+ $id,
+ $_SESSION['user_id']));
+
+ $IDENTITY_RECORD = $DB->fetch_assoc();
+
+ if (is_array($IDENTITY_RECORD))
+ $OUTPUT->add_script(sprintf("%s.set_env('iid', '%s');", $JS_OBJECT_NAME, $IDENTITY_RECORD['identity_id']));
+
+ $PAGE_TITLE = rcube_label('edititem');
+ }
+else
+ $PAGE_TITLE = rcube_label('newitem');
+
+
+
+function rcube_identity_form($attrib)
+ {
+ global $IDENTITY_RECORD, $JS_OBJECT_NAME;
+
+ if (!$IDENTITY_RECORD && $GLOBALS['_action']!='add-identity')
+ return rcube_label('notfound');
+
+ list($form_start, $form_end) = get_form_tags($attrib, 'save-identity', array('name' => '_iid', 'value' => $IDENTITY_RECORD['identity_id']));
+ unset($attrib['form']);
+
+
+ // list of available cols
+ $a_show_cols = array('name' => array('type' => 'text'),
+ 'email' => array('type' => 'text'),
+ 'organization' => array('type' => 'text'),
+ 'reply-to' => array('type' => 'text', 'label' => 'replyto'),
+ 'bcc' => array('type' => 'text'),
+ 'default' => array('type' => 'checkbox', 'label' => 'setdefault'));
+
+
+ // a specific part is requested
+ if ($attrib['part'])
+ {
+ $colprop = $a_show_cols[$attrib['part']];
+ if (is_array($colprop))
+ {
+ $out = $form_start;
+ $out .= rcmail_get_edit_field($attrib['part'], $IDENTITY_RECORD[$attrib['part']], $attrib, $colprop['type']);
+ return $out;
+ }
+ else
+ return '';
+ }
+
+
+ // return the complete edit form as table
+ $out = "$form_start<table>\n\n";
+
+ foreach ($a_show_cols as $col => $colprop)
+ {
+ $attrib['id'] = 'rcmfd_'.$col;
+ $label = strlen($colprop['label']) ? $colprop['label'] : $col;
+ $value = rcmail_get_edit_field($col, $IDENTITY_RECORD[$col], $attrib, $colprop['type']);
+
+ $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
+ $attrib['id'],
+ rcube_label($label),
+ $value);
+ }
+
+ $out .= "\n</table>$form_end";
+
+ return $out;
+ }
+
+
+
+if ($_action=='add-identity' && template_exists('addidentity'))
+ parse_template('addidentity');
+
+parse_template('editidentity');
+?> \ No newline at end of file
diff --git a/program/steps/settings/func.inc b/program/steps/settings/func.inc
new file mode 100644
index 000000000..826717fd9
--- /dev/null
+++ b/program/steps/settings/func.inc
@@ -0,0 +1,194 @@
+<?php
+
+/*
+ +-----------------------------------------------------------------------+
+ | program/steps/settings/func.inc |
+ | |
+ | This file is part of the RoundCube Webmail client |
+ | Copyright (C) 2005, RoundCube Dev. - Switzerland |
+ | All rights reserved. |
+ | |
+ | PURPOSE: |
+ | Provide functionality for user's settings & preferences |
+ | |
+ +-----------------------------------------------------------------------+
+ | Author: Thomas Bruederli <roundcube@gmail.com> |
+ +-----------------------------------------------------------------------+
+
+ $Id$
+
+*/
+
+
+// get user record
+$sql_result = $DB->query(sprintf("SELECT username, mail_host FROM %s
+ WHERE user_id=%d",
+ get_table_name('users'),
+ $_SESSION['user_id']));
+
+if ($USER_DATA = $DB->fetch_assoc($sql_result))
+ $PAGE_TITLE = sprintf('%s %s@%s', rcube_label('settingsfor'), $USER_DATA['username'], $USER_DATA['mail_host']);
+
+
+
+function rcmail_user_prefs_form($attrib)
+ {
+ global $DB, $CONFIG, $sess_user_lang;
+
+ list($form_start, $form_end) = get_form_tags($attrib, 'save-prefs');
+ unset($attrib['form']);
+
+ // allow the following attributes to be added to the <table> tag
+ $attrib_str = create_attrib_string($attrib, array('style', 'class', 'id', 'cellpadding', 'cellspacing', 'border', 'summary'));
+
+ // return the complete edit form as table
+ $out = "$form_start<table" . $attrib_str . ">\n\n";
+
+ $a_show_cols = array('language' => array('type' => 'text'),
+ 'pagesize' => array('type' => 'text'),
+ 'timezone' => array('type' => 'text'));
+
+ // show language selection
+ $field_id = 'rcmfd_lang';
+ $select_lang = new select(array('name' => '_language', 'id' => $field_id));
+ $select_lang->add('English', 'en');
+ $select_lang->add('Deutsch', 'de');
+
+ $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
+ $field_id,
+ rcube_label('language'),
+ $select_lang->show($sess_user_lang));
+
+
+ // show page size selection
+ $field_id = 'rcmfd_timezone';
+ $select_timezone = new select(array('name' => '_timezone', 'id' => $field_id));
+ $select_timezone->add('(GMT -11:00) Midway Island, Samoa', '-11');
+ $select_timezone->add('(GMT -10:00) Hawaii', '-10');
+ $select_timezone->add('(GMT -9:00) Alaska', '-9');
+ $select_timezone->add('(GMT -8:00) Pacific Time (US/Canada)', '-8');
+ $select_timezone->add('(GMT -7:00) Mountain Time (US/Canada)', '-7');
+ $select_timezone->add('(GMT -6:00) Central Time (US/Canada), Mexico City', '-6');
+ $select_timezone->add('(GMT -5:00) Eastern Time (US/Canada), Bogota, Lima', '-5');
+ $select_timezone->add('(GMT -4:00) Atlantic Time (Canada), Caracas, La Paz', '-4');
+ $select_timezone->add('(GMT -3:00) Brazil, Buenos Aires, Georgetown', '-3');
+ $select_timezone->add('(GMT -2:00) Mid-Atlantic', '-2');
+ $select_timezone->add('(GMT -1:00) Azores, Cape Verde Islands', '-1');
+ $select_timezone->add('(GMT) Western Europe, London, Lisbon, Casablanca', '0');
+ $select_timezone->add('(GMT +1:00) Central European Time', '1');
+ $select_timezone->add('(GMT +2:00) EET: Kaliningrad, South Africa', '2');
+ $select_timezone->add('(GMT +3:00) Baghdad, Kuwait, Riyadh, Moscow, Nairobi', '3');
+ $select_timezone->add('(GMT +4:00) Abu Dhabi, Muscat, Baku, Tbilisi', '4');
+ $select_timezone->add('(GMT +5:00) Ekaterinburg, Islamabad, Karachi', '5');
+ $select_timezone->add('(GMT +6:00) Almaty, Dhaka, Colombo', '6');
+ $select_timezone->add('(GMT +7:00) Bangkok, Hanoi, Jakarta', '7');
+ $select_timezone->add('(GMT +8:00) Beijing, Perth, Singapore, Taipei', '8');
+ $select_timezone->add('(GMT +9:00) Tokyo, Seoul, Yakutsk', '9');
+ $select_timezone->add('(GMT +10:00) EAST/AEST: Guam, Vladivostok', '10');
+ $select_timezone->add('(GMT +11:00) Magadan, Solomon Islands', '11');
+ $select_timezone->add('(GMT +12:00) Auckland, Wellington, Kamchatka', '12');
+ $select_timezone->add('(GMT +13:00) Tonga, Pheonix Islands', '13');
+ $select_timezone->add('(GMT +14:00) Kiribati', '14');
+
+
+ $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
+ $field_id,
+ rcube_label('timezone'),
+ $select_timezone->show($CONFIG['timezone']));
+
+
+ // show page size selection
+ $field_id = 'rcmfd_pgsize';
+ $input_pagesize = new textfield(array('name' => '_pagesize', 'id' => $field_id, 'size' => 5));
+
+ $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
+ $field_id,
+ rcube_label('pagesize'),
+ $input_pagesize->show($CONFIG['pagesize']));
+
+ // show checkbox for HTML/plaintext messages
+ $field_id = 'rcmfd_htmlmsg';
+ $input_pagesize = new checkbox(array('name' => '_prefer_html', 'id' => $field_id, 'value' => 1));
+
+ $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
+ $field_id,
+ rcube_label('preferhtml'),
+ $input_pagesize->show($CONFIG['prefer_html']?1:0));
+
+
+ $out .= "\n</table>$form_end";
+
+ return $out;
+ }
+
+
+
+
+function rcmail_identities_list($attrib)
+ {
+ global $DB, $CONFIG, $OUTPUT, $JS_OBJECT_NAME;
+
+
+ // get contacts from DB
+ $sql_result = $DB->query(sprintf("SELECT * FROM %s
+ WHERE del!='1'
+ AND user_id=%d
+ ORDER BY `default` DESC, name ASC",
+ get_table_name('identities'),
+ $_SESSION['user_id']));
+
+
+ // add id to message list table if not specified
+ if (!strlen($attrib['id']))
+ $attrib['id'] = 'rcmIdentitiesList';
+
+ // define list of cols to be displayed
+ $a_show_cols = array('name', 'email', 'organization', 'reply-to');
+
+ // create XHTML table
+ $out = rcube_table_output($attrib, $sql_result, $a_show_cols, 'identity_id');
+
+ // set client env
+ $javascript = sprintf("%s.gui_object('identitieslist', '%s');\n", $JS_OBJECT_NAME, $attrib['id']);
+ $OUTPUT->add_script($javascript);
+
+ return $out;
+ }
+
+
+
+// similar function as in /steps/addressbook/edit.inc
+function get_form_tags($attrib, $action, $add_hidden=array())
+ {
+ global $OUTPUT, $JS_OBJECT_NAME, $EDIT_FORM, $SESS_HIDDEN_FIELD;
+
+ $form_start = '';
+ if (!strlen($EDIT_FORM))
+ {
+ $hiddenfields = new hiddenfield(array('name' => '_task', 'value' => $GLOBALS['_task']));
+ $hiddenfields->add(array('name' => '_action', 'value' => $action));
+
+ if ($add_hidden)
+ $hiddenfields->add($add_hidden);
+
+ if ($_GET['_framed'] || $_POST['_framed'])
+ $hiddenfields->add(array('name' => '_framed', 'value' => 1));
+
+ $form_start = !strlen($attrib['form']) ? '<form name="form" action="./" method="post">' : '';
+ $form_start .= "\n$SESS_HIDDEN_FIELD\n";
+ $form_start .= $hiddenfields->show();
+ }
+
+ $form_end = (!strlen($EDIT_FORM) && !strlen($attrib['form'])) ? '</form>' : '';
+ $form_name = strlen($attrib['form']) ? $attrib['form'] : 'form';
+
+ if (!strlen($EDIT_FORM))
+ $OUTPUT->add_script("$JS_OBJECT_NAME.gui_object('editform', '$form_name');");
+
+ $EDIT_FORM = $form_name;
+
+ return array($form_start, $form_end);
+ }
+
+
+?> \ No newline at end of file
diff --git a/program/steps/settings/identities.inc b/program/steps/settings/identities.inc
new file mode 100644
index 000000000..b760f09bf
--- /dev/null
+++ b/program/steps/settings/identities.inc
@@ -0,0 +1,48 @@
+<?php
+
+/*
+ +-----------------------------------------------------------------------+
+ | program/steps/settings/identities.inc |
+ | |
+ | This file is part of the RoundCube Webmail client |
+ | Copyright (C) 2005, RoundCube Dev. - Switzerland |
+ | All rights reserved. |
+ | |
+ | PURPOSE: |
+ | Manage identities of a user account |
+ | |
+ +-----------------------------------------------------------------------+
+ | Author: Thomas Bruederli <roundcube@gmail.com> |
+ +-----------------------------------------------------------------------+
+
+ $Id$
+
+*/
+
+if ($USER_DATA = $DB->fetch_assoc($sql_result))
+ $PAGE_TITLE = sprintf('%s (%s@%s)', rcube_label('identities'), $USER_DATA['username'], $USER_DATA['mail_host']);
+
+
+
+// similar function as /steps/addressbook/func.inc::rcmail_contact_frame()
+function rcmail_identity_frame($attrib)
+ {
+ global $OUTPUT, $JS_OBJECT_NAME;
+
+ if (!$attrib['id'])
+ $attrib['id'] = 'rcmIdentityFrame';
+
+ $attrib['name'] = $attrib['id'];
+
+ $OUTPUT->add_script(sprintf("%s.set_env('contentframe', '%s');", $JS_OBJECT_NAME, $attrib['name']));
+
+ $attrib_str = create_attrib_string($attrib, array('name', 'id', 'class', 'style', 'src', 'width', 'height', 'frameborder'));
+ $out = '<iframe'. $attrib_str . '></iframe>';
+
+ return $out;
+ }
+
+
+
+parse_template('identities');
+?> \ No newline at end of file
diff --git a/program/steps/settings/manage_folders.inc b/program/steps/settings/manage_folders.inc
new file mode 100644
index 000000000..38f9e1a0e
--- /dev/null
+++ b/program/steps/settings/manage_folders.inc
@@ -0,0 +1,176 @@
+<?php
+
+/*
+ +-----------------------------------------------------------------------+
+ | program/steps/settings/manage_folders.inc |
+ | |
+ | This file is part of the RoundCube Webmail client |
+ | Copyright (C) 2005, RoundCube Dev. - Switzerland |
+ | All rights reserved. |
+ | |
+ | PURPOSE: |
+ | Provide functionality to create/delete/rename folders |
+ | |
+ +-----------------------------------------------------------------------+
+ | Author: Thomas Bruederli <roundcube@gmail.com> |
+ +-----------------------------------------------------------------------+
+
+ $Id$
+
+*/
+
+// init IAMP connection
+rcmail_imap_init(TRUE);
+
+
+// subscribe to one or more mailboxes
+if ($_action=='subscribe')
+ {
+ if (strlen($_GET['_mboxes']))
+ $IMAP->subscribe(explode(',', $_GET['_mboxes']));
+
+ if ($_GET['_remote'])
+ rcube_remote_response('// subscribed');
+ }
+
+// unsubscribe one or more mailboxes
+else if ($_action=='unsubscribe')
+ {
+ if (strlen($_GET['_mboxes']))
+ $IMAP->unsubscribe(explode(',', $_GET['_mboxes']));
+
+ if ($_GET['_remote'])
+ rcube_remote_response('// unsubscribed');
+ }
+
+// create a new mailbox
+else if ($_action=='create-folder')
+ {
+ if (strlen($_GET['_name']))
+ $create = $IMAP->create_mailbox(trim($_GET['_name']), TRUE);
+
+ if ($create && $_GET['_remote'])
+ {
+ $commands = sprintf("this.add_folder_row('%s')", rep_specialchars_output($_GET['_name'], 'js'));
+ rcube_remote_response($commands);
+ }
+ else if (!$create && $_GET['_remote'])
+ {
+ $commands = show_message('errorsaving', 'error');
+ rcube_remote_response($commands);
+ }
+ else if (!$create)
+ show_message('errorsaving', 'error');
+ }
+
+// delete an existing IMAP mailbox
+else if ($_action=='delete-folder')
+ {
+ if (strlen($_GET['_mboxes']))
+ $IMAP->delete_mailbox(explode(',', $_GET['_mboxes']));
+
+ if ($_GET['_remote'])
+ rcube_remote_response('// deleted');
+ }
+
+
+
+// build table with all folders listed by server
+function rcube_subscription_form($attrib)
+ {
+ global $IMAP, $CONFIG, $OUTPUT, $JS_OBJECT_NAME;
+
+ list($form_start, $form_end) = get_form_tags($attrib, 'folders');
+ unset($attrib['form']);
+
+
+ if (!$attrib['id'])
+ $attrib['id'] = 'rcmSubscriptionlist';
+
+ // allow the following attributes to be added to the <table> tag
+ $attrib_str = create_attrib_string($attrib, array('style', 'class', 'id', 'cellpadding', 'cellspacing', 'border', 'summary'));
+
+ $out = "$form_start\n<table" . $attrib_str . ">\n";
+
+
+ // add table header
+ $out .= "<thead><tr>\n";
+ $out .= sprintf('<td>%s</td><td>%s</td><td></td>', rcube_label('foldername'), rcube_label('subscribed'));
+ $out .= "\n</tr></thead>\n<tbody>\n";
+
+
+ // get folders from server
+ $a_unsubscribed = $IMAP->list_unsubscribed();
+ $a_subscribed = $IMAP->list_mailboxes();
+ $a_js_folders = array();
+
+ $checkbox_subscribe = new checkbox(array('name' => '_subscribed[]', 'onclick' => "$JS_OBJECT_NAME.command(this.checked?'subscribe':'unsubscribe',this.value)"));
+
+ if ($attrib['deleteicon'])
+ $button = sprintf('<img src="%s%s" alt="%s" border="0" />', $CONFIG['skin_path'], $attrib['deleteicon'], rcube_label('delete'));
+ else
+ $button = rcube_label('delete');
+
+
+ // create list of available folders
+ foreach ($a_unsubscribed as $i => $folder)
+ {
+ $zebra_class = $i%2 ? 'even' : 'odd';
+ $folder_js = rep_specialchars_output($folder, 'js');
+ $a_js_folders['rcmrow'.($i+1)] = $folder_js;
+
+ $out .= sprintf('<tr id="rcmrow%d" class="%s"><td>%s</td><td>%s</td><td><a href="#delete" onclick="%s.command(\'delete-folder\',\'%s\')" title="%s">%s</a></td>',
+ $i+1,
+ $zebra_class,
+ rep_specialchars_output($folder, 'html'),
+ $checkbox_subscribe->show(in_array($folder, $a_subscribed)?$folder:'', array('value' => $folder)),
+ $JS_OBJECT_NAME,
+ $folder_js,
+ rcube_label('deletefolder'),
+ $button);
+
+ $out .= "</tr>\n";
+ }
+
+ $out .= "</tbody>\n</table>";
+ $out .= "\n$form_end";
+
+
+ $javascript = sprintf("%s.gui_object('subscriptionlist', '%s');\n", $JS_OBJECT_NAME, $attrib['id']);
+ $javascript .= sprintf("%s.set_env('subscriptionrows', %s);", $JS_OBJECT_NAME, array2js($a_js_folders));
+ $OUTPUT->add_script($javascript);
+
+ return $out;
+ }
+
+
+function rcube_create_folder_form($attrib)
+ {
+ global $JS_OBJECT_NAME;
+
+ list($form_start, $form_end) = get_form_tags($attrib, 'create-folder');
+ unset($attrib['form']);
+
+
+ // return the complete edit form as table
+ $out = "$form_start\n";
+
+ $input = new textfield(array('name' => '_folder_name'));
+ $out .= $input->show();
+
+ if (get_boolean($attrib['button']))
+ {
+ $button = new input_field(array('type' => 'button',
+ 'value' => rcube_label('create'),
+ 'onclick' => "$JS_OBJECT_NAME.command('create-folder',this.form)"));
+ $out .= $button->show();
+ }
+
+ $out .= "\n$form_end";
+
+ return $out;
+ }
+
+
+parse_template('managefolders');
+?> \ No newline at end of file
diff --git a/program/steps/settings/save_identity.inc b/program/steps/settings/save_identity.inc
new file mode 100644
index 000000000..b4b1fec27
--- /dev/null
+++ b/program/steps/settings/save_identity.inc
@@ -0,0 +1,136 @@
+<?php
+
+/*
+ +-----------------------------------------------------------------------+
+ | program/steps/settings/save_identity.inc |
+ | |
+ | This file is part of the RoundCube Webmail client |
+ | Copyright (C) 2005, RoundCube Dev. - Switzerland |
+ | All rights reserved. |
+ | |
+ | PURPOSE: |
+ | Save an identity record or to add a new one |
+ | |
+ +-----------------------------------------------------------------------+
+ | Author: Thomas Bruederli <roundcube@gmail.com> |
+ +-----------------------------------------------------------------------+
+
+ $Id$
+
+*/
+
+$a_save_cols = array('name', 'email', 'organization', 'reply-to', 'bcc', 'default');
+
+
+// update an existing contact
+if ($_POST['_iid'])
+ {
+ $a_write_sql = array();
+
+ foreach ($a_save_cols as $col)
+ {
+ $fname = '_'.$col;
+ if (!isset($_POST[$fname]))
+ continue;
+
+ $a_write_sql[] = sprintf("`%s`='%s'", $col, addslashes($_POST[$fname]));
+ }
+
+ if (sizeof($a_write_sql))
+ {
+ $DB->query(sprintf("UPDATE %s
+ SET %s
+ WHERE identity_id=%d
+ AND user_id=%d
+ AND del!='1'",
+ get_table_name('identities'),
+ join(', ', $a_write_sql),
+ $_POST['_iid'],
+ $_SESSION['user_id']));
+
+ $updated = $DB->affected_rows();
+ }
+
+ if ($updated)
+ {
+ show_message('successfullysaved', 'confirmation');
+
+ // mark all other identities as 'not-default'
+ $DB->query(sprintf("UPDATE %s
+ SET `default`='0'
+ WHERE identity_id!=%d
+ AND user_id=%d
+ AND del!='1'",
+ get_table_name('identities'),
+ $_POST['_iid'],
+ $_SESSION['user_id']));
+
+ if ($_POST['_framed'])
+ {
+ // update the changed col in list
+ // ...
+ }
+ }
+ else
+ {
+ // show error message
+
+ }
+ }
+
+// insert a new contact
+else
+ {
+ $a_insert_cols = $a_insert_values = array();
+
+ foreach ($a_save_cols as $col)
+ {
+ $fname = '_'.$col;
+ if (!isset($_POST[$fname]))
+ continue;
+
+ $a_insert_cols[] = "`$col`";
+ $a_insert_values[] = sprintf("'%s'", addslashes($_POST[$fname]));
+ }
+
+ if (sizeof($a_insert_cols))
+ {
+ $DB->query(sprintf("INSERT INTO %s
+ (user_id, %s)
+ VALUES (%d, %s)",
+ get_table_name('identities'),
+ join(', ', $a_insert_cols),
+ $_SESSION['user_id'],
+ join(', ', $a_insert_values)));
+
+ $insert_id = $DB->insert_id();
+ }
+
+ if ($insert_id)
+ {
+ $_GET['_iid'] = $insert_id;
+
+ if ($_POST['_framed'])
+ {
+ // add contact row or jump to the page where it should appear
+ // ....
+ }
+ }
+ else
+ {
+ // show error message
+ }
+ }
+
+
+// go to next step
+if ($_POST['_framed'])
+ $_action = 'edit-identitiy';
+else
+ $_action = 'identities';
+
+
+// overwrite action variable
+$OUTPUT->add_script(sprintf("\n%s.set_env('action', '%s');", $JS_OBJECT_NAME, $_action));
+
+?> \ No newline at end of file
diff --git a/program/steps/settings/save_prefs.inc b/program/steps/settings/save_prefs.inc
new file mode 100644
index 000000000..1524b9ead
--- /dev/null
+++ b/program/steps/settings/save_prefs.inc
@@ -0,0 +1,59 @@
+<?php
+
+/*
+ +-----------------------------------------------------------------------+
+ | program/steps/settings/save_prefs.inc |
+ | |
+ | This file is part of the RoundCube Webmail client |
+ | Copyright (C) 2005, RoundCube Dev. - Switzerland |
+ | All rights reserved. |
+ | |
+ | PURPOSE: |
+ | Save user preferences to DB and to the current session |
+ | |
+ +-----------------------------------------------------------------------+
+ | Author: Thomas Bruederli <roundcube@gmail.com> |
+ +-----------------------------------------------------------------------+
+
+ $Id$
+
+*/
+
+$a_user_prefs = $_SESSION['user_prefs'];
+if (!is_array($a_user_prefs))
+ $a_user_prefs = array();
+
+
+$a_user_prefs['timezone'] = isset($_POST['_timezone']) ? (int)$_POST['_timezone'] : $CONFIG['timezone'];
+$a_user_prefs['pagesize'] = is_numeric($_POST['_pagesize']) ? (int)$_POST['_pagesize'] : $CONFIG['pagesize'];
+$a_user_prefs['prefer_html'] = isset($_POST['_prefer_html']) ? TRUE : FALSE;
+
+if (isset($_POST['_language']))
+ $sess_user_lang = $_SESSION['user_lang'] = $_POST['_language'];
+
+
+$DB->query(sprintf("UPDATE %s
+ SET preferences='%s',
+ language='%s'
+ WHERE user_id=%d",
+ get_table_name('users'),
+ addslashes(serialize($a_user_prefs)),
+ $sess_user_lang,
+ $_SESSION['user_id']));
+
+if ($DB->affected_rows())
+ {
+ show_message('successfullysaved', 'confirmation');
+
+ $_SESSION['user_prefs'] = $a_user_prefs;
+ $CONFIG = array_merge($CONFIG, $a_user_prefs);
+ }
+
+
+// go to next step
+$_action = 'preferences';
+
+// overwrite action variable
+$OUTPUT->add_script(sprintf("\n%s.set_env('action', '%s');", $JS_OBJECT_NAME, $_action));
+
+?> \ No newline at end of file