From 2d08c58e56ebe9c0dd8c55679c887714178ed994 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Wed, 17 Oct 2012 11:54:25 +0200 Subject: [PATCH] Fix/prepare plugins to use out of Roundcube (where rcmail object doesn't exist) --- plugins/calendar/calendar.php | 8 +++--- plugins/calendar/drivers/calendar_driver.php | 2 +- plugins/calendar/lib/calendar_itip.php | 6 ++-- plugins/kolab_activesync/kolab_activesync.php | 2 +- .../kolab_activesync/kolab_activesync_ui.php | 6 ++-- .../kolab_addressbook/kolab_addressbook.php | 2 +- .../lib/kolab_addressbook_ui.php | 2 +- .../lib/rcube_kolab_contacts.php | 2 +- plugins/kolab_auth/kolab_auth.php | 28 +++++++++---------- plugins/kolab_config/kolab_config.php | 2 +- plugins/kolab_folders/kolab_folders.php | 2 +- plugins/kolab_zpush/kolab_zpush.php | 2 +- plugins/kolab_zpush/kolab_zpush_ui.php | 6 ++-- .../ldap_authentication.php | 10 +++---- plugins/libcalendaring/libcalendaring.php | 4 +-- plugins/libkolab/bin/modcache.sh | 2 +- plugins/odfviewer/odfviewer.php | 6 ++-- plugins/owncloud/owncloud.php | 18 ++++++------ plugins/piwik_analytics/piwik_analytics.php | 2 +- plugins/tasklist/drivers/tasklist_driver.php | 2 +- plugins/tasklist/tasklist.php | 8 +++--- plugins/tinymce_config/tinymce_config.php | 2 +- 22 files changed, 62 insertions(+), 62 deletions(-) diff --git a/plugins/calendar/calendar.php b/plugins/calendar/calendar.php index f51af3cc..a5265704 100644 --- a/plugins/calendar/calendar.php +++ b/plugins/calendar/calendar.php @@ -75,7 +75,7 @@ class calendar extends rcube_plugin { $this->require_plugin('libcalendaring'); - $this->rc = rcmail::get_instance(); + $this->rc = rcube::get_instance(); $this->lib = libcalendaring::get_instance(); $this->register_task('calendar', 'calendar'); @@ -1094,7 +1094,7 @@ class calendar extends rcube_plugin } foreach ((array)$event['attachments'] as $k => $attachment) { - $event['attachments'][$k]['classname'] = rcmail_filetype2classname($attachment['mimetype'], $attachment['name']); + $event['attachments'][$k]['classname'] = rcube_utils::file2class($attachment['mimetype'], $attachment['name']); } return array( @@ -1936,13 +1936,13 @@ class calendar extends rcube_plugin if ($attachment['status'] && !$attachment['abort']) { $id = $attachment['id']; - $attachment['classname'] = rcmail_filetype2classname($attachment['mimetype'], $attachment['name']); + $attachment['classname'] = rcube_utils::file2class($attachment['mimetype'], $attachment['name']); // store new attachment in session unset($attachment['status'], $attachment['abort'], $attachment['data']); $_SESSION[self::SESSION_KEY]['attachments'][$id] = $attachment; - $attachment['id'] = 'rcmfile' . $attachment['id']; # add prefix to consider it 'new' + $attachment['id'] = 'rcmfile' . $attachment['id']; // add prefix to consider it 'new' $event['attachments'][] = $attachment; } } diff --git a/plugins/calendar/drivers/calendar_driver.php b/plugins/calendar/drivers/calendar_driver.php index 7feca605..88c7f450 100644 --- a/plugins/calendar/drivers/calendar_driver.php +++ b/plugins/calendar/drivers/calendar_driver.php @@ -298,7 +298,7 @@ abstract class calendar_driver */ public function list_categories() { - $rcmail = rcmail::get_instance(); + $rcmail = rcube::get_instance(); return $rcmail->config->get('calendar_categories', array()); } diff --git a/plugins/calendar/lib/calendar_itip.php b/plugins/calendar/lib/calendar_itip.php index 50f012f5..dc4cfa0f 100644 --- a/plugins/calendar/lib/calendar_itip.php +++ b/plugins/calendar/lib/calendar_itip.php @@ -103,7 +103,7 @@ class calendar_itip // finally send the message $this->itip_send = true; - $sent = rcmail_deliver_message($message, $headers['X-Sender'], $mailto, $smtp_error); + $sent = $this->rc->deliver_message($message, $headers['X-Sender'], $mailto, $smtp_error); $this->itip_send = false; return $sent; @@ -147,8 +147,8 @@ class calendar_itip // compose common headers array $headers = array( 'From' => $sender, - 'Date' => rcmail_user_date(), - 'Message-ID' => rcmail_gen_message_id(), + 'Date' => $this->rc->user_date(), + 'Message-ID' => $this->rc->gen_message_id(), 'X-Sender' => $from, ); if ($agent = $this->rc->config->get('useragent')) diff --git a/plugins/kolab_activesync/kolab_activesync.php b/plugins/kolab_activesync/kolab_activesync.php index c87e9197..0238f116 100644 --- a/plugins/kolab_activesync/kolab_activesync.php +++ b/plugins/kolab_activesync/kolab_activesync.php @@ -44,7 +44,7 @@ class kolab_activesync extends rcube_plugin */ public function init() { - $this->rc = rcmail::get_instance(); + $this->rc = rcube::get_instance(); $this->require_plugin('jqueryui'); $this->require_plugin('libkolab'); diff --git a/plugins/kolab_activesync/kolab_activesync_ui.php b/plugins/kolab_activesync/kolab_activesync_ui.php index a3ca623d..a1912554 100644 --- a/plugins/kolab_activesync/kolab_activesync_ui.php +++ b/plugins/kolab_activesync/kolab_activesync_ui.php @@ -32,7 +32,7 @@ class kolab_activesync_ui public function __construct($plugin) { $this->plugin = $plugin; - $this->rc = rcmail::get_instance(); + $this->rc = rcube::get_instance(); $skin_path = $this->plugin->local_skin_path() . '/'; $this->skin_path = 'plugins/kolab_activesync/' . $skin_path; @@ -170,8 +170,8 @@ class kolab_activesync_ui $names[] = $origname; $classes = array('mailbox'); - if ($folder_class = rcmail_folder_classname($folder)) { - $foldername = html::quote(rcube_label($folder_class)); + if ($folder_class = $this->rc->folder_classname($folder)) { + $foldername = html::quote($this->rc->gettext($folder_class)); $classes[] = $folder_class; } diff --git a/plugins/kolab_addressbook/kolab_addressbook.php b/plugins/kolab_addressbook/kolab_addressbook.php index 2920ebda..3ec072e5 100644 --- a/plugins/kolab_addressbook/kolab_addressbook.php +++ b/plugins/kolab_addressbook/kolab_addressbook.php @@ -48,7 +48,7 @@ class kolab_addressbook extends rcube_plugin { require_once(dirname(__FILE__) . '/lib/rcube_kolab_contacts.php'); - $this->rc = rcmail::get_instance(); + $this->rc = rcube::get_instance(); // load required plugin $this->require_plugin('libkolab'); diff --git a/plugins/kolab_addressbook/lib/kolab_addressbook_ui.php b/plugins/kolab_addressbook/lib/kolab_addressbook_ui.php index 74186497..a98b6ce5 100644 --- a/plugins/kolab_addressbook/lib/kolab_addressbook_ui.php +++ b/plugins/kolab_addressbook/lib/kolab_addressbook_ui.php @@ -32,7 +32,7 @@ class kolab_addressbook_ui */ public function __construct($plugin) { - $this->rc = rcmail::get_instance(); + $this->rc = rcube::get_instance(); $this->plugin = $plugin; $this->init_ui(); diff --git a/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php b/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php index 11c46f35..1c179330 100644 --- a/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php +++ b/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php @@ -132,7 +132,7 @@ class rcube_kolab_contacts extends rcube_addressbook } } - $this->action = rcmail::get_instance()->action; + $this->action = rcube::get_instance()->action; } diff --git a/plugins/kolab_auth/kolab_auth.php b/plugins/kolab_auth/kolab_auth.php index fb19e9e2..bea3ae7d 100644 --- a/plugins/kolab_auth/kolab_auth.php +++ b/plugins/kolab_auth/kolab_auth.php @@ -35,7 +35,7 @@ class kolab_auth extends rcube_plugin public function init() { - $rcmail = rcmail::get_instance(); + $rcmail = rcube::get_instance(); $this->add_hook('authenticate', array($this, 'authenticate')); $this->add_hook('startup', array($this, 'startup')); @@ -76,7 +76,7 @@ class kolab_auth extends rcube_plugin } public function load_user_role_plugins_and_settings($role_dns) { - $rcmail = rcmail::get_instance(); + $rcmail = rcube::get_instance(); $this->load_config(); // Check role dependent plugins to enable and settings to modify @@ -152,7 +152,7 @@ class kolab_auth extends rcube_plugin } public function write_log($args) { - $rcmail = rcmail::get_instance(); + $rcmail = rcube::get_instance(); if (!$rcmail->config->get('kolab_auth_auditlog', false)) { return $args; @@ -230,7 +230,7 @@ class kolab_auth extends rcube_plugin $this->load_config(); $this->add_texts('localization/'); - $rcmail = rcmail::get_instance(); + $rcmail = rcube::get_instance(); $admin_login = $rcmail->config->get('kolab_auth_admin_login'); $group = $rcmail->config->get('kolab_auth_group'); $role_attr = $rcmail->config->get('kolab_auth_role'); @@ -263,7 +263,7 @@ class kolab_auth extends rcube_plugin return $args; } - $rcmail = rcmail::get_instance(); + $rcmail = rcube::get_instance(); $admin_login = $rcmail->config->get('kolab_auth_admin_login'); $admin_pass = $rcmail->config->get('kolab_auth_admin_password'); $login_attr = $rcmail->config->get('kolab_auth_login'); @@ -391,8 +391,8 @@ class kolab_auth extends rcube_plugin // Log "Login As" usage if (!empty($origname)) { - write_log('userlogins', sprintf('Admin login for %s by %s from %s', - $args['user'], $origname, rcmail_remote_ip())); + rcube::write_log('userlogins', sprintf('Admin login for %s by %s from %s', + $args['user'], $origname, rcube_utils::remote_ip())); } return $args; @@ -404,7 +404,7 @@ class kolab_auth extends rcube_plugin public function imap_connect($args) { if (!empty($_SESSION['kolab_auth_admin'])) { - $rcmail = rcmail::get_instance(); + $rcmail = rcube::get_instance(); $admin_login = $rcmail->decrypt($_SESSION['kolab_auth_login']); $admin_pass = $rcmail->decrypt($_SESSION['kolab_auth_password']); @@ -421,7 +421,7 @@ class kolab_auth extends rcube_plugin public function smtp_connect($args) { if (!empty($_SESSION['kolab_auth_admin'])) { - $rcmail = rcmail::get_instance(); + $rcmail = rcube::get_instance(); $admin_login = $rcmail->decrypt($_SESSION['kolab_auth_login']); $admin_pass = $rcmail->decrypt($_SESSION['kolab_auth_password']); @@ -441,7 +441,7 @@ class kolab_auth extends rcube_plugin return $this->ldap->ready; } - $rcmail = rcmail::get_instance(); + $rcmail = rcube::get_instance(); $addressbook = $rcmail->config->get('kolab_auth_addressbook'); @@ -468,7 +468,7 @@ class kolab_auth extends rcube_plugin */ private function get_user_record($user, $host) { - $rcmail = rcmail::get_instance(); + $rcmail = rcube::get_instance(); $filter = $rcmail->config->get('kolab_auth_filter'); $filter = $this->parse_vars($filter, $user, $host); @@ -490,15 +490,15 @@ class kolab_auth extends rcube_plugin */ private function parse_vars($str, $user, $host) { - $rcmail = rcmail::get_instance(); + $rcmail = rcube::get_instance(); $domain = $rcmail->config->get('username_domain'); if (!empty($domain) && strpos($user, '@') === false) { if (is_array($domain) && isset($domain[$host])) { - $user .= '@'.rcube_parse_host($domain[$host], $host); + $user .= '@'.rcube_utils::parse_host($domain[$host], $host); } else if (is_string($domain)) { - $user .= '@'.rcube_parse_host($domain, $host); + $user .= '@'.rcube_utils::parse_host($domain, $host); } } diff --git a/plugins/kolab_config/kolab_config.php b/plugins/kolab_config/kolab_config.php index cbe9313b..4fe8a7f3 100644 --- a/plugins/kolab_config/kolab_config.php +++ b/plugins/kolab_config/kolab_config.php @@ -40,7 +40,7 @@ class kolab_config extends rcube_plugin */ public function init() { - $rcmail = rcmail::get_instance(); + $rcmail = rcube::get_instance(); // Register spellchecker dictionary handlers if (strtolower($rcmail->config->get('spellcheck_dictionary')) != 'shared') { diff --git a/plugins/kolab_folders/kolab_folders.php b/plugins/kolab_folders/kolab_folders.php index 297c858d..6773b85c 100644 --- a/plugins/kolab_folders/kolab_folders.php +++ b/plugins/kolab_folders/kolab_folders.php @@ -39,7 +39,7 @@ class kolab_folders extends rcube_plugin function init() { self::$instance = $this; - $this->rc = rcmail::get_instance(); + $this->rc = rcube::get_instance(); // load required plugin $this->require_plugin('libkolab'); diff --git a/plugins/kolab_zpush/kolab_zpush.php b/plugins/kolab_zpush/kolab_zpush.php index b65f39ca..6f38182f 100644 --- a/plugins/kolab_zpush/kolab_zpush.php +++ b/plugins/kolab_zpush/kolab_zpush.php @@ -44,7 +44,7 @@ class kolab_zpush extends rcube_plugin */ public function init() { - $this->rc = rcmail::get_instance(); + $this->rc = rcube::get_instance(); $this->require_plugin('jqueryui'); $this->add_texts('localization/', true); diff --git a/plugins/kolab_zpush/kolab_zpush_ui.php b/plugins/kolab_zpush/kolab_zpush_ui.php index 4c99cf78..3d2fbcc4 100644 --- a/plugins/kolab_zpush/kolab_zpush_ui.php +++ b/plugins/kolab_zpush/kolab_zpush_ui.php @@ -30,7 +30,7 @@ class kolab_zpush_ui public function __construct($config) { $this->config = $config; - $this->rc = rcmail::get_instance(); + $this->rc = rcube::get_instance(); $skin = $this->rc->config->get('skin'); $this->config->include_stylesheet('skins/' . $skin . '/config.css'); @@ -146,8 +146,8 @@ class kolab_zpush_ui $classes = array('mailbox'); - if ($folder_class = rcmail_folder_classname($folder)) { - $foldername = rcube_label($folder_class); + if ($folder_class = $this->rc->folder_classname($folder)) { + $foldername = $this->rc->gettext($folder_class); $classes[] = $folder_class; } diff --git a/plugins/ldap_authentication/ldap_authentication.php b/plugins/ldap_authentication/ldap_authentication.php index d1561185..3dc9f667 100644 --- a/plugins/ldap_authentication/ldap_authentication.php +++ b/plugins/ldap_authentication/ldap_authentication.php @@ -51,19 +51,19 @@ class ldap_authentication extends rcube_plugin function authenticate($args) { if ($this->init_ldap()) { - $rcmail = rcmail::get_instance(); + $rcmail = rcube::get_instance(); $filter = $rcmail->config->get('ldap_authentication_filter'); $domain = $rcmail->config->get('username_domain'); // get username and host $user = $args['user']; - $host = rcube_parse_host($args['host']); + $host = rcube_utils::parse_host($args['host']); if (!empty($domain) && strpos($user, '@') === false) { if (is_array($domain) && isset($domain[$args['host']])) - $user .= '@'.rcube_parse_host($domain[$host], $host); + $user .= '@'.rcube_utils::parse_host($domain[$host], $host); else if (is_string($domain)) - $user .= '@'.rcube_parse_host($domain, $host); + $user .= '@'.rcube_utils::parse_host($domain, $host); } // replace variables in filter @@ -102,7 +102,7 @@ class ldap_authentication extends rcube_plugin return $this->ldap->ready; $this->load_config(); - $rcmail = rcmail::get_instance(); + $rcmail = rcube::get_instance(); $addressbook = $rcmail->config->get('ldap_authentication_addressbook'); diff --git a/plugins/libcalendaring/libcalendaring.php b/plugins/libcalendaring/libcalendaring.php index 2d530a34..ea174f25 100644 --- a/plugins/libcalendaring/libcalendaring.php +++ b/plugins/libcalendaring/libcalendaring.php @@ -72,7 +72,7 @@ class libcalendaring extends rcube_plugin { self::$instance = $this; - $this->rc = rcmail::get_instance(); + $this->rc = rcube::get_instance(); // set user's timezone $this->timezone = new DateTimeZone($this->rc->config->get('timezone', 'GMT')); @@ -529,7 +529,7 @@ class libcalendaring extends rcube_plugin 'html' => $content, 'name' => $attachment['name'], 'mimetype' => $attachment['mimetype'], - 'classname' => rcmail_filetype2classname($attachment['mimetype'], $attachment['name']), + 'classname' => rcube_utils::file2class($attachment['mimetype'], $attachment['name']), 'complete' => true), $uploadid); } else { // upload failed diff --git a/plugins/libkolab/bin/modcache.sh b/plugins/libkolab/bin/modcache.sh index 58086d09..04d36a58 100755 --- a/plugins/libkolab/bin/modcache.sh +++ b/plugins/libkolab/bin/modcache.sh @@ -56,7 +56,7 @@ $opts = get_opt(array( $opts['username'] = !empty($opts[1]) ? $opts[1] : $opts['user']; $action = $opts[0]; -$rcmail = rcmail::get_instance(); +$rcmail = rcube::get_instance(); /* diff --git a/plugins/odfviewer/odfviewer.php b/plugins/odfviewer/odfviewer.php index 3ffb5b1d..da967472 100644 --- a/plugins/odfviewer/odfviewer.php +++ b/plugins/odfviewer/odfviewer.php @@ -57,7 +57,7 @@ class odfviewer extends rcube_plugin if ($ua->ie && $ua->ver < 9) return; // extend list of mimetypes that should open in preview - $rcmail = rcmail::get_instance(); + $rcmail = rcube::get_instance(); if ($rcmail->action == 'preview' || $rcmail->action == 'show' || $rcmail->task == 'calendar' || $rcmail->task == 'tasks') { $mimetypes = $rcmail->config->get('client_mimetypes', 'text/plain,text/html,text/xml,image/jpeg,image/gif,image/png,application/x-javascript,application/pdf,application/x-shockwave-flash'); if (!is_array($mimetypes)) @@ -87,7 +87,7 @@ class odfviewer extends rcube_plugin } else { $fp = fopen($tempfn, 'w'); - $imap = rcmail::get_instance()->get_storage(); + $imap = rcube::get_instance()->get_storage(); $imap->get_message_part($args['uid'], $args['id'], $args['part'], false, $fp); fclose($fp); } @@ -138,7 +138,7 @@ class odfviewer extends rcube_plugin */ function gc_cleanup() { - $rcmail = rcmail::get_instance(); + $rcmail = rcube::get_instance(); $tmp = unslashify($this->tempdir); $expire = mktime() - 172800; // expire in 48 hours diff --git a/plugins/owncloud/owncloud.php b/plugins/owncloud/owncloud.php index 09edcee5..f43177a9 100644 --- a/plugins/owncloud/owncloud.php +++ b/plugins/owncloud/owncloud.php @@ -21,7 +21,7 @@ class owncloud extends rcube_plugin function init() { - $rcmail = rcmail::get_instance(); + $rcmail = rcube::get_instance(); // requires kolab_auth plugin if (empty($_SESSION['kolab_uid'])) { @@ -39,20 +39,20 @@ class owncloud extends rcube_plugin // add taskbar button $this->add_button(array( - 'command' => 'owncloud', - 'class' => 'button-owncloud', - 'classsel' => 'button-owncloud button-selected', - 'innerclass' => 'button-inner', - 'label' => 'owncloud.owncloud', + 'command' => 'owncloud', + 'class' => 'button-owncloud', + 'classsel' => 'button-owncloud button-selected', + 'innerclass' => 'button-inner', + 'label' => 'owncloud.owncloud', ), 'taskbar'); - // add style for taskbar button (must be here) and Help UI + // add style for taskbar button (must be here) and Help UI $this->include_stylesheet($this->local_skin_path()."/owncloud.css"); } function action() { - $rcmail = rcmail::get_instance(); + $rcmail = rcube::get_instance(); $rcmail->output->add_handlers(array('owncloudframe' => array($this, 'frame'))); $rcmail->output->set_pagetitle($this->gettext('owncloud')); @@ -61,7 +61,7 @@ class owncloud extends rcube_plugin function frame() { - $rcmail = rcmail::get_instance(); + $rcmail = rcube::get_instance(); $this->load_config(); diff --git a/plugins/piwik_analytics/piwik_analytics.php b/plugins/piwik_analytics/piwik_analytics.php index 27a2603f..4f69b7e2 100644 --- a/plugins/piwik_analytics/piwik_analytics.php +++ b/plugins/piwik_analytics/piwik_analytics.php @@ -36,7 +36,7 @@ class piwik_analytics extends rcube_plugin } function add_script($args) { - $rcmail = rcmail::get_instance(); + $rcmail = rcube::get_instance(); $exclude = $rcmail->config->get('piwik_analytics_exclude'); diff --git a/plugins/tasklist/drivers/tasklist_driver.php b/plugins/tasklist/drivers/tasklist_driver.php index f8107996..99e54534 100644 --- a/plugins/tasklist/drivers/tasklist_driver.php +++ b/plugins/tasklist/drivers/tasklist_driver.php @@ -251,7 +251,7 @@ abstract class tasklist_driver */ public function list_categories() { - $rcmail = rcmail::get_instance(); + $rcmail = rcube::get_instance(); return $rcmail->config->get('tasklist_categories', array()); } diff --git a/plugins/tasklist/tasklist.php b/plugins/tasklist/tasklist.php index f9ae1c07..08079464 100644 --- a/plugins/tasklist/tasklist.php +++ b/plugins/tasklist/tasklist.php @@ -63,7 +63,7 @@ class tasklist extends rcube_plugin { $this->require_plugin('libcalendaring'); - $this->rc = rcmail::get_instance(); + $this->rc = rcube::get_instance(); $this->lib = libcalendaring::get_instance(); $this->register_task('tasks', 'tasklist'); @@ -601,7 +601,7 @@ class tasklist extends rcube_plugin $rec['alarms_text'] = libcalendaring::alarms_text($rec['alarms']); foreach ((array)$rec['attachments'] as $k => $attachment) { - $rec['attachments'][$k]['classname'] = rcmail_filetype2classname($attachment['mimetype'], $attachment['name']); + $rec['attachments'][$k]['classname'] = rcube_utils::file2class($attachment['mimetype'], $attachment['name']); } if (in_array($rec['id'], $this->collapsed_tasks)) @@ -844,13 +844,13 @@ class tasklist extends rcube_plugin if ($attachment['status'] && !$attachment['abort']) { $id = $attachment['id']; - $attachment['classname'] = rcmail_filetype2classname($attachment['mimetype'], $attachment['name']); + $attachment['classname'] = rcube_utils::file2class($attachment['mimetype'], $attachment['name']); // store new attachment in session unset($attachment['status'], $attachment['abort'], $attachment['data']); $_SESSION[self::SESSION_KEY]['attachments'][$id] = $attachment; - $attachment['id'] = 'rcmfile' . $attachment['id']; # add prefix to consider it 'new' + $attachment['id'] = 'rcmfile' . $attachment['id']; // add prefix to consider it 'new' $task['attachments'][] = $attachment; } } diff --git a/plugins/tinymce_config/tinymce_config.php b/plugins/tinymce_config/tinymce_config.php index faa17f3d..e6e5828f 100644 --- a/plugins/tinymce_config/tinymce_config.php +++ b/plugins/tinymce_config/tinymce_config.php @@ -31,7 +31,7 @@ class tinymce_config extends rcube_plugin function config($args) { - $rcmail = rcmail::get_instance(); + $rcmail = rcube::get_instance(); $config = array( 'forced_root_block' => '',