summaryrefslogtreecommitdiff
path: root/program/steps
diff options
context:
space:
mode:
authorthomascube <thomas@roundcube.net>2007-12-10 15:27:19 +0000
committerthomascube <thomas@roundcube.net>2007-12-10 15:27:19 +0000
commitfba1f5ab813f2eb4bedc5d9c4a75e77bbaa90131 (patch)
treecebde4edb06ac3a87eb2306b0c0125610a1bd5ce /program/steps
parentd39eecad6db1caee97624b80634587d98a75e701 (diff)
New class rcube_user + send message disposition notification
Diffstat (limited to 'program/steps')
-rw-r--r--program/steps/mail/compose.inc11
-rw-r--r--program/steps/mail/func.inc66
-rw-r--r--program/steps/mail/sendmail.inc111
-rw-r--r--program/steps/mail/sendmdn.inc97
-rw-r--r--program/steps/mail/show.inc3
-rw-r--r--program/steps/settings/delete_identity.inc11
-rw-r--r--program/steps/settings/edit_identity.inc9
-rw-r--r--program/steps/settings/func.inc24
-rw-r--r--program/steps/settings/save_identity.inc107
-rw-r--r--program/steps/settings/save_prefs.inc7
10 files changed, 224 insertions, 222 deletions
diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc
index 5131010af..36a3d7069 100644
--- a/program/steps/mail/compose.inc
+++ b/program/steps/mail/compose.inc
@@ -230,7 +230,7 @@ function rcmail_compose_headers($attrib)
function rcmail_compose_header_from($attrib)
{
- global $IMAP, $MESSAGE, $DB, $OUTPUT, $compose_mode;
+ global $IMAP, $MESSAGE, $DB, $USER, $OUTPUT, $compose_mode;
// pass the following attributes to the form class
$field_attrib = array('name' => '_from');
@@ -263,12 +263,7 @@ function rcmail_compose_header_from($attrib)
}
// get this user's identities
- $sql_result = $DB->query("SELECT identity_id, name, email, signature, html_signature
- FROM ".get_table_name('identities')."
- WHERE user_id=?
- AND del<>1
- ORDER BY ".$DB->quoteIdentifier('standard')." DESC, name ASC",
- $_SESSION['user_id']);
+ $sql_result = $USER->list_identities();
if ($DB->num_rows($sql_result))
{
@@ -869,7 +864,7 @@ $OUTPUT->add_handlers(array(
require_once('include/rcube_contacts.inc');
-$CONTACTS = new rcube_contacts($DB, $_SESSION['user_id']);
+$CONTACTS = new rcube_contacts($DB, $USER->ID);
$CONTACTS->set_pagesize(1000);
if ($result = $CONTACTS->list_records())
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index dd3801672..de8987248 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -21,6 +21,7 @@
require_once('lib/html2text.inc');
require_once('lib/enriched.inc');
+require_once('include/rcube_smtp.inc');
$EMAIL_ADDRESS_PATTERN = '/([a-z0-9][a-z0-9\-\.\+\_]*@[a-z0-9]([a-z0-9\-][.]?)*[a-z0-9]\\.[a-z]{2,5})/i';
@@ -725,7 +726,7 @@ function rcmail_parse_message(&$structure, $arg=array(), $recursive=FALSE)
// part text/[plain|html] OR message/delivery-status
else if (($primary_type=='text' && ($secondary_type=='plain' || $secondary_type=='html') && $mail_part->disposition!='attachment') ||
- ($primary_type=='message' && $secondary_type=='delivery-status'))
+ ($primary_type=='message' && ($secondary_type=='delivery-status' || $secondary_type=='disposition-notification')))
{
$mail_part->type = 'content';
$a_return_parts[] = $mail_part;
@@ -758,7 +759,7 @@ function rcmail_parse_message(&$structure, $arg=array(), $recursive=FALSE)
else
{
if (!$mail_part->filename)
- $mail_part->filename = 'file_'.$mail_part->mime_id;
+ $mail_part->filename = 'Part '.$mail_part->mime_id;
$a_attachments[] = $mail_part;
}
}
@@ -1250,6 +1251,67 @@ function rcmail_compose_cleanup()
unset($_SESSION['compose']);
}
+
+
+/**
+ * Send the given message compose object using the configured method
+ */
+function rcmail_deliver_message(&$message, $from, $mailto)
+{
+ global $CONFIG;
+
+ $headers = $message->headers();
+ $msg_body = $message->get();
+
+ // send thru SMTP server using custom SMTP library
+ if ($CONFIG['smtp_server'])
+ {
+ // generate list of recipients
+ $a_recipients = array($mailto);
+
+ if (strlen($headers['Cc']))
+ $a_recipients[] = $headers['Cc'];
+ if (strlen($headers['Bcc']))
+ $a_recipients[] = $headers['Bcc'];
+
+ // clean Bcc from header for recipients
+ $send_headers = $headers;
+ unset($send_headers['Bcc']);
+
+ // send message
+ $smtp_response = array();
+ $sent = smtp_mail($from, $a_recipients, ($foo = $message->txtHeaders($send_headers)), $msg_body, $smtp_response);
+
+ // log error
+ if (!$sent)
+ raise_error(array('code' => 800, 'type' => 'smtp', 'line' => __LINE__, 'file' => __FILE__,
+ 'message' => "SMTP error: ".join("\n", $smtp_response)), TRUE, FALSE);
+ }
+
+ // send mail using PHP's mail() function
+ else
+ {
+ // unset some headers because they will be added by the mail() function
+ $headers_enc = $message->headers($headers);
+ $headers_php = $message->_headers;
+ unset($headers_php['To'], $headers_php['Subject']);
+
+ // reset stored headers and overwrite
+ $message->_headers = array();
+ $header_str = $message->txtHeaders($headers_php);
+
+ if (ini_get('safe_mode'))
+ $sent = mail($headers_enc['To'], $headers_enc['Subject'], $msg_body, $header_str);
+ else
+ $sent = mail($headers_enc['To'], $headers_enc['Subject'], $msg_body, $header_str, "-f$from");
+ }
+
+
+ $message->_headers = array();
+ $message->headers($headers);
+
+ return $sent;
+}
// register UI objects
diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc
index d118af53f..6f4744db9 100644
--- a/program/steps/mail/sendmail.inc
+++ b/program/steps/mail/sendmail.inc
@@ -22,7 +22,6 @@
//require_once('lib/smtp.inc');
-require_once('include/rcube_smtp.inc');
require_once('lib/html2text.inc');
require_once('lib/rc_mail_mime.inc');
@@ -37,26 +36,19 @@ if (!isset($_SESSION['compose']['id']))
/****** message sending functions ********/
+// get identity record
function rcmail_get_identity($id)
{
- global $DB, $OUTPUT;
+ global $USER, $OUTPUT;
- // get identity record
- $sql_result = $DB->query("SELECT *, email AS mailto
- FROM ".get_table_name('identities')."
- WHERE identity_id=?
- AND user_id=?
- AND del<>1",
- $id,$_SESSION['user_id']);
-
- if ($DB->num_rows($sql_result))
+ if ($sql_arr = $USER->get_identity($id))
{
- $sql_arr = $DB->fetch_assoc($sql_result);
$out = $sql_arr;
+ $out['mailto'] = $sql_arr['email'];
$name = strpos($sql_arr['name'], ",") ? '"'.$sql_arr['name'].'"' : $sql_arr['name'];
$out['string'] = sprintf('%s <%s>',
rcube_charset_convert($name, RCMAIL_CHARSET, $OUTPUT->get_charset()),
- $sql_arr['mailto']);
+ $sql_arr['email']);
return $out;
}
@@ -166,7 +158,7 @@ if (empty($identity_arr['string']))
$identity_arr['string'] = $from;
// compose headers array
-$headers = array('Date' => date('D, j M Y H:i:s O'),
+$headers = array('Date' => date('r'),
'From' => rcube_charset_convert($identity_arr['string'], RCMAIL_CHARSET, $message_charset),
'To' => $mailto);
@@ -225,23 +217,11 @@ $message_body = get_input_value('_message', RCUBE_INPUT_POST, TRUE, $message_cha
if (!$savedraft && !empty($CONFIG['generic_message_footer']) && ($footer = file_get_contents(realpath($CONFIG['generic_message_footer']))))
$message_body .= "\r\n" . rcube_charset_convert($footer, 'UTF-8', $message_charset);
-// try to autodetect operating system and use the correct line endings
-// use the configured delimiter for headers
-if (!empty($CONFIG['mail_header_delimiter']))
- $header_delm = $CONFIG['mail_header_delimiter'];
-else if (strtolower(substr(PHP_OS, 0, 3)=='win'))
- $header_delm = "\r\n";
-else if (strtolower(substr(PHP_OS, 0, 3)=='mac'))
- $header_delm = "\r\n";
-else
- $header_delm = "\n";
-
-
$isHtmlVal = strtolower(get_input_value('_is_html', RCUBE_INPUT_POST));
$isHtml = ($isHtmlVal == "1");
// create extended PEAR::Mail_mime instance
-$MAIL_MIME = new rc_mail_mime($header_delm);
+$MAIL_MIME = new rc_mail_mime(rcmail_header_delm());
// For HTML-formatted messages, construct the MIME message with both
// the HTML part and the plain-text part
@@ -282,80 +262,30 @@ $charset_7bit = array('ASCII', 'ISO-2022-JP', 'ISO-8859-1', 'ISO-8859-2', 'ISO-8
$transfer_encoding = in_array(strtoupper($message_charset), $charset_7bit) ? '7bit' : '8bit';
// encoding settings for mail composing
-$message_param = array(
+$MAIL_MIME->setParam(array(
'text_encoding' => $transfer_encoding,
'html_encoding' => 'quoted-printable',
'head_encoding' => 'quoted-printable',
'head_charset' => $message_charset,
'html_charset' => $message_charset,
'text_charset' => $message_charset,
-);
-
-// compose message body and get headers
-$msg_body = $MAIL_MIME->get($message_param);
-// unset to save memory.
-unset($MAIL_MIME->_parts);
+));
// encoding subject header with mb_encode provides better results with asian characters
if ($MBSTRING && function_exists("mb_encode_mimeheader"))
{
mb_internal_encoding($message_charset);
- $mb_subject = mb_encode_mimeheader($headers['Subject'], $message_charset, 'Q');
+ $headers['Subject'] = mb_encode_mimeheader($headers['Subject'], $message_charset, 'Q');
mb_internal_encoding(RCMAIL_CHARSET);
}
-// Begin SMTP Delivery Block
-if (!$savedraft) {
+// pass headers to message object
+$MAIL_MIME->headers($headers);
- // send thru SMTP server using custom SMTP library
- if ($CONFIG['smtp_server'])
- {
- // generate list of recipients
- $a_recipients = array($mailto);
-
- if (strlen($headers['Cc']))
- $a_recipients[] = $headers['Cc'];
- if (strlen($headers['Bcc']))
- $a_recipients[] = $headers['Bcc'];
-
- // clean Bcc from header for recipients
- $send_headers = $headers;
- unset($send_headers['Bcc']);
-
- if (!empty($mb_subject))
- $send_headers['Subject'] = $mb_subject;
-
- // send message
- $smtp_response = array();
- $sent = smtp_mail($from, $a_recipients, ($foo = $MAIL_MIME->txtHeaders($send_headers)), $msg_body, $smtp_response);
-
- // log error
- if (!$sent)
- raise_error(array('code' => 800, 'type' => 'smtp', 'line' => __LINE__, 'file' => __FILE__,
- 'message' => "SMTP error: ".join("\n", $smtp_response)), TRUE, FALSE);
- }
-
- // send mail using PHP's mail() function
- else
- {
- // unset some headers because they will be added by the mail() function
- $headers_enc = $MAIL_MIME->headers($headers);
- $headers_php = $MAIL_MIME->_headers;
- unset($headers_php['To'], $headers_php['Subject']);
-
- if (!empty($mb_subject))
- $headers_enc['Subject'] = $mb_subject;
-
- // reset stored headers and overwrite
- $MAIL_MIME->_headers = array();
- $header_str = $MAIL_MIME->txtHeaders($headers_php);
-
- if (ini_get('safe_mode'))
- $sent = mail($headers_enc['To'], $headers_enc['Subject'], $msg_body, $header_str);
- else
- $sent = mail($headers_enc['To'], $headers_enc['Subject'], $msg_body, $header_str, "-f$from");
- }
-
+// Begin SMTP Delivery Block
+if (!$savedraft)
+{
+ $sent = rcmail_deliver_message($MAIL_MIME, $from, $mailto);
// return to compose page if sending failed
if (!$sent)
@@ -365,7 +295,6 @@ if (!$savedraft) {
return;
}
-
// set repliead flag
if ($_SESSION['compose']['reply_uid'])
$IMAP->set_flag($_SESSION['compose']['reply_uid'], 'ANSWERED');
@@ -382,21 +311,15 @@ else
if ($CONFIG[$store_target])
{
- // create string of complete message headers
- $header_str = $MAIL_MIME->txtHeaders($headers);
-
// check if mailbox exists
if (!in_array_nocase($CONFIG[$store_target], $IMAP->list_mailboxes()))
$store_folder = $IMAP->create_mailbox($CONFIG[$store_target], TRUE);
else
$store_folder = TRUE;
- // add headers to message body
- $msg_body = $header_str."\r\n".$msg_body;
-
// append message to sent box
if ($store_folder)
- $saved = $IMAP->save_message($CONFIG[$store_target], $msg_body);
+ $saved = $IMAP->save_message($CONFIG[$store_target], $MAIL_MIME->getMessage());
// raise error if saving failed
if (!$saved)
diff --git a/program/steps/mail/sendmdn.inc b/program/steps/mail/sendmdn.inc
new file mode 100644
index 000000000..0944e7602
--- /dev/null
+++ b/program/steps/mail/sendmdn.inc
@@ -0,0 +1,97 @@
+<?php
+
+/*
+ +-----------------------------------------------------------------------+
+ | program/steps/mail/sendmdn.inc |
+ | |
+ | This file is part of the RoundCube Webmail client |
+ | Copyright (C) 2007, RoundCube Dev. - Switzerland |
+ | Licensed under the GNU GPL |
+ | |
+ | PURPOSE: |
+ | Send a message disposition notification for a specific mail |
+ | |
+ +-----------------------------------------------------------------------+
+ | Author: Thomas Bruederli <roundcube@gmail.com> |
+ +-----------------------------------------------------------------------+
+
+ $Id: sendmail.inc 930 2007-11-25 17:34:19Z thomasb $
+
+*/
+
+require_once('lib/rc_mail_mime.inc');
+
+
+if (!empty($_POST['_uid']))
+ {
+ $MESSAGE = array('UID' => get_input_value('_uid', RCUBE_INPUT_POST));
+ $MESSAGE['headers'] = $IMAP->get_headers($MESSAGE['UID']);
+ $MESSAGE['subject'] = rcube_imap::decode_mime_string($MESSAGE['headers']->subject, $MESSAGE['headers']->charset);
+
+ if ($MESSAGE['headers']->mdn_to && !$MESSAGE['headers']->mdn_sent)
+ {
+ $identity = $USER->get_identity();
+ $sender = format_email_recipient($identity['email'], $identity['name']);
+ $recipient = array_shift($IMAP->decode_address_list($MESSAGE['headers']->mdn_to));
+ $mailto = $recipient['mailto'];
+
+ $COMPOSE = new rc_mail_mime(rcmail_header_delm());
+ $COMPOSE->setParam(array(
+ 'text_encoding' => 'quoted-printable',
+ 'html_encoding' => 'quoted-printable',
+ 'head_encoding' => 'quoted-printable',
+ 'head_charset' => RCMAIL_CHARSET,
+ 'html_charset' => RCMAIL_CHARSET,
+ 'text_charset' => RCMAIL_CHARSET,
+ ));
+
+ // compose headers array
+ $headers = array(
+ 'Date' => date('r'),
+ 'From' => $sender,
+ 'To' => $MESSAGE['headers']->mdn_to,
+ 'Subject' => rcube_label('receiptread') . ': ' . $MESSAGE['subject'],
+ 'Message-ID' => sprintf('<%s@%s>', md5(uniqid('rcmail'.rand(),true)), rcmail_mail_domain($_SESSION['imap_host'])),
+ 'X-Sender' => $identity['email'],
+ 'Content-Type' => 'multipart/report; report-type=disposition-notification',
+ );
+
+ if (!empty($CONFIG['useragent']))
+ $headers['User-Agent'] = $CONFIG['useragent'];
+
+ $body = rcube_label("yourmessage") . "\r\n\r\n" .
+ "\t" . rcube_label("to") . ': ' . rcube_imap::decode_mime_string($MESSAGE['headers']->to, $MESSAGE['headers']->charset) . "\r\n" .
+ "\t" . rcube_label("subject") . ': ' . $MESSAGE['subject'] . "\r\n" .
+ "\t" . rcube_label("sent") . ': ' . format_date(strtotime($MESSAGE['headers']->date), $CONFIG['date_long']) . "\r\n" .
+ "\r\n" . rcube_label("receiptnote") . "\r\n";
+
+ $report = "Reporting-UA: RoundCube Webmail (Version ".RCMAIL_VERSION.")\r\n";
+
+ if ($MESSAGE['headers']->to)
+ $report .= "Original-Recipient: {$MESSAGE['headers']->to}\r\n";
+
+ $report .= "Final-Recipient: rfc822; {$identity['email']}\r\n" .
+ "Original-Message-ID: {$MESSAGE['headers']->messageID}\r\n" .
+ "Disposition: manual-action/MDN-sent-manually; displayed\r\n";
+
+ $COMPOSE->headers($headers, true);
+ $COMPOSE->setTXTBody($body);
+ $COMPOSE->addAttachment($report, 'message/disposition-notification', 'MDNPart2.txt', false, '7bit', 'inline');
+
+ $sent = rcmail_deliver_message($COMPOSE, $identity['email'], $mailto);
+
+ if ($sent)
+ {
+ $IMAP->set_flag($MESSAGE['UID'], 'MDNSENT');
+ $OUTPUT->set_env('mdn_request', false);
+ $OUTPUT->show_message('receiptsent', 'confirmation');
+ $OUTPUT->send();
+ }
+ }
+}
+
+// Error if arrive here
+$OUTPUT->show_message('errorsendingreceipt', 'error');
+$OUTPUT->send();
+
+?> \ No newline at end of file
diff --git a/program/steps/mail/show.inc b/program/steps/mail/show.inc
index 022edb0ed..45d64b87b 100644
--- a/program/steps/mail/show.inc
+++ b/program/steps/mail/show.inc
@@ -75,7 +75,10 @@ if ($_GET['_uid'])
// check for unset disposition notification
if ($MESSAGE['headers']->mdn_to && !$MESSAGE['headers']->mdn_sent)
+ {
+ rcube_add_label('mdnrequest');
$OUTPUT->set_env('mdn_request', true);
+ }
$next = $prev = -1;
// get previous, first, next and last message UID
diff --git a/program/steps/settings/delete_identity.inc b/program/steps/settings/delete_identity.inc
index 3614a3e96..06fdd94f4 100644
--- a/program/steps/settings/delete_identity.inc
+++ b/program/steps/settings/delete_identity.inc
@@ -21,15 +21,8 @@
if (($ids = get_input_value('_iid', RCUBE_INPUT_GET)) && preg_match('/^[0-9]+(,[0-9]+)*$/', $ids))
{
- $DB->query(
- "UPDATE ".get_table_name('identities')."
- SET del=1
- WHERE user_id=?
- AND identity_id IN (".$ids.")",
- $_SESSION['user_id']);
-
- $count = $DB->affected_rows();
- if ($count)
+
+ if ($USER->delete_identity($ids))
$OUTPUT->show_message('deletedsuccessfully', 'confirmation');
// send response
diff --git a/program/steps/settings/edit_identity.inc b/program/steps/settings/edit_identity.inc
index 51a0cd0a0..4d89f7cbc 100644
--- a/program/steps/settings/edit_identity.inc
+++ b/program/steps/settings/edit_identity.inc
@@ -21,14 +21,7 @@
if (($_GET['_iid'] || $_POST['_iid']) && $_action=='edit-identity')
{
- $DB->query("SELECT * FROM ".get_table_name('identities')."
- WHERE identity_id=?
- AND user_id=?
- AND del<>1",
- get_input_value('_iid', RCUBE_INPUT_GPC),
- $_SESSION['user_id']);
-
- $IDENTITY_RECORD = $DB->fetch_assoc();
+ $IDENTITY_RECORD = $USER->get_identity(get_input_value('_iid', RCUBE_INPUT_GPC));
if (is_array($IDENTITY_RECORD))
$OUTPUT->set_env('iid', $IDENTITY_RECORD['identity_id']);
diff --git a/program/steps/settings/func.inc b/program/steps/settings/func.inc
index ecdbcbd76..e63f01620 100644
--- a/program/steps/settings/func.inc
+++ b/program/steps/settings/func.inc
@@ -20,15 +20,8 @@
*/
-// get user record
-$sql_result = $DB->query("SELECT username, mail_host FROM ".get_table_name('users')."
- WHERE user_id=?",
- $_SESSION['user_id']);
-
-if ($USER_DATA = $DB->fetch_assoc($sql_result))
-{
- $OUTPUT->set_pagetitle(rcube_label('settingsfor') . " ". $USER_DATA['username'] . (!strpos($USER_DATA['username'], '@') ? '@'.$USER_DATA['mail_host'] : ''));
-}
+if ($USER->ID)
+ $OUTPUT->set_pagetitle(rcube_label('settingsfor') . " ". $USER->get_username());
@@ -204,16 +197,7 @@ function rcmail_user_prefs_form($attrib)
function rcmail_identities_list($attrib)
{
- global $DB, $CONFIG, $OUTPUT;
-
-
- // get contacts from DB
- $sql_result = $DB->query("SELECT * FROM ".get_table_name('identities')."
- WHERE del<>1
- AND user_id=?
- ORDER BY standard DESC, name ASC",
- $_SESSION['user_id']);
-
+ global $OUTPUT, $USER;
// add id to message list table if not specified
if (!strlen($attrib['id']))
@@ -223,7 +207,7 @@ function rcmail_identities_list($attrib)
$a_show_cols = array('name', 'email', 'organization', 'reply-to');
// create XHTML table
- $out = rcube_table_output($attrib, $sql_result, $a_show_cols, 'identity_id');
+ $out = rcube_table_output($attrib, $USER->list_identities(), $a_show_cols, 'identity_id');
// set client env
$OUTPUT->add_gui_object('identitieslist', $attrib['id']);
diff --git a/program/steps/settings/save_identity.inc b/program/steps/settings/save_identity.inc
index 8079b589a..2c2a55e49 100644
--- a/program/steps/settings/save_identity.inc
+++ b/program/steps/settings/save_identity.inc
@@ -33,123 +33,78 @@ if (empty($_POST['_name']) || empty($_POST['_email']))
}
+$save_data = array();
+foreach ($a_save_cols as $col)
+{
+ $fname = '_'.$col;
+ if (isset($_POST[$fname]))
+ $save_data[$col] = get_input_value($fname, RCUBE_INPUT_POST, in_array($col, $a_html_cols));
+}
+
+// set "off" values for checkboxes that were not checked, and therefore
+// not included in the POST body.
+foreach ($a_boolean_cols as $col)
+{
+ $fname = '_' . $col;
+ if (!isset($_POST[$fname]))
+ $save_data[$col] = 0;
+}
+
+
// update an existing contact
if ($_POST['_iid'])
+{
+ if ($updated = $USER->update_identity(get_input_value('_iid', RCUBE_INPUT_POST), $save_data))
{
- $a_write_sql = array();
-
- foreach ($a_save_cols as $col)
- {
- $fname = '_'.$col;
- if (isset($_POST[$fname]))
- $a_write_sql[] = sprintf("%s=%s",
- $DB->quoteIdentifier($col),
- $DB->quote(get_input_value($fname, RCUBE_INPUT_POST, in_array($col, $a_html_cols))));
- }
-
- // set "off" values for checkboxes that were not checked, and therefore
- // not included in the POST body.
- foreach ($a_boolean_cols as $col)
- {
- $fname = '_' . $col;
- if (!isset($_POST[$fname]))
- $a_write_sql[] = sprintf("%s=0", $DB->quoteIdentifier($col));
- }
-
- if (sizeof($a_write_sql))
- {
- $DB->query(
- "UPDATE ".get_table_name('identities')."
- SET ".join(', ', $a_write_sql)."
- WHERE identity_id=?
- AND user_id=?
- AND del<>1",
- get_input_value('_iid', RCUBE_INPUT_POST),
- $_SESSION['user_id']);
-
- $updated = $DB->affected_rows();
- }
-
- if ($updated)
- {
$OUTPUT->show_message('successfullysaved', 'confirmation');
if (!empty($_POST['_standard']))
$default_id = get_input_value('_iid', RCUBE_INPUT_POST);
if ($_POST['_framed'])
- {
+ {
// update the changed col in list
// ...
- }
}
+ }
else if ($DB->is_error())
- {
+ {
// show error message
$OUTPUT->show_message('errorsaving', 'error');
rcmail_overwrite_action('edit-identitiy');
return;
- }
}
+}
// insert a new contact
else
+{
+ if ($insert_id = $USER->insert_identity($save_data))
{
- $a_insert_cols = $a_insert_values = array();
-
- foreach ($a_save_cols as $col)
- {
- $fname = '_'.$col;
- if (!isset($_POST[$fname]))
- continue;
-
- $a_insert_cols[] = $DB->quoteIdentifier($col);
- $a_insert_values[] = $DB->quote(get_input_value($fname, RCUBE_INPUT_POST, in_array($col, $a_html_cols)));
- }
-
- if (sizeof($a_insert_cols))
- {
- $DB->query("INSERT INTO ".get_table_name('identities')."
- (user_id, ".join(', ', $a_insert_cols).")
- VALUES (?, ".join(', ', $a_insert_values).")",
- $_SESSION['user_id']);
-
- $insert_id = $DB->insert_id(get_sequence_name('identities'));
- }
-
- if ($insert_id)
- {
$_GET['_iid'] = $insert_id;
if (!empty($_POST['_standard']))
$default_id = $insert_id;
if ($_POST['_framed'])
- {
+ {
// add contact row or jump to the page where it should appear
// ....
- }
}
+ }
else
- {
+ {
// show error message
$OUTPUT->show_message('errorsaving', 'error');
rcmail_overwrite_action('edit-identity');
return;
- }
}
+}
// mark all other identities as 'not-default'
if ($default_id)
- $DB->query(
- "UPDATE ".get_table_name('identities')."
- SET ".$DB->quoteIdentifier('standard')."='0'
- WHERE user_id=?
- AND identity_id<>?
- AND del<>1",
- $_SESSION['user_id'],
- $default_id);
+ $USER->set_default($default_id);
// go to next step
rcmail_overwrite_action($_framed ? 'edit-identity' : 'identities');
diff --git a/program/steps/settings/save_prefs.inc b/program/steps/settings/save_prefs.inc
index 0565260f0..caa4a49e5 100644
--- a/program/steps/settings/save_prefs.inc
+++ b/program/steps/settings/save_prefs.inc
@@ -44,15 +44,12 @@ if (isset($_POST['_language']))
// force min size
if ($a_user_prefs['pagesize'] < 1)
- {
$a_user_prefs['pagesize'] = 10;
- }
+
if (isset($CONFIG['max_pagesize']) && ($a_user_prefs['pagesize'] > $CONFIG['max_pagesize']))
- {
$a_user_prefs['pagesize'] = (int) $CONFIG['max_pagesize'];
- }
-if (rcmail_save_user_prefs($a_user_prefs))
+if ($USER->save_prefs($a_user_prefs))
$OUTPUT->show_message('successfullysaved', 'confirmation');