summaryrefslogtreecommitdiff
path: root/program/lib
diff options
context:
space:
mode:
Diffstat (limited to 'program/lib')
-rw-r--r--program/lib/Roundcube/bootstrap.php4
-rw-r--r--program/lib/Roundcube/rcube.php139
-rw-r--r--program/lib/Roundcube/rcube_base_replacer.php9
-rw-r--r--program/lib/Roundcube/rcube_charset.php5
-rw-r--r--program/lib/Roundcube/rcube_config.php5
-rw-r--r--program/lib/Roundcube/rcube_contacts.php4
-rw-r--r--program/lib/Roundcube/rcube_content_filter.php2
-rw-r--r--program/lib/Roundcube/rcube_csv2vcard.php47
-rw-r--r--program/lib/Roundcube/rcube_db_oracle.php4
-rw-r--r--program/lib/Roundcube/rcube_imap_generic.php4
-rw-r--r--program/lib/Roundcube/rcube_imap_search.php2
-rw-r--r--program/lib/Roundcube/rcube_ldap.php22
-rw-r--r--program/lib/Roundcube/rcube_message.php6
-rw-r--r--program/lib/Roundcube/rcube_plugin_api.php1
-rw-r--r--program/lib/Roundcube/rcube_spellcheck_atd.php2
-rw-r--r--program/lib/Roundcube/rcube_user.php59
-rw-r--r--program/lib/Roundcube/rcube_utils.php2
-rw-r--r--program/lib/Roundcube/rcube_vcard.php3
18 files changed, 231 insertions, 89 deletions
diff --git a/program/lib/Roundcube/bootstrap.php b/program/lib/Roundcube/bootstrap.php
index fe9c389fe..af87beb24 100644
--- a/program/lib/Roundcube/bootstrap.php
+++ b/program/lib/Roundcube/bootstrap.php
@@ -408,7 +408,7 @@ if (!extension_loaded('mbstring'))
if (!function_exists('idn_to_utf8'))
{
- function idn_to_utf8($domain, $flags=null)
+ function idn_to_utf8($domain)
{
static $idn, $loaded;
@@ -430,7 +430,7 @@ if (!function_exists('idn_to_utf8'))
if (!function_exists('idn_to_ascii'))
{
- function idn_to_ascii($domain, $flags=null)
+ function idn_to_ascii($domain)
{
static $idn, $loaded;
diff --git a/program/lib/Roundcube/rcube.php b/program/lib/Roundcube/rcube.php
index 03f49637c..547e2b4ac 100644
--- a/program/lib/Roundcube/rcube.php
+++ b/program/lib/Roundcube/rcube.php
@@ -28,9 +28,15 @@
*/
class rcube
{
- const INIT_WITH_DB = 1;
+ // Init options
+ const INIT_WITH_DB = 1;
const INIT_WITH_PLUGINS = 2;
+ // Request status
+ const REQUEST_VALID = 0;
+ const REQUEST_ERROR_URL = 1;
+ const REQUEST_ERROR_TOKEN = 2;
+
/**
* Singleton instace of rcube
*
@@ -101,6 +107,12 @@ class rcube
*/
public $user;
+ /**
+ * Request status
+ *
+ * @var int
+ */
+ public $request_status = 0;
/* private/protected vars */
protected $texts;
@@ -978,6 +990,104 @@ class rcube
/**
+ * Returns session token for secure URLs
+ *
+ * @param bool $generate Generate token if not exists in session yet
+ *
+ * @return string|bool Token string, False when disabled
+ */
+ public function get_secure_url_token($generate = false)
+ {
+ if ($len = $this->config->get('use_secure_urls')) {
+ if (empty($_SESSION['secure_token']) && $generate) {
+ // generate x characters long token
+ $length = $len > 1 ? $len : 16;
+ $token = openssl_random_pseudo_bytes($length / 2);
+ $token = bin2hex($token);
+
+ $plugin = $this->plugins->exec_hook('secure_token',
+ array('value' => $token, 'length' => $length));
+
+ $_SESSION['secure_token'] = $plugin['value'];
+ }
+
+ return $_SESSION['secure_token'];
+ }
+
+ return false;
+ }
+
+
+ /**
+ * Generate a unique token to be used in a form request
+ *
+ * @return string The request token
+ */
+ public function get_request_token()
+ {
+ $sess_id = $_COOKIE[ini_get('session.name')];
+ if (!$sess_id) {
+ $sess_id = session_id();
+ }
+
+ $plugin = $this->plugins->exec_hook('request_token', array(
+ 'value' => md5('RT' . $this->get_user_id() . $this->config->get('des_key') . $sess_id)));
+
+ return $plugin['value'];
+ }
+
+
+ /**
+ * Check if the current request contains a valid token.
+ * Empty requests aren't checked until use_secure_urls is set.
+ *
+ * @param int Request method
+ *
+ * @return boolean True if request token is valid false if not
+ */
+ public function check_request($mode = rcube_utils::INPUT_POST)
+ {
+ // check secure token in URL if enabled
+ if ($token = $this->get_secure_url_token()) {
+ foreach (explode('/', preg_replace('/[?#&].*$/', '', $_SERVER['REQUEST_URI'])) as $tok) {
+ if ($tok == $token) {
+ return true;
+ }
+ }
+
+ $this->request_status = self::REQUEST_ERROR_URL;
+
+ return false;
+ }
+
+ $sess_tok = $this->get_request_token();
+
+ // ajax requests
+ if (rcube_utils::request_header('X-Roundcube-Request') == $sess_tok) {
+ return true;
+ }
+
+ // skip empty requests
+ if (($mode == rcube_utils::INPUT_POST && empty($_POST))
+ || ($mode == rcube_utils::INPUT_GET && empty($_GET))
+ ) {
+ return true;
+ }
+
+ // default method of securing requests
+ $token = rcube_utils::get_input_value('_token', $mode);
+ $sess_id = $_COOKIE[ini_get('session.name')];
+
+ if (empty($sess_id) || $token != $sess_tok) {
+ $this->request_status = self::REQUEST_ERROR_TOKEN;
+ return false;
+ }
+
+ return true;
+ }
+
+
+ /**
* Build a valid URL to this instance of Roundcube
*
* @param mixed Either a string with the action or url parameters as key-value pairs
@@ -1551,7 +1661,7 @@ class rcube
// send thru SMTP server using custom SMTP library
if ($this->config->get('smtp_server')) {
// generate list of recipients
- $a_recipients = array($mailto);
+ $a_recipients = (array) $mailto;
if (strlen($headers['Cc']))
$a_recipients[] = $headers['Cc'];
@@ -1651,19 +1761,24 @@ class rcube
// remove MDN headers after sending
unset($headers['Return-Receipt-To'], $headers['Disposition-Notification-To']);
- // get all recipients
- if ($headers['Cc'])
- $mailto .= $headers['Cc'];
- if ($headers['Bcc'])
- $mailto .= $headers['Bcc'];
- if (preg_match_all('/<([^@]+@[^>]+)>/', $mailto, $m))
- $mailto = implode(', ', array_unique($m[1]));
-
if ($this->config->get('smtp_log')) {
+ // get all recipient addresses
+ if (is_array($mailto)) {
+ $mailto = implode(',', $mailto);
+ }
+ if ($headers['Cc']) {
+ $mailto .= ',' . $headers['Cc'];
+ }
+ if ($headers['Bcc']) {
+ $mailto .= ',' . $headers['Bcc'];
+ }
+
+ $mailto = rcube_mime::decode_address_list($mailto, null, false, null, true);
+
self::write_log('sendmail', sprintf("User %s [%s]; Message for %s; %s",
$this->user->get_username(),
- $_SERVER['REMOTE_ADDR'],
- $mailto,
+ rcube_utils::remote_addr(),
+ implode(', ', $mailto),
!empty($response) ? join('; ', $response) : ''));
}
}
diff --git a/program/lib/Roundcube/rcube_base_replacer.php b/program/lib/Roundcube/rcube_base_replacer.php
index fa6764753..a306086ee 100644
--- a/program/lib/Roundcube/rcube_base_replacer.php
+++ b/program/lib/Roundcube/rcube_base_replacer.php
@@ -61,9 +61,6 @@ class rcube_base_replacer
*/
public static function absolute_url($path, $base_url)
{
- $host_url = $base_url;
- $abs_path = $path;
-
// check if path is an absolute URL
if (preg_match('/^[fhtps]+:\/\//', $path)) {
return $path;
@@ -74,6 +71,9 @@ class rcube_base_replacer
return $path;
}
+ $host_url = $base_url;
+ $abs_path = $path;
+
// cut base_url to the last directory
if (strrpos($base_url, '/') > 7) {
$host_url = substr($base_url, 0, strpos($base_url, '/', 7));
@@ -89,7 +89,8 @@ class rcube_base_replacer
$path = preg_replace('/^\.\//', '', $path);
if (preg_match_all('/\.\.\//', $path, $matches, PREG_SET_ORDER)) {
- foreach ($matches as $a_match) {
+ $cnt = count($matches);
+ while ($cnt--) {
if ($pos = strrpos($base_url, '/')) {
$base_url = substr($base_url, 0, $pos);
}
diff --git a/program/lib/Roundcube/rcube_charset.php b/program/lib/Roundcube/rcube_charset.php
index 3e2dac19c..3657626bd 100644
--- a/program/lib/Roundcube/rcube_charset.php
+++ b/program/lib/Roundcube/rcube_charset.php
@@ -175,7 +175,6 @@ class rcube_charset
static $iconv_options = null;
static $mbstring_list = null;
static $mbstring_sch = null;
- static $conv = null;
$to = empty($to) ? RCUBE_CHARSET : $to;
$from = self::parse_charset($from);
@@ -274,7 +273,7 @@ class rcube_charset
return utf8_encode($str);
}
else {
- user_error("No suitable function found for UTF-8 encoding", E_USER_WARNING);
+ trigger_error("No suitable function found for UTF-8 encoding");
}
}
@@ -290,7 +289,7 @@ class rcube_charset
return utf8_decode($str);
}
else {
- user_error("No suitable function found for UTF-8 decoding", E_USER_WARNING);
+ trigger_error("No suitable function found for UTF-8 decoding");
}
}
diff --git a/program/lib/Roundcube/rcube_config.php b/program/lib/Roundcube/rcube_config.php
index afe13e879..53409f26f 100644
--- a/program/lib/Roundcube/rcube_config.php
+++ b/program/lib/Roundcube/rcube_config.php
@@ -39,7 +39,6 @@ class rcube_config
*/
private $legacy_props = array(
// new name => old name
- 'default_folders' => 'default_imap_folders',
'mail_pagesize' => 'pagesize',
'addressbook_pagesize' => 'pagesize',
'reply_mode' => 'top_posting',
@@ -143,10 +142,6 @@ class rcube_config
foreach (array('drafts_mbox', 'junk_mbox', 'sent_mbox', 'trash_mbox') as $folder)
$this->prop[$folder] = rcube_charset::convert($this->prop[$folder], RCUBE_CHARSET, 'UTF7-IMAP');
- if (!empty($this->prop['default_folders']))
- foreach ($this->prop['default_folders'] as $n => $folder)
- $this->prop['default_folders'][$n] = rcube_charset::convert($folder, RCUBE_CHARSET, 'UTF7-IMAP');
-
// set PHP error logging according to config
if ($this->prop['debug_level'] & 1) {
ini_set('log_errors', 1);
diff --git a/program/lib/Roundcube/rcube_contacts.php b/program/lib/Roundcube/rcube_contacts.php
index bd3a3f82b..6ac9fd5de 100644
--- a/program/lib/Roundcube/rcube_contacts.php
+++ b/program/lib/Roundcube/rcube_contacts.php
@@ -909,7 +909,7 @@ class rcube_contacts extends rcube_addressbook
$name, $gid, $this->user_id
);
- return $this->db->affected_rows() ? $name : false;
+ return $this->db->affected_rows($sql_result) ? $name : false;
}
@@ -983,7 +983,7 @@ class rcube_contacts extends rcube_addressbook
$group_id
);
- return $this->db->affected_rows();
+ return $this->db->affected_rows($sql_result);
}
diff --git a/program/lib/Roundcube/rcube_content_filter.php b/program/lib/Roundcube/rcube_content_filter.php
index ae6617d1b..7d3d02970 100644
--- a/program/lib/Roundcube/rcube_content_filter.php
+++ b/program/lib/Roundcube/rcube_content_filter.php
@@ -33,7 +33,7 @@ class rcube_content_filter extends php_user_filter
return true;
}
- function filter($in, $out, &$consumed, $closing)
+ function filter($in, $out, &$consumed)
{
while ($bucket = stream_bucket_make_writeable($in)) {
$this->buffer .= $bucket->data;
diff --git a/program/lib/Roundcube/rcube_csv2vcard.php b/program/lib/Roundcube/rcube_csv2vcard.php
index b7d159178..4b6e4fd3c 100644
--- a/program/lib/Roundcube/rcube_csv2vcard.php
+++ b/program/lib/Roundcube/rcube_csv2vcard.php
@@ -52,9 +52,9 @@ class rcube_csv2vcard
'company' => 'organization',
//'company_main_phone' => '',
'department' => 'department',
- //'email_2_address' => '', //@TODO
+ 'email_2_address' => 'email:other',
//'email_2_type' => '',
- //'email_3_address' => '', //@TODO
+ 'email_3_address' => 'email:other',
//'email_3_type' => '',
'email_address' => 'email:pref',
//'email_type' => '',
@@ -186,9 +186,9 @@ class rcube_csv2vcard
//'company_main_phone' => "Company Main Phone",
'department' => "Department",
//'directory_server' => "Directory Server",
- //'email_2_address' => "E-mail 2 Address",
+ 'email_2_address' => "E-mail 2 Address",
//'email_2_type' => "E-mail 2 Type",
- //'email_3_address' => "E-mail 3 Address",
+ 'email_3_address' => "E-mail 3 Address",
//'email_3_type' => "E-mail 3 Type",
'email_address' => "E-mail Address",
//'email_type' => "E-mail Type",
@@ -302,6 +302,7 @@ class rcube_csv2vcard
'Value' => array(
'home' => 'email:home',
'work' => 'email:work',
+ '*' => 'email:other',
),
),
'Phone' => array(
@@ -553,7 +554,13 @@ class rcube_csv2vcard
foreach ($this->map as $idx => $name) {
$value = $data[$idx];
if ($value !== null && $value !== '') {
- $contact[$name] = $value;
+ if (!empty($contact[$name])) {
+ $contact[$name] = (array) $contact[$name];
+ $contact[$name][] = $value;
+ }
+ else {
+ $contact[$name] = $value;
+ }
}
}
@@ -567,8 +574,20 @@ class rcube_csv2vcard
foreach ($item as $item_key => $item_idx) {
$value = $data[$item_idx];
- if ($value !== null && $value !== '' && ($data_idx = $this->gmail_label_map[$key][$item_key][$type])) {
- $contact[$data_idx] = $value;
+ if ($value !== null && $value !== '') {
+ foreach (array($type, '*') as $_type) {
+ if ($data_idx = $this->gmail_label_map[$key][$item_key][$_type]) {
+ $value = explode(' ::: ', $value);
+
+ if (!empty($contact[$data_idx])) {
+ $contact[$data_idx] = array_merge((array) $contact[$data_idx], $value);
+ }
+ else {
+ $contact[$data_idx] = $value;
+ }
+ break;
+ }
+ }
}
}
}
@@ -584,11 +603,14 @@ class rcube_csv2vcard
if (!empty($contact['groups'])) {
// categories/groups separator in vCard is ',' not ';'
+ $contact['groups'] = str_replace(',', '', $contact['groups']);
$contact['groups'] = str_replace(';', ',', $contact['groups']);
- // remove "* " added by GMail
if (!empty($this->gmail_map)) {
+ // remove "* " added by GMail
$contact['groups'] = str_replace('* ', '', $contact['groups']);
+ // replace strange delimiter
+ $contact['groups'] = str_replace(' ::: ', ',', $contact['groups']);
}
}
@@ -621,7 +643,14 @@ class rcube_csv2vcard
$vcard = new rcube_vcard();
foreach ($contact as $name => $value) {
$name = explode(':', $name);
- $vcard->set($name[0], $value, $name[1]);
+ if (is_array($value) && $name[0] != 'address') {
+ foreach ((array) $value as $val) {
+ $vcard->set($name[0], $val, $name[1]);
+ }
+ }
+ else {
+ $vcard->set($name[0], $value, $name[1]);
+ }
}
// add to the list
diff --git a/program/lib/Roundcube/rcube_db_oracle.php b/program/lib/Roundcube/rcube_db_oracle.php
index 362beb075..453746446 100644
--- a/program/lib/Roundcube/rcube_db_oracle.php
+++ b/program/lib/Roundcube/rcube_db_oracle.php
@@ -171,7 +171,7 @@ class rcube_db_oracle extends rcube_db
$mode = $this->in_transaction ? OCI_NO_AUTO_COMMIT : OCI_COMMIT_ON_SUCCESS;
if ($result) {
- foreach ($args as $param => $arg) {
+ foreach (array_keys($args) as $param) {
oci_bind_by_name($result, $param, $args[$param], -1, SQLT_LNG);
}
}
@@ -587,7 +587,7 @@ class rcube_db_oracle extends rcube_db
$this->debug('ROLLBACK TRANSACTION');
- if ($result = @oci_rollback($this->dbh)) {
+ if (@oci_rollback($this->dbh)) {
$this->in_transaction = false;
}
else {
diff --git a/program/lib/Roundcube/rcube_imap_generic.php b/program/lib/Roundcube/rcube_imap_generic.php
index d78b526dd..450dcdce2 100644
--- a/program/lib/Roundcube/rcube_imap_generic.php
+++ b/program/lib/Roundcube/rcube_imap_generic.php
@@ -1108,7 +1108,8 @@ class rcube_imap_generic
// folder name with spaces. Let's try to handle this situation
if (!is_array($items) && ($pos = strpos($response, '(')) !== false) {
$response = substr($response, $pos);
- $items = $this->tokenizeResponse($response, 1);
+ $items = $this->tokenizeResponse($response, 1);
+
if (!is_array($items)) {
return $result;
}
@@ -1704,7 +1705,6 @@ class rcube_imap_generic
$encoding = $encoding ? trim($encoding) : 'US-ASCII';
$algorithm = $algorithm ? trim($algorithm) : 'REFERENCES';
$criteria = $criteria ? 'ALL '.trim($criteria) : 'ALL';
- $data = '';
list($code, $response) = $this->execute($return_uid ? 'UID THREAD' : 'THREAD',
array($algorithm, $encoding, $criteria));
diff --git a/program/lib/Roundcube/rcube_imap_search.php b/program/lib/Roundcube/rcube_imap_search.php
index 365d78f76..eac64b035 100644
--- a/program/lib/Roundcube/rcube_imap_search.php
+++ b/program/lib/Roundcube/rcube_imap_search.php
@@ -124,9 +124,7 @@ class rcube_imap_search_job /* extends Stackable */
private $charset;
private $sort_field;
private $threading;
- private $searchset;
private $result;
- private $pagesize = 100;
public function __construct($folder, $str, $charset = null, $sort_field = null, $threading=false)
{
diff --git a/program/lib/Roundcube/rcube_ldap.php b/program/lib/Roundcube/rcube_ldap.php
index 6805c4902..981f2e841 100644
--- a/program/lib/Roundcube/rcube_ldap.php
+++ b/program/lib/Roundcube/rcube_ldap.php
@@ -64,7 +64,6 @@ class rcube_ldap extends rcube_addressbook
private $base_dn = '';
private $groups_base_dn = '';
- private $group_url;
private $group_data;
private $group_search_cache;
private $cache;
@@ -766,16 +765,16 @@ class rcube_ldap extends rcube_addressbook
if ($this->prop['vlv_search'] && $this->ready && join(',', (array)$fields) == join(',', $list_fields)) {
$this->result = new rcube_result_set(0);
- $search_suffix = $this->prop['fuzzy_search'] && $mode != 1 ? '*' : '';
+ $this->ldap->config_set('fuzzy_search', intval($this->prop['fuzzy_search'] && $mode != 1));
$ldap_data = $this->ldap->search($this->base_dn, $this->prop['filter'], $this->prop['scope'], $this->prop['attributes'],
- array('search' => $value . $search_suffix /*, 'sort' => $this->prop['sort'] */));
+ array('search' => $value /*, 'sort' => $this->prop['sort'] */));
if ($ldap_data === false) {
return $this->result;
}
// get all entries of this page and post-filter those that really match the query
$search = mb_strtolower($value);
- foreach ($ldap_data as $i => $entry) {
+ foreach ($ldap_data as $entry) {
$rec = $this->_ldap2result($entry);
foreach ($fields as $f) {
foreach ((array)$rec[$f] as $val) {
@@ -1531,7 +1530,6 @@ class rcube_ldap extends rcube_addressbook
return $ldap_data;
}
-
/**
* Returns unified attribute name (resolving aliases)
*/
@@ -1563,17 +1561,6 @@ class rcube_ldap extends rcube_addressbook
}
/**
- * Prints debug info to the log
- */
- private function _debug($str)
- {
- if ($this->debug) {
- rcube::write_log('ldap', $str);
- }
- }
-
-
- /**
* Activate/deactivate debug mode
*
* @param boolean $dbg True if LDAP commands should be logged
@@ -1587,7 +1574,6 @@ class rcube_ldap extends rcube_addressbook
}
}
-
/**
* Setter for the current group
*/
@@ -1990,7 +1976,7 @@ class rcube_ldap extends rcube_addressbook
$filter = strtr("(|(member=$contact_dn)(uniqueMember=$contact_dn)$add_filter)", array('\\' => '\\\\'));
$ldap_data = $this->ldap->search($base_dn, $filter, 'sub', array('dn', $name_attr));
- if ($res === false) {
+ if ($ldap_data === false) {
return array();
}
diff --git a/program/lib/Roundcube/rcube_message.php b/program/lib/Roundcube/rcube_message.php
index 169d00ce1..20329a7f1 100644
--- a/program/lib/Roundcube/rcube_message.php
+++ b/program/lib/Roundcube/rcube_message.php
@@ -550,12 +550,6 @@ class rcube_message
else if ($mimetype == 'multipart/alternative'
&& is_array($structure->parts) && count($structure->parts) > 1
) {
- $plain_part = null;
- $html_part = null;
- $print_part = null;
- $related_part = null;
- $attach_part = null;
-
// get html/plaintext parts, other add to attachments list
foreach ($structure->parts as $p => $sub_part) {
$sub_mimetype = $sub_part->mimetype;
diff --git a/program/lib/Roundcube/rcube_plugin_api.php b/program/lib/Roundcube/rcube_plugin_api.php
index 92a56363a..c74162619 100644
--- a/program/lib/Roundcube/rcube_plugin_api.php
+++ b/program/lib/Roundcube/rcube_plugin_api.php
@@ -252,6 +252,7 @@ class rcube_plugin_api
'GPLv2' => 'http://www.gnu.org/licenses/gpl-2.0.html',
'GPL-2.0' => 'http://www.gnu.org/licenses/gpl-2.0.html',
'GPLv3' => 'http://www.gnu.org/licenses/gpl-3.0.html',
+ 'GPLv3+' => 'http://www.gnu.org/licenses/gpl-3.0.html',
'GPL-3.0' => 'http://www.gnu.org/licenses/gpl-3.0.html',
'GPL-3.0+' => 'http://www.gnu.org/licenses/gpl.html',
'GPL-2.0+' => 'http://www.gnu.org/licenses/gpl.html',
diff --git a/program/lib/Roundcube/rcube_spellcheck_atd.php b/program/lib/Roundcube/rcube_spellcheck_atd.php
index 9f073f56f..917ec0899 100644
--- a/program/lib/Roundcube/rcube_spellcheck_atd.php
+++ b/program/lib/Roundcube/rcube_spellcheck_atd.php
@@ -127,7 +127,7 @@ class rcube_spellcheck_atd extends rcube_spellcheck_engine
$result = new SimpleXMLElement($response);
}
catch (Exception $e) {
- $thid->error = "Unexpected response from server: " . $store;
+ $this->error = "Unexpected response from server: " . $response;
return array();
}
diff --git a/program/lib/Roundcube/rcube_user.php b/program/lib/Roundcube/rcube_user.php
index b2110df8b..77c58dd14 100644
--- a/program/lib/Roundcube/rcube_user.php
+++ b/program/lib/Roundcube/rcube_user.php
@@ -51,6 +51,14 @@ class rcube_user
*/
private $identities = array();
+ /**
+ * Internal emails cache
+ *
+ * @var array
+ */
+ private $emails;
+
+
const SEARCH_ADDRESSBOOK = 1;
const SEARCH_MAIL = 2;
@@ -79,7 +87,6 @@ class rcube_user
}
}
-
/**
* Build a user name string (as e-mail address)
*
@@ -118,7 +125,6 @@ class rcube_user
return false;
}
-
/**
* Get the preferences saved for this user
*
@@ -154,7 +160,6 @@ class rcube_user
return $prefs;
}
-
/**
* Write the given user prefs to the user's record
*
@@ -233,6 +238,33 @@ class rcube_user
}
/**
+ * Return a list of all user emails (from identities)
+ *
+ * @param bool Return only default identity
+ *
+ * @return array List of emails (identity_id, name, email)
+ */
+ function list_emails($default = false)
+ {
+ if ($this->emails === null) {
+ $this->emails = array();
+
+ $sql_result = $this->db->query(
+ "SELECT `identity_id`, `name`, `email`"
+ ." FROM " . $this->db->table_name('identities', true)
+ ." WHERE `user_id` = ? AND `del` <> 1"
+ ." ORDER BY `standard` DESC, `name` ASC, `email` ASC, `identity_id` ASC",
+ $this->ID);
+
+ while ($sql_arr = $this->db->fetch_assoc($sql_result)) {
+ $this->emails[] = $sql_arr;
+ }
+ }
+
+ return $default ? $this->emails[0] : $this->emails;
+ }
+
+ /**
* Get default identity of this user
*
* @param int $id Identity ID. If empty, the default identity is returned
@@ -250,7 +282,6 @@ class rcube_user
return $this->identities[$id];
}
-
/**
* Return a list of all identities linked with this user
*
@@ -286,7 +317,6 @@ class rcube_user
return $result;
}
-
/**
* Update a specific identity record
*
@@ -317,12 +347,13 @@ class rcube_user
call_user_func_array(array($this->db, 'query'),
array_merge(array($sql), $query_params));
+ // clear the cache
$this->identities = array();
+ $this->emails = null;
return $this->db->affected_rows();
}
-
/**
* Create a new identity record linked with this user
*
@@ -351,12 +382,13 @@ class rcube_user
call_user_func_array(array($this->db, 'query'),
array_merge(array($sql), $insert_values));
+ // clear the cache
$this->identities = array();
+ $this->emails = null;
return $this->db->insert_id('identities');
}
-
/**
* Mark the given identity as deleted
*
@@ -387,12 +419,13 @@ class rcube_user
$this->ID,
$iid);
+ // clear the cache
$this->identities = array();
+ $this->emails = null;
return $this->db->affected_rows();
}
-
/**
* Make this identity the default one for this user
*
@@ -412,7 +445,6 @@ class rcube_user
}
}
-
/**
* Update user's last_login timestamp
*/
@@ -427,7 +459,6 @@ class rcube_user
}
}
-
/**
* Clear the saved object state
*/
@@ -437,7 +468,6 @@ class rcube_user
$this->data = null;
}
-
/**
* Find a user record matching the given name and host
*
@@ -473,7 +503,6 @@ class rcube_user
return false;
}
-
/**
* Create a new user record and return a rcube_user instance
*
@@ -587,7 +616,6 @@ class rcube_user
return $user_id ? $user_instance : false;
}
-
/**
* Resolve username using a virtuser plugins
*
@@ -603,7 +631,6 @@ class rcube_user
return $plugin['user'];
}
-
/**
* Resolve e-mail address from virtuser plugins
*
@@ -622,7 +649,6 @@ class rcube_user
return empty($plugin['email']) ? NULL : $plugin['email'];
}
-
/**
* Return a list of saved searches linked with this user
*
@@ -655,7 +681,6 @@ class rcube_user
return $result;
}
-
/**
* Return saved search data.
*
@@ -690,7 +715,6 @@ class rcube_user
return null;
}
-
/**
* Deletes given saved search record
*
@@ -712,7 +736,6 @@ class rcube_user
return $this->db->affected_rows();
}
-
/**
* Create a new saved search record linked with this user
*
diff --git a/program/lib/Roundcube/rcube_utils.php b/program/lib/Roundcube/rcube_utils.php
index a51247eae..add97ee07 100644
--- a/program/lib/Roundcube/rcube_utils.php
+++ b/program/lib/Roundcube/rcube_utils.php
@@ -797,7 +797,7 @@ class rcube_utils
// try to parse string with DateTime first
if (!empty($date)) {
try {
- $dt = new DateTime($date, $timezone);
+ $dt = $timezone ? new DateTime($date, $timezone) : new DateTime($date);
}
catch (Exception $e) {
// ignore
diff --git a/program/lib/Roundcube/rcube_vcard.php b/program/lib/Roundcube/rcube_vcard.php
index 96add110f..7f6b11851 100644
--- a/program/lib/Roundcube/rcube_vcard.php
+++ b/program/lib/Roundcube/rcube_vcard.php
@@ -414,9 +414,10 @@ class rcube_vcard
* Find index with the '$type' attribute
*
* @param string Field name
+ *
* @return int Field index having $type set
*/
- private function get_type_index($field, $type = 'pref')
+ private function get_type_index($field)
{
$result = 0;
if ($this->raw[$field]) {