summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <machniak@kolabsys.com>2012-01-23 09:16:30 (GMT)
committerAleksander Machniak <machniak@kolabsys.com>2012-01-23 09:16:30 (GMT)
commit607fd7b43b711c3304880422492b9fcf2ea6977f (patch)
tree4a44b2a45541a1553458faa7d8ac51ed705bf188
parentb6cabf81006af154999ee8aa5dd7929d89d0c156 (diff)
downloadroundcubemail-plugins-kolab-607fd7b43b711c3304880422492b9fcf2ea6977f.tar.gz
Updates for Roundcube 0.8
-rw-r--r--plugins/calendar/drivers/kolab/kolab_calendar.php2
-rw-r--r--plugins/calendar/drivers/kolab/kolab_driver.php42
-rw-r--r--plugins/kolab_addressbook/kolab_addressbook.php18
-rw-r--r--plugins/kolab_addressbook/lib/rcube_kolab_contacts.php6
-rw-r--r--plugins/kolab_auth/kolab_auth.php4
-rw-r--r--plugins/kolab_core/rcube_kolab.php39
-rw-r--r--plugins/kolab_folders/kolab_folders.php80
-rw-r--r--plugins/kolab_zpush/kolab_zpush.php40
8 files changed, 122 insertions, 109 deletions
diff --git a/plugins/calendar/drivers/kolab/kolab_calendar.php b/plugins/calendar/drivers/kolab/kolab_calendar.php
index a346037..ccd542a 100644
--- a/plugins/calendar/drivers/kolab/kolab_calendar.php
+++ b/plugins/calendar/drivers/kolab/kolab_calendar.php
@@ -145,7 +145,7 @@ class kolab_calendar
public function get_foldername()
{
$parts = explode('/', $this->imap_folder);
- return rcube_charset_convert(end($parts), 'UTF7-IMAP');
+ return rcube_charset::convert(end($parts), 'UTF7-IMAP');
}
/**
diff --git a/plugins/calendar/drivers/kolab/kolab_driver.php b/plugins/calendar/drivers/kolab/kolab_driver.php
index a55a8cc..a70ddfe 100644
--- a/plugins/calendar/drivers/kolab/kolab_driver.php
+++ b/plugins/calendar/drivers/kolab/kolab_driver.php
@@ -78,7 +78,7 @@ class kolab_driver extends calendar_driver
// convert to UTF8 and sort
$names = array();
foreach ($folders as $folder)
- $names[$folder->name] = rcube_charset_convert($folder->name, 'UTF7-IMAP');
+ $names[$folder->name] = rcube_charset::convert($folder->name, 'UTF7-IMAP');
asort($names, SORT_LOCALE_STRING);
@@ -160,8 +160,8 @@ class kolab_driver extends calendar_driver
}
// subscribe to new calendar by default
- $this->rc->imap_connect();
- $this->rc->imap->subscribe($folder);
+ $storage = $this->rc->get_storage();
+ $storage->subscribe($folder);
// create ID
$id = rcube_kolab::folder_id($folder);
@@ -226,11 +226,11 @@ class kolab_driver extends calendar_driver
public function subscribe_calendar($prop)
{
if ($prop['id'] && ($cal = $this->calendars[$prop['id']])) {
- $this->rc->imap_connect();
+ $storage = $this->rc->get_storage();
if ($prop['active'])
- return $this->rc->imap->subscribe($cal->get_realname());
+ return $storage->subscribe($cal->get_realname());
else
- return $this->rc->imap->unsubscribe($cal->get_realname());
+ return $storage->unsubscribe($cal->get_realname());
}
return false;
@@ -246,14 +246,14 @@ class kolab_driver extends calendar_driver
*/
private function folder_update(&$prop)
{
- $folder = rcube_charset_convert($prop['name'], RCMAIL_CHARSET, 'UTF7-IMAP');
+ $folder = rcube_charset::convert($prop['name'], RCMAIL_CHARSET, 'UTF7-IMAP');
$oldfolder = $prop['oldname']; // UTF7
$parent = $prop['parent']; // UTF7
- $delimiter = $_SESSION['imap_delimiter'];
+ $storage = $this->rc->get_storage();
+ $delimiter = $storage->get_hierarchy_delimiter();
if (strlen($oldfolder)) {
- $this->rc->imap_connect();
- $options = $this->rc->imap->mailbox_info($oldfolder);
+ $options = $storage->folder_info($oldfolder);
}
if (!empty($options) && ($options['norename'] || $options['protected'])) {
@@ -285,14 +285,12 @@ class kolab_driver extends calendar_driver
}
else {
// add namespace prefix (when needed)
- $this->rc->imap_init();
- $folder = $this->rc->imap->mod_mailbox($folder, 'in');
+ $folder = $storage->mod_folder($folder, 'in');
}
// Check access rights to the parent folder
if (strlen($parent) && (!strlen($oldfolder) || $oldfolder != $folder)) {
- $this->rc->imap_connect();
- $parent_opts = $this->rc->imap->mailbox_info($parent);
+ $parent_opts = $storage->folder_info($parent);
if ($parent_opts['namespace'] != 'personal'
&& (empty($parent_opts['rights']) || !preg_match('/[ck]/', implode($parent_opts)))
) {
@@ -320,8 +318,8 @@ class kolab_driver extends calendar_driver
// TODO: also save 'showalarams' and other properties here
if ($result && $prop['color']) {
- if (!($meta_saved = $this->rc->imap->set_metadata($folder, array('/shared/vendor/kolab/color' => $prop['color'])))) // try in shared namespace
- $meta_saved = $this->rc->imap->set_metadata($folder, array('/private/vendor/kolab/color' => $prop['color'])); // try in private namespace
+ if (!($meta_saved = $storage->set_metadata($folder, array('/shared/vendor/kolab/color' => $prop['color'])))) // try in shared namespace
+ $meta_saved = $storage->set_metadata($folder, array('/private/vendor/kolab/color' => $prop['color'])); // try in private namespace
if ($meta_saved)
unset($prop['color']); // unsetting will prevent fallback to local user prefs
}
@@ -1016,7 +1014,8 @@ class kolab_driver extends calendar_driver
$hidden_fields[] = array('name' => 'oldname', 'value' => $folder);
- $delim = $_SESSION['imap_delimiter'];
+ $storage = $this->rc->get_storage();
+ $delim = $storage->get_hierarchy_delimiter();
$form = array();
if (strlen($folder)) {
@@ -1024,8 +1023,7 @@ class kolab_driver extends calendar_driver
array_pop($path_imap); // pop off name part
$path_imap = implode($path_imap, $delim);
- $this->rc->imap_connect();
- $options = $this->rc->imap->mailbox_info($folder);
+ $options = $storage->folder_info($folder);
}
else {
$path_imap = '';
@@ -1179,7 +1177,8 @@ class kolab_driver extends calendar_driver
$hidden_fields[] = array('name' => 'oldname', 'value' => $folder);
- $delim = $_SESSION['imap_delimiter'];
+ $storage = $this->rc->get_storage();
+ $delim = $storage->get_hierarchy_delimiter();
$form = array();
if (strlen($folder)) {
@@ -1187,8 +1186,7 @@ class kolab_driver extends calendar_driver
array_pop($path_imap); // pop off name part
$path_imap = implode($path_imap, $delim);
- $this->rc->imap_connect();
- $options = $this->rc->imap->mailbox_info($folder);
+ $options = $storage->folder_info($folder);
// Allow plugins to modify the form content (e.g. with ACL form)
$plugin = $this->rc->plugins->exec_hook('calendar_form_kolab',
diff --git a/plugins/kolab_addressbook/kolab_addressbook.php b/plugins/kolab_addressbook/kolab_addressbook.php
index ec75162..5a47657 100644
--- a/plugins/kolab_addressbook/kolab_addressbook.php
+++ b/plugins/kolab_addressbook/kolab_addressbook.php
@@ -131,7 +131,7 @@ class kolab_addressbook extends rcube_plugin
'editable' => $abook->editable,
'groups' => $abook->groups,
'undelete' => $abook->undelete && $undelete,
- 'realname' => rcube_charset_convert($abook->get_realname(), 'UTF7-IMAP'), // IMAP folder name
+ 'realname' => rcube_charset::convert($abook->get_realname(), 'UTF7-IMAP'), // IMAP folder name
'class_name' => $abook->get_namespace(),
'kolab' => true,
);
@@ -258,7 +258,7 @@ class kolab_addressbook extends rcube_plugin
// convert to UTF8 and sort
$names = array();
foreach ($this->folders as $c_folder)
- $names[$c_folder->name] = rcube_charset_convert($c_folder->name, 'UTF7-IMAP');
+ $names[$c_folder->name] = rcube_charset::convert($c_folder->name, 'UTF7-IMAP');
asort($names, SORT_LOCALE_STRING);
@@ -420,14 +420,14 @@ class kolab_addressbook extends rcube_plugin
*/
public function book_save()
{
+ $storage = $this->rc->get_storage();
$folder = trim(get_input_value('_name', RCUBE_INPUT_POST, true, 'UTF7-IMAP'));
$oldfolder = trim(get_input_value('_oldname', RCUBE_INPUT_POST, true)); // UTF7-IMAP
$path = trim(get_input_value('_parent', RCUBE_INPUT_POST, true)); // UTF7-IMAP
- $delimiter = $_SESSION['imap_delimiter'];
+ $delimiter = $storage->get_hierarchy_delimiter();
if (strlen($oldfolder)) {
- $this->rc->imap_connect();
- $options = $this->rc->imap->mailbox_info($oldfolder);
+ $options = $storage->folder_info($oldfolder);
}
if (!empty($options) && ($options['norename'] || $options['protected'])) {
@@ -458,14 +458,12 @@ class kolab_addressbook extends rcube_plugin
}
else {
// add namespace prefix (when needed)
- $this->rc->imap_init();
- $folder = $this->rc->imap->mod_mailbox($folder, 'in');
+ $folder = $storage->mod_folder($folder, 'in');
}
// Check access rights to the parent folder
if (strlen($path) && (!strlen($oldfolder) || $oldfolder != $folder)) {
- $this->rc->imap_connect();
- $parent_opts = $this->rc->imap->mailbox_info($path);
+ $parent_opts = $storage->folder_info($path);
if ($parent_opts['namespace'] != 'personal'
&& (empty($parent_opts['rights']) || !preg_match('/[ck]/', implode($parent_opts)))
) {
@@ -552,7 +550,7 @@ class kolab_addressbook extends rcube_plugin
'readonly' => false,
'editable' => true,
'groups' => true,
- 'realname' => rcube_charset_convert($folder, 'UTF7-IMAP'), // IMAP folder name
+ 'realname' => rcube_charset::convert($folder, 'UTF7-IMAP'), // IMAP folder name
'class_name' => $kolab_folder->get_namespace(),
'kolab' => true,
), rcube_kolab::folder_id($oldfolder));
diff --git a/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php b/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php
index 9c40afb..2ffc740 100644
--- a/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php
+++ b/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php
@@ -131,8 +131,9 @@ class rcube_kolab_contacts extends rcube_addressbook
public function __construct($imap_folder = null)
{
- if ($imap_folder)
+ if ($imap_folder) {
$this->imap_folder = $imap_folder;
+ }
// extend coltypes configuration
$format = rcube_kolab::get_format('contact');
@@ -653,8 +654,9 @@ class rcube_kolab_contacts extends rcube_addressbook
}
// store IMAP uids for undelete()
- if (!$force)
+ if (!$force) {
$_SESSION['kolab_delete_uids'] = $imap_uids;
+ }
return $count;
}
diff --git a/plugins/kolab_auth/kolab_auth.php b/plugins/kolab_auth/kolab_auth.php
index 3fa8524..07800cd 100644
--- a/plugins/kolab_auth/kolab_auth.php
+++ b/plugins/kolab_auth/kolab_auth.php
@@ -43,7 +43,7 @@ class kolab_auth extends rcube_plugin
// Hooks related to "Login As" feature
$this->add_hook('template_object_loginform', array($this, 'login_form'));
- $this->add_hook('imap_connect', array($this, 'imap_connect'));
+ $this->add_hook('storage_connect', array($this, 'imap_connect'));
$this->add_hook('managesieve_connect', array($this, 'imap_connect'));
$this->add_hook('smtp_connect', array($this, 'smtp_connect'));
@@ -135,7 +135,7 @@ class kolab_auth extends rcube_plugin
} else {
$dont_override = $rcmail->config->get('dont_override');
if (in_array($setting_name, $dont_override)) {
- $_dont_override = Array();
+ $_dont_override = array();
foreach ($dont_override as $_setting) {
if ($_setting != $setting_name) {
$_dont_override[] = $_setting;
diff --git a/plugins/kolab_core/rcube_kolab.php b/plugins/kolab_core/rcube_kolab.php
index 7f2702f..6bd5f60 100644
--- a/plugins/kolab_core/rcube_kolab.php
+++ b/plugins/kolab_core/rcube_kolab.php
@@ -222,15 +222,9 @@ class rcube_kolab
static $subscribed; // local cache
if (!$subscribed) {
- $rcmail = rcmail::get_instance();
- // try without connection first (list could be served from cache)
- $subscribed = $rcmail->imap ? $rcmail->imap->list_mailboxes() : array();
-
- // now really get the list from the IMAP server
- if (empty($subscribed) || $subscribed == array('INBOX')) {
- $rcmail->imap_connect();
- $subscribed = $rcmail->imap->list_mailboxes();
- }
+ $rcmail = rcmail::get_instance();
+ $storage = $rcmail->get_storage();
+ $subscribed = $storage->list_folders();
}
return in_array($folder, $subscribed);
@@ -390,10 +384,9 @@ class rcube_kolab
*/
public static function object_name($folder, &$folder_ns=null)
{
- $rcmail = rcmail::get_instance();
- $rcmail->imap_init();
-
- $namespace = $rcmail->imap->get_namespace();
+ $rcmail = rcmail::get_instance();
+ $storage = $rcmail->get_storage();
+ $namespace = $storage->get_namespace();
$found = false;
if (!empty($namespace['shared'])) {
@@ -444,9 +437,9 @@ class rcube_kolab
}
if (empty($delim))
- $delim = $rcmail->imap->get_hierarchy_delimiter();
+ $delim = $storage->get_hierarchy_delimiter();
- $folder = rcube_charset_convert($folder, 'UTF7-IMAP');
+ $folder = rcube_charset::convert($folder, 'UTF7-IMAP');
$folder = str_replace($delim, ' &raquo; ', $folder);
if ($prefix)
@@ -467,10 +460,9 @@ class rcube_kolab
*/
public static function folder_namespace($folder)
{
- $rcmail = rcmail::get_instance();
- $rcmail->imap_init();
-
- $namespace = $rcmail->imap->get_namespace();
+ $rcmail = rcmail::get_instance();
+ $storage = $rcmail->get_storage();
+ $namespace = $storage->get_namespace();
if (!empty($namespace)) {
foreach ($namespace as $nsname => $nsvalue) {
@@ -498,10 +490,13 @@ class rcube_kolab
*/
public static function folder_selector($type, $attrs, $current = '')
{
+ $rcmail = rcmail::get_instance();
+ $storage = $rcmail->get_storage();
+
// get all folders of specified type
$folders = self::get_folders($type);
- $delim = $_SESSION['imap_delimiter'];
+ $delim = $storage->get_hierarchy_delimiter();
$names = array();
$len = strlen($current);
@@ -528,12 +523,12 @@ class rcube_kolab
}
}
- $names[$name] = rcube_charset_convert($name, 'UTF7-IMAP');
+ $names[$name] = rcube_charset::convert($name, 'UTF7-IMAP');
}
// Make sure parent folder is listed (might be skipped e.g. if it's namespace root)
if ($p_len && !isset($names[$parent])) {
- $names[$parent] = rcube_charset_convert($parent, 'UTF7-IMAP');
+ $names[$parent] = rcube_charset::convert($parent, 'UTF7-IMAP');
}
// Sort folders list
diff --git a/plugins/kolab_folders/kolab_folders.php b/plugins/kolab_folders/kolab_folders.php
index 446a091..044f636 100644
--- a/plugins/kolab_folders/kolab_folders.php
+++ b/plugins/kolab_folders/kolab_folders.php
@@ -41,7 +41,7 @@ class kolab_folders extends rcube_plugin
$this->rc = rcmail::get_instance();
// Folder listing hooks
- $this->add_hook('mailboxes_list', array($this, 'mailboxes_list'));
+ $this->add_hook('storage_folders', array($this, 'mailboxes_list'));
// Folder manager hooks
$this->add_hook('folder_form', array($this, 'folder_form'));
@@ -72,7 +72,6 @@ class kolab_folders extends rcube_plugin
$folderdata = $this->get_folder_type_list($args['root'].$args['name'], true);
if (!is_array($folderdata)) {
- $args['folders'] = false;
return $args;
}
@@ -91,9 +90,11 @@ class kolab_folders extends rcube_plugin
return $args;
}
+ $storage = $this->rc->get_storage();
+
// Get folders list
if ($args['mode'] == 'LIST') {
- $args['folders'] = $this->rc->imap->conn->listMailboxes($args['root'], $args['name']);
+ $args['folders'] = $storage->conn->listMailboxes($args['root'], $args['name']);
}
else {
$args['folders'] = $this->list_subscribed($args['root'], $args['name']);
@@ -200,16 +201,21 @@ class kolab_folders extends rcube_plugin
$ctype = 'mail';
}
+ $storage = $this->rc->get_storage();
+
// Don't allow changing type of shared folder, according to ACL
if (strlen($mbox)) {
- $options = $this->rc->imap->mailbox_info($mbox);
+ $options = $storage->folder_info($mbox);
if ($options['namespace'] != 'personal' && !in_array('a', $options['rights'])) {
- if (in_array($ctype, $this->types))
+ if (in_array($ctype, $this->types)) {
$value = $this->gettext('foldertype'.$ctype);
- else
+ }
+ else {
$value = $ctype;
- if ($subtype)
+ }
+ if ($subtype) {
$value .= ' ('. ($subtype == 'default' ? $this->gettext('default') : $subtype) .')';
+ }
$args['form']['props']['fieldsets']['settings']['content']['foldertype'] = array(
'label' => $this->gettext('folderctype'),
@@ -298,13 +304,15 @@ class kolab_folders extends rcube_plugin
$ctype .= $subtype ? '.'.$subtype : '';
+ $storage = $this->rc->get_storage();
+
// Create folder
if (!strlen($old_mbox)) {
// By default don't subscribe to non-mail folders
if ($subscribe)
$subscribe = (bool) preg_match('/^mail/', $ctype);
- $result = $this->rc->imap->create_mailbox($mbox, $subscribe);
+ $result = $storage->create_folder($mbox, $subscribe);
// Set folder type
if ($result) {
$this->set_folder_type($mbox, $ctype);
@@ -313,7 +321,7 @@ class kolab_folders extends rcube_plugin
// Rename folder
else {
if ($old_mbox != $mbox) {
- $result = $this->rc->imap->rename_mailbox($old_mbox, $mbox);
+ $result = $storage->rename_folder($old_mbox, $mbox);
}
else {
$result = true;
@@ -348,9 +356,11 @@ class kolab_folders extends rcube_plugin
*/
function metadata_support()
{
- return $this->rc->imap->get_capability('METADATA') ||
- $this->rc->imap->get_capability('ANNOTATEMORE') ||
- $this->rc->imap->get_capability('ANNOTATEMORE2');
+ $storage = $this->rc->get_storage();
+
+ return $storage->get_capability('METADATA') ||
+ $storage->get_capability('ANNOTATEMORE') ||
+ $storage->get_capability('ANNOTATEMORE2');
}
/**
@@ -362,7 +372,8 @@ class kolab_folders extends rcube_plugin
*/
function get_folder_type($folder)
{
- $folderdata = $this->rc->imap->get_metadata($folder, array(kolab_folders::CTYPE_KEY));
+ $storage = $this->rc->get_storage();
+ $folderdata = $storage->get_metadata($folder, array(kolab_folders::CTYPE_KEY));
return explode('.', $folderdata[$folder][kolab_folders::CTYPE_KEY]);
}
@@ -377,7 +388,9 @@ class kolab_folders extends rcube_plugin
*/
function set_folder_type($folder, $type='mail')
{
- return $this->rc->imap->set_metadata($folder, array(kolab_folders::CTYPE_KEY => $type));
+ $storage = $this->rc->get_storage();
+
+ return $storage->set_metadata($folder, array(kolab_folders::CTYPE_KEY => $type));
}
/**
@@ -390,23 +403,23 @@ class kolab_folders extends rcube_plugin
*/
private function list_subscribed($root='', $name='*')
{
- $imap = $this->rc->imap;
+ $storage = $this->rc->get_storage();
// Code copied from rcube_imap::_list_mailboxes()
// Server supports LIST-EXTENDED, we can use selection options
// #1486225: Some dovecot versions returns wrong result using LIST-EXTENDED
if (!$this->rc->config->get('imap_force_lsub') && $imap->get_capability('LIST-EXTENDED')) {
// This will also set mailbox options, LSUB doesn't do that
- $a_folders = $imap->conn->listMailboxes($root, $name,
+ $a_folders = $storage->conn->listMailboxes($root, $name,
NULL, array('SUBSCRIBED'));
// remove non-existent folders
if (is_array($a_folders) && $name = '*') {
foreach ($a_folders as $idx => $folder) {
- if ($imap->conn->data['LIST'] && ($opts = $imap->conn->data['LIST'][$folder])
+ if ($storage->conn->data['LIST'] && ($opts = $storage->conn->data['LIST'][$folder])
&& in_array('\\NonExistent', $opts)
) {
- $imap->conn->unsubscribe($folder);
+ $storage->conn->unsubscribe($folder);
unset($a_folders[$idx]);
}
}
@@ -414,17 +427,17 @@ class kolab_folders extends rcube_plugin
}
// retrieve list of folders from IMAP server using LSUB
else {
- $a_folders = $imap->conn->listSubscribed($root, $name);
+ $a_folders = $storage->conn->listSubscribed($root, $name);
// unsubscribe non-existent folders, remove from the list
if (is_array($a_folders) && $name == '*') {
foreach ($a_folders as $idx => $folder) {
- if ($imap->conn->data['LIST'] && ($opts = $imap->conn->data['LIST'][$folder])
+ if ($storage->conn->data['LIST'] && ($opts = $storage->conn->data['LIST'][$folder])
&& in_array('\\Noselect', $opts)
) {
// Some servers returns \Noselect for existing folders
- if (!$imap->mailbox_exists($folder)) {
- $imap->conn->unsubscribe($folder);
+ if (!$storage->folder_exists($folder)) {
+ $storage->conn->unsubscribe($folder);
unset($a_folders[$idx]);
}
}
@@ -445,15 +458,17 @@ class kolab_folders extends rcube_plugin
*/
function get_folder_type_list($mbox, $create_defaults = false)
{
+ $storage = $this->rc->get_storage();
+
// Use mailboxes. prefix so the cache will be cleared by core
// together with other mailboxes-related cache data
$cache_key = 'mailboxes.folder-type.'.$mbox;
// get cached metadata
- $metadata = $this->rc->imap->get_cache($cache_key);
+ $metadata = $storage->get_cache($cache_key);
if (!is_array($metadata)) {
- $metadata = $this->rc->imap->get_metadata($mbox, kolab_folders::CTYPE_KEY);
+ $metadata = $storage->get_metadata($mbox, kolab_folders::CTYPE_KEY);
$need_update = true;
}
@@ -473,7 +488,7 @@ class kolab_folders extends rcube_plugin
// write mailboxlist to cache
if ($need_update) {
- $this->rc->imap->update_cache($cache_key, $metadata);
+ $storage->update_cache($cache_key, $metadata);
}
return $metadata;
@@ -488,6 +503,7 @@ class kolab_folders extends rcube_plugin
*/
function get_default_folder($type)
{
+ $storage = $this->rc->get_storage();
$folderdata = $this->get_folder_type_list('*');
if (!is_array($folderdata)) {
@@ -495,7 +511,7 @@ class kolab_folders extends rcube_plugin
}
$type .= '.default';
- $namespace = $this->rc->imap->get_namespace();
+ $namespace = $storage->get_namespace();
// get all folders of specified type
$folderdata = array_intersect($folderdata, array($type));
@@ -552,7 +568,8 @@ class kolab_folders extends rcube_plugin
*/
private function create_default_folders(&$folderdata, $cache_key = null)
{
- $namespace = $this->rc->imap->get_namespace();
+ $storage = $this->rc->get_storage();
+ $namespace = $storage->get_namespace();
$defaults = array();
$need_update = false;
@@ -573,7 +590,7 @@ class kolab_folders extends rcube_plugin
$opt_name = 'kolab_folders_' . $type . '_' . $subtype;
if ($folder = $this->rc->config->get($opt_name)) {
// convert configuration value to UTF7-IMAP charset
- $folder = rcube_charset_convert($folder, RCMAIL_CHARSET, 'UTF7-IMAP');
+ $folder = rcube_charset::convert($folder, RCMAIL_CHARSET, 'UTF7-IMAP');
// and namespace prefix if needed
if ($prefix && strpos($folder, $prefix) === false && $folder != 'INBOX') {
$folder = $prefix . $folder;
@@ -621,8 +638,8 @@ class kolab_folders extends rcube_plugin
list($type1, $type2) = explode('.', $type);
// create folder
- if ($type1 != 'mail' || !$this->rc->imap->mailbox_exists($foldername)) {
- $this->rc->imap->create_mailbox($foldername, $type1 == 'mail');
+ if ($type1 != 'mail' || !$storage->folder_exists($foldername)) {
+ $storage->create_folder($foldername, $type1 == 'mail');
}
// set type
@@ -637,7 +654,8 @@ class kolab_folders extends rcube_plugin
// update cache
if ($need_update && $cache_key) {
- $this->rc->imap->update_cache($cache_key, $folderdata);
+ $storage->update_cache($cache_key, $folderdata);
}
}
+
}
diff --git a/plugins/kolab_zpush/kolab_zpush.php b/plugins/kolab_zpush/kolab_zpush.php
index 7624cd0..f19fe3a 100644
--- a/plugins/kolab_zpush/kolab_zpush.php
+++ b/plugins/kolab_zpush/kolab_zpush.php
@@ -64,11 +64,12 @@ class kolab_zpush extends rcube_plugin
*/
public function init_imap()
{
- $this->rc->imap_connect();
+ $storage = $this->rc->get_storage();
+
$this->cache = $this->rc->get_cache('zpush', 'db', 900);
$this->cache->expunge();
- if ($meta = $this->rc->imap->get_metadata(self::ROOT_MAILBOX, self::ACTIVESYNC_KEY)) {
+ if ($meta = $storage->get_metadata(self::ROOT_MAILBOX, self::ACTIVESYNC_KEY)) {
// clear cache if device config changed
if (($oldmeta = $this->cache->read('devicemeta')) && $oldmeta != $meta)
$this->cache->remove();
@@ -85,13 +86,13 @@ class kolab_zpush extends rcube_plugin
*/
public function json_command()
{
- $cmd = get_input_value('cmd', RCUBE_INPUT_GPC);
- $imei = get_input_value('id', RCUBE_INPUT_GPC);
+ $storage = $this->rc->get_storage();
+ $cmd = get_input_value('cmd', RCUBE_INPUT_GPC);
+ $imei = get_input_value('id', RCUBE_INPUT_GPC);
switch ($cmd) {
case 'load':
$result = array();
- $this->init_imap();
$devices = $this->list_devices();
if ($device = $devices[$imei]) {
$result['id'] = $imei;
@@ -113,7 +114,6 @@ class kolab_zpush extends rcube_plugin
break;
case 'save':
- $this->init_imap();
$devices = $this->list_devices();
$syncmode = intval(get_input_value('syncmode', RCUBE_INPUT_POST));
$devicealias = get_input_value('devicealias', RCUBE_INPUT_POST, true);
@@ -132,13 +132,13 @@ class kolab_zpush extends rcube_plugin
$this->root_meta['DEVICE'][$imei]['LAXPIC'] = $laxpic;
$this->root_meta['FOLDER'][$imei]['S'] = intval($subsciptions[self::ROOT_MAILBOX]);
- $err = !$this->rc->imap->set_metadata(self::ROOT_MAILBOX,
+ $err = !$storage->set_metadata(self::ROOT_MAILBOX,
array(self::ACTIVESYNC_KEY => $this->serialize_metadata($this->root_meta)));
// update cached meta data
if (!$err) {
$this->cache->remove('devicemeta');
- $this->cache->write('devicemeta', $this->rc->imap->get_metadata(self::ROOT_MAILBOX, self::ACTIVESYNC_KEY));
+ $this->cache->write('devicemeta', $storage->get_metadata(self::ROOT_MAILBOX, self::ACTIVESYNC_KEY));
}
}
// iterate over folders list and update metadata if necessary
@@ -153,12 +153,12 @@ class kolab_zpush extends rcube_plugin
unset($meta['TYPE']);
// read metadata first
- $folderdata = $this->rc->imap->get_metadata($folder, array(self::ACTIVESYNC_KEY));
+ $folderdata = $storage->get_metadata($folder, array(self::ACTIVESYNC_KEY));
if ($asyncdata = $folderdata[$folder][self::ACTIVESYNC_KEY])
$metadata = $this->unserialize_metadata($asyncdata);
$metadata['FOLDER'] = $meta;
- $err |= !$this->rc->imap->set_metadata($folder, array(self::ACTIVESYNC_KEY => $this->serialize_metadata($metadata)));
+ $err |= !$storage->set_metadata($folder, array(self::ACTIVESYNC_KEY => $this->serialize_metadata($metadata)));
}
}
@@ -184,9 +184,9 @@ class kolab_zpush extends rcube_plugin
unset($this->root_meta['DEVICE'][$imei], $this->root_meta['FOLDER'][$imei]);
// update annotation and cached meta data
- if ($success = $this->rc->imap->set_metadata(self::ROOT_MAILBOX, array(self::ACTIVESYNC_KEY => $this->serialize_metadata($this->root_meta)))) {
+ if ($success = $storage->set_metadata(self::ROOT_MAILBOX, array(self::ACTIVESYNC_KEY => $this->serialize_metadata($this->root_meta)))) {
$this->cache->remove('devicemeta');
- $this->cache->write('devicemeta', $this->rc->imap->get_metadata(self::ROOT_MAILBOX, self::ACTIVESYNC_KEY));
+ $this->cache->write('devicemeta', $storage->get_metadata(self::ROOT_MAILBOX, self::ACTIVESYNC_KEY));
// remove device annotation in every folder
foreach ($this->folders_meta() as $folder => $meta) {
@@ -199,12 +199,12 @@ class kolab_zpush extends rcube_plugin
unset($meta[$imei], $meta['TYPE']);
// read metadata first and update FOLDER property
- $folderdata = $this->rc->imap->get_metadata($folder, array(self::ACTIVESYNC_KEY));
+ $folderdata = $storage->get_metadata($folder, array(self::ACTIVESYNC_KEY));
if ($asyncdata = $folderdata[$folder][self::ACTIVESYNC_KEY])
$metadata = $this->unserialize_metadata($asyncdata);
$metadata['FOLDER'] = $meta;
- if ($this->rc->imap->set_metadata($folder, array(self::ACTIVESYNC_KEY => $this->serialize_metadata($metadata)))) {
+ if ($storage->set_metadata($folder, array(self::ACTIVESYNC_KEY => $this->serialize_metadata($metadata)))) {
$this->folders_meta[$folder] = $metadata;
$this->folders_meta[$folder]['TYPE'] = $type;
}
@@ -236,12 +236,12 @@ class kolab_zpush extends rcube_plugin
*/
public function config_view()
{
- require_once($this->home . '/kolab_zpush_ui.php');
+ require_once $this->home . '/kolab_zpush_ui.php';
- $this->init_imap();
+ $storage = $this->rc->get_storage();
// checks if IMAP server supports any of METADATA, ANNOTATEMORE, ANNOTATEMORE2
- if (!($this->rc->imap->get_capability('METADATA') || $this->rc->imap->get_capability('ANNOTATEMORE') || $this->rc->imap->get_capability('ANNOTATEMORE2'))) {
+ if (!($storage->get_capability('METADATA') || $storage->get_capability('ANNOTATEMORE') || $storage->get_capability('ANNOTATEMORE2'))) {
$this->rc->output->show_message($this->gettext('notsupported'), 'error');
}
@@ -286,9 +286,11 @@ class kolab_zpush extends rcube_plugin
}
// fetch folder data from server
else {
- $this->folders = $this->rc->imap->list_folders();
+ $storage = $this->rc->get_storage();
+ $this->folders = $storage->list_folders();
+
foreach ($this->folders as $folder) {
- $folderdata = $this->rc->imap->get_metadata($folder, array(self::ACTIVESYNC_KEY, self::CTYPE_KEY));
+ $folderdata = $storage->get_metadata($folder, array(self::ACTIVESYNC_KEY, self::CTYPE_KEY));
$foldertype = explode('.', $folderdata[$folder][self::CTYPE_KEY]);
if ($asyncdata = $folderdata[$folder][self::ACTIVESYNC_KEY]) {