summaryrefslogtreecommitdiff
path: root/program/include
diff options
context:
space:
mode:
Diffstat (limited to 'program/include')
-rw-r--r--program/include/html.php3
-rw-r--r--program/include/rcmail.php16
-rw-r--r--program/include/rcube.php30
-rw-r--r--program/include/rcube_addressbook.php3
-rw-r--r--program/include/rcube_base_replacer.php5
-rw-r--r--program/include/rcube_browser.php3
-rw-r--r--program/include/rcube_cache.php4
-rw-r--r--program/include/rcube_charset.php66
-rw-r--r--program/include/rcube_config.php5
-rw-r--r--program/include/rcube_contacts.php3
-rw-r--r--program/include/rcube_content_filter.php3
-rw-r--r--program/include/rcube_csv2vcard.php382
-rw-r--r--program/include/rcube_db.php9
-rw-r--r--program/include/rcube_db_mssql.php5
-rw-r--r--program/include/rcube_db_mysql.php4
-rw-r--r--program/include/rcube_db_pgsql.php5
-rw-r--r--program/include/rcube_db_sqlite.php5
-rw-r--r--program/include/rcube_db_sqlsrv.php5
-rw-r--r--program/include/rcube_image.php6
-rw-r--r--program/include/rcube_imap.php4
-rw-r--r--program/include/rcube_imap_cache.php4
-rw-r--r--program/include/rcube_imap_generic.php4
-rw-r--r--program/include/rcube_ldap.php8
-rw-r--r--program/include/rcube_message.php12
-rw-r--r--program/include/rcube_message_header.php5
-rw-r--r--program/include/rcube_message_part.php4
-rw-r--r--program/include/rcube_mime.php7
-rw-r--r--program/include/rcube_output.php3
-rw-r--r--program/include/rcube_output_html.php5
-rw-r--r--program/include/rcube_output_json.php3
-rw-r--r--program/include/rcube_plugin.php3
-rw-r--r--program/include/rcube_plugin_api.php5
-rw-r--r--program/include/rcube_result_index.php3
-rw-r--r--program/include/rcube_result_set.php3
-rw-r--r--program/include/rcube_result_thread.php3
-rw-r--r--program/include/rcube_session.php23
-rw-r--r--program/include/rcube_shared.inc3
-rw-r--r--program/include/rcube_smtp.php3
-rw-r--r--program/include/rcube_spellchecker.php3
-rw-r--r--program/include/rcube_storage.php8
-rw-r--r--program/include/rcube_string_replacer.php3
-rw-r--r--program/include/rcube_user.php32
-rw-r--r--program/include/rcube_utils.php5
-rw-r--r--program/include/rcube_vcard.php66
44 files changed, 586 insertions, 198 deletions
diff --git a/program/include/html.php b/program/include/html.php
index 0f93e969d..8ff685a84 100644
--- a/program/include/html.php
+++ b/program/include/html.php
@@ -23,7 +23,8 @@
/**
* Class for HTML code creation
*
- * @package HTML
+ * @package Framework
+ * @subpackage HTML
*/
class html
{
diff --git a/program/include/rcmail.php b/program/include/rcmail.php
index 3728e5d19..99a68e81d 100644
--- a/program/include/rcmail.php
+++ b/program/include/rcmail.php
@@ -94,9 +94,6 @@ class rcmail extends rcube
// create user object
$this->set_user(new rcube_user($_SESSION['user_id']));
- // configure session (after user config merge!)
- $this->session_configure();
-
// set task and action properties
$this->set_task(rcube_utils::get_input_value('_task', rcube_utils::INPUT_GPC));
$this->action = asciiwords(rcube_utils::get_input_value('_action', rcube_utils::INPUT_GPC));
@@ -320,10 +317,9 @@ class rcmail extends rcube
if (!($this->output instanceof rcube_output_html))
$this->output = new rcube_output_html($this->task, $framed);
- // set keep-alive/check-recent interval
- if ($this->session && ($keep_alive = $this->session->get_keep_alive())) {
- $this->output->set_env('keep_alive', $keep_alive);
- }
+ // set refresh interval
+ $this->output->set_env('refresh_interval', $this->config->get('refresh_interval', 0));
+ $this->output->set_env('session_lifetime', $this->config->get('session_lifetime', 0) * 60);
if ($framed) {
$this->comm_path .= '&_framed=1';
@@ -336,7 +332,7 @@ class rcmail extends rcube
$this->output->set_charset(RCMAIL_CHARSET);
// add some basic labels to client
- $this->output->add_label('loading', 'servererror', 'requesttimedout');
+ $this->output->add_label('loading', 'servererror', 'requesttimedout', 'refreshing');
return $this->output;
}
@@ -522,7 +518,6 @@ class rcmail extends rcube
// Configure environment
$this->set_user($user);
$this->set_storage_prop();
- $this->session_configure();
// fix some old settings according to namespace prefix
$this->fix_namespace_settings($user);
@@ -775,6 +770,7 @@ class rcmail extends rcube
}
}
+
/**
* Registers action aliases for current task
*
@@ -789,6 +785,7 @@ class rcmail extends rcube
}
}
+
/**
* Returns current action filename
*
@@ -803,6 +800,7 @@ class rcmail extends rcube
return strtr($this->action, '-', '_') . '.inc';
}
+
/**
* Fixes some user preferences according to namespace handling change.
* Old Roundcube versions were using folder names with removed namespace prefix.
diff --git a/program/include/rcube.php b/program/include/rcube.php
index 0e40b3c6b..9c1a6d84a 100644
--- a/program/include/rcube.php
+++ b/program/include/rcube.php
@@ -434,6 +434,9 @@ class rcube
$this->session->register_gc_handler(array($this, 'temp_gc'));
$this->session->register_gc_handler(array($this, 'cache_gc'));
+ $this->session->set_secret($this->config->get('des_key') . dirname($_SERVER['SCRIPT_NAME']));
+ $this->session->set_ip_check($this->config->get('ip_check'));
+
// start PHP session (if not in CLI mode)
if ($_SERVER['REMOTE_ADDR']) {
session_start();
@@ -442,33 +445,6 @@ class rcube
/**
- * Configure session object internals
- */
- public function session_configure()
- {
- if (!$this->session) {
- return;
- }
-
- $lifetime = $this->config->get('session_lifetime', 0) * 60;
- $keep_alive = $this->config->get('keep_alive');
-
- // set keep-alive/check-recent interval
- if ($keep_alive) {
- // be sure that it's less than session lifetime
- if ($lifetime) {
- $keep_alive = min($keep_alive, $lifetime - 30);
- }
- $keep_alive = max(60, $keep_alive);
- $this->session->set_keep_alive($keep_alive);
- }
-
- $this->session->set_secret($this->config->get('des_key') . dirname($_SERVER['SCRIPT_NAME']));
- $this->session->set_ip_check($this->config->get('ip_check'));
- }
-
-
- /**
* Garbage collector function for temp files.
* Remove temp files older than two days
*/
diff --git a/program/include/rcube_addressbook.php b/program/include/rcube_addressbook.php
index 892ae263a..b5fb8cf43 100644
--- a/program/include/rcube_addressbook.php
+++ b/program/include/rcube_addressbook.php
@@ -23,7 +23,8 @@
/**
* Abstract skeleton of an address book/repository
*
- * @package Addressbook
+ * @package Framework
+ * @subpackage Addressbook
*/
abstract class rcube_addressbook
{
diff --git a/program/include/rcube_base_replacer.php b/program/include/rcube_base_replacer.php
index 4ec367552..b2a0fc13c 100644
--- a/program/include/rcube_base_replacer.php
+++ b/program/include/rcube_base_replacer.php
@@ -23,8 +23,9 @@
* Helper class to turn relative urls into absolute ones
* using a predefined base
*
- * @package Core
- * @author Thomas Bruederli <roundcube@gmail.com>
+ * @package Framework
+ * @subpackage Core
+ * @author Thomas Bruederli <roundcube@gmail.com>
*/
class rcube_base_replacer
{
diff --git a/program/include/rcube_browser.php b/program/include/rcube_browser.php
index 7cfae709d..154e7ef4e 100644
--- a/program/include/rcube_browser.php
+++ b/program/include/rcube_browser.php
@@ -22,7 +22,8 @@
/**
* Provide details about the client's browser based on the User-Agent header
*
- * @package Core
+ * @package Framework
+ * @subpackage Core
*/
class rcube_browser
{
diff --git a/program/include/rcube_cache.php b/program/include/rcube_cache.php
index 4e60deaff..3e1ce4fc8 100644
--- a/program/include/rcube_cache.php
+++ b/program/include/rcube_cache.php
@@ -25,10 +25,10 @@
/**
* Interface class for accessing Roundcube cache
*
- * @package Cache
+ * @package Framework
+ * @subpackage Cache
* @author Thomas Bruederli <roundcube@gmail.com>
* @author Aleksander Machniak <alec@alec.pl>
- * @version 1.1
*/
class rcube_cache
{
diff --git a/program/include/rcube_charset.php b/program/include/rcube_charset.php
index ff4c2bbce..e8cce00e3 100644
--- a/program/include/rcube_charset.php
+++ b/program/include/rcube_charset.php
@@ -25,10 +25,11 @@
/**
* Character sets conversion functionality
*
- * @package Core
- * @author Thomas Bruederli <roundcube@gmail.com>
- * @author Aleksander Machniak <alec@alec.pl>
- * @author Edmund Grimley Evans <edmundo@rano.org>
+ * @package Framework
+ * @subpackage Core
+ * @author Thomas Bruederli <roundcube@gmail.com>
+ * @author Aleksander Machniak <alec@alec.pl>
+ * @author Edmund Grimley Evans <edmundo@rano.org>
*/
class rcube_charset
{
@@ -655,22 +656,49 @@ class rcube_charset
*/
public static function detect($string, $failover='')
{
- if (!function_exists('mb_detect_encoding')) {
- return $failover;
- }
-
- // FIXME: the order is important, because sometimes
- // iso string is detected as euc-jp and etc.
- $enc = array(
- 'UTF-8', 'SJIS', 'BIG5', 'GB2312',
- 'ISO-8859-1', 'ISO-8859-2', 'ISO-8859-3', 'ISO-8859-4',
- 'ISO-8859-5', 'ISO-8859-6', 'ISO-8859-7', 'ISO-8859-8', 'ISO-8859-9',
- 'ISO-8859-10', 'ISO-8859-13', 'ISO-8859-14', 'ISO-8859-15', 'ISO-8859-16',
- 'WINDOWS-1252', 'WINDOWS-1251', 'EUC-JP', 'EUC-TW', 'KOI8-R',
- 'ISO-2022-KR', 'ISO-2022-JP'
- );
+ if (substr($string, 0, 4) == "\0\0\xFE\xFF") return 'UTF-32BE'; // Big Endian
+ if (substr($string, 0, 4) == "\xFF\xFE\0\0") return 'UTF-32LE'; // Little Endian
+ if (substr($string, 0, 2) == "\xFE\xFF") return 'UTF-16BE'; // Big Endian
+ if (substr($string, 0, 2) == "\xFF\xFE") return 'UTF-16LE'; // Little Endian
+ if (substr($string, 0, 3) == "\xEF\xBB\xBF") return 'UTF-8';
+
+ // heuristics
+ if ($string[0] == "\0" && $string[1] == "\0" && $string[2] == "\0" && $string[3] != "\0") return 'UTF-32BE';
+ if ($string[0] != "\0" && $string[1] == "\0" && $string[2] == "\0" && $string[3] == "\0") return 'UTF-32LE';
+ if ($string[0] == "\0" && $string[1] != "\0" && $string[2] == "\0" && $string[3] != "\0") return 'UTF-16BE';
+ if ($string[0] != "\0" && $string[1] == "\0" && $string[2] != "\0" && $string[3] == "\0") return 'UTF-16LE';
+
+ if (function_exists('mb_detect_encoding')) {
+ // FIXME: the order is important, because sometimes
+ // iso string is detected as euc-jp and etc.
+ $enc = array(
+ 'UTF-8', 'SJIS', 'GB2312',
+ 'ISO-8859-1', 'ISO-8859-2', 'ISO-8859-3', 'ISO-8859-4',
+ 'ISO-8859-5', 'ISO-8859-6', 'ISO-8859-7', 'ISO-8859-8', 'ISO-8859-9',
+ 'ISO-8859-10', 'ISO-8859-13', 'ISO-8859-14', 'ISO-8859-15', 'ISO-8859-16',
+ 'WINDOWS-1252', 'WINDOWS-1251', 'EUC-JP', 'EUC-TW', 'KOI8-R', 'BIG5',
+ 'ISO-2022-KR', 'ISO-2022-JP',
+ );
- $result = mb_detect_encoding($string, join(',', $enc));
+ $result = mb_detect_encoding($string, join(',', $enc));
+ }
+ else {
+ // No match, check for UTF-8
+ // from http://w3.org/International/questions/qa-forms-utf-8.html
+ if (preg_match('/\A(
+ [\x09\x0A\x0D\x20-\x7E]
+ | [\xC2-\xDF][\x80-\xBF]
+ | \xE0[\xA0-\xBF][\x80-\xBF]
+ | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}
+ | \xED[\x80-\x9F][\x80-\xBF]
+ | \xF0[\x90-\xBF][\x80-\xBF]{2}
+ | [\xF1-\xF3][\x80-\xBF]{3}
+ | \xF4[\x80-\x8F][\x80-\xBF]{2}
+ )*\z/xs', substr($string, 0, 2048))
+ ) {
+ return 'UTF-8';
+ }
+ }
return $result ? $result : $failover;
}
diff --git a/program/include/rcube_config.php b/program/include/rcube_config.php
index 1f165ba4a..dab539412 100644
--- a/program/include/rcube_config.php
+++ b/program/include/rcube_config.php
@@ -22,7 +22,8 @@
/**
* Configuration class for Roundcube
*
- * @package Core
+ * @package Framework
+ * @subpackage Core
*/
class rcube_config
{
@@ -43,6 +44,8 @@ class rcube_config
'mail_pagesize' => 'pagesize',
'addressbook_pagesize' => 'pagesize',
'reply_mode' => 'top_posting',
+ 'refresh_interval' => 'keep_alive',
+ 'min_refresh_interval' => 'min_keep_alive',
);
diff --git a/program/include/rcube_contacts.php b/program/include/rcube_contacts.php
index 534a65cb9..e4500c744 100644
--- a/program/include/rcube_contacts.php
+++ b/program/include/rcube_contacts.php
@@ -23,7 +23,8 @@
/**
* Model class for the local address book database
*
- * @package Addressbook
+ * @package Framework
+ * @subpackage Addressbook
*/
class rcube_contacts extends rcube_addressbook
{
diff --git a/program/include/rcube_content_filter.php b/program/include/rcube_content_filter.php
index 36e61a271..99916a300 100644
--- a/program/include/rcube_content_filter.php
+++ b/program/include/rcube_content_filter.php
@@ -21,6 +21,9 @@
/**
* PHP stream filter to detect html/javascript code in attachments
+ *
+ * @package Framework
+ * @subpackage Core
*/
class rcube_content_filter extends php_user_filter
{
diff --git a/program/include/rcube_csv2vcard.php b/program/include/rcube_csv2vcard.php
new file mode 100644
index 000000000..114d36d85
--- /dev/null
+++ b/program/include/rcube_csv2vcard.php
@@ -0,0 +1,382 @@
+<?php
+
+/*
+ +-----------------------------------------------------------------------+
+ | program/include/rcube_csv2vcard.php |
+ | |
+ | This file is part of the Roundcube Webmail client |
+ | Copyright (C) 2008-2012, The Roundcube Dev Team |
+ | |
+ | Licensed under the GNU General Public License version 3 or |
+ | any later version with exceptions for skins & plugins. |
+ | See the README file for a full license statement. |
+ | |
+ | PURPOSE: |
+ | CSV to vCard data conversion |
+ +-----------------------------------------------------------------------+
+ | Author: Aleksander Machniak <alec@alec.pl> |
+ +-----------------------------------------------------------------------+
+*/
+
+/**
+ * CSV to vCard data converter
+ *
+ * @package Framework
+ * @subpackage Addressbook
+ * @author Aleksander Machniak <alec@alec.pl>
+ */
+class rcube_csv2vcard
+{
+ /**
+ * CSV to vCard fields mapping
+ *
+ * @var array
+ */
+ protected $csv2vcard_map = array(
+ // MS Outlook 2010
+ 'anniversary' => 'anniversary',
+ 'assistants_name' => 'assistant',
+ 'assistants_phone' => 'phone:assistant',
+ 'birthday' => 'birthday',
+ 'business_city' => 'locality:work',
+ 'business_countryregion' => 'country:work',
+ 'business_fax' => 'phone:work,fax',
+ 'business_phone' => 'phone:work',
+ 'business_phone_2' => 'phone:work2',
+ 'business_postal_code' => 'zipcode:work',
+ 'business_state' => 'region:work',
+ 'business_street' => 'street:work',
+ //'business_street_2' => '',
+ //'business_street_3' => '',
+ 'car_phone' => 'phone:car',
+ 'categories' => 'categories',
+ //'children' => '',
+ 'company' => 'organization',
+ //'company_main_phone' => '',
+ 'department' => 'department',
+ //'email_2_address' => '', //@TODO
+ //'email_2_type' => '',
+ //'email_3_address' => '', //@TODO
+ //'email_3_type' => '',
+ 'email_address' => 'email:main',
+ //'email_type' => '',
+ 'first_name' => 'firstname',
+ 'gender' => 'gender',
+ 'home_city' => 'locality:home',
+ 'home_countryregion' => 'country:home',
+ 'home_fax' => 'phone:home,fax',
+ 'home_phone' => 'phone:home',
+ 'home_phone_2' => 'phone:home2',
+ 'home_postal_code' => 'zipcode:home',
+ 'home_state' => 'region:home',
+ 'home_street' => 'street:home',
+ //'home_street_2' => '',
+ //'home_street_3' => '',
+ //'initials' => '',
+ //'isdn' => '',
+ 'job_title' => 'jobtitle',
+ //'keywords' => '',
+ //'language' => '',
+ 'last_name' => 'surname',
+ //'location' => '',
+ 'managers_name' => 'manager',
+ 'middle_name' => 'middlename',
+ //'mileage' => '',
+ 'mobile_phone' => 'phone:cell',
+ 'notes' => 'notes',
+ //'office_location' => '',
+ 'other_city' => 'locality:other',
+ 'other_countryregion' => 'country:other',
+ 'other_fax' => 'phone:other,fax',
+ 'other_phone' => 'phone:other',
+ 'other_postal_code' => 'zipcode:other',
+ 'other_state' => 'region:other',
+ 'other_street' => 'street:other',
+ //'other_street_2' => '',
+ //'other_street_3' => '',
+ 'pager' => 'phone:pager',
+ 'primary_phone' => 'phone:pref',
+ //'profession' => '',
+ //'radio_phone' => '',
+ 'spouse' => 'spouse',
+ 'suffix' => 'suffix',
+ 'title' => 'title',
+ 'web_page' => 'website:homepage',
+
+ // Thunderbird
+ 'birth_day' => 'birthday-d',
+ 'birth_month' => 'birthday-m',
+ 'birth_year' => 'birthday-y',
+ 'display_name' => 'displayname',
+ 'fax_number' => 'phone:fax',
+ 'home_address' => 'street:home',
+ //'home_address_2' => '',
+ 'home_country' => 'country:home',
+ 'home_zipcode' => 'zipcode:home',
+ 'mobile_number' => 'phone:cell',
+ 'nickname' => 'nickname',
+ 'organization' => 'organization',
+ 'pager_number' => 'phone:pager',
+ 'primary_email' => 'email:pref',
+ 'secondary_email' => 'email:other',
+ 'web_page_1' => 'website:homepage',
+ 'web_page_2' => 'website:other',
+ 'work_phone' => 'phone:work',
+ 'work_address' => 'street:work',
+ //'work_address_2' => '',
+ 'work_country' => 'country:work',
+ 'work_zipcode' => 'zipcode:work',
+ );
+
+ /**
+ * CSV label to text mapping for English
+ *
+ * @var array
+ */
+ protected $label_map = array(
+ // MS Outlook 2010
+ 'anniversary' => "Anniversary",
+ 'assistants_name' => "Assistant's Name",
+ 'assistants_phone' => "Assistant's Phone",
+ 'birthday' => "Birthday",
+ 'business_city' => "Business City",
+ 'business_countryregion' => "Business Country/Region",
+ 'business_fax' => "Business Fax",
+ 'business_phone' => "Business Phone",
+ 'business_phone_2' => "Business Phone 2",
+ 'business_postal_code' => "Business Postal Code",
+ 'business_state' => "Business State",
+ 'business_street' => "Business Street",
+ //'business_street_2' => "Business Street 2",
+ //'business_street_3' => "Business Street 3",
+ 'car_phone' => "Car Phone",
+ 'categories' => "Categories",
+ //'children' => "Children",
+ 'company' => "Company",
+ //'company_main_phone' => "Company Main Phone",
+ 'department' => "Department",
+ //'directory_server' => "Directory Server",
+ //'email_2_address' => "E-mail 2 Address",
+ //'email_2_type' => "E-mail 2 Type",
+ //'email_3_address' => "E-mail 3 Address",
+ //'email_3_type' => "E-mail 3 Type",
+ 'email_address' => "E-mail Address",
+ //'email_type' => "E-mail Type",
+ 'first_name' => "First Name",
+ 'gender' => "Gender",
+ 'home_city' => "Home City",
+ 'home_countryregion' => "Home Country/Region",
+ 'home_fax' => "Home Fax",
+ 'home_phone' => "Home Phone",
+ 'home_phone_2' => "Home Phone 2",
+ 'home_postal_code' => "Home Postal Code",
+ 'home_state' => "Home State",
+ 'home_street' => "Home Street",
+ //'home_street_2' => "Home Street 2",
+ //'home_street_3' => "Home Street 3",
+ //'initials' => "Initials",
+ //'isdn' => "ISDN",
+ 'job_title' => "Job Title",
+ //'keywords' => "Keywords",
+ //'language' => "Language",
+ 'last_name' => "Last Name",
+ //'location' => "Location",
+ 'managers_name' => "Manager's Name",
+ 'middle_name' => "Middle Name",
+ //'mileage' => "Mileage",
+ 'mobile_phone' => "Mobile Phone",
+ 'notes' => "Notes",
+ //'office_location' => "Office Location",
+ 'other_city' => "Other City",
+ 'other_countryregion' => "Other Country/Region",
+ 'other_fax' => "Other Fax",
+ 'other_phone' => "Other Phone",
+ 'other_postal_code' => "Other Postal Code",
+ 'other_state' => "Other State",
+ 'other_street' => "Other Street",
+ //'other_street_2' => "Other Street 2",
+ //'other_street_3' => "Other Street 3",
+ 'pager' => "Pager",
+ 'primary_phone' => "Primary Phone",
+ //'profession' => "Profession",
+ //'radio_phone' => "Radio Phone",
+ 'spouse' => "Spouse",
+ 'suffix' => "Suffix",
+ 'title' => "Title",
+ 'web_page' => "Web Page",
+
+ // Thunderbird
+ 'birth_day' => "Birth Day",
+ 'birth_month' => "Birth Month",
+ 'birth_year' => "Birth Year",
+ 'display_name' => "Display Name",
+ 'fax_number' => "Fax Number",
+ 'home_address' => "Home Address",
+ //'home_address_2' => "Home Address 2",
+ 'home_country' => "Home Country",
+ 'home_zipcode' => "Home ZipCode",
+ 'mobile_number' => "Mobile Number",
+ 'nickname' => "Nickname",
+ 'organization' => "Organization",
+ 'pager_number' => "Pager Namber",
+ 'primary_email' => "Primary Email",
+ 'secondary_email' => "Secondary Email",
+ 'web_page_1' => "Web Page 1",
+ 'web_page_2' => "Web Page 2",
+ 'work_phone' => "Work Phone",
+ 'work_address' => "Work Address",
+ //'work_address_2' => "Work Address 2",
+ 'work_country' => "Work Country",
+ 'work_zipcode' => "Work ZipCode",
+ );
+
+ protected $local_label_map = array();
+ protected $vcards = array();
+ protected $map = array();
+
+
+ /**
+ * Class constructor
+ *
+ * @param string $lang File language
+ */
+ public function __construct($lang = 'en_US')
+ {
+ // Localize fields map
+ if ($lang && $lang != 'en_US') {
+ if (file_exists(INSTALL_PATH . "program/localization/$lang/csv2vcard.inc")) {
+ include INSTALL_PATH . "program/localization/$lang/csv2vcard.inc";
+ }
+
+ if (!empty($map)) {
+ $this->local_label_map = array_merge($this->label_map, $map);
+ }
+ }
+
+ $this->label_map = array_flip($this->label_map);
+ $this->local_label_map = array_flip($this->local_label_map);
+ }
+
+ /**
+ *
+ */
+ public function import($csv)
+ {
+ // convert to UTF-8
+ $head = substr($csv, 0, 4096);
+ $fallback = rcube::get_instance()->config->get('default_charset', 'ISO-8859-1'); // fallback to Latin-1?
+ $charset = rcube_charset::detect($head, RCMAIL_CHARSET);
+ $csv = rcube_charset::convert($csv, $charset);
+ $head = '';
+
+ $this->map = array();
+
+ // Parse file
+ foreach (preg_split("/[\r\n]+/", $csv) as $i => $line) {
+ $line = trim($line);
+ if (empty($line)) {
+ continue;
+ }
+
+ $elements = rcube_utils::explode_quoted_string(',', $line);
+
+ if (empty($elements)) {
+ continue;
+ }
+
+ // Parse header
+ if (empty($this->map)) {
+ $this->parse_header($elements);
+ if (empty($this->map)) {
+ break;
+ }
+ }
+ // Parse data row
+ else {
+ $this->csv_to_vcard($elements);
+ }
+ }
+ }
+
+ /**
+ * @return array rcube_vcard List of vcards
+ */
+ public function export()
+ {
+ return $this->vcards;
+ }
+
+ /**
+ * Parse CSV header line, detect fields mapping
+ */
+ protected function parse_header($elements)
+ {
+ $map1 = array();
+ $map2 = array();
+ $size = count($elements);
+
+ // check English labels
+ for ($i = 0; $i < $size; $i++) {
+ $label = $this->label_map[$elements[$i]];
+ if ($label && !empty($this->csv2vcard_map[$label])) {
+ $map1[$i] = $this->csv2vcard_map[$label];
+ }
+ }
+ // check localized labels
+ if (!empty($this->local_label_map)) {
+ for ($i = 0; $i < $size; $i++) {
+ $label = $this->local_label_map[$elements[$i]];
+ if ($label && !empty($this->csv2vcard_map[$label])) {
+ $map2[$i] = $this->csv2vcard_map[$label];
+ }
+ }
+ }
+
+ $this->map = count($map1) >= count($map2) ? $map1 : $map2;
+ }
+
+ /**
+ * Convert CSV data row to vCard
+ */
+ protected function csv_to_vcard($data)
+ {
+ $contact = array();
+ foreach ($this->map as $idx => $name) {
+ $value = $data[$idx];
+ if ($value !== null && $value !== '') {
+ $contact[$name] = $value;
+ }
+ }
+
+ if (empty($contact)) {
+ return;
+ }
+
+ // Handle special values
+ if (!empty($contact['birthday-d']) && !empty($contact['birthday-m']) && !empty($contact['birthday-y'])) {
+ $contact['birthday'] = $contact['birthday-y'] .'-' .$contact['birthday-m'] . '-' . $contact['birthday-d'];
+ }
+
+ foreach (array('birthday', 'anniversary') as $key) {
+ if (!empty($contact[$key]) && $contact[$key] == '0/0/00') { // @TODO: localization?
+ unset($contact[$key]);
+ }
+ }
+
+ if (!empty($contact['gender']) && ($gender = strtolower($contact['gender']))) {
+ if (!in_array($gender, array('male', 'female'))) {
+ unset($contact['gender']);
+ }
+ }
+
+ // Create vcard object
+ $vcard = new rcube_vcard();
+ foreach ($contact as $name => $value) {
+ $name = explode(':', $name);
+ $vcard->set($name[0], $value, $name[1]);
+ }
+
+ // add to the list
+ $this->vcards[] = $vcard;
+ }
+}
diff --git a/program/include/rcube_db.php b/program/include/rcube_db.php
index b066101b3..5d8c4a534 100644
--- a/program/include/rcube_db.php
+++ b/program/include/rcube_db.php
@@ -21,12 +21,11 @@
/**
- * Database independent query interface
+ * Database independent query interface.
+ * This is a wrapper for the PHP PDO.
*
- * This is a wrapper for the PHP PDO
- *
- * @package Database
- * @version 1.0
+ * @package Framework
+ * @sbpackage Database
*/
class rcube_db
{
diff --git a/program/include/rcube_db_mssql.php b/program/include/rcube_db_mssql.php
index 119647d95..c95663c74 100644
--- a/program/include/rcube_db_mssql.php
+++ b/program/include/rcube_db_mssql.php
@@ -23,11 +23,10 @@
/**
* Database independent query interface
- *
* This is a wrapper for the PHP PDO
*
- * @package Database
- * @version 1.0
+ * @package Framework
+ * @subpackage Database
*/
class rcube_db_mssql extends rcube_db
{
diff --git a/program/include/rcube_db_mysql.php b/program/include/rcube_db_mysql.php
index 6f0acba54..1c5ba1de7 100644
--- a/program/include/rcube_db_mysql.php
+++ b/program/include/rcube_db_mysql.php
@@ -26,8 +26,8 @@
*
* This is a wrapper for the PHP PDO
*
- * @package Database
- * @version 1.0
+ * @package Framework
+ * @subpackage Database
*/
class rcube_db_mysql extends rcube_db
{
diff --git a/program/include/rcube_db_pgsql.php b/program/include/rcube_db_pgsql.php
index 0d0caadde..797860a84 100644
--- a/program/include/rcube_db_pgsql.php
+++ b/program/include/rcube_db_pgsql.php
@@ -23,11 +23,10 @@
/**
* Database independent query interface
- *
* This is a wrapper for the PHP PDO
*
- * @package Database
- * @version 1.0
+ * @package Framework
+ * @subpackage Database
*/
class rcube_db_pgsql extends rcube_db
{
diff --git a/program/include/rcube_db_sqlite.php b/program/include/rcube_db_sqlite.php
index a7397674b..9aa67d0fd 100644
--- a/program/include/rcube_db_sqlite.php
+++ b/program/include/rcube_db_sqlite.php
@@ -23,11 +23,10 @@
/**
* Database independent query interface
- *
* This is a wrapper for the PHP PDO
*
- * @package Database
- * @version 1.0
+ * @package Framework
+ * @subpackage Database
*/
class rcube_db_sqlite extends rcube_db
{
diff --git a/program/include/rcube_db_sqlsrv.php b/program/include/rcube_db_sqlsrv.php
index e58bf0704..8b6ffe807 100644
--- a/program/include/rcube_db_sqlsrv.php
+++ b/program/include/rcube_db_sqlsrv.php
@@ -23,11 +23,10 @@
/**
* Database independent query interface
- *
* This is a wrapper for the PHP PDO
*
- * @package Database
- * @version 1.0
+ * @package Framework
+ * @subpackage Database
*/
class rcube_db_sqlsrv extends rcube_db
{
diff --git a/program/include/rcube_image.php b/program/include/rcube_image.php
index c0d4e878d..b72a24c51 100644
--- a/program/include/rcube_image.php
+++ b/program/include/rcube_image.php
@@ -21,6 +21,12 @@
+-----------------------------------------------------------------------+
*/
+/**
+ * Image resizer and converter
+ *
+ * @package Framework
+ * @subpackage Utils
+ */
class rcube_image
{
private $image_file;
diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php
index f2645f60f..9054b6bab 100644
--- a/program/include/rcube_imap.php
+++ b/program/include/rcube_imap.php
@@ -25,10 +25,10 @@
/**
* Interface class for accessing an IMAP server
*
- * @package Mail
+ * @package Framework
+ * @subpackage Storage
* @author Thomas Bruederli <roundcube@gmail.com>
* @author Aleksander Machniak <alec@alec.pl>
- * @version 2.0
*/
class rcube_imap extends rcube_storage
{
diff --git a/program/include/rcube_imap_cache.php b/program/include/rcube_imap_cache.php
index f36ace0eb..31214cfbf 100644
--- a/program/include/rcube_imap_cache.php
+++ b/program/include/rcube_imap_cache.php
@@ -24,10 +24,10 @@
/**
* Interface class for accessing Roundcube messages cache
*
- * @package Cache
+ * @package Framework
+ * @subpackage Storage
* @author Thomas Bruederli <roundcube@gmail.com>
* @author Aleksander Machniak <alec@alec.pl>
- * @version 1.0
*/
class rcube_imap_cache
{
diff --git a/program/include/rcube_imap_generic.php b/program/include/rcube_imap_generic.php
index bc7ecfc37..a0a8f3b77 100644
--- a/program/include/rcube_imap_generic.php
+++ b/program/include/rcube_imap_generic.php
@@ -30,8 +30,8 @@
/**
* PHP based wrapper class to connect to an IMAP server
*
- * @package Mail
- * @author Aleksander Machniak <alec@alec.pl>
+ * @package Framework
+ * @subpackage Storage
*/
class rcube_imap_generic
{
diff --git a/program/include/rcube_ldap.php b/program/include/rcube_ldap.php
index 90ce73ae2..34e37e3b9 100644
--- a/program/include/rcube_ldap.php
+++ b/program/include/rcube_ldap.php
@@ -6,7 +6,7 @@
| |
| This file is part of the Roundcube Webmail client |
| Copyright (C) 2006-2012, The Roundcube Dev Team |
- | Copyright (C) 2011, Kolab Systems AG |
+ | Copyright (C) 2011-2012, Kolab Systems AG |
| |
| Licensed under the GNU General Public License version 3 or |
| any later version with exceptions for skins & plugins. |
@@ -26,7 +26,8 @@
/**
* Model class to access an LDAP address directory
*
- * @package Addressbook
+ * @package Framework
+ * @subpackage Addressbook
*/
class rcube_ldap extends rcube_addressbook
{
@@ -160,7 +161,8 @@ class rcube_ldap extends rcube_addressbook
}
// make sure LDAP_rdn field is required
- if (!empty($this->prop['LDAP_rdn']) && !in_array($this->prop['LDAP_rdn'], $this->prop['required_fields']) && !in_array($this->prop['LDAP_rdn'], array_keys($this->prop['autovalues']))) {
+ if (!empty($this->prop['LDAP_rdn']) && !in_array($this->prop['LDAP_rdn'], $this->prop['required_fields'])
+ && !in_array($this->prop['LDAP_rdn'], array_keys((array)$this->prop['autovalues']))) {
$this->prop['required_fields'][] = $this->prop['LDAP_rdn'];
}
diff --git a/program/include/rcube_message.php b/program/include/rcube_message.php
index 47aa4493e..87319f04f 100644
--- a/program/include/rcube_message.php
+++ b/program/include/rcube_message.php
@@ -24,7 +24,8 @@
* Logical representation of a mail message with all its data
* and related functions
*
- * @package Mail
+ * @package Framework
+ * @subpackage Storage
* @author Thomas Bruederli <roundcube@gmail.com>
*/
class rcube_message
@@ -198,14 +199,15 @@ class rcube_message
* Determine if the message contains a HTML part
*
* @param bool $recursive Enables checking in all levels of the structure
+ * @param bool $enriched Enables checking for text/enriched parts too
*
* @return bool True if a HTML is available, False if not
*/
- function has_html_part($recursive = true)
+ function has_html_part($recursive = true, $enriched = false)
{
// check all message parts
foreach ($this->parts as $part) {
- if ($part->mimetype == 'text/html') {
+ if ($part->mimetype == 'text/html' || ($enriched && $part->mimetype == 'text/enriched')) {
// Level check, we'll skip e.g. HTML attachments
if (!$recursive) {
$level = explode('.', $part->mime_id);
@@ -270,10 +272,6 @@ class rcube_message
else if ($part->mimetype == 'text/html') {
$out = $this->get_part_content($mime_id);
- // remove special chars encoding
- $trans = array_flip(get_html_translation_table(HTML_ENTITIES));
- $out = strtr($out, $trans);
-
// create instance of html2text class
$txt = new html2text($out);
return $txt->get_text();
diff --git a/program/include/rcube_message_header.php b/program/include/rcube_message_header.php
index 378fb98c9..db82247f9 100644
--- a/program/include/rcube_message_header.php
+++ b/program/include/rcube_message_header.php
@@ -23,8 +23,9 @@
/**
* Struct representing an e-mail message header
*
- * @package Mail
- * @author Aleksander Machniak <alec@alec.pl>
+ * @package Framework
+ * @subpackage Storage
+ * @author Aleksander Machniak <alec@alec.pl>
*/
class rcube_message_header
{
diff --git a/program/include/rcube_message_part.php b/program/include/rcube_message_part.php
index 80a019e50..c9c9257eb 100644
--- a/program/include/rcube_message_part.php
+++ b/program/include/rcube_message_part.php
@@ -25,10 +25,10 @@
/**
* Class representing a message part
*
- * @package Mail
+ * @package Framework
+ * @subpackage Storage
* @author Thomas Bruederli <roundcube@gmail.com>
* @author Aleksander Machniak <alec@alec.pl>
- * @version 2.0
*/
class rcube_message_part
{
diff --git a/program/include/rcube_mime.php b/program/include/rcube_mime.php
index d8e04a97c..2dbeaf67a 100644
--- a/program/include/rcube_mime.php
+++ b/program/include/rcube_mime.php
@@ -25,9 +25,10 @@
/**
* Class for parsing MIME messages
*
- * @package Mail
- * @author Thomas Bruederli <roundcube@gmail.com>
- * @author Aleksander Machniak <alec@alec.pl>
+ * @package Framework
+ * @subpackage Storage
+ * @author Thomas Bruederli <roundcube@gmail.com>
+ * @author Aleksander Machniak <alec@alec.pl>
*/
class rcube_mime
{
diff --git a/program/include/rcube_output.php b/program/include/rcube_output.php
index 5c582e67c..f7ac3002f 100644
--- a/program/include/rcube_output.php
+++ b/program/include/rcube_output.php
@@ -22,7 +22,8 @@
/**
* Class for output generation
*
- * @package HTML
+ * @package Framework
+ * @subpackage View
*/
abstract class rcube_output
{
diff --git a/program/include/rcube_output_html.php b/program/include/rcube_output_html.php
index 7b186b99d..6dd58fd36 100644
--- a/program/include/rcube_output_html.php
+++ b/program/include/rcube_output_html.php
@@ -23,7 +23,8 @@
/**
* Class to create HTML page output using a skin template
*
- * @package View
+ * @package Framework
+ * @subpackage View
*/
class rcube_output_html extends rcube_output
{
@@ -1090,7 +1091,7 @@ class rcube_output_html extends rcube_output
// make valid href to specific buttons
if (in_array($attrib['command'], rcmail::$main_tasks)) {
$attrib['href'] = $this->app->url(array('task' => $attrib['command']));
- $attrib['onclick'] = sprintf("%s.command('switch-task','%s',null,event); return false", rcmail::JS_OBJECT_NAME, $attrib['command']);
+ $attrib['onclick'] = sprintf("return %s.command('switch-task','%s',this,event)", rcmail::JS_OBJECT_NAME, $attrib['command']);
}
else if ($attrib['task'] && in_array($attrib['task'], rcmail::$main_tasks)) {
$attrib['href'] = $this->app->url(array('action' => $attrib['command'], 'task' => $attrib['task']));
diff --git a/program/include/rcube_output_json.php b/program/include/rcube_output_json.php
index eb1a9380d..fcd52c789 100644
--- a/program/include/rcube_output_json.php
+++ b/program/include/rcube_output_json.php
@@ -23,7 +23,8 @@
/**
* View class to produce JSON responses
*
- * @package View
+ * @package Framework
+ * @subpackage View
*/
class rcube_output_json extends rcube_output
{
diff --git a/program/include/rcube_plugin.php b/program/include/rcube_plugin.php
index 45088850a..dbb15e8be 100644
--- a/program/include/rcube_plugin.php
+++ b/program/include/rcube_plugin.php
@@ -22,7 +22,8 @@
/**
* Plugin interface class
*
- * @package PluginAPI
+ * @package Framework
+ * @subpackage PluginAPI
*/
abstract class rcube_plugin
{
diff --git a/program/include/rcube_plugin_api.php b/program/include/rcube_plugin_api.php
index 107c81026..51daf2797 100644
--- a/program/include/rcube_plugin_api.php
+++ b/program/include/rcube_plugin_api.php
@@ -27,7 +27,8 @@ if (!defined('RCMAIL_PLUGINS_DIR'))
/**
* The plugin loader and global API
*
- * @package PluginAPI
+ * @package Framework
+ * @subpackage PluginAPI
*/
class rcube_plugin_api
{
@@ -327,7 +328,7 @@ class rcube_plugin_api
if (isset($this->actions[$action])) {
call_user_func($this->actions[$action]);
}
- else {
+ else if (rcube::get_instance()->action != 'refresh') {
rcube::raise_error(array('code' => 524, 'type' => 'php',
'file' => __FILE__, 'line' => __LINE__,
'message' => "No handler found for action $action"), true, true);
diff --git a/program/include/rcube_result_index.php b/program/include/rcube_result_index.php
index 334ec8530..4d1ae13b6 100644
--- a/program/include/rcube_result_index.php
+++ b/program/include/rcube_result_index.php
@@ -24,6 +24,9 @@
/**
* Class for accessing IMAP's SORT/SEARCH/ESEARCH result
+ *
+ * @package Framework
+ * @subpackage Storage
*/
class rcube_result_index
{
diff --git a/program/include/rcube_result_set.php b/program/include/rcube_result_set.php
index 809d8743f..456d1c9d6 100644
--- a/program/include/rcube_result_set.php
+++ b/program/include/rcube_result_set.php
@@ -24,7 +24,8 @@
* Roundcube result set class.
* Representing an address directory result set.
*
- * @package Addressbook
+ * @package Framework
+ * @subpackage Addressbook
*/
class rcube_result_set
{
diff --git a/program/include/rcube_result_thread.php b/program/include/rcube_result_thread.php
index b2325a499..c609bdc39 100644
--- a/program/include/rcube_result_thread.php
+++ b/program/include/rcube_result_thread.php
@@ -24,6 +24,9 @@
/**
* Class for accessing IMAP's THREAD result
+ *
+ * @package Framework
+ * @subpackage Storage
*/
class rcube_result_thread
{
diff --git a/program/include/rcube_session.php b/program/include/rcube_session.php
index 6192466cd..fdbf668ca 100644
--- a/program/include/rcube_session.php
+++ b/program/include/rcube_session.php
@@ -24,7 +24,8 @@
/**
* Class to provide database supported session storage
*
- * @package Core
+ * @package Framework
+ * @subpackage Core
* @author Thomas Bruederli <roundcube@gmail.com>
* @author Aleksander Machniak <alec@alec.pl>
*/
@@ -43,7 +44,6 @@ class rcube_session
private $secret = '';
private $ip_check = false;
private $logging = false;
- private $keep_alive = 0;
private $memcache;
/**
@@ -525,24 +525,6 @@ class rcube_session
$this->now = $now - ($now % ($this->lifetime / 2));
}
- /**
- * Setter for keep_alive interval
- */
- public function set_keep_alive($keep_alive)
- {
- $this->keep_alive = $keep_alive;
-
- if ($this->lifetime < $keep_alive)
- $this->set_lifetime($keep_alive + 30);
- }
-
- /**
- * Getter for keep_alive interval
- */
- public function get_keep_alive()
- {
- return $this->keep_alive;
- }
/**
* Getter for remote IP saved with this session
@@ -552,6 +534,7 @@ class rcube_session
return $this->ip;
}
+
/**
* Setter for cookie encryption secret
*/
diff --git a/program/include/rcube_shared.inc b/program/include/rcube_shared.inc
index 4577c6df5..5105fe22f 100644
--- a/program/include/rcube_shared.inc
+++ b/program/include/rcube_shared.inc
@@ -23,7 +23,8 @@
/**
* Roundcube shared functions
*
- * @package Core
+ * @package Framework
+ * @subpackage Core
*/
diff --git a/program/include/rcube_smtp.php b/program/include/rcube_smtp.php
index b28be5206..490ea8ad6 100644
--- a/program/include/rcube_smtp.php
+++ b/program/include/rcube_smtp.php
@@ -25,7 +25,8 @@ define('SMTP_MIME_CRLF', "\r\n");
/**
* Class to provide SMTP functionality using PEAR Net_SMTP
*
- * @package Mail
+ * @package Framework
+ * @subpackage Mail
* @author Thomas Bruederli <roundcube@gmail.com>
* @author Aleksander Machniak <alec@alec.pl>
*/
diff --git a/program/include/rcube_spellchecker.php b/program/include/rcube_spellchecker.php
index 219dca780..30d15d721 100644
--- a/program/include/rcube_spellchecker.php
+++ b/program/include/rcube_spellchecker.php
@@ -25,7 +25,8 @@
/**
* Helper class for spellchecking with Googielspell and PSpell support.
*
- * @package Core
+ * @package Framework
+ * @subpackage Utils
*/
class rcube_spellchecker
{
diff --git a/program/include/rcube_storage.php b/program/include/rcube_storage.php
index 933ebcc25..1556aae41 100644
--- a/program/include/rcube_storage.php
+++ b/program/include/rcube_storage.php
@@ -25,10 +25,10 @@
/**
* Abstract class for accessing mail messages storage server
*
- * @package Mail
- * @author Thomas Bruederli <roundcube@gmail.com>
- * @author Aleksander Machniak <alec@alec.pl>
- * @version 2.0
+ * @package Framework
+ * @subpackage Storage
+ * @author Thomas Bruederli <roundcube@gmail.com>
+ * @author Aleksander Machniak <alec@alec.pl>
*/
abstract class rcube_storage
{
diff --git a/program/include/rcube_string_replacer.php b/program/include/rcube_string_replacer.php
index edb2ac34f..9af6b33e0 100644
--- a/program/include/rcube_string_replacer.php
+++ b/program/include/rcube_string_replacer.php
@@ -23,7 +23,8 @@
/**
* Helper class for string replacements based on preg_replace_callback
*
- * @package Core
+ * @package Framework
+ * @subpackage Utils
*/
class rcube_string_replacer
{
diff --git a/program/include/rcube_user.php b/program/include/rcube_user.php
index b92187ad4..5a8e9005e 100644
--- a/program/include/rcube_user.php
+++ b/program/include/rcube_user.php
@@ -5,7 +5,7 @@
| program/include/rcube_user.inc |
| |
| This file is part of the Roundcube Webmail client |
- | Copyright (C) 2005-2010, The Roundcube Dev Team |
+ | Copyright (C) 2005-2012, The Roundcube Dev Team |
| |
| Licensed under the GNU General Public License version 3 or |
| any later version with exceptions for skins & plugins. |
@@ -17,6 +17,7 @@
| |
+-----------------------------------------------------------------------+
| Author: Thomas Bruederli <roundcube@gmail.com> |
+ | Author: Aleksander Machniak <alec@alec.pl> |
+-----------------------------------------------------------------------+
*/
@@ -24,8 +25,8 @@
/**
* Class representing a system user
*
- * @package Core
- * @author Thomas Bruederli <roundcube@gmail.com>
+ * @package Framework
+ * @subpackage Core
*/
class rcube_user
{
@@ -47,6 +48,13 @@ class rcube_user
*/
private $rc;
+ /**
+ * Internal identities cache
+ *
+ * @var array
+ */
+ private $identities = array();
+
const SEARCH_ADDRESSBOOK = 1;
const SEARCH_MAIL = 2;
@@ -213,8 +221,14 @@ class rcube_user
*/
function get_identity($id = null)
{
- $result = $this->list_identities($id ? sprintf('AND identity_id = %d', $id) : '');
- return $result[0];
+ $id = (int)$id;
+ // cache identities for better performance
+ if (!array_key_exists($id, $this->identities)) {
+ $result = $this->list_identities($id ? 'AND identity_id = ' . $id : '');
+ $this->identities[$id] = $result[0];
+ }
+
+ return $this->identities[$id];
}
@@ -273,6 +287,8 @@ class rcube_user
call_user_func_array(array($this->db, 'query'),
array_merge(array($sql), $query_params));
+ $this->identities = array();
+
return $this->db->affected_rows();
}
@@ -305,6 +321,8 @@ class rcube_user
call_user_func_array(array($this->db, 'query'),
array_merge(array($sql), $insert_values));
+ $this->identities = array();
+
return $this->db->insert_id('identities');
}
@@ -339,6 +357,8 @@ class rcube_user
$this->ID,
$iid);
+ $this->identities = array();
+
return $this->db->affected_rows();
}
@@ -359,6 +379,8 @@ class rcube_user
" AND del <> 1",
$this->ID,
$iid);
+
+ unset($this->identities[0]);
}
}
diff --git a/program/include/rcube_utils.php b/program/include/rcube_utils.php
index 2a4d4c482..dfaa9b943 100644
--- a/program/include/rcube_utils.php
+++ b/program/include/rcube_utils.php
@@ -24,7 +24,8 @@
/**
* Utility class providing common functions
*
- * @package Core
+ * @package Framework
+ * @subpackage Utils
*/
class rcube_utils
{
@@ -761,7 +762,7 @@ class rcube_utils
}
}
- $result[] = substr($string, $p);
+ $result[] = (string) substr($string, $p);
return $result;
}
diff --git a/program/include/rcube_vcard.php b/program/include/rcube_vcard.php
index 00903c257..d0a341da1 100644
--- a/program/include/rcube_vcard.php
+++ b/program/include/rcube_vcard.php
@@ -5,7 +5,7 @@
| program/include/rcube_vcard.php |
| |
| This file is part of the Roundcube Webmail client |
- | Copyright (C) 2008-2011, The Roundcube Dev Team |
+ | Copyright (C) 2008-2012, The Roundcube Dev Team |
| |
| Licensed under the GNU General Public License version 3 or |
| any later version with exceptions for skins & plugins. |
@@ -15,6 +15,7 @@
| Logical representation of a vcard address record |
+-----------------------------------------------------------------------+
| Author: Thomas Bruederli <roundcube@gmail.com> |
+ | Author: Aleksander Machniak <alec@alec.pl> |
+-----------------------------------------------------------------------+
*/
@@ -23,8 +24,8 @@
* Logical representation of a vcard-based address record
* Provides functions to parse and export vCard data format
*
- * @package Addressbook
- * @author Thomas Bruederli <roundcube@gmail.com>
+ * @package Framework
+ * @subpackage Addressbook
*/
class rcube_vcard
{
@@ -62,7 +63,6 @@ class rcube_vcard
public $middlename;
public $nickname;
public $organization;
- public $notes;
public $email = array();
public static $eol = "\r\n";
@@ -265,26 +265,25 @@ class rcube_vcard
*/
public function set($field, $value, $type = 'HOME')
{
- $field = strtolower($field);
+ $field = strtolower($field);
$type_uc = strtoupper($type);
- $typemap = array_flip($this->typemap);
switch ($field) {
case 'name':
case 'displayname':
- $this->raw['FN'][0][0] = $value;
+ $this->raw['FN'][0][0] = $this->displayname = $value;
break;
case 'surname':
- $this->raw['N'][0][0] = $value;
+ $this->raw['N'][0][0] = $this->surname = $value;
break;
case 'firstname':
- $this->raw['N'][0][1] = $value;
+ $this->raw['N'][0][1] = $this->firstname = $value;
break;
case 'middlename':
- $this->raw['N'][0][2] = $value;
+ $this->raw['N'][0][2] = $this->middlename = $value;
break;
case 'prefix':
@@ -296,11 +295,11 @@ class rcube_vcard
break;
case 'nickname':
- $this->raw['NICKNAME'][0][0] = $value;
+ $this->raw['NICKNAME'][0][0] = $this->nickname = $value;
break;
case 'organization':
- $this->raw['ORG'][0][0] = $value;
+ $this->raw['ORG'][0][0] = $this->organization = $value;
break;
case 'photo':
@@ -348,8 +347,10 @@ class rcube_vcard
if (($tag = self::$fieldmap[$field]) && (is_array($value) || strlen($value))) {
$index = count($this->raw[$tag]);
$this->raw[$tag][$index] = (array)$value;
- if ($type)
+ if ($type) {
+ $typemap = array_flip($this->typemap);
$this->raw[$tag][$index]['type'] = explode(',', ($typemap[$type_uc] ? $typemap[$type_uc] : $type));
+ }
}
break;
}
@@ -784,42 +785,9 @@ class rcube_vcard
*/
private static function detect_encoding($string)
{
- if (substr($string, 0, 4) == "\0\0\xFE\xFF") return 'UTF-32BE'; // Big Endian
- if (substr($string, 0, 4) == "\xFF\xFE\0\0") return 'UTF-32LE'; // Little Endian
- if (substr($string, 0, 2) == "\xFE\xFF") return 'UTF-16BE'; // Big Endian
- if (substr($string, 0, 2) == "\xFF\xFE") return 'UTF-16LE'; // Little Endian
- if (substr($string, 0, 3) == "\xEF\xBB\xBF") return 'UTF-8';
-
- // heuristics
- if ($string[0] == "\0" && $string[1] == "\0" && $string[2] == "\0" && $string[3] != "\0") return 'UTF-32BE';
- if ($string[0] != "\0" && $string[1] == "\0" && $string[2] == "\0" && $string[3] == "\0") return 'UTF-32LE';
- if ($string[0] == "\0" && $string[1] != "\0" && $string[2] == "\0" && $string[3] != "\0") return 'UTF-16BE';
- if ($string[0] != "\0" && $string[1] == "\0" && $string[2] != "\0" && $string[3] == "\0") return 'UTF-16LE';
-
- // use mb_detect_encoding()
- $encodings = array('UTF-8', 'ISO-8859-1', 'ISO-8859-2', 'ISO-8859-3',
- 'ISO-8859-4', 'ISO-8859-5', 'ISO-8859-6', 'ISO-8859-7', 'ISO-8859-8', 'ISO-8859-9',
- 'ISO-8859-10', 'ISO-8859-13', 'ISO-8859-14', 'ISO-8859-15', 'ISO-8859-16',
- 'WINDOWS-1252', 'WINDOWS-1251', 'BIG5', 'GB2312');
-
- if (function_exists('mb_detect_encoding') && ($enc = mb_detect_encoding($string, $encodings)))
- return $enc;
-
- // No match, check for UTF-8
- // from http://w3.org/International/questions/qa-forms-utf-8.html
- if (preg_match('/\A(
- [\x09\x0A\x0D\x20-\x7E]
- | [\xC2-\xDF][\x80-\xBF]
- | \xE0[\xA0-\xBF][\x80-\xBF]
- | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}
- | \xED[\x80-\x9F][\x80-\xBF]
- | \xF0[\x90-\xBF][\x80-\xBF]{2}
- | [\xF1-\xF3][\x80-\xBF]{3}
- | \xF4[\x80-\x8F][\x80-\xBF]{2}
- )*\z/xs', substr($string, 0, 2048)))
- return 'UTF-8';
-
- return rcube::get_instance()->config->get('default_charset', 'ISO-8859-1'); # fallback to Latin-1
+ $fallback = rcube::get_instance()->config->get('default_charset', 'ISO-8859-1'); // fallback to Latin-1
+
+ return rcube_charset::detect($string, $fallback);
}
}