From dfc57863d1b054534f8e0ce8e3babb38d4fe89cb Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Tue, 18 Dec 2012 09:45:20 +0100 Subject: Plugin API: Added message_before_send hook --- program/include/rcmail.php | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'program/include/rcmail.php') diff --git a/program/include/rcmail.php b/program/include/rcmail.php index 8e01a2155..249bd0559 100644 --- a/program/include/rcmail.php +++ b/program/include/rcmail.php @@ -934,15 +934,26 @@ class rcmail extends rcube * @param object $message Reference to Mail_MIME object * @param string $from Sender address string * @param array $mailto Array of recipient address strings - * @param array $smtp_error SMTP error array (reference) + * @param array $error SMTP error array (reference) * @param string $body_file Location of file with saved message body (reference), * used when delay_file_io is enabled - * @param array $smtp_opts SMTP options (e.g. DSN request) + * @param array $options SMTP options (e.g. DSN request) * * @return boolean Send status. */ - public function deliver_message(&$message, $from, $mailto, &$smtp_error, &$body_file = null, $smtp_opts = null) + public function deliver_message(&$message, $from, $mailto, &$error, &$body_file = null, $options = null) { + $plugin = $this->plugins->exec_hook('message_before_send', array( + 'message' => $message, + 'from' => $from, + 'mailto' => $mailto, + 'options' => $options, + )); + + $from = $plugin['from']; + $mailto = $plugin['mailto']; + $options = $plugin['options']; + $message = $plugin['message']; $headers = $message->headers(); // send thru SMTP server using custom SMTP library @@ -985,15 +996,15 @@ class rcmail extends rcube $this->smtp_init(true); } - $sent = $this->smtp->send_mail($from, $a_recipients, $smtp_headers, $msg_body, $smtp_opts); - $smtp_response = $this->smtp->get_response(); - $smtp_error = $this->smtp->get_error(); + $sent = $this->smtp->send_mail($from, $a_recipients, $smtp_headers, $msg_body, $options); + $response = $this->smtp->get_response(); + $error = $this->smtp->get_error(); // log error if (!$sent) { self::raise_error(array('code' => 800, 'type' => 'smtp', 'line' => __LINE__, 'file' => __FILE__, - 'message' => "SMTP error: ".join("\n", $smtp_response)), TRUE, FALSE); + 'message' => "SMTP error: ".join("\n", $response)), TRUE, FALSE); } } // send mail using PHP's mail() function @@ -1061,7 +1072,7 @@ class rcmail extends rcube $this->user->get_username(), $_SERVER['REMOTE_ADDR'], $mailto, - !empty($smtp_response) ? join('; ', $smtp_response) : '')); + !empty($response) ? join('; ', $response) : '')); } } -- cgit v1.2.3 From 4d7964d9101d08b5e7533cea50e52e07bf3f783a Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Fri, 18 Jan 2013 13:24:52 +0100 Subject: Improved folder path presentation in page title (use unified delimiter, localize path). E.g. folder "INBOX.test" will be displayed as "Inbox >> test" --- program/include/rcmail.php | 23 +++++++++++++++++++++-- program/steps/mail/func.inc | 8 ++++++-- program/steps/mail/list.inc | 1 - 3 files changed, 27 insertions(+), 5 deletions(-) (limited to 'program/include/rcmail.php') diff --git a/program/include/rcmail.php b/program/include/rcmail.php index 249bd0559..c734216ac 100644 --- a/program/include/rcmail.php +++ b/program/include/rcmail.php @@ -1677,12 +1677,31 @@ class rcmail extends rcube * Try to localize the given IMAP folder name. * UTF-7 decode it in case no localized text was found * - * @param string $name Folder name + * @param string $name Folder name + * @param bool $with_path Enable path localization * * @return string Localized folder name in UTF-8 encoding */ - public function localize_foldername($name) + public function localize_foldername($name, $with_path = true) { + // try to localize path of the folder + if ($with_path) { + $storage = $this->get_storage(); + $delimiter = $storage->get_hierarchy_delimiter(); + $path = explode($delimiter, $name); + $count = count($path); + + if ($count > 1) { + for ($i = 1; $i < $count; $i++) { + $folder = implode($delimiter, array_slice($path, 0, -$i)); + if ($folder_class = $this->folder_classname($folder)) { + $name = implode($delimiter, array_slice($path, $count - $i)); + return $this->gettext($folder_class) . $delimiter . rcube_charset::convert($name, 'UTF7-IMAP'); + } + } + } + } + if ($folder_class = $this->folder_classname($name)) { return $this->gettext($folder_class); } diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc index f82e60a36..6b8879dcf 100644 --- a/program/steps/mail/func.inc +++ b/program/steps/mail/func.inc @@ -89,11 +89,12 @@ if (empty($RCMAIL->action) || $RCMAIL->action == 'list') { } $threading = (bool) $RCMAIL->storage->get_threading(); + $delimiter = $RCMAIL->storage->get_hierarchy_delimiter(); // set current mailbox and some other vars in client environment $OUTPUT->set_env('mailbox', $mbox_name); $OUTPUT->set_env('pagesize', $RCMAIL->storage->get_pagesize()); - $OUTPUT->set_env('delimiter', $RCMAIL->storage->get_hierarchy_delimiter()); + $OUTPUT->set_env('delimiter', $delimiter); $OUTPUT->set_env('threading', $threading); $OUTPUT->set_env('threads', $threading || $RCMAIL->storage->get_capability('THREAD')); $OUTPUT->set_env('preview_pane_mark_read', $RCMAIL->config->get('preview_pane_mark_read', 0)); @@ -121,7 +122,10 @@ if (empty($RCMAIL->action) || $RCMAIL->action == 'list') { 'movingmessage', 'copyingmessage', 'deletingmessage', 'markingmessage', 'copy', 'move', 'quota'); - $OUTPUT->set_pagetitle(rcmail_localize_foldername($RCMAIL->storage->mod_folder($mbox_name))); + $pagetitle = $RCMAIL->localize_foldername($RCMAIL->storage->mod_folder($mbox_name), true); + $pagetitle = str_replace($delimiter, " \xC2\xBB ", $pagetitle); + + $OUTPUT->set_pagetitle($pagetitle); } /** diff --git a/program/steps/mail/list.inc b/program/steps/mail/list.inc index b8c3ee021..a2380131a 100644 --- a/program/steps/mail/list.inc +++ b/program/steps/mail/list.inc @@ -97,7 +97,6 @@ $OUTPUT->set_env('threading', $threading); $OUTPUT->set_env('current_page', $count ? $RCMAIL->storage->get_page() : 1); $OUTPUT->set_env('exists', $RCMAIL->storage->count($mbox_name, 'EXISTS')); $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($count), $mbox_name); -$OUTPUT->command('set_mailboxname', rcmail_get_mailbox_name_text()); // add message rows rcmail_js_message_list($a_headers, FALSE, $cols); -- cgit v1.2.3 From 61be822d62ea245b7f54ad313f49a956ab49076d Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Fri, 18 Jan 2013 15:24:49 +0100 Subject: Remove deprecated functions (from bc.php file) usage in plugins --- plugins/acl/acl.php | 42 +-- plugins/archive/archive.php | 4 +- .../database_attachments/database_attachments.php | 10 +- plugins/enigma/enigma.php | 26 +- plugins/enigma/lib/enigma_engine.php | 24 +- plugins/enigma/lib/enigma_ui.php | 26 +- plugins/hide_blockquote/hide_blockquote.php | 2 +- .../http_authentication/http_authentication.php | 2 +- plugins/managesieve/Changelog | 1 + plugins/managesieve/lib/Roundcube/rcube_sieve.php | 2 +- plugins/managesieve/managesieve.php | 354 ++++++++++----------- plugins/markasjunk/markasjunk.php | 4 +- plugins/new_user_dialog/new_user_dialog.php | 16 +- plugins/new_user_identity/new_user_identity.php | 2 +- plugins/newmail_notifier/newmail_notifier.php | 4 +- plugins/password/drivers/chpasswd.php | 2 +- plugins/password/drivers/dbmail.php | 2 +- plugins/password/drivers/directadmin.php | 2 +- plugins/password/drivers/expect.php | 2 +- plugins/password/drivers/hmail.php | 12 +- plugins/password/drivers/ldap.php | 2 +- plugins/password/drivers/ldap_simple.php | 2 +- plugins/password/drivers/pam.php | 4 +- plugins/password/drivers/pw_usermod.php | 2 +- plugins/password/drivers/sasl.php | 2 +- plugins/password/drivers/smb.php | 2 +- plugins/password/drivers/sql.php | 14 +- plugins/password/drivers/virtualmin.php | 2 +- plugins/password/drivers/xmail.php | 4 +- plugins/password/password.php | 32 +- .../squirrelmail_usercopy.php | 16 +- .../subscriptions_option/subscriptions_option.php | 2 +- plugins/userinfo/userinfo.php | 24 +- plugins/vcard_attachments/vcard_attachments.php | 12 +- plugins/virtuser_file/virtuser_file.php | 2 +- plugins/virtuser_query/virtuser_query.php | 62 ++-- plugins/zipdownload/zipdownload.php | 29 +- program/include/rcmail.php | 2 +- 38 files changed, 380 insertions(+), 374 deletions(-) (limited to 'program/include/rcmail.php') diff --git a/plugins/acl/acl.php b/plugins/acl/acl.php index 1952dad49..5ae9e4e0a 100644 --- a/plugins/acl/acl.php +++ b/plugins/acl/acl.php @@ -55,7 +55,7 @@ class acl extends rcube_plugin */ function acl_actions() { - $action = trim(get_input_value('_act', RCUBE_INPUT_GPC)); + $action = trim(rcube_utils::get_input_value('_act', rcube_utils::INPUT_GPC)); // Connect to IMAP $this->rc->storage_init(); @@ -85,8 +85,8 @@ class acl extends rcube_plugin { $this->load_config(); - $search = get_input_value('_search', RCUBE_INPUT_GPC, true); - $sid = get_input_value('_id', RCUBE_INPUT_GPC); + $search = rcube_utils::get_input_value('_search', rcube_utils::INPUT_GPC, true); + $sid = rcube_utils::get_input_value('_id', rcube_utils::INPUT_GPC); $users = array(); if ($this->init_ldap()) { @@ -157,12 +157,12 @@ class acl extends rcube_plugin // add Info fieldset if it doesn't exist if (!isset($args['form']['props']['fieldsets']['info'])) $args['form']['props']['fieldsets']['info'] = array( - 'name' => rcube_label('info'), + 'name' => $this->rc->gettext('info'), 'content' => array()); // Display folder rights to 'Info' fieldset $args['form']['props']['fieldsets']['info']['content']['myrights'] = array( - 'label' => Q($this->gettext('myrights')), + 'label' => rcube::Q($this->gettext('myrights')), 'value' => $this->acl2text($myrights) ); @@ -186,7 +186,7 @@ class acl extends rcube_plugin $this->rc->output->add_label('autocompletechars', 'autocompletemore'); $args['form']['sharing'] = array( - 'name' => Q($this->gettext('sharing')), + 'name' => rcube::Q($this->gettext('sharing')), 'content' => $this->rc->output->parse('acl.table', false, false), ); @@ -392,14 +392,14 @@ class acl extends rcube_plugin // filter out virtual rights (c or d) the server may return $userrights = array_intersect($rights, $supported); - $userid = html_identifier($user); + $userid = rcube_utils::html_identifier($user); if (!empty($this->specials) && in_array($user, $this->specials)) { $user = $this->gettext($user); } $table->add_row(array('id' => 'rcmrow'.$userid)); - $table->add('user', Q($user)); + $table->add('user', rcube::Q($user)); foreach ($items as $key => $right) { $in = $this->acl_compare($userrights, $right); @@ -427,10 +427,10 @@ class acl extends rcube_plugin */ private function action_save() { - $mbox = trim(get_input_value('_mbox', RCUBE_INPUT_GPC, true)); // UTF7-IMAP - $user = trim(get_input_value('_user', RCUBE_INPUT_GPC)); - $acl = trim(get_input_value('_acl', RCUBE_INPUT_GPC)); - $oldid = trim(get_input_value('_old', RCUBE_INPUT_GPC)); + $mbox = trim(rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_GPC, true)); // UTF7-IMAP + $user = trim(rcube_utils::get_input_value('_user', rcube_utils::INPUT_GPC)); + $acl = trim(rcube_utils::get_input_value('_acl', rcube_utils::INPUT_GPC)); + $oldid = trim(rcube_utils::get_input_value('_old', rcube_utils::INPUT_GPC)); $acl = array_intersect(str_split($acl), $this->rights_supported()); $users = $oldid ? array($user) : explode(',', $user); @@ -443,7 +443,7 @@ class acl extends rcube_plugin } else { if (!strpos($user, '@') && ($realm = $this->get_realm())) { - $user .= '@' . rcube_idn_to_ascii(preg_replace('/^@/', '', $realm)); + $user .= '@' . rcube_utils::idn_to_ascii(preg_replace('/^@/', '', $realm)); } $username = $user; } @@ -454,7 +454,7 @@ class acl extends rcube_plugin if ($user != $_SESSION['username'] && $username != $_SESSION['username']) { if ($this->rc->storage->set_acl($mbox, $user, $acl)) { - $ret = array('id' => html_identifier($user), + $ret = array('id' => rcube_utils::html_identifier($user), 'username' => $username, 'acl' => implode($acl), 'old' => $oldid); $this->rc->output->command('acl_update', $ret); $result++; @@ -475,15 +475,15 @@ class acl extends rcube_plugin */ private function action_delete() { - $mbox = trim(get_input_value('_mbox', RCUBE_INPUT_GPC, true)); //UTF7-IMAP - $user = trim(get_input_value('_user', RCUBE_INPUT_GPC)); + $mbox = trim(rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_GPC, true)); //UTF7-IMAP + $user = trim(rcube_utils::get_input_value('_user', rcube_utils::INPUT_GPC)); $user = explode(',', $user); foreach ($user as $u) { $u = trim($u); if ($this->rc->storage->delete_acl($mbox, $u)) { - $this->rc->output->command('acl_remove_row', html_identifier($u)); + $this->rc->output->command('acl_remove_row', rcube_utils::html_identifier($u)); } else { $error = true; @@ -507,8 +507,8 @@ class acl extends rcube_plugin return; } - $this->mbox = trim(get_input_value('_mbox', RCUBE_INPUT_GPC, true)); // UTF7-IMAP - $advanced = trim(get_input_value('_mode', RCUBE_INPUT_GPC)); + $this->mbox = trim(rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_GPC, true)); // UTF7-IMAP + $advanced = trim(rcube_utils::get_input_value('_mode', rcube_utils::INPUT_GPC)); $advanced = $advanced == 'advanced' ? true : false; // Save state in user preferences @@ -543,12 +543,12 @@ class acl extends rcube_plugin foreach ($supported as $right) { if (in_array($right, $rights)) { - $list[] = html::tag('li', null, Q($this->gettext('acl' . $right))); + $list[] = html::tag('li', null, rcube::Q($this->gettext('acl' . $right))); } } if (count($list) == count($supported)) - return Q($this->gettext('aclfull')); + return rcube::Q($this->gettext('aclfull')); return html::tag('ul', $attrib, implode("\n", $list)); } diff --git a/plugins/archive/archive.php b/plugins/archive/archive.php index 0a298cbe3..9b03cb186 100644 --- a/plugins/archive/archive.php +++ b/plugins/archive/archive.php @@ -104,7 +104,7 @@ class archive extends rcube_plugin // load folders list when needed if ($CURR_SECTION) - $select = rcmail_mailbox_select(array('noselection' => '---', 'realnames' => true, + $select = $rcmail->folder_selector(array('noselection' => '---', 'realnames' => true, 'maxlength' => 30, 'exceptions' => array('INBOX'), 'folder_filter' => 'mail', 'folder_rights' => 'w')); else $select = new html_select(); @@ -121,7 +121,7 @@ class archive extends rcube_plugin function save_prefs($args) { if ($args['section'] == 'folders') { - $args['prefs']['archive_mbox'] = get_input_value('_archive_mbox', RCUBE_INPUT_POST); + $args['prefs']['archive_mbox'] = rcube_utils::get_input_value('_archive_mbox', rcube_utils::INPUT_POST); return $args; } } diff --git a/plugins/database_attachments/database_attachments.php b/plugins/database_attachments/database_attachments.php index 079f4e567..2511dbbb2 100644 --- a/plugins/database_attachments/database_attachments.php +++ b/plugins/database_attachments/database_attachments.php @@ -46,7 +46,7 @@ class database_attachments extends filesystem_attachments $data = base64_encode($data); $status = $rcmail->db->query( - "INSERT INTO ".get_table_name('cache') + "INSERT INTO ".$rcmail->db->table_name('cache') ." (created, user_id, cache_key, data)" ." VALUES (".$rcmail->db->now().", ?, ?, ?)", $_SESSION['user_id'], @@ -82,7 +82,7 @@ class database_attachments extends filesystem_attachments $data = base64_encode($args['data']); $status = $rcmail->db->query( - "INSERT INTO ".get_table_name('cache') + "INSERT INTO ".$rcmail->db->table_name('cache') ." (created, user_id, cache_key, data)" ." VALUES (".$rcmail->db->now().", ?, ?, ?)", $_SESSION['user_id'], @@ -106,7 +106,7 @@ class database_attachments extends filesystem_attachments $args['status'] = false; $rcmail = rcmail::get_instance(); $status = $rcmail->db->query( - "DELETE FROM ".get_table_name('cache') + "DELETE FROM ".$rcmail->db->table_name('cache') ." WHERE user_id = ?" ." AND cache_key = ?", $_SESSION['user_id'], @@ -139,7 +139,7 @@ class database_attachments extends filesystem_attachments $sql_result = $rcmail->db->query( "SELECT data" - ." FROM ".get_table_name('cache') + ." FROM ".$rcmail->db->table_name('cache') ." WHERE user_id=?" ." AND cache_key=?", $_SESSION['user_id'], @@ -161,7 +161,7 @@ class database_attachments extends filesystem_attachments $prefix = $this->cache_prefix . $args['group']; $rcmail = rcmail::get_instance(); $rcmail->db->query( - "DELETE FROM ".get_table_name('cache') + "DELETE FROM ".$rcmail->db->table_name('cache') ." WHERE user_id = ?" ." AND cache_key LIKE '{$prefix}%'", $_SESSION['user_id']); diff --git a/plugins/enigma/enigma.php b/plugins/enigma/enigma.php index a4009ce26..c96b94620 100644 --- a/plugins/enigma/enigma.php +++ b/plugins/enigma/enigma.php @@ -79,7 +79,7 @@ class enigma extends rcube_plugin $this->register_action('plugin.enigma', array($this, 'preferences_ui')); // grab keys/certs management iframe requests - $section = get_input_value('_section', RCUBE_INPUT_GET); + $section = rcube_utils::get_input_value('_section', rcube_utils::INPUT_GET); if ($this->rc->action == 'edit-prefs' && preg_match('/^enigma(certs|keys)/', $section)) { $this->load_ui(); $this->ui->init($section); @@ -230,7 +230,7 @@ class enigma extends rcube_plugin { if ($p['section'] == 'enigmasettings') { $a['prefs'] = array( -// 'dummy' => get_input_value('_dummy', RCUBE_INPUT_POST), +// 'dummy' => rcube_utils::get_input_value('_dummy', rcube_utils::INPUT_POST), ); } @@ -285,16 +285,16 @@ class enigma extends rcube_plugin $attrib['class'] = 'enigmaerror'; $code = $status->getCode(); if ($code == enigma_error::E_KEYNOTFOUND) - $msg = Q(str_replace('$keyid', enigma_key::format_id($status->getData('id')), + $msg = rcube::Q(str_replace('$keyid', enigma_key::format_id($status->getData('id')), $this->gettext('decryptnokey'))); else if ($code == enigma_error::E_BADPASS) - $msg = Q($this->gettext('decryptbadpass')); + $msg = rcube::Q($this->gettext('decryptbadpass')); else - $msg = Q($this->gettext('decrypterror')); + $msg = rcube::Q($this->gettext('decrypterror')); } else { $attrib['class'] = 'enigmanotice'; - $msg = Q($this->gettext('decryptok')); + $msg = rcube::Q($this->gettext('decryptok')); } $p['prefix'] .= html::div($attrib, $msg); @@ -315,27 +315,27 @@ class enigma extends rcube_plugin if ($sig->valid) { $attrib['class'] = 'enigmanotice'; $sender = ($sig->name ? $sig->name . ' ' : '') . '<' . $sig->email . '>'; - $msg = Q(str_replace('$sender', $sender, $this->gettext('sigvalid'))); + $msg = rcube::Q(str_replace('$sender', $sender, $this->gettext('sigvalid'))); } else { $attrib['class'] = 'enigmawarning'; $sender = ($sig->name ? $sig->name . ' ' : '') . '<' . $sig->email . '>'; - $msg = Q(str_replace('$sender', $sender, $this->gettext('siginvalid'))); + $msg = rcube::Q(str_replace('$sender', $sender, $this->gettext('siginvalid'))); } } else if ($sig->getCode() == enigma_error::E_KEYNOTFOUND) { $attrib['class'] = 'enigmawarning'; - $msg = Q(str_replace('$keyid', enigma_key::format_id($sig->getData('id')), + $msg = rcube::Q(str_replace('$keyid', enigma_key::format_id($sig->getData('id')), $this->gettext('signokey'))); } else { $attrib['class'] = 'enigmaerror'; - $msg = Q($this->gettext('sigerror')); + $msg = rcube::Q($this->gettext('sigerror')); } /* $msg .= ' ' . html::a(array('href' => "#sigdetails", - 'onclick' => JS_OBJECT_NAME.".command('enigma-sig-details')"), - Q($this->gettext('showdetails'))); + 'onclick' => rcmail_output::JS_OBJECT_NAME.".command('enigma-sig-details')"), + rcube::Q($this->gettext('showdetails'))); */ // test // $msg .= '
'.$sig->body.'
'; @@ -433,7 +433,7 @@ class enigma extends rcube_plugin $p['content'] .= html::p(array('style' => $style), html::a(array( 'href' => "#", - 'onclick' => "return ".JS_OBJECT_NAME.".enigma_import_attachment('".JQ($part)."')", + 'onclick' => "return ".rcmail_output::JS_OBJECT_NAME.".enigma_import_attachment('".rcube::JQ($part)."')", 'title' => $this->gettext('keyattimport')), html::img(array('src' => $this->url('skins/classic/key_add.png'), 'style' => "vertical-align:middle"))) . ' ' . html::span(null, $this->gettext('keyattfound'))); diff --git a/plugins/enigma/lib/enigma_engine.php b/plugins/enigma/lib/enigma_engine.php index 89cb4b796..220d6c0b3 100644 --- a/plugins/enigma/lib/enigma_engine.php +++ b/plugins/enigma/lib/enigma_engine.php @@ -65,7 +65,7 @@ class enigma_engine $this->pgp_driver = new $driver($username); if (!$this->pgp_driver) { - raise_error(array( + rcube::raise_error(array( 'code' => 600, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "Enigma plugin: Unable to load PGP driver: $driver" @@ -76,7 +76,7 @@ class enigma_engine $result = $this->pgp_driver->init(); if ($result instanceof enigma_error) { - raise_error(array( + rcube::raise_error(array( 'code' => 600, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "Enigma plugin: ".$result->getMessage() @@ -102,7 +102,7 @@ class enigma_engine $this->smime_driver = new $driver($username); if (!$this->smime_driver) { - raise_error(array( + rcube::raise_error(array( 'code' => 600, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "Enigma plugin: Unable to load S/MIME driver: $driver" @@ -113,7 +113,7 @@ class enigma_engine $result = $this->smime_driver->init(); if ($result instanceof enigma_error) { - raise_error(array( + rcube::raise_error(array( 'code' => 600, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "Enigma plugin: ".$result->getMessage() @@ -378,7 +378,7 @@ class enigma_engine $sig = $this->pgp_driver->verify($msg_body, $sig_body); if (($sig instanceof enigma_error) && $sig->getCode() != enigma_error::E_KEYNOTFOUND) - raise_error(array( + rcube::raise_error(array( 'code' => 600, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "Enigma plugin: " . $error->getMessage() @@ -407,7 +407,7 @@ class enigma_engine if ($result instanceof enigma_error) { $err_code = $result->getCode(); if (!in_array($err_code, array(enigma_error::E_KEYNOTFOUND, enigma_error::E_BADPASS))) - raise_error(array( + rcube::raise_error(array( 'code' => 600, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "Enigma plugin: " . $result->getMessage() @@ -432,7 +432,7 @@ class enigma_engine $result = $this->pgp_driver->list_keys($pattern); if ($result instanceof enigma_error) { - raise_error(array( + rcube::raise_error(array( 'code' => 600, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "Enigma plugin: " . $result->getMessage() @@ -455,7 +455,7 @@ class enigma_engine $result = $this->pgp_driver->get_key($keyid); if ($result instanceof enigma_error) { - raise_error(array( + rcube::raise_error(array( 'code' => 600, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "Enigma plugin: " . $result->getMessage() @@ -479,7 +479,7 @@ class enigma_engine $result = $this->pgp_driver->import($content, $isfile); if ($result instanceof enigma_error) { - raise_error(array( + rcube::raise_error(array( 'code' => 600, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "Enigma plugin: " . $result->getMessage() @@ -498,9 +498,9 @@ class enigma_engine */ function import_file() { - $uid = get_input_value('_uid', RCUBE_INPUT_POST); - $mbox = get_input_value('_mbox', RCUBE_INPUT_POST); - $mime_id = get_input_value('_part', RCUBE_INPUT_POST); + $uid = rcube_utils::get_input_value('_uid', rcube_utils::INPUT_POST); + $mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST); + $mime_id = rcube_utils::get_input_value('_part', rcube_utils::INPUT_POST); if ($uid && $mime_id) { $part = $this->rc->storage->get_message_part($uid, $mime_id); diff --git a/plugins/enigma/lib/enigma_ui.php b/plugins/enigma/lib/enigma_ui.php index dc3580872..47366b7e8 100644 --- a/plugins/enigma/lib/enigma_ui.php +++ b/plugins/enigma/lib/enigma_ui.php @@ -49,7 +49,7 @@ class enigma_ui // Enigma actions if ($this->rc->action == 'plugin.enigma') { - $action = get_input_value('_a', RCUBE_INPUT_GPC); + $action = rcube_utils::get_input_value('_a', rcube_utils::INPUT_GPC); switch ($action) { case 'keyedit': @@ -152,7 +152,7 @@ class enigma_ui $a_show_cols = array('name'); // create XHTML table - $out = rcube_table_output($attrib, array(), $a_show_cols, 'id'); + $out = $this->rc->table_output($attrib, array(), $a_show_cols, 'id'); // set client env $this->rc->output->add_gui_object('keyslist', $attrib['id']); @@ -172,8 +172,8 @@ class enigma_ui $this->enigma->load_engine(); $pagesize = $this->rc->config->get('pagesize', 100); - $page = max(intval(get_input_value('_p', RCUBE_INPUT_GPC)), 1); - $search = get_input_value('_q', RCUBE_INPUT_GPC); + $page = max(intval(rcube_utils::get_input_value('_p', rcube_utils::INPUT_GPC)), 1); + $search = rcube_utils::get_input_value('_q', rcube_utils::INPUT_GPC); // define list of cols to be displayed $a_show_cols = array('name'); @@ -202,7 +202,7 @@ class enigma_ui // Add rows foreach($list as $idx => $key) { $this->rc->output->command('enigma_add_list_row', - array('name' => Q($key->name), 'id' => $key->id)); + array('name' => rcube::Q($key->name), 'id' => $key->id)); } } } @@ -261,7 +261,7 @@ class enigma_ui */ private function key_info() { - $id = get_input_value('_id', RCUBE_INPUT_GET); + $id = rcube_utils::get_input_value('_id', rcube_utils::INPUT_GET); $this->enigma->load_engine(); $res = $this->enigma->engine->get_key($id); @@ -288,7 +288,7 @@ class enigma_ui */ function tpl_key_name($attrib) { - return Q($this->data->name); + return rcube::Q($this->data->name); } /** @@ -301,7 +301,7 @@ class enigma_ui // Key user ID $table->add('title', $this->enigma->gettext('keyuserid')); - $table->add(null, Q($this->data->name)); + $table->add(null, rcube::Q($this->data->name)); // Key ID $table->add('title', $this->enigma->gettext('keyid')); $table->add(null, $this->data->subkeys[0]->get_short_id()); @@ -369,7 +369,7 @@ class enigma_ui else if ($err = $_FILES['_file']['error']) { if ($err == UPLOAD_ERR_INI_SIZE || $err == UPLOAD_ERR_FORM_SIZE) { $this->rc->output->show_message('filesizeerror', 'error', - array('size' => show_bytes(parse_bytes(ini_get('upload_max_filesize'))))); + array('size' => $this->rc->show_bytes(parse_bytes(ini_get('upload_max_filesize'))))); } else { $this->rc->output->show_message('fileuploaderror', 'error'); } @@ -394,7 +394,7 @@ class enigma_ui 'id' => 'rcmimportfile', 'size' => 30)); $form = html::p(null, - Q($this->enigma->gettext('keyimporttext'), 'show') + rcube::Q($this->enigma->gettext('keyimporttext'), 'show') . html::br() . html::br() . $upload->show() ); @@ -433,15 +433,15 @@ class enigma_ui $chbox = new html_checkbox(array('value' => 1)); $menu->add(null, html::label(array('for' => 'enigmadefaultopt'), - Q($this->enigma->gettext('identdefault')))); + rcube::Q($this->enigma->gettext('identdefault')))); $menu->add(null, $chbox->show(1, array('name' => '_enigma_default', 'id' => 'enigmadefaultopt'))); $menu->add(null, html::label(array('for' => 'enigmasignopt'), - Q($this->enigma->gettext('signmsg')))); + rcube::Q($this->enigma->gettext('signmsg')))); $menu->add(null, $chbox->show(1, array('name' => '_enigma_sign', 'id' => 'enigmasignopt'))); $menu->add(null, html::label(array('for' => 'enigmacryptopt'), - Q($this->enigma->gettext('encryptmsg')))); + rcube::Q($this->enigma->gettext('encryptmsg')))); $menu->add(null, $chbox->show(1, array('name' => '_enigma_crypt', 'id' => 'enigmacryptopt'))); $menu = html::div(array('id' => 'enigmamenu', 'class' => 'popupmenu'), diff --git a/plugins/hide_blockquote/hide_blockquote.php b/plugins/hide_blockquote/hide_blockquote.php index 7af163dcd..1168656fd 100644 --- a/plugins/hide_blockquote/hide_blockquote.php +++ b/plugins/hide_blockquote/hide_blockquote.php @@ -69,7 +69,7 @@ class hide_blockquote extends rcube_plugin function save_prefs($args) { if ($args['section'] == 'mailview') { - $args['prefs']['hide_blockquote_limit'] = (int) get_input_value('_hide_blockquote_limit', RCUBE_INPUT_POST); + $args['prefs']['hide_blockquote_limit'] = (int) rcube_utils::get_input_value('_hide_blockquote_limit', rcube_utils::INPUT_POST); } return $args; diff --git a/plugins/http_authentication/http_authentication.php b/plugins/http_authentication/http_authentication.php index a94b6121a..57227cb03 100644 --- a/plugins/http_authentication/http_authentication.php +++ b/plugins/http_authentication/http_authentication.php @@ -53,7 +53,7 @@ class http_authentication extends rcube_plugin $host = rcmail::get_instance()->config->get('http_authentication_host'); if (is_string($host) && trim($host) !== '') - $args['host'] = rcube_idn_to_ascii(rcube_parse_host($host)); + $args['host'] = rcube_utils::idn_to_ascii(rcube_utils::parse_host($host)); // Allow entering other user data in login form, // e.g. after log out (#1487953) diff --git a/plugins/managesieve/Changelog b/plugins/managesieve/Changelog index 19799a302..d8baf63ef 100644 --- a/plugins/managesieve/Changelog +++ b/plugins/managesieve/Changelog @@ -1,4 +1,5 @@ - Support tls:// prefix in managesieve_host option +- Removed depracated functions usage * version 6.1 [2012-12-21] ----------------------------------------------------------- diff --git a/plugins/managesieve/lib/Roundcube/rcube_sieve.php b/plugins/managesieve/lib/Roundcube/rcube_sieve.php index 4f66bf029..736f73146 100644 --- a/plugins/managesieve/lib/Roundcube/rcube_sieve.php +++ b/plugins/managesieve/lib/Roundcube/rcube_sieve.php @@ -379,6 +379,6 @@ class rcube_sieve */ public function debug_handler(&$sieve, $message) { - write_log('sieve', preg_replace('/\r\n$/', '', $message)); + rcube::write_log('sieve', preg_replace('/\r\n$/', '', $message)); } } diff --git a/plugins/managesieve/managesieve.php b/plugins/managesieve/managesieve.php index d30404ac7..8f50cd5a2 100644 --- a/plugins/managesieve/managesieve.php +++ b/plugins/managesieve/managesieve.php @@ -205,8 +205,8 @@ class managesieve extends rcube_plugin $port = $this->rc->config->get('managesieve_port'); $tls = $this->rc->config->get('managesieve_usetls', false); - $host = rcube_parse_host($host); - $host = rcube_idn_to_ascii($host); + $host = rcube_utils::parse_host($host); + $host = rcube_utils::idn_to_ascii($host); // remove tls:// prefix, set TLS flag if (($host = preg_replace('|^tls://|i', '', $host, 1, $cnt)) && $cnt) { @@ -252,7 +252,7 @@ class managesieve extends rcube_plugin $list = $this->list_scripts(); if (!empty($_GET['_set']) || !empty($_POST['_set'])) { - $script_name = get_input_value('_set', RCUBE_INPUT_GPC, true); + $script_name = rcube_utils::get_input_value('_set', rcube_utils::INPUT_GPC, true); } else if (!empty($_SESSION['managesieve_current'])) { $script_name = $_SESSION['managesieve_current']; @@ -304,7 +304,7 @@ class managesieve extends rcube_plugin break; } - raise_error(array('code' => 403, 'type' => 'php', + rcube::raise_error(array('code' => 403, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "Unable to connect to managesieve on $host:$port"), true, false); @@ -329,8 +329,8 @@ class managesieve extends rcube_plugin $error = $this->managesieve_start(); // Handle user requests - if ($action = get_input_value('_act', RCUBE_INPUT_GPC)) { - $fid = (int) get_input_value('_fid', RCUBE_INPUT_POST); + if ($action = rcube_utils::get_input_value('_act', rcube_utils::INPUT_GPC)) { + $fid = (int) rcube_utils::get_input_value('_fid', rcube_utils::INPUT_POST); if ($action == 'delete' && !$error) { if (isset($this->script[$fid])) { @@ -347,7 +347,7 @@ class managesieve extends rcube_plugin } else if ($action == 'move' && !$error) { if (isset($this->script[$fid])) { - $to = (int) get_input_value('_to', RCUBE_INPUT_POST); + $to = (int) rcube_utils::get_input_value('_to', rcube_utils::INPUT_POST); $rule = $this->script[$fid]; // remove rule @@ -408,7 +408,7 @@ class managesieve extends rcube_plugin } } else if ($action == 'setact' && !$error) { - $script_name = get_input_value('_set', RCUBE_INPUT_GPC, true); + $script_name = rcube_utils::get_input_value('_set', rcube_utils::INPUT_GPC, true); $result = $this->activate_script($script_name); $kep14 = $this->rc->config->get('managesieve_kolab_master'); @@ -422,7 +422,7 @@ class managesieve extends rcube_plugin } } else if ($action == 'deact' && !$error) { - $script_name = get_input_value('_set', RCUBE_INPUT_GPC, true); + $script_name = rcube_utils::get_input_value('_set', rcube_utils::INPUT_GPC, true); $result = $this->deactivate_script($script_name); if ($result === true) { @@ -435,7 +435,7 @@ class managesieve extends rcube_plugin } } else if ($action == 'setdel' && !$error) { - $script_name = get_input_value('_set', RCUBE_INPUT_GPC, true); + $script_name = rcube_utils::get_input_value('_set', rcube_utils::INPUT_GPC, true); $result = $this->remove_script($script_name); if ($result === true) { @@ -448,7 +448,7 @@ class managesieve extends rcube_plugin } } else if ($action == 'setget') { - $script_name = get_input_value('_set', RCUBE_INPUT_GPC, true); + $script_name = rcube_utils::get_input_value('_set', rcube_utils::INPUT_GPC, true); $script = $this->sieve->get_script($script_name); if (PEAR::isError($script)) @@ -479,14 +479,14 @@ class managesieve extends rcube_plugin $this->rc->output->command('managesieve_updatelist', 'list', array('list' => $result)); } else if ($action == 'ruleadd') { - $rid = get_input_value('_rid', RCUBE_INPUT_GPC); + $rid = rcube_utils::get_input_value('_rid', rcube_utils::INPUT_GPC); $id = $this->genid(); $content = $this->rule_div($fid, $id, false); $this->rc->output->command('managesieve_rulefill', $content, $id, $rid); } else if ($action == 'actionadd') { - $aid = get_input_value('_aid', RCUBE_INPUT_GPC); + $aid = rcube_utils::get_input_value('_aid', rcube_utils::INPUT_GPC); $id = $this->genid(); $content = $this->action_div($fid, $id, false); @@ -497,7 +497,7 @@ class managesieve extends rcube_plugin } else if ($this->rc->task == 'mail') { // Initialize the form - $rules = get_input_value('r', RCUBE_INPUT_GET); + $rules = rcube_utils::get_input_value('r', rcube_utils::INPUT_GET); if (!empty($rules)) { $i = 0; foreach ($rules as $rule) { @@ -570,9 +570,9 @@ class managesieve extends rcube_plugin } // filters set add action else if (!empty($_POST['_newset'])) { - $name = get_input_value('_name', RCUBE_INPUT_POST, true); - $copy = get_input_value('_copy', RCUBE_INPUT_POST, true); - $from = get_input_value('_from', RCUBE_INPUT_POST); + $name = rcube_utils::get_input_value('_name', rcube_utils::INPUT_POST, true); + $copy = rcube_utils::get_input_value('_copy', rcube_utils::INPUT_POST, true); + $from = rcube_utils::get_input_value('_from', rcube_utils::INPUT_POST); $exceptions = $this->rc->config->get('managesieve_filename_exceptions'); $kolab = $this->rc->config->get('managesieve_kolab_master'); $name_uc = mb_strtolower($name); @@ -609,9 +609,9 @@ class managesieve extends rcube_plugin $err = $_FILES['_file']['error']; if ($err == UPLOAD_ERR_INI_SIZE || $err == UPLOAD_ERR_FORM_SIZE) { - $msg = rcube_label(array('name' => 'filesizeerror', + $msg = $this->rc->gettext(array('name' => 'filesizeerror', 'vars' => array('size' => - show_bytes(parse_bytes(ini_get('upload_max_filesize')))))); + $this->rc->show_bytes(parse_bytes(ini_get('upload_max_filesize')))))); } else { $this->errors['file'] = $this->gettext('fileuploaderror'); @@ -640,40 +640,40 @@ class managesieve extends rcube_plugin } // filter add/edit action else if (isset($_POST['_name'])) { - $name = trim(get_input_value('_name', RCUBE_INPUT_POST, true)); - $fid = trim(get_input_value('_fid', RCUBE_INPUT_POST)); - $join = trim(get_input_value('_join', RCUBE_INPUT_POST)); + $name = trim(rcube_utils::get_input_value('_name', rcube_utils::INPUT_POST, true)); + $fid = trim(rcube_utils::get_input_value('_fid', rcube_utils::INPUT_POST)); + $join = trim(rcube_utils::get_input_value('_join', rcube_utils::INPUT_POST)); // and arrays - $headers = get_input_value('_header', RCUBE_INPUT_POST); - $cust_headers = get_input_value('_custom_header', RCUBE_INPUT_POST); - $ops = get_input_value('_rule_op', RCUBE_INPUT_POST); - $sizeops = get_input_value('_rule_size_op', RCUBE_INPUT_POST); - $sizeitems = get_input_value('_rule_size_item', RCUBE_INPUT_POST); - $sizetargets = get_input_value('_rule_size_target', RCUBE_INPUT_POST); - $targets = get_input_value('_rule_target', RCUBE_INPUT_POST, true); - $mods = get_input_value('_rule_mod', RCUBE_INPUT_POST); - $mod_types = get_input_value('_rule_mod_type', RCUBE_INPUT_POST); - $body_trans = get_input_value('_rule_trans', RCUBE_INPUT_POST); - $body_types = get_input_value('_rule_trans_type', RCUBE_INPUT_POST, true); - $comparators = get_input_value('_rule_comp', RCUBE_INPUT_POST); - $act_types = get_input_value('_action_type', RCUBE_INPUT_POST, true); - $mailboxes = get_input_value('_action_mailbox', RCUBE_INPUT_POST, true); - $act_targets = get_input_value('_action_target', RCUBE_INPUT_POST, true); - $area_targets = get_input_value('_action_target_area', RCUBE_INPUT_POST, true); - $reasons = get_input_value('_action_reason', RCUBE_INPUT_POST, true); - $addresses = get_input_value('_action_addresses', RCUBE_INPUT_POST, true); - $days = get_input_value('_action_days', RCUBE_INPUT_POST); - $subject = get_input_value('_action_subject', RCUBE_INPUT_POST, true); - $flags = get_input_value('_action_flags', RCUBE_INPUT_POST); - $varnames = get_input_value('_action_varname', RCUBE_INPUT_POST); - $varvalues = get_input_value('_action_varvalue', RCUBE_INPUT_POST); - $varmods = get_input_value('_action_varmods', RCUBE_INPUT_POST); - $notifyaddrs = get_input_value('_action_notifyaddress', RCUBE_INPUT_POST); - $notifybodies = get_input_value('_action_notifybody', RCUBE_INPUT_POST); - $notifymessages = get_input_value('_action_notifymessage', RCUBE_INPUT_POST); - $notifyfrom = get_input_value('_action_notifyfrom', RCUBE_INPUT_POST); - $notifyimp = get_input_value('_action_notifyimportance', RCUBE_INPUT_POST); + $headers = rcube_utils::get_input_value('_header', rcube_utils::INPUT_POST); + $cust_headers = rcube_utils::get_input_value('_custom_header', rcube_utils::INPUT_POST); + $ops = rcube_utils::get_input_value('_rule_op', rcube_utils::INPUT_POST); + $sizeops = rcube_utils::get_input_value('_rule_size_op', rcube_utils::INPUT_POST); + $sizeitems = rcube_utils::get_input_value('_rule_size_item', rcube_utils::INPUT_POST); + $sizetargets = rcube_utils::get_input_value('_rule_size_target', rcube_utils::INPUT_POST); + $targets = rcube_utils::get_input_value('_rule_target', rcube_utils::INPUT_POST, true); + $mods = rcube_utils::get_input_value('_rule_mod', rcube_utils::INPUT_POST); + $mod_types = rcube_utils::get_input_value('_rule_mod_type', rcube_utils::INPUT_POST); + $body_trans = rcube_utils::get_input_value('_rule_trans', rcube_utils::INPUT_POST); + $body_types = rcube_utils::get_input_value('_rule_trans_type', rcube_utils::INPUT_POST, true); + $comparators = rcube_utils::get_input_value('_rule_comp', rcube_utils::INPUT_POST); + $act_types = rcube_utils::get_input_value('_action_type', rcube_utils::INPUT_POST, true); + $mailboxes = rcube_utils::get_input_value('_action_mailbox', rcube_utils::INPUT_POST, true); + $act_targets = rcube_utils::get_input_value('_action_target', rcube_utils::INPUT_POST, true); + $area_targets = rcube_utils::get_input_value('_action_target_area', rcube_utils::INPUT_POST, true); + $reasons = rcube_utils::get_input_value('_action_reason', rcube_utils::INPUT_POST, true); + $addresses = rcube_utils::get_input_value('_action_addresses', rcube_utils::INPUT_POST, true); + $days = rcube_utils::get_input_value('_action_days', rcube_utils::INPUT_POST); + $subject = rcube_utils::get_input_value('_action_subject', rcube_utils::INPUT_POST, true); + $flags = rcube_utils::get_input_value('_action_flags', rcube_utils::INPUT_POST); + $varnames = rcube_utils::get_input_value('_action_varname', rcube_utils::INPUT_POST); + $varvalues = rcube_utils::get_input_value('_action_varvalue', rcube_utils::INPUT_POST); + $varmods = rcube_utils::get_input_value('_action_varmods', rcube_utils::INPUT_POST); + $notifyaddrs = rcube_utils::get_input_value('_action_notifyaddress', rcube_utils::INPUT_POST); + $notifybodies = rcube_utils::get_input_value('_action_notifybody', rcube_utils::INPUT_POST); + $notifymessages = rcube_utils::get_input_value('_action_notifymessage', rcube_utils::INPUT_POST); + $notifyfrom = rcube_utils::get_input_value('_action_notifyfrom', rcube_utils::INPUT_POST); + $notifyimp = rcube_utils::get_input_value('_action_notifyimportance', rcube_utils::INPUT_POST); // we need a "hack" for radiobuttons foreach ($sizeitems as $item) @@ -858,7 +858,7 @@ class managesieve extends rcube_plugin if ($this->form['actions'][$i]['target'] == '') $this->errors['actions'][$i]['target'] = $this->gettext('cannotbeempty'); - else if (!check_email($this->form['actions'][$i]['target'])) + else if (!rcube_utils::check_email($this->form['actions'][$i]['target'])) $this->errors['actions'][$i]['target'] = $this->gettext('noemailwarning'); if ($type == 'redirect_copy') { @@ -895,7 +895,7 @@ class managesieve extends rcube_plugin $address = trim($address); if (!$address) unset($this->form['actions'][$i]['addresses'][$aidx]); - else if(!check_email($address)) { + else if(!rcube_utils::check_email($address)) { $this->errors['actions'][$i]['addresses'] = $this->gettext('noemailwarning'); break; } else @@ -932,10 +932,10 @@ class managesieve extends rcube_plugin if (empty($notifyaddrs[$idx])) { $this->errors['actions'][$i]['address'] = $this->gettext('cannotbeempty'); } - else if (!check_email($notifyaddrs[$idx])) { + else if (!rcube_utils::check_email($notifyaddrs[$idx])) { $this->errors['actions'][$i]['address'] = $this->gettext('noemailwarning'); } - if (!empty($notifyfrom[$idx]) && !check_email($notifyfrom[$idx])) { + if (!empty($notifyfrom[$idx]) && !rcube_utils::check_email($notifyfrom[$idx])) { $this->errors['actions'][$i]['from'] = $this->gettext('noemailwarning'); } $this->form['actions'][$i]['address'] = $notifyaddrs[$idx]; @@ -967,7 +967,7 @@ class managesieve extends rcube_plugin $this->rc->output->command('parent.managesieve_updatelist', isset($new) ? 'add' : 'update', array( - 'name' => Q($this->form['name']), + 'name' => rcube::Q($this->form['name']), 'id' => $fid, 'disabled' => $this->form['disabled'] )); @@ -1016,7 +1016,7 @@ class managesieve extends rcube_plugin $result = $this->list_rules(); // create XHTML table - $out = rcube_table_output($attrib, $result, $a_show_cols, 'id'); + $out = $this->rc->table_output($attrib, $result, $a_show_cols, 'id'); // set client env $this->rc->output->add_gui_object('filterslist', $attrib['id']); @@ -1049,7 +1049,7 @@ class managesieve extends rcube_plugin foreach ($list as $idx => $set) { $scripts['S'.$idx] = $set; $result[] = array( - 'name' => Q($set), + 'name' => rcube::Q($set), 'id' => 'S'.$idx, 'class' => !in_array($set, $this->active) ? 'disabled' : '', ); @@ -1057,7 +1057,7 @@ class managesieve extends rcube_plugin } // create XHTML table - $out = rcube_table_output($attrib, $result, $a_show_cols, 'id'); + $out = $this->rc->table_output($attrib, $result, $a_show_cols, 'id'); $this->rc->output->set_env('filtersets', $scripts); $this->rc->output->include_script('list.js'); @@ -1111,21 +1111,21 @@ class managesieve extends rcube_plugin $out .= $hiddenfields->show(); - $name = get_input_value('_name', RCUBE_INPUT_POST); - $copy = get_input_value('_copy', RCUBE_INPUT_POST); - $selected = get_input_value('_from', RCUBE_INPUT_POST); + $name = rcube_utils::get_input_value('_name', rcube_utils::INPUT_POST); + $copy = rcube_utils::get_input_value('_copy', rcube_utils::INPUT_POST); + $selected = rcube_utils::get_input_value('_from', rcube_utils::INPUT_POST); // filter set name input $input_name = new html_inputfield(array('name' => '_name', 'id' => '_name', 'size' => 30, 'class' => ($this->errors['name'] ? 'error' : ''))); $out .= sprintf(' %s

', - '_name', Q($this->gettext('filtersetname')), $input_name->show($name)); + '_name', rcube::Q($this->gettext('filtersetname')), $input_name->show($name)); $out .="\n
" . $this->gettext('filters') . ":\n"; $out .= ''; - $out .= sprintf(' ', 'from_none', Q($this->gettext('none'))); + $out .= sprintf(' ', 'from_none', rcube::Q($this->gettext('none'))); // filters set list $list = $this->list_scripts(); @@ -1143,7 +1143,7 @@ class managesieve extends rcube_plugin $out .= '
'; - $out .= sprintf(' ', 'from_set', Q($this->gettext('fromset'))); + $out .= sprintf(' ', 'from_set', rcube::Q($this->gettext('fromset'))); $out .= $select->show($copy); } @@ -1153,7 +1153,7 @@ class managesieve extends rcube_plugin $out .= '
'; - $out .= sprintf(' ', 'from_file', Q($this->gettext('fromfile'))); + $out .= sprintf(' ', 'from_file', rcube::Q($this->gettext('fromfile'))); $out .= $upload->show(); $out .= '
'; @@ -1175,7 +1175,7 @@ class managesieve extends rcube_plugin if (!$attrib['id']) $attrib['id'] = 'rcmfilterform'; - $fid = get_input_value('_fid', RCUBE_INPUT_GPC); + $fid = rcube_utils::get_input_value('_fid', rcube_utils::INPUT_GPC); $scr = isset($this->form) ? $this->form : $this->script[$fid]; $hiddenfields = new html_hiddenfield(array('name' => '_task', 'value' => $this->rc->task)); @@ -1204,16 +1204,16 @@ class managesieve extends rcube_plugin $input_name = $input_name->show(); $out .= sprintf("\n %s\n", - $field_id, Q($this->gettext('filtername')), $input_name); + $field_id, rcube::Q($this->gettext('filtername')), $input_name); // filter set selector if ($this->rc->task == 'mail') { $out .= sprintf("\n  %s\n", - $field_id, Q($this->gettext('filterset')), + $field_id, rcube::Q($this->gettext('filterset')), $this->filtersets_list(array('id' => 'sievescriptname'), true)); } - $out .= '

' . Q($this->gettext('messagesrules')) . "\n"; + $out .= '

' . rcube::Q($this->gettext('messagesrules')) . "\n"; // any, allof, anyof radio buttons $field_id = '_allof'; @@ -1226,7 +1226,7 @@ class managesieve extends rcube_plugin $input_join = $input_join->show(); $out .= sprintf("%s \n", - $input_join, $field_id, Q($this->gettext('filterallof'))); + $input_join, $field_id, rcube::Q($this->gettext('filterallof'))); $field_id = '_anyof'; $input_join = new html_radiobutton(array('name' => '_join', 'id' => $field_id, 'value' => 'anyof', @@ -1238,7 +1238,7 @@ class managesieve extends rcube_plugin $input_join = $input_join->show('anyof'); // default $out .= sprintf("%s\n", - $input_join, $field_id, Q($this->gettext('filteranyof'))); + $input_join, $field_id, rcube::Q($this->gettext('filteranyof'))); $field_id = '_any'; $input_join = new html_radiobutton(array('name' => '_join', 'id' => $field_id, 'value' => 'any', @@ -1247,7 +1247,7 @@ class managesieve extends rcube_plugin $input_join = $input_join->show($any ? 'any' : ''); $out .= sprintf("%s\n", - $input_join, $field_id, Q($this->gettext('filterany'))); + $input_join, $field_id, rcube::Q($this->gettext('filterany'))); $rows_num = isset($scr) ? sizeof($scr['tests']) : 1; @@ -1259,7 +1259,7 @@ class managesieve extends rcube_plugin $out .= "
\n"; // actions - $out .= '
' . Q($this->gettext('messagesactions')) . "\n"; + $out .= '
' . rcube::Q($this->gettext('messagesactions')) . "\n"; $rows_num = isset($scr) ? sizeof($scr['actions']) : 1; @@ -1293,11 +1293,11 @@ class managesieve extends rcube_plugin $select_header = new html_select(array('name' => "_header[]", 'id' => 'header'.$id, 'onchange' => 'rule_header_select(' .$id .')')); foreach($this->headers as $name => $val) - $select_header->add(Q($this->gettext($name)), Q($val)); + $select_header->add(rcube::Q($this->gettext($name)), Q($val)); if (in_array('body', $this->exts)) - $select_header->add(Q($this->gettext('body')), 'body'); - $select_header->add(Q($this->gettext('size')), 'size'); - $select_header->add(Q($this->gettext('...')), '...'); + $select_header->add(rcube::Q($this->gettext('body')), 'body'); + $select_header->add(rcube::Q($this->gettext('size')), 'size'); + $select_header->add(rcube::Q($this->gettext('...')), '...'); // TODO: list arguments $aout = ''; @@ -1337,38 +1337,38 @@ class managesieve extends rcube_plugin $tout = '
error_class($id, 'test', 'header', 'custom_header_i') - .' value="' .Q($custom). '" size="15" /> 
' . "\n"; + .' value="' .rcube::Q($custom). '" size="15" /> ' . "\n"; // matching type select (operator) $select_op = new html_select(array('name' => "_rule_op[]", 'id' => 'rule_op'.$id, 'style' => 'display:' .($rule['test']!='size' ? 'inline' : 'none'), 'class' => 'operator_selector', 'onchange' => 'rule_op_select('.$id.')')); - $select_op->add(Q($this->gettext('filtercontains')), 'contains'); - $select_op->add(Q($this->gettext('filternotcontains')), 'notcontains'); - $select_op->add(Q($this->gettext('filteris')), 'is'); - $select_op->add(Q($this->gettext('filterisnot')), 'notis'); - $select_op->add(Q($this->gettext('filterexists')), 'exists'); - $select_op->add(Q($this->gettext('filternotexists')), 'notexists'); - $select_op->add(Q($this->gettext('filtermatches')), 'matches'); - $select_op->add(Q($this->gettext('filternotmatches')), 'notmatches'); + $select_op->add(rcube::Q($this->gettext('filtercontains')), 'contains'); + $select_op->add(rcube::Q($this->gettext('filternotcontains')), 'notcontains'); + $select_op->add(rcube::Q($this->gettext('filteris')), 'is'); + $select_op->add(rcube::Q($this->gettext('filterisnot')), 'notis'); + $select_op->add(rcube::Q($this->gettext('filterexists')), 'exists'); + $select_op->add(rcube::Q($this->gettext('filternotexists')), 'notexists'); + $select_op->add(rcube::Q($this->gettext('filtermatches')), 'matches'); + $select_op->add(rcube::Q($this->gettext('filternotmatches')), 'notmatches'); if (in_array('regex', $this->exts)) { - $select_op->add(Q($this->gettext('filterregex')), 'regex'); - $select_op->add(Q($this->gettext('filternotregex')), 'notregex'); + $select_op->add(rcube::Q($this->gettext('filterregex')), 'regex'); + $select_op->add(rcube::Q($this->gettext('filternotregex')), 'notregex'); } if (in_array('relational', $this->exts)) { - $select_op->add(Q($this->gettext('countisgreaterthan')), 'count-gt'); - $select_op->add(Q($this->gettext('countisgreaterthanequal')), 'count-ge'); - $select_op->add(Q($this->gettext('countislessthan')), 'count-lt'); - $select_op->add(Q($this->gettext('countislessthanequal')), 'count-le'); - $select_op->add(Q($this->gettext('countequals')), 'count-eq'); - $select_op->add(Q($this->gettext('countnotequals')), 'count-ne'); - $select_op->add(Q($this->gettext('valueisgreaterthan')), 'value-gt'); - $select_op->add(Q($this->gettext('valueisgreaterthanequal')), 'value-ge'); - $select_op->add(Q($this->gettext('valueislessthan')), 'value-lt'); - $select_op->add(Q($this->gettext('valueislessthanequal')), 'value-le'); - $select_op->add(Q($this->gettext('valueequals')), 'value-eq'); - $select_op->add(Q($this->gettext('valuenotequals')), 'value-ne'); + $select_op->add(rcube::Q($this->gettext('countisgreaterthan')), 'count-gt'); + $select_op->add(rcube::Q($this->gettext('countisgreaterthanequal')), 'count-ge'); + $select_op->add(rcube::Q($this->gettext('countislessthan')), 'count-lt'); + $select_op->add(rcube::Q($this->gettext('countislessthanequal')), 'count-le'); + $select_op->add(rcube::Q($this->gettext('countequals')), 'count-eq'); + $select_op->add(rcube::Q($this->gettext('countnotequals')), 'count-ne'); + $select_op->add(rcube::Q($this->gettext('valueisgreaterthan')), 'value-gt'); + $select_op->add(rcube::Q($this->gettext('valueisgreaterthanequal')), 'value-ge'); + $select_op->add(rcube::Q($this->gettext('valueislessthan')), 'value-lt'); + $select_op->add(rcube::Q($this->gettext('valueislessthanequal')), 'value-le'); + $select_op->add(rcube::Q($this->gettext('valueequals')), 'value-eq'); + $select_op->add(rcube::Q($this->gettext('valuenotequals')), 'value-ne'); } // target input (TODO: lists) @@ -1400,53 +1400,53 @@ class managesieve extends rcube_plugin $tout .= $select_op->show($test); $tout .= 'error_class($id, 'test', 'target', 'rule_target') + value="' .rcube::Q($target). '" size="20" ' . $this->error_class($id, 'test', 'target', 'rule_target') . ' style="display:' . ($rule['test']!='size' && $rule['test'] != 'exists' ? 'inline' : 'none') . '" />'."\n"; $select_size_op = new html_select(array('name' => "_rule_size_op[]", 'id' => 'rule_size_op'.$id)); - $select_size_op->add(Q($this->gettext('filterover')), 'over'); - $select_size_op->add(Q($this->gettext('filterunder')), 'under'); + $select_size_op->add(rcube::Q($this->gettext('filterover')), 'over'); + $select_size_op->add(rcube::Q($this->gettext('filterunder')), 'under'); $tout .= '
'; $tout .= $select_size_op->show($rule['test']=='size' ? $rule['type'] : ''); $tout .= 'error_class($id, 'test', 'sizetarget', 'rule_size_i') .' /> '.rcube_label('B').' + . (!$sizeitem ? ' checked="checked"' : '') .' class="radio" />'.$this->rc->gettext('B').' '.rcube_label('KB').' + . ($sizeitem=='K' ? ' checked="checked"' : '') .' class="radio" />'.$this->rc->gettext('KB').' '.rcube_label('MB').' + . ($sizeitem=='M' ? ' checked="checked"' : '') .' class="radio" />'.$this->rc->gettext('MB').' '.rcube_label('GB'); + . ($sizeitem=='G' ? ' checked="checked"' : '') .' class="radio" />'.$this->rc->gettext('GB'); $tout .= '
'; // Advanced modifiers (address, envelope) $select_mod = new html_select(array('name' => "_rule_mod[]", 'id' => 'rule_mod_op'.$id, 'onchange' => 'rule_mod_select(' .$id .')')); - $select_mod->add(Q($this->gettext('none')), ''); - $select_mod->add(Q($this->gettext('address')), 'address'); + $select_mod->add(rcube::Q($this->gettext('none')), ''); + $select_mod->add(rcube::Q($this->gettext('address')), 'address'); if (in_array('envelope', $this->exts)) - $select_mod->add(Q($this->gettext('envelope')), 'envelope'); + $select_mod->add(rcube::Q($this->gettext('envelope')), 'envelope'); $select_type = new html_select(array('name' => "_rule_mod_type[]", 'id' => 'rule_mod_type'.$id)); - $select_type->add(Q($this->gettext('allparts')), 'all'); - $select_type->add(Q($this->gettext('domain')), 'domain'); - $select_type->add(Q($this->gettext('localpart')), 'localpart'); + $select_type->add(rcube::Q($this->gettext('allparts')), 'all'); + $select_type->add(rcube::Q($this->gettext('domain')), 'domain'); + $select_type->add(rcube::Q($this->gettext('localpart')), 'localpart'); if (in_array('subaddress', $this->exts)) { - $select_type->add(Q($this->gettext('user')), 'user'); - $select_type->add(Q($this->gettext('detail')), 'detail'); + $select_type->add(rcube::Q($this->gettext('user')), 'user'); + $select_type->add(rcube::Q($this->gettext('detail')), 'detail'); } $need_mod = $rule['test'] != 'size' && $rule['test'] != 'body'; $mout = '
'; $mout .= ' '; - $mout .= Q($this->gettext('modifier')) . ' '; + $mout .= rcube::Q($this->gettext('modifier')) . ' '; $mout .= $select_mod->show($rule['test']); $mout .= ''; $mout .= ' '; - $mout .= Q($this->gettext('modtype')) . ' '; + $mout .= rcube::Q($this->gettext('modtype')) . ' '; $mout .= $select_type->show($rule['part']); $mout .= ''; $mout .= '
'; @@ -1454,13 +1454,13 @@ class managesieve extends rcube_plugin // Advanced modifiers (body transformations) $select_mod = new html_select(array('name' => "_rule_trans[]", 'id' => 'rule_trans_op'.$id, 'onchange' => 'rule_trans_select(' .$id .')')); - $select_mod->add(Q($this->gettext('text')), 'text'); - $select_mod->add(Q($this->gettext('undecoded')), 'raw'); - $select_mod->add(Q($this->gettext('contenttype')), 'content'); + $select_mod->add(rcube::Q($this->gettext('text')), 'text'); + $select_mod->add(rcube::Q($this->gettext('undecoded')), 'raw'); + $select_mod->add(rcube::Q($this->gettext('contenttype')), 'content'); $mout .= '
'; $mout .= ' '; - $mout .= Q($this->gettext('modifier')) . ' '; + $mout .= rcube::Q($this->gettext('modifier')) . ' '; $mout .= $select_mod->show($rule['part']); $mout .= ' 'rule_comp_op'.$id)); - $select_comp->add(Q($this->gettext('default')), ''); - $select_comp->add(Q($this->gettext('octet')), 'i;octet'); - $select_comp->add(Q($this->gettext('asciicasemap')), 'i;ascii-casemap'); + $select_comp->add(rcube::Q($this->gettext('default')), ''); + $select_comp->add(rcube::Q($this->gettext('octet')), 'i;octet'); + $select_comp->add(rcube::Q($this->gettext('asciicasemap')), 'i;ascii-casemap'); if (in_array('comparator-i;ascii-numeric', $this->exts)) { - $select_comp->add(Q($this->gettext('asciinumeric')), 'i;ascii-numeric'); + $select_comp->add(rcube::Q($this->gettext('asciinumeric')), 'i;ascii-numeric'); } $mout .= '
'; $mout .= ' '; - $mout .= Q($this->gettext('comparator')) . ' '; + $mout .= rcube::Q($this->gettext('comparator')) . ' '; $mout .= $select_comp->show($rule['comparator']); $mout .= ''; $mout .= '
'; @@ -1489,7 +1489,7 @@ class managesieve extends rcube_plugin $out = $div ? '
'."\n" : ''; $out .= ''; $out .= ''; $out .= ''; @@ -1499,9 +1499,9 @@ class managesieve extends rcube_plugin // add/del buttons $out .= ''; $out .= '
'; - $out .= '  '; $out .= '' . $aout . ''; - $out .= ''; - $out .= ''; $out .= '
'; @@ -1524,31 +1524,31 @@ class managesieve extends rcube_plugin $select_action = new html_select(array('name' => "_action_type[$id]", 'id' => 'action_type'.$id, 'onchange' => 'action_type_select(' .$id .')')); if (in_array('fileinto', $this->exts)) - $select_action->add(Q($this->gettext('messagemoveto')), 'fileinto'); + $select_action->add(rcube::Q($this->gettext('messagemoveto')), 'fileinto'); if (in_array('fileinto', $this->exts) && in_array('copy', $this->exts)) - $select_action->add(Q($this->gettext('messagecopyto')), 'fileinto_copy'); - $select_action->add(Q($this->gettext('messageredirect')), 'redirect'); + $select_action->add(rcube::Q($this->gettext('messagecopyto')), 'fileinto_copy'); + $select_action->add(rcube::Q($this->gettext('messageredirect')), 'redirect'); if (in_array('copy', $this->exts)) - $select_action->add(Q($this->gettext('messagesendcopy')), 'redirect_copy'); + $select_action->add(rcube::Q($this->gettext('messagesendcopy')), 'redirect_copy'); if (in_array('reject', $this->exts)) - $select_action->add(Q($this->gettext('messagediscard')), 'reject'); + $select_action->add(rcube::Q($this->gettext('messagediscard')), 'reject'); else if (in_array('ereject', $this->exts)) - $select_action->add(Q($this->gettext('messagediscard')), 'ereject'); + $select_action->add(rcube::Q($this->gettext('messagediscard')), 'ereject'); if (in_array('vacation', $this->exts)) - $select_action->add(Q($this->gettext('messagereply')), 'vacation'); - $select_action->add(Q($this->gettext('messagedelete')), 'discard'); + $select_action->add(rcube::Q($this->gettext('messagereply')), 'vacation'); + $select_action->add(rcube::Q($this->gettext('messagedelete')), 'discard'); if (in_array('imapflags', $this->exts) || in_array('imap4flags', $this->exts)) { - $select_action->add(Q($this->gettext('setflags')), 'setflag'); - $select_action->add(Q($this->gettext('addflags')), 'addflag'); - $select_action->add(Q($this->gettext('removeflags')), 'removeflag'); + $select_action->add(rcube::Q($this->gettext('setflags')), 'setflag'); + $select_action->add(rcube::Q($this->gettext('addflags')), 'addflag'); + $select_action->add(rcube::Q($this->gettext('removeflags')), 'removeflag'); } if (in_array('variables', $this->exts)) { - $select_action->add(Q($this->gettext('setvariable')), 'set'); + $select_action->add(rcube::Q($this->gettext('setvariable')), 'set'); } if (in_array('enotify', $this->exts) || in_array('notify', $this->exts)) { - $select_action->add(Q($this->gettext('notify')), 'notify'); + $select_action->add(rcube::Q($this->gettext('notify')), 'notify'); } - $select_action->add(Q($this->gettext('rulestop')), 'stop'); + $select_action->add(rcube::Q($this->gettext('rulestop')), 'stop'); $select_type = $action['type']; if (in_array($action['type'], array('fileinto', 'redirect')) && $action['copy']) { @@ -1562,32 +1562,32 @@ class managesieve extends rcube_plugin $out .= ''; // shared targets $out .= 'error_class($id, 'action', 'target', 'action_target') .' />'; $out .= '\n"; // vacation $out .= '
'; - $out .= ''. Q($this->gettext('vacationreason')) .'
' + $out .= ''. rcube::Q($this->gettext('vacationreason')) .'
' .'\n"; - $out .= '
' .Q($this->gettext('vacationsubject')) . '
' + $out .= '
' .rcube::Q($this->gettext('vacationsubject')) . '
' .'error_class($id, 'action', 'subject', 'action_subject') .' />'; - $out .= '
' .Q($this->gettext('vacationaddresses')) . '
' + $out .= '
' .rcube::Q($this->gettext('vacationaddresses')) . '
' .'error_class($id, 'action', 'addresses', 'action_addr') .' />'; - $out .= '
' . Q($this->gettext('vacationdays')) . '
' + $out .= '
' . rcube::Q($this->gettext('vacationdays')) . '
' .'error_class($id, 'action', 'days', 'action_days') .' />'; $out .= '
'; @@ -1607,7 +1607,7 @@ class managesieve extends rcube_plugin foreach ($flags as $fidx => $flag) { $out .= '' - . Q($this->gettext('flag'.$fidx)) .'
'; + . rcube::Q($this->gettext('flag'.$fidx)) .'
'; } $out .= '
'; @@ -1622,42 +1622,42 @@ class managesieve extends rcube_plugin ); $out .= '
'; - $out .= '' .Q($this->gettext('setvarname')) . '
' + $out .= '' .rcube::Q($this->gettext('setvarname')) . '
' .'error_class($id, 'action', 'name', 'action_varname') .' />'; - $out .= '
' .Q($this->gettext('setvarvalue')) . '
' + $out .= '
' .rcube::Q($this->gettext('setvarvalue')) . '
' .'error_class($id, 'action', 'value', 'action_varvalue') .' />'; - $out .= '
' .Q($this->gettext('setvarmodifiers')) . '
'; + $out .= '
' .rcube::Q($this->gettext('setvarmodifiers')) . '
'; foreach ($set_modifiers as $j => $s_m) { $s_m_id = 'action_varmods' . $id . $s_m; $out .= sprintf('%s
', $id, $s_m, $s_m_id, (array_key_exists($s_m, (array)$action) && $action[$s_m] ? ' checked="checked"' : ''), - Q($this->gettext('var' . $s_m))); + rcube::Q($this->gettext('var' . $s_m))); } $out .= '
'; // notify // skip :options tag - not used by the mailto method $out .= '
'; - $out .= '' .Q($this->gettext('notifyaddress')) . '
' + $out .= '' .rcube::Q($this->gettext('notifyaddress')) . '
' .'error_class($id, 'action', 'address', 'action_notifyaddress') .' />'; - $out .= '
'. Q($this->gettext('notifybody')) .'
' + $out .= '
'. rcube::Q($this->gettext('notifybody')) .'
' .'\n"; - $out .= '
' .Q($this->gettext('notifysubject')) . '
' + . rcube::Q($action['body'], 'strict', false) . "\n"; + $out .= '
' .rcube::Q($this->gettext('notifysubject')) . '
' .'error_class($id, 'action', 'message', 'action_notifymessage') .' />'; - $out .= '
' .Q($this->gettext('notifyfrom')) . '
' + $out .= '
' .rcube::Q($this->gettext('notifyfrom')) . '
' .'error_class($id, 'action', 'from', 'action_notifyfrom') .' />'; $importance_options = array( 3 => 'notifyimportancelow', @@ -1669,9 +1669,9 @@ class managesieve extends rcube_plugin 'id' => '_action_notifyimportance' . $id, 'class' => $this->error_class($id, 'action', 'importance', 'action_notifyimportance'))); foreach ($importance_options as $io_v => $io_n) { - $select_importance->add(Q($this->gettext($io_n)), $io_v); + $select_importance->add(rcube::Q($this->gettext($io_n)), $io_v); } - $out .= '
' . Q($this->gettext('notifyimportance')) . '
'; + $out .= '
' . rcube::Q($this->gettext('notifyimportance')) . '
'; $out .= $select_importance->show($action['importance'] ? $action['importance'] : 2); $out .= '
'; @@ -1681,7 +1681,7 @@ class managesieve extends rcube_plugin else $mailbox = ''; - $select = rcmail_mailbox_select(array( + $select = $this->rc->folder_selector(array( 'realnames' => false, 'maxlength' => 100, 'id' => 'action_mailbox' . $id, @@ -1693,9 +1693,9 @@ class managesieve extends rcube_plugin // add/del buttons $out .= ''; - $out .= ''; - $out .= ''; $out .= ''; @@ -1746,7 +1746,7 @@ class managesieve extends rcube_plugin if (empty($this->tips)) return; - $script = JS_OBJECT_NAME.'.managesieve_tip_register('.json_encode($this->tips).');'; + $script = rcmail_output::JS_OBJECT_NAME.'.managesieve_tip_register('.json_encode($this->tips).');'; $this->rc->output->add_script($script, 'foot'); } @@ -1766,12 +1766,12 @@ class managesieve extends rcube_plugin $mbox_encoding = $this->rc->config->get('managesieve_mbox_encoding', 'UTF7-IMAP'); if ($mode == 'out') { - $mailbox = rcube_charset_convert($mailbox, $mbox_encoding, 'UTF7-IMAP'); + $mailbox = rcube_charset::convert($mailbox, $mbox_encoding, 'UTF7-IMAP'); if ($replace_delimiter && $replace_delimiter != $delimiter) $mailbox = str_replace($replace_delimiter, $delimiter, $mailbox); } else { - $mailbox = rcube_charset_convert($mailbox, 'UTF7-IMAP', $mbox_encoding); + $mailbox = rcube_charset::convert($mailbox, 'UTF7-IMAP', $mbox_encoding); if ($replace_delimiter && $replace_delimiter != $delimiter) $mailbox = str_replace($delimiter, $replace_delimiter, $mailbox); } @@ -2039,7 +2039,7 @@ class managesieve extends rcube_plugin $fname = $filter['name'] ? $filter['name'] : "#$i"; $result[] = array( 'id' => $idx, - 'name' => Q($fname), + 'name' => rcube::Q($fname), 'class' => $filter['disabled'] ? 'disabled' : '', ); $i++; diff --git a/plugins/markasjunk/markasjunk.php b/plugins/markasjunk/markasjunk.php index 4db90c1bc..76b14c140 100644 --- a/plugins/markasjunk/markasjunk.php +++ b/plugins/markasjunk/markasjunk.php @@ -45,8 +45,8 @@ class markasjunk extends rcube_plugin $GLOBALS['IMAP_FLAGS']['JUNK'] = 'Junk'; $GLOBALS['IMAP_FLAGS']['NONJUNK'] = 'NonJunk'; - $uids = get_input_value('_uid', RCUBE_INPUT_POST); - $mbox = get_input_value('_mbox', RCUBE_INPUT_POST); + $uids = rcube_utils::get_input_value('_uid', rcube_utils::INPUT_POST); + $mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST); $rcmail = rcmail::get_instance(); $rcmail->storage->unset_flag($uids, 'NONJUNK'); diff --git a/plugins/new_user_dialog/new_user_dialog.php b/plugins/new_user_dialog/new_user_dialog.php index 9c9dcce1c..871384e47 100644 --- a/plugins/new_user_dialog/new_user_dialog.php +++ b/plugins/new_user_dialog/new_user_dialog.php @@ -63,7 +63,7 @@ class new_user_dialog extends rcube_plugin $table->add(null, html::tag('input', array( 'type' => 'text', 'name' => '_email', - 'value' => rcube_idn_to_utf8($identity['email']), + 'value' => rcube_utils::idn_to_utf8($identity['email']), 'disabled' => ($identities_level == 1 || $identities_level == 3) ))); @@ -86,8 +86,8 @@ class new_user_dialog extends rcube_plugin 'id' => 'newuserdialog', 'action' => $rcmail->url('plugin.newusersave'), 'method' => 'post'), - html::tag('h3', null, Q($this->gettext('identitydialogtitle'))) . - html::p('hint', Q($this->gettext('identitydialoghint'))) . + html::tag('h3', null, rcube::Q($this->gettext('identitydialogtitle'))) . + html::p('hint', rcube::Q($this->gettext('identitydialoghint'))) . $table->show() . html::p(array('class' => 'formbuttons'), html::tag('input', array('type' => 'submit', @@ -119,17 +119,17 @@ class new_user_dialog extends rcube_plugin $identities_level = intval($rcmail->config->get('identities_level', 0)); $save_data = array( - 'name' => get_input_value('_name', RCUBE_INPUT_POST), - 'email' => get_input_value('_email', RCUBE_INPUT_POST), - 'organization' => get_input_value('_organization', RCUBE_INPUT_POST), - 'signature' => get_input_value('_signature', RCUBE_INPUT_POST), + 'name' => rcube_utils::get_input_value('_name', rcube_utils::INPUT_POST), + 'email' => rcube_utils::get_input_value('_email', rcube_utils::INPUT_POST), + 'organization' => rcube_utils::get_input_value('_organization', rcube_utils::INPUT_POST), + 'signature' => rcube_utils::get_input_value('_signature', rcube_utils::INPUT_POST), ); // don't let the user alter the e-mail address if disabled by config if ($identities_level == 1 || $identities_level == 3) $save_data['email'] = $identity['email']; else - $save_data['email'] = rcube_idn_to_ascii($save_data['email']); + $save_data['email'] = rcube_utils::idn_to_ascii($save_data['email']); // save data if not empty if (!empty($save_data['name']) && !empty($save_data['email'])) { diff --git a/plugins/new_user_identity/new_user_identity.php b/plugins/new_user_identity/new_user_identity.php index 200d9accd..f98145b6c 100644 --- a/plugins/new_user_identity/new_user_identity.php +++ b/plugins/new_user_identity/new_user_identity.php @@ -43,7 +43,7 @@ class new_user_identity extends rcube_plugin $args['user_name'] = $user_name; if (!$args['user_email'] && strpos($user_email, '@')) { - $args['user_email'] = rcube_idn_to_ascii($user_email); + $args['user_email'] = rcube_utils::idn_to_ascii($user_email); } } } diff --git a/plugins/newmail_notifier/newmail_notifier.php b/plugins/newmail_notifier/newmail_notifier.php index 942421166..a45eeaedb 100644 --- a/plugins/newmail_notifier/newmail_notifier.php +++ b/plugins/newmail_notifier/newmail_notifier.php @@ -93,7 +93,7 @@ class newmail_notifier extends rcube_plugin $this->gettext('test')); $args['blocks']['new_message']['options'][$key] = array( - 'title' => html::label($field_id, Q($this->gettext($type))), + 'title' => html::label($field_id, rcube::Q($this->gettext($type))), 'content' => $content ); } @@ -120,7 +120,7 @@ class newmail_notifier extends rcube_plugin foreach (array('basic', 'desktop', 'sound') as $type) { $key = 'newmail_notifier_' . $type; if (!in_array($key, $dont_override)) { - $args['prefs'][$key] = get_input_value('_'.$key, RCUBE_INPUT_POST) ? true : false; + $args['prefs'][$key] = rcube_utils::get_input_value('_'.$key, rcube_utils::INPUT_POST) ? true : false; } } diff --git a/plugins/password/drivers/chpasswd.php b/plugins/password/drivers/chpasswd.php index 3ea10159c..137275e69 100644 --- a/plugins/password/drivers/chpasswd.php +++ b/plugins/password/drivers/chpasswd.php @@ -26,7 +26,7 @@ class rcube_chpasswd_password return PASSWORD_SUCCESS; } else { - raise_error(array( + rcube::raise_error(array( 'code' => 600, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, diff --git a/plugins/password/drivers/dbmail.php b/plugins/password/drivers/dbmail.php index e4c0d52e3..529027b8d 100644 --- a/plugins/password/drivers/dbmail.php +++ b/plugins/password/drivers/dbmail.php @@ -29,7 +29,7 @@ class rcube_dbmail_password return PASSWORD_SUCCESS; } else { - raise_error(array( + rcube::raise_error(array( 'code' => 600, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, diff --git a/plugins/password/drivers/directadmin.php b/plugins/password/drivers/directadmin.php index fb156cea9..8bf0dc613 100644 --- a/plugins/password/drivers/directadmin.php +++ b/plugins/password/drivers/directadmin.php @@ -43,7 +43,7 @@ class rcube_directadmin_password $response = $Socket->fetch_parsed_body(); //DEBUG - //console("Password Plugin: [USER: $da_user] [HOST: $da_host] - Response: [SOCKET: ".$Socket->result_status_code."] [DA ERROR: ".strip_tags($response['error'])."] [TEXT: ".$response[text]."]"); + //rcube::console("Password Plugin: [USER: $da_user] [HOST: $da_host] - Response: [SOCKET: ".$Socket->result_status_code."] [DA ERROR: ".strip_tags($response['error'])."] [TEXT: ".$response[text]."]"); if($Socket->result_status_code != 200) return array('code' => PASSWORD_CONNECT_ERROR, 'message' => $Socket->error[0]); diff --git a/plugins/password/drivers/expect.php b/plugins/password/drivers/expect.php index 7a191e254..1f68924df 100644 --- a/plugins/password/drivers/expect.php +++ b/plugins/password/drivers/expect.php @@ -45,7 +45,7 @@ class rcube_expect_password return PASSWORD_SUCCESS; } else { - raise_error(array( + rcube::raise_error(array( 'code' => 600, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, diff --git a/plugins/password/drivers/hmail.php b/plugins/password/drivers/hmail.php index 104c851ae..a8f07a23b 100644 --- a/plugins/password/drivers/hmail.php +++ b/plugins/password/drivers/hmail.php @@ -26,8 +26,8 @@ class rcube_hmail_password $obApp = new COM("hMailServer.Application"); } catch (Exception $e) { - write_log('errors', "Plugin password (hmail driver): " . trim(strip_tags($e->getMessage()))); - write_log('errors', "Plugin password (hmail driver): This problem is often caused by DCOM permissions not being set."); + rcube::write_log('errors', "Plugin password (hmail driver): " . trim(strip_tags($e->getMessage()))); + rcube::write_log('errors', "Plugin password (hmail driver): This problem is often caused by DCOM permissions not being set."); return PASSWORD_ERROR; } @@ -39,8 +39,8 @@ class rcube_hmail_password else { $domain = $rcmail->config->get('username_domain',false); if (!$domain) { - write_log('errors','Plugin password (hmail driver): $rcmail_config[\'username_domain\'] is not defined.'); - write_log('errors','Plugin password (hmail driver): Hint: Use hmail_login plugin (http://myroundcube.googlecode.com'); + rcube::write_log('errors','Plugin password (hmail driver): $rcmail_config[\'username_domain\'] is not defined.'); + rcube::write_log('errors','Plugin password (hmail driver): Hint: Use hmail_login plugin (http://myroundcube.googlecode.com'); return PASSWORD_ERROR; } $username = $username . "@" . $domain; @@ -55,8 +55,8 @@ class rcube_hmail_password return PASSWORD_SUCCESS; } catch (Exception $e) { - write_log('errors', "Plugin password (hmail driver): " . trim(strip_tags($e->getMessage()))); - write_log('errors', "Plugin password (hmail driver): This problem is often caused by DCOM permissions not being set."); + rcube::write_log('errors', "Plugin password (hmail driver): " . trim(strip_tags($e->getMessage()))); + rcube::write_log('errors', "Plugin password (hmail driver): This problem is often caused by DCOM permissions not being set."); return PASSWORD_ERROR; } } diff --git a/plugins/password/drivers/ldap.php b/plugins/password/drivers/ldap.php index f773335ac..548d327e1 100644 --- a/plugins/password/drivers/ldap.php +++ b/plugins/password/drivers/ldap.php @@ -271,7 +271,7 @@ class rcube_ldap_password case 'samba': if (function_exists('hash')) { - $cryptedPassword = hash('md4', rcube_charset_convert($passwordClear, RCMAIL_CHARSET, 'UTF-16LE')); + $cryptedPassword = hash('md4', rcube_charset::convert($passwordClear, RCUBE_CHARSET, 'UTF-16LE')); $cryptedPassword = strtoupper($cryptedPassword); } else { /* Your PHP install does not have the hash() function */ diff --git a/plugins/password/drivers/ldap_simple.php b/plugins/password/drivers/ldap_simple.php index 01385f2d0..d47e14492 100644 --- a/plugins/password/drivers/ldap_simple.php +++ b/plugins/password/drivers/ldap_simple.php @@ -240,7 +240,7 @@ class rcube_ldap_simple_password break; case 'samba': if (function_exists('hash')) { - $crypted_password = hash('md4', rcube_charset_convert($password_clear, RCMAIL_CHARSET, 'UTF-16LE')); + $crypted_password = hash('md4', rcube_charset::convert($password_clear, RCUBE_CHARSET, 'UTF-16LE')); $crypted_password = strtoupper($crypted_password); } else { /* Your PHP install does not have the hash() function */ diff --git a/plugins/password/drivers/pam.php b/plugins/password/drivers/pam.php index 20524d9f1..8cd94c737 100644 --- a/plugins/password/drivers/pam.php +++ b/plugins/password/drivers/pam.php @@ -20,7 +20,7 @@ class rcube_pam_password } } else { - raise_error(array( + rcube::raise_error(array( 'code' => 600, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, @@ -29,7 +29,7 @@ class rcube_pam_password } } else { - raise_error(array( + rcube::raise_error(array( 'code' => 600, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, diff --git a/plugins/password/drivers/pw_usermod.php b/plugins/password/drivers/pw_usermod.php index 5b92fcbfb..237e275a7 100644 --- a/plugins/password/drivers/pw_usermod.php +++ b/plugins/password/drivers/pw_usermod.php @@ -28,7 +28,7 @@ class rcube_pw_usermod_password return PASSWORD_SUCCESS; } else { - raise_error(array( + rcube::raise_error(array( 'code' => 600, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, diff --git a/plugins/password/drivers/sasl.php b/plugins/password/drivers/sasl.php index 9380cf838..8776eff2e 100644 --- a/plugins/password/drivers/sasl.php +++ b/plugins/password/drivers/sasl.php @@ -32,7 +32,7 @@ class rcube_sasl_password return PASSWORD_SUCCESS; } else { - raise_error(array( + rcube::raise_error(array( 'code' => 600, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, diff --git a/plugins/password/drivers/smb.php b/plugins/password/drivers/smb.php index 88021156f..d56924eee 100644 --- a/plugins/password/drivers/smb.php +++ b/plugins/password/drivers/smb.php @@ -44,7 +44,7 @@ class rcube_smb_password return PASSWORD_SUCCESS; } else { - raise_error(array( + rcube::raise_error(array( 'code' => 600, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, diff --git a/plugins/password/drivers/sql.php b/plugins/password/drivers/sql.php index b08833dbf..e02bff146 100644 --- a/plugins/password/drivers/sql.php +++ b/plugins/password/drivers/sql.php @@ -117,7 +117,7 @@ class rcube_sql_password // hashed passwords if (preg_match('/%[n|q]/', $sql)) { if (!extension_loaded('hash')) { - raise_error(array( + rcube::raise_error(array( 'code' => 600, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, @@ -164,14 +164,14 @@ class rcube_sql_password // convert domains to/from punnycode if ($rcmail->config->get('password_idn_ascii')) { - $domain_part = rcube_idn_to_ascii($domain_part); - $username = rcube_idn_to_ascii($username); - $host = rcube_idn_to_ascii($host); + $domain_part = rcube_utils::idn_to_ascii($domain_part); + $username = rcube_utils::idn_to_ascii($username); + $host = rcube_utils::idn_to_ascii($host); } else { - $domain_part = rcube_idn_to_utf8($domain_part); - $username = rcube_idn_to_utf8($username); - $host = rcube_idn_to_utf8($host); + $domain_part = rcube_utils::idn_to_utf8($domain_part); + $username = rcube_utils::idn_to_utf8($username); + $host = rcube_utils::idn_to_utf8($host); } // at least we should always have the local part diff --git a/plugins/password/drivers/virtualmin.php b/plugins/password/drivers/virtualmin.php index d2b765a9e..2c7aee617 100644 --- a/plugins/password/drivers/virtualmin.php +++ b/plugins/password/drivers/virtualmin.php @@ -67,7 +67,7 @@ class rcube_virtualmin_password return PASSWORD_SUCCESS; } else { - raise_error(array( + rcube::raise_error(array( 'code' => 600, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, diff --git a/plugins/password/drivers/xmail.php b/plugins/password/drivers/xmail.php index 33a49ffe3..37abc3001 100644 --- a/plugins/password/drivers/xmail.php +++ b/plugins/password/drivers/xmail.php @@ -32,7 +32,7 @@ class rcube_xmail_password $xmail->port = $rcmail->config->get('xmail_port'); if (!$xmail->connect()) { - raise_error(array( + rcube::raise_error(array( 'code' => 600, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, @@ -42,7 +42,7 @@ class rcube_xmail_password } else if (!$xmail->send("userpasswd\t".$domain."\t".$user."\t".$newpass."\n")) { $xmail->close(); - raise_error(array( + rcube::raise_error(array( 'code' => 600, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, diff --git a/plugins/password/password.php b/plugins/password/password.php index 806db0586..39020a0bf 100644 --- a/plugins/password/password.php +++ b/plugins/password/password.php @@ -112,22 +112,22 @@ class password extends rcube_plugin $rc_charset = strtoupper($rcmail->output->get_charset()); $sespwd = $rcmail->decrypt($_SESSION['password']); - $curpwd = $confirm ? get_input_value('_curpasswd', RCUBE_INPUT_POST, true, $charset) : $sespwd; - $newpwd = get_input_value('_newpasswd', RCUBE_INPUT_POST, true); - $conpwd = get_input_value('_confpasswd', RCUBE_INPUT_POST, true); + $curpwd = $confirm ? rcube_utils::get_input_value('_curpasswd', rcube_utils::INPUT_POST, true, $charset) : $sespwd; + $newpwd = rcube_utils::get_input_value('_newpasswd', rcube_utils::INPUT_POST, true); + $conpwd = rcube_utils::get_input_value('_confpasswd', rcube_utils::INPUT_POST, true); // check allowed characters according to the configured 'password_charset' option // by converting the password entered by the user to this charset and back to UTF-8 $orig_pwd = $newpwd; - $chk_pwd = rcube_charset_convert($orig_pwd, $rc_charset, $charset); - $chk_pwd = rcube_charset_convert($chk_pwd, $charset, $rc_charset); + $chk_pwd = rcube_charset::convert($orig_pwd, $rc_charset, $charset); + $chk_pwd = rcube_charset::convert($chk_pwd, $charset, $rc_charset); // WARNING: Default password_charset is ISO-8859-1, so conversion will // change national characters. This may disable possibility of using // the same password in other MUA's. // We're doing this for consistence with Roundcube core - $newpwd = rcube_charset_convert($newpwd, $rc_charset, $charset); - $conpwd = rcube_charset_convert($conpwd, $rc_charset, $charset); + $newpwd = rcube_charset::convert($newpwd, $rc_charset, $charset); + $conpwd = rcube_charset::convert($conpwd, $rc_charset, $charset); if ($chk_pwd != $orig_pwd) { $rcmail->output->command('display_message', $this->gettext('passwordforbidden'), 'error'); @@ -141,7 +141,7 @@ class password extends rcube_plugin } else if ($required_length && strlen($newpwd) < $required_length) { $rcmail->output->command('display_message', $this->gettext( - array('name' => 'passwordshort', 'vars' => array('length' => $required_length))), 'error'); + array('name' => 'passwordshort', 'vars' => array('length' => $required_length))), 'error'); } else if ($check_strength && (!preg_match("/[0-9]/", $newpwd) || !preg_match("/[^A-Za-z0-9]/", $newpwd))) { $rcmail->output->command('display_message', $this->gettext('passwordweak'), 'error'); @@ -163,8 +163,8 @@ class password extends rcube_plugin // Log password change if ($rcmail->config->get('password_log')) { - write_log('password', sprintf('Password changed for user %s (ID: %d) from %s', - $rcmail->get_user_name(), $rcmail->user->ID, rcmail_remote_ip())); + rcube::write_log('password', sprintf('Password changed for user %s (ID: %d) from %s', + $rcmail->get_user_name(), $rcmail->user->ID, rcube_utils::remote_ip())); } } else { @@ -172,7 +172,7 @@ class password extends rcube_plugin } } - rcmail_overwrite_action('plugin.password'); + $rcmail->overwrite_action('plugin.password'); $rcmail->output->send('plugin'); } @@ -197,7 +197,7 @@ class password extends rcube_plugin $input_curpasswd = new html_passwordfield(array('name' => '_curpasswd', 'id' => $field_id, 'size' => 20, 'autocomplete' => 'off')); - $table->add('title', html::label($field_id, Q($this->gettext('curpasswd')))); + $table->add('title', html::label($field_id, rcube::Q($this->gettext('curpasswd')))); $table->add(null, $input_curpasswd->show()); } @@ -206,7 +206,7 @@ class password extends rcube_plugin $input_newpasswd = new html_passwordfield(array('name' => '_newpasswd', 'id' => $field_id, 'size' => 20, 'autocomplete' => 'off')); - $table->add('title', html::label($field_id, Q($this->gettext('newpasswd')))); + $table->add('title', html::label($field_id, rcube::Q($this->gettext('newpasswd')))); $table->add(null, $input_newpasswd->show()); // show confirm password selection @@ -214,7 +214,7 @@ class password extends rcube_plugin $input_confpasswd = new html_passwordfield(array('name' => '_confpasswd', 'id' => $field_id, 'size' => 20, 'autocomplete' => 'off')); - $table->add('title', html::label($field_id, Q($this->gettext('confpasswd')))); + $table->add('title', html::label($field_id, rcube::Q($this->gettext('confpasswd')))); $table->add(null, $input_confpasswd->show()); $out = html::div(array('class' => 'box'), @@ -246,7 +246,7 @@ class password extends rcube_plugin $file = $this->home . "/drivers/$driver.php"; if (!file_exists($file)) { - raise_error(array( + rcube::raise_error(array( 'code' => 600, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, @@ -258,7 +258,7 @@ class password extends rcube_plugin include_once $file; if (!class_exists($class, false) || !method_exists($class, 'save')) { - raise_error(array( + rcube::raise_error(array( 'code' => 600, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, diff --git a/plugins/squirrelmail_usercopy/squirrelmail_usercopy.php b/plugins/squirrelmail_usercopy/squirrelmail_usercopy.php index 7849f915e..d5d0d47ec 100644 --- a/plugins/squirrelmail_usercopy/squirrelmail_usercopy.php +++ b/plugins/squirrelmail_usercopy/squirrelmail_usercopy.php @@ -73,8 +73,8 @@ class squirrelmail_usercopy extends rcube_plugin foreach ($this->abook as $rec) { // #1487096 handle multi-address and/or too long items $rec['email'] = array_shift(explode(';', $rec['email'])); - if (check_email(rcube_idn_to_ascii($rec['email']))) { - $rec['email'] = rcube_idn_to_utf8($rec['email']); + if (rcube_utils::check_email(rcube_utils::idn_to_ascii($rec['email']))) { + $rec['email'] = rcube_utils::idn_to_utf8($rec['email']); $contacts->insert($rec, true); } } @@ -167,7 +167,7 @@ class squirrelmail_usercopy extends rcube_plugin $sql_result = $db->query('SELECT * FROM '.$userprefs_table.' WHERE user=?', $uname); // ? is replaced with emailaddress while ($sql_array = $db->fetch_assoc($sql_result) ) { // fetch one row from result - $this->prefs[$sql_array['prefkey']] = rcube_charset_convert(rtrim($sql_array['prefval']), $db_charset); + $this->prefs[$sql_array['prefkey']] = rcube_charset::convert(rtrim($sql_array['prefval']), $db_charset); } /* retrieve address table data */ @@ -175,11 +175,11 @@ class squirrelmail_usercopy extends rcube_plugin // parse addres book while ($sql_array = $db->fetch_assoc($sql_result) ) { // fetch one row from result - $rec['name'] = rcube_charset_convert(rtrim($sql_array['nickname']), $db_charset); - $rec['firstname'] = rcube_charset_convert(rtrim($sql_array['firstname']), $db_charset); - $rec['surname'] = rcube_charset_convert(rtrim($sql_array['lastname']), $db_charset); - $rec['email'] = rcube_charset_convert(rtrim($sql_array['email']), $db_charset); - $rec['notes'] = rcube_charset_convert(rtrim($sql_array['label']), $db_charset); + $rec['name'] = rcube_charset::convert(rtrim($sql_array['nickname']), $db_charset); + $rec['firstname'] = rcube_charset::convert(rtrim($sql_array['firstname']), $db_charset); + $rec['surname'] = rcube_charset::convert(rtrim($sql_array['lastname']), $db_charset); + $rec['email'] = rcube_charset::convert(rtrim($sql_array['email']), $db_charset); + $rec['notes'] = rcube_charset::convert(rtrim($sql_array['label']), $db_charset); if ($rec['name'] && $rec['email']) $this->abook[] = $rec; diff --git a/plugins/subscriptions_option/subscriptions_option.php b/plugins/subscriptions_option/subscriptions_option.php index b81a5ac8a..7678d8e94 100644 --- a/plugins/subscriptions_option/subscriptions_option.php +++ b/plugins/subscriptions_option/subscriptions_option.php @@ -46,7 +46,7 @@ class subscriptions_option extends rcube_plugin $checkbox = new html_checkbox(array('name' => '_use_subscriptions', 'id' => $field_id, 'value' => 1)); $args['blocks']['main']['options']['use_subscriptions'] = array( - 'title' => html::label($field_id, Q($this->gettext('useimapsubscriptions'))), + 'title' => html::label($field_id, rcube::Q($this->gettext('useimapsubscriptions'))), 'content' => $checkbox->show($use_subscriptions?1:0), ); } diff --git a/plugins/userinfo/userinfo.php b/plugins/userinfo/userinfo.php index efb65f51d..a175563ef 100644 --- a/plugins/userinfo/userinfo.php +++ b/plugins/userinfo/userinfo.php @@ -31,25 +31,25 @@ class userinfo extends rcube_plugin $table = new html_table(array('cols' => 2, 'cellpadding' => 3)); $table->add('title', 'ID'); - $table->add('', Q($user->ID)); + $table->add('', rcube::Q($user->ID)); - $table->add('title', Q($this->gettext('username'))); - $table->add('', Q($user->data['username'])); + $table->add('title', rcube::Q($this->gettext('username'))); + $table->add('', rcube::Q($user->data['username'])); - $table->add('title', Q($this->gettext('server'))); - $table->add('', Q($user->data['mail_host'])); + $table->add('title', rcube::Q($this->gettext('server'))); + $table->add('', rcube::Q($user->data['mail_host'])); - $table->add('title', Q($this->gettext('created'))); - $table->add('', Q($user->data['created'])); + $table->add('title', rcube::Q($this->gettext('created'))); + $table->add('', rcube::Q($user->data['created'])); - $table->add('title', Q($this->gettext('lastlogin'))); - $table->add('', Q($user->data['last_login'])); + $table->add('title', rcube::Q($this->gettext('lastlogin'))); + $table->add('', rcube::Q($user->data['last_login'])); $identity = $user->get_identity(); - $table->add('title', Q($this->gettext('defaultidentity'))); - $table->add('', Q($identity['name'] . ' <' . $identity['email'] . '>')); + $table->add('title', rcube::Q($this->gettext('defaultidentity'))); + $table->add('', rcube::Q($identity['name'] . ' <' . $identity['email'] . '>')); - return html::tag('h4', null, Q('Infos for ' . $user->get_username())) . $table->show(); + return html::tag('h4', null, rcube::Q('Infos for ' . $user->get_username())) . $table->show(); } } diff --git a/plugins/vcard_attachments/vcard_attachments.php b/plugins/vcard_attachments/vcard_attachments.php index e7f7d5f1f..4905b373e 100644 --- a/plugins/vcard_attachments/vcard_attachments.php +++ b/plugins/vcard_attachments/vcard_attachments.php @@ -90,10 +90,10 @@ class vcard_attachments extends rcube_plugin $p['content'] .= html::p(array('class' => 'vcardattachment'), html::a(array( 'href' => "#", - 'onclick' => "return plugin_vcard_save_contact('" . JQ($part.':'.$idx) . "')", + 'onclick' => "return plugin_vcard_save_contact('" . rcube::JQ($part.':'.$idx) . "')", 'title' => $this->gettext('addvcardmsg'), ), - html::span(null, Q($display))) + html::span(null, rcube::Q($display))) ); } @@ -115,9 +115,9 @@ class vcard_attachments extends rcube_plugin { $this->add_texts('localization', true); - $uid = get_input_value('_uid', RCUBE_INPUT_POST); - $mbox = get_input_value('_mbox', RCUBE_INPUT_POST); - $mime_id = get_input_value('_part', RCUBE_INPUT_POST); + $uid = rcube_utils::get_input_value('_uid', rcube_utils::INPUT_POST); + $mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST); + $mime_id = rcube_utils::get_input_value('_part', rcube_utils::INPUT_POST); $rcmail = rcmail::get_instance(); $storage = $rcmail->get_storage(); @@ -144,7 +144,7 @@ class vcard_attachments extends rcube_plugin } else { // We're using UTF8 internally - $email = rcube_idn_to_utf8($email); + $email = rcube_utils::idn_to_utf8($email); // compare e-mail address $existing = $CONTACTS->search('email', $email, 1, false); diff --git a/plugins/virtuser_file/virtuser_file.php b/plugins/virtuser_file/virtuser_file.php index 01032616c..2c705b2d0 100644 --- a/plugins/virtuser_file/virtuser_file.php +++ b/plugins/virtuser_file/virtuser_file.php @@ -41,7 +41,7 @@ class virtuser_file extends rcube_plugin $arr = preg_split('/\s+/', $r[$i]); if (count($arr) > 0 && strpos($arr[0], '@')) { - $result[] = rcube_idn_to_ascii(trim(str_replace('\\@', '@', $arr[0]))); + $result[] = rcube_utils::idn_to_ascii(trim(str_replace('\\@', '@', $arr[0]))); if ($p['first']) { $p['email'] = $result[0]; diff --git a/plugins/virtuser_query/virtuser_query.php b/plugins/virtuser_query/virtuser_query.php index 073b4e230..c479a4f7f 100644 --- a/plugins/virtuser_query/virtuser_query.php +++ b/plugins/virtuser_query/virtuser_query.php @@ -28,8 +28,8 @@ class virtuser_query extends rcube_plugin function init() { - $this->app = rcmail::get_instance(); - $this->config = $this->app->config->get('virtuser_query'); + $this->app = rcmail::get_instance(); + $this->config = $this->app->config->get('virtuser_query'); if (!empty($this->config)) { if (is_string($this->config)) { @@ -53,35 +53,35 @@ class virtuser_query extends rcube_plugin */ function user2email($p) { - $dbh = $this->app->get_dbh(); - - $sql_result = $dbh->query(preg_replace('/%u/', $dbh->escapeSimple($p['user']), $this->config['email'])); - - while ($sql_arr = $dbh->fetch_array($sql_result)) { - if (strpos($sql_arr[0], '@')) { - if ($p['extended'] && count($sql_arr) > 1) { - $result[] = array( - 'email' => rcube_idn_to_ascii($sql_arr[0]), - 'name' => $sql_arr[1], - 'organization' => $sql_arr[2], - 'reply-to' => rcube_idn_to_ascii($sql_arr[3]), - 'bcc' => rcube_idn_to_ascii($sql_arr[4]), - 'signature' => $sql_arr[5], - 'html_signature' => (int)$sql_arr[6], - ); - } - else { - $result[] = $sql_arr[0]; - } - - if ($p['first']) - break; - } - } - - $p['email'] = $result; - - return $p; + $dbh = $this->app->get_dbh(); + + $sql_result = $dbh->query(preg_replace('/%u/', $dbh->escapeSimple($p['user']), $this->config['email'])); + + while ($sql_arr = $dbh->fetch_array($sql_result)) { + if (strpos($sql_arr[0], '@')) { + if ($p['extended'] && count($sql_arr) > 1) { + $result[] = array( + 'email' => rcube_utils::idn_to_ascii($sql_arr[0]), + 'name' => $sql_arr[1], + 'organization' => $sql_arr[2], + 'reply-to' => rcube_utils::idn_to_ascii($sql_arr[3]), + 'bcc' => rcube_utils::idn_to_ascii($sql_arr[4]), + 'signature' => $sql_arr[5], + 'html_signature' => (int)$sql_arr[6], + ); + } + else { + $result[] = $sql_arr[0]; + } + + if ($p['first']) + break; + } + } + + $p['email'] = $result; + + return $p; } /** diff --git a/plugins/zipdownload/zipdownload.php b/plugins/zipdownload/zipdownload.php index 8bad9b341..96c76eec9 100644 --- a/plugins/zipdownload/zipdownload.php +++ b/plugins/zipdownload/zipdownload.php @@ -30,7 +30,7 @@ class zipdownload extends rcube_plugin } $rcmail = rcmail::get_instance(); - $this->charset = $rcmail->config->get('zipdownload_charset', RCMAIL_CHARSET); + $this->charset = $rcmail->config->get('zipdownload_charset', RCUBE_CHARSET); $this->load_config(); $this->add_texts('localization'); @@ -62,11 +62,14 @@ class zipdownload extends rcube_plugin // only show the link if there is more than the configured number of attachments if (substr_count($p['content'], ' $rcmail->config->get('zipdownload_attachments', 1)) { - $link = html::a(array( - 'href' => rcmail_url('plugin.zipdownload.zip_attachments', array('_mbox' => $rcmail->output->env['mailbox'], '_uid' => $rcmail->output->env['uid'])), - 'class' => 'button zipdownload', - ), - Q($this->gettext('downloadall')) + $href = $rcmail->url(array( + '_action' => 'plugin.zipdownload.zip_attachments', + '_mbox' => $rcmail->output->env['mailbox'], + '_uid' => $rcmail->output->env['uid'], + )); + + $link = html::a(array('href' => $href, 'class' => 'button zipdownload'), + rcube::Q($this->gettext('downloadall')) ); // append link to attachments list, slightly different in some skins @@ -96,7 +99,7 @@ class zipdownload extends rcube_plugin $temp_dir = $rcmail->config->get('temp_dir'); $tmpfname = tempnam($temp_dir, 'zipdownload'); $tempfiles = array($tmpfname); - $message = new rcube_message(get_input_value('_uid', RCUBE_INPUT_GET)); + $message = new rcube_message(rcube_utils::get_input_value('_uid', rcube_utils::INPUT_GET)); // open zip file $zip = new ZipArchive(); @@ -140,7 +143,7 @@ class zipdownload extends rcube_plugin public function download_selection() { if (isset($_REQUEST['_uid'])) { - $uids = explode(",", get_input_value('_uid', RCUBE_INPUT_GPC)); + $uids = explode(",", rcube_utils::get_input_value('_uid', rcube_utils::INPUT_GPC)); if (sizeof($uids) > 0) $this->_download_messages($uids); @@ -157,7 +160,7 @@ class zipdownload extends rcube_plugin // initialize searching result if search_filter is used if ($_SESSION['search_filter'] && $_SESSION['search_filter'] != 'ALL') { - $imap->search($mbox_name, $_SESSION['search_filter'], RCMAIL_CHARSET); + $imap->search($mbox_name, $_SESSION['search_filter'], RCUBE_CHARSET); } // fetch message headers for all pages @@ -234,7 +237,9 @@ class zipdownload extends rcube_plugin private function _deliver_zipfile($tmpfname, $filename) { $browser = new rcube_browser; - send_nocacheing_headers(); + $rcmail = rcmail::get_instance(); + + $rcmail->output->nocacheing_headers(); if ($browser->ie && $browser->ver < 7) $filename = rawurlencode(abbreviate_string($filename, 55)); @@ -258,9 +263,9 @@ class zipdownload extends rcube_plugin /** * Helper function to convert filenames to the configured charset */ - private function _convert_filename($str, $from = RCMAIL_CHARSET) + private function _convert_filename($str, $from = RCUBE_CHARSET) { - return strtr(rcube_charset_convert($str, $from, $this->charset), array(':'=>'', '/'=>'-')); + return strtr(rcube_charset::convert($str, $from, $this->charset), array(':'=>'', '/'=>'-')); } } diff --git a/program/include/rcmail.php b/program/include/rcmail.php index c734216ac..5f2a2177b 100644 --- a/program/include/rcmail.php +++ b/program/include/rcmail.php @@ -1692,7 +1692,7 @@ class rcmail extends rcube $count = count($path); if ($count > 1) { - for ($i = 1; $i < $count; $i++) { + for ($i = 0; $i < $count; $i++) { $folder = implode($delimiter, array_slice($path, 0, -$i)); if ($folder_class = $this->folder_classname($folder)) { $name = implode($delimiter, array_slice($path, $count - $i)); -- cgit v1.2.3 From 3c309af0663f1673f921682c6ae3f673426e1397 Mon Sep 17 00:00:00 2001 From: Thomas Bruederli Date: Thu, 31 Jan 2013 13:49:35 +0100 Subject: - Refactored the hierarchical mailboxlist control into a separate widget class - Build address book directories list as hierarchical list - Make address book groups collapsible using the new new treelist widget - Use encoded identifiers for address book directory list items --- program/include/rcmail.php | 16 +- program/js/app.js | 206 +++++---------- program/js/treelist.js | 425 +++++++++++++++++++++++++++++++ program/steps/addressbook/func.inc | 28 +- skins/classic/addressbook.css | 35 ++- skins/classic/templates/addressbook.html | 3 +- skins/larry/addressbook.css | 21 +- skins/larry/templates/addressbook.html | 2 +- 8 files changed, 566 insertions(+), 170 deletions(-) create mode 100644 program/js/treelist.js (limited to 'program/include/rcmail.php') diff --git a/program/include/rcmail.php b/program/include/rcmail.php index 5f2a2177b..70dba4192 100644 --- a/program/include/rcmail.php +++ b/program/include/rcmail.php @@ -1406,6 +1406,7 @@ class rcmail extends rcube $js_mailboxlist = array(); $out = html::tag('ul', $attrib, $rcmail->render_folder_tree_html($a_mailboxes, $mbox_name, $js_mailboxlist, $attrib), html::$common_attrib); + $rcmail->output->include_script('treelist.js'); $rcmail->output->add_gui_object('mailboxlist', $attrib['id']); $rcmail->output->set_env('mailboxes', $js_mailboxlist); $rcmail->output->set_env('unreadwrap', $attrib['unreadwrap']); @@ -1584,14 +1585,13 @@ class rcmail extends rcube 'id' => "rcmli".$folder_id, 'class' => join(' ', $classes), 'noclose' => true), - html::a($link_attrib, $html_name) . - (!empty($folder['folders']) ? html::div(array( - 'class' => ($is_collapsed ? 'collapsed' : 'expanded'), - 'style' => "position:absolute", - 'onclick' => sprintf("%s.command('collapse-folder', '%s')", rcmail_output::JS_OBJECT_NAME, $js_name) - ), ' ') : '')); - - $jslist[$folder_id] = array( + html::a($link_attrib, $html_name)); + + if (!empty($folder['folders'])) { + $out .= html::div('treetoggle ' . ($is_collapsed ? 'collapsed' : 'expanded'), ' '); + } + + $jslist[$folder['id']] = array( 'id' => $folder['id'], 'name' => $foldername, 'virtual' => $folder['virtual'] diff --git a/program/js/app.js b/program/js/app.js index 6d5bdfe74..dbb65eea4 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -4,7 +4,7 @@ | | | This file is part of the Roundcube Webmail client | | Copyright (C) 2005-2013, The Roundcube Dev Team | - | Copyright (C) 2011-2012, Kolab Systems AG | + | Copyright (C) 2011-2013, Kolab Systems AG | | | | Licensed under the GNU General Public License version 3 or | | any later version with exceptions for skins & plugins. | @@ -459,9 +459,22 @@ function rcube_webmail() this.display_message(this.pending_message[0], this.pending_message[1], this.pending_message[2]); // map implicit containers - if (this.gui_objects.folderlist) + if (this.gui_objects.folderlist) { this.gui_containers.foldertray = $(this.gui_objects.folderlist); + // init treelist widget + if (window.rcube_treelist_widget) { + this.treelist = new rcube_treelist_widget(this.gui_objects.folderlist, { + id_prefix: 'rcmli', + id_encode: this.html_identifier_encode, + id_decode: this.html_identifier_decode, + check_droptarget: function(node){ return !node.virtual && ref.check_droptarget(node.id) } + }); + this.treelist.addEventListener('collapse', function(node){ ref.folder_collapsed(node) }); + this.treelist.addEventListener('expand', function(node){ ref.folder_collapsed(node) }); + } + } + // activate html5 file drop feature (if browser supports it and if configured) if (this.gui_objects.filedrop && this.env.filedrop && ((window.XMLHttpRequest && XMLHttpRequest.prototype && XMLHttpRequest.prototype.sendAsBinary) || window.FormData)) { $(document.body).bind('dragover dragleave drop', function(e){ return ref.document_drag_hover(e, e.type == 'dragover'); }); @@ -1263,11 +1276,12 @@ function rcube_webmail() this.html_identifier = function(str, encode) { - str = String(str); - if (encode) - return Base64.encode(str).replace(/=+$/, '').replace(/\+/g, '-').replace(/\//g, '_'); - else - return str.replace(this.identifier_expr, '_'); + return encode ? this.html_identifier_encode(str) : String(str).replace(this.identifier_expr, '_'); + }; + + this.html_identifier_encode = function(str) + { + return Base64.encode(String(str)).replace(/=+$/, '').replace(/\+/g, '-').replace(/\//g, '_'); }; this.html_identifier_decode = function(str) @@ -1320,29 +1334,9 @@ function rcube_webmail() if (this.preview_read_timer) clearTimeout(this.preview_read_timer); - // save folderlist and folders location/sizes for droptarget calculation in drag_move() - if (this.gui_objects.folderlist && model) { - this.initialBodyScrollTop = bw.ie ? 0 : window.pageYOffset; - this.initialListScrollTop = this.gui_objects.folderlist.parentNode.scrollTop; - - var k, li, height, - list = $(this.gui_objects.folderlist); - pos = list.offset(); - - this.env.folderlist_coords = { x1:pos.left, y1:pos.top, x2:pos.left + list.width(), y2:pos.top + list.height() }; - - this.env.folder_coords = []; - for (k in model) { - if (li = this.get_folder_li(k)) { - // only visible folders - if (height = li.firstChild.offsetHeight) { - pos = $(li.firstChild).offset(); - this.env.folder_coords[k] = { x1:pos.left, y1:pos.top, - x2:pos.left + li.firstChild.offsetWidth, y2:pos.top + height, on:0 }; - } - } - } - } + // prepare treelist widget for dragging interactions + if (this.treelist) + this.treelist.drag_start(); }; this.drag_end = function(e) @@ -1350,87 +1344,28 @@ function rcube_webmail() this.drag_active = false; this.env.last_folder_target = null; - if (this.folder_auto_timer) { - clearTimeout(this.folder_auto_timer); - this.folder_auto_timer = null; - this.folder_auto_expand = null; - } - - // over the folders - if (this.gui_objects.folderlist && this.env.folder_coords) { - for (var k in this.env.folder_coords) { - if (this.env.folder_coords[k].on) - $(this.get_folder_li(k)).removeClass('droptarget'); - } - } + if (this.treelist) + this.treelist.drag_end(); }; this.drag_move = function(e) { - if (this.gui_objects.folderlist && this.env.folder_coords) { - var k, li, div, check, oldclass, + if (this.gui_objects.folderlist) { + var drag_target, oldclass, layerclass = 'draglayernormal', - mouse = rcube_event.get_mouse_pos(e), - pos = this.env.folderlist_coords, - // offsets to compensate for scrolling while dragging a message - boffset = bw.ie ? -document.documentElement.scrollTop : this.initialBodyScrollTop, - moffset = this.initialListScrollTop-this.gui_objects.folderlist.parentNode.scrollTop; + mouse = rcube_event.get_mouse_pos(e); if (this.contact_list && this.contact_list.draglayer) oldclass = this.contact_list.draglayer.attr('class'); - mouse.y += -moffset-boffset; - - // if mouse pointer is outside of folderlist - if (mouse.x < pos.x1 || mouse.x >= pos.x2 || mouse.y < pos.y1 || mouse.y >= pos.y2) { - if (this.env.last_folder_target) { - $(this.get_folder_li(this.env.last_folder_target)).removeClass('droptarget'); - this.env.folder_coords[this.env.last_folder_target].on = 0; - this.env.last_folder_target = null; - } - if (layerclass != oldclass && this.contact_list && this.contact_list.draglayer) - this.contact_list.draglayer.attr('class', layerclass); - return; + // mouse intersects a valid drop target on the treelist + if (this.treelist && (drag_target = this.treelist.intersects(mouse, true))) { + this.env.last_folder_target = drag_target; + layerclass = 'draglayer' + (this.check_droptarget(drag_target) > 1 ? 'copy' : 'normal'); } - - // over the folders - for (k in this.env.folder_coords) { - pos = this.env.folder_coords[k]; - if (mouse.x >= pos.x1 && mouse.x < pos.x2 && mouse.y >= pos.y1 && mouse.y < pos.y2) { - if (check = this.check_droptarget(k)) { - li = this.get_folder_li(k); - div = $(li.getElementsByTagName('div')[0]); - - // if the folder is collapsed, expand it after 1sec and restart the drag & drop process. - if (div.hasClass('collapsed')) { - if (this.folder_auto_timer) - clearTimeout(this.folder_auto_timer); - - this.folder_auto_expand = this.env.mailboxes[k].id; - this.folder_auto_timer = setTimeout(function() { - rcmail.command('collapse-folder', rcmail.folder_auto_expand); - rcmail.drag_start(null); - }, 1000); - } - else if (this.folder_auto_timer) { - clearTimeout(this.folder_auto_timer); - this.folder_auto_timer = null; - this.folder_auto_expand = null; - } - - $(li).addClass('droptarget'); - this.env.folder_coords[k].on = 1; - this.env.last_folder_target = k; - layerclass = 'draglayer' + (check > 1 ? 'copy' : 'normal'); - } - // Clear target, otherwise drag end will trigger move into last valid droptarget - else - this.env.last_folder_target = null; - } - else if (pos.on) { - $(this.get_folder_li(k)).removeClass('droptarget'); - this.env.folder_coords[k].on = 0; - } + else { + // Clear target, otherwise drag end will trigger move into last valid droptarget + this.env.last_folder_target = null; } if (layerclass != oldclass && this.contact_list && this.contact_list.draglayer) @@ -1440,40 +1375,33 @@ function rcube_webmail() this.collapse_folder = function(name) { - var li = this.get_folder_li(name, '', true), - div = $('div:first', li), - ul = $('ul:first', li); + if (this.treelist) + this.treelist.toggle(name); + }; + + this.folder_collapsed = function(node) + { + var prefname = this.env.task == 'addressbook' ? 'collapsed_abooks' : 'collapsed_folders'; - if (div.hasClass('collapsed')) { - ul.show(); - div.removeClass('collapsed').addClass('expanded'); - var reg = new RegExp('&'+urlencode(name)+'&'); - this.env.collapsed_folders = this.env.collapsed_folders.replace(reg, ''); - } - else if (div.hasClass('expanded')) { - ul.hide(); - div.removeClass('expanded').addClass('collapsed'); - this.env.collapsed_folders = this.env.collapsed_folders+'&'+urlencode(name)+'&'; + if (node.collapsed) { + this.env[prefname] = this.env[prefname] + '&'+urlencode(node.id)+'&'; // select the folder if one of its childs is currently selected // don't select if it's virtual (#1488346) - if (this.env.mailbox.indexOf(name + this.env.delimiter) == 0 && !$(li).hasClass('virtual')) + if (this.env.mailbox && this.env.mailbox.indexOf(name + this.env.delimiter) == 0 && !node.virtual) this.command('list', name); } - else - return; - - // Work around a bug in IE6 and IE7, see #1485309 - if (bw.ie6 || bw.ie7) { - var siblings = li.nextSibling ? li.nextSibling.getElementsByTagName('ul') : null; - if (siblings && siblings.length && (li = siblings[0]) && li.style && li.style.display != 'none') { - li.style.display = 'none'; - li.style.display = ''; - } + else { + var reg = new RegExp('&'+urlencode(node.id)+'&'); + this.env[prefname] = this.env[prefname].replace(reg, ''); } - this.command('save-pref', { name: 'collapsed_folders', value: this.env.collapsed_folders }); - this.set_unread_count_display(name, false); + if (!this.drag_active) { + this.command('save-pref', { name: prefname, value: this.env[prefname] }); + + if (this.env.unread_counts) + this.set_unread_count_display(node.id, false); + } }; this.doc_mouse_up = function(e) @@ -1498,9 +1426,9 @@ function rcube_webmail() if (this.drag_active && model && this.env.last_folder_target) { var target = model[this.env.last_folder_target]; - $(this.get_folder_li(this.env.last_folder_target)).removeClass('droptarget'); this.env.last_folder_target = null; list.draglayer.hide(); + this.drag_end(e); if (!this.drag_menu(e, target)) this.command('moveto', target); @@ -4164,7 +4092,7 @@ function rcube_webmail() else if (!this.env.search_request) folder = group ? 'G'+src+group : src; - this.select_folder(folder); + this.select_folder(folder, '', true); this.env.source = src; this.env.group = group; @@ -4468,7 +4396,7 @@ function rcube_webmail() this.name_input.bind('keydown', function(e){ return rcmail.add_input_keydown(e); }); this.env.group_renaming = true; - var link, li = this.get_folder_li(this.env.source+this.env.group, 'rcmliG'); + var link, li = this.get_folder_li('G'+this.env.source+this.env.group,'',true); if (li && (link = li.firstChild)) { $(link).hide().before(this.name_input); } @@ -4489,7 +4417,7 @@ function rcube_webmail() this.remove_group_item = function(prop) { var li, key = 'G'+prop.source+prop.id; - if ((li = this.get_folder_li(key))) { + if ((li = this.get_folder_li(key,'',true))) { this.triggerEvent('group_delete', { source:prop.source, id:prop.id, li:li }); li.parentNode.removeChild(li); @@ -4511,7 +4439,7 @@ function rcube_webmail() this.name_input.bind('keydown', function(e){ return rcmail.add_input_keydown(e); }); this.name_input_li = $('
  • ').addClass(type).append(this.name_input); - var li = type == 'contactsearch' ? $('li:last', this.gui_objects.folderlist) : this.get_folder_li(this.env.source); + var li = type == 'contactsearch' ? $('li:last', this.gui_objects.folderlist) : $('ul.groups li:last', this.get_folder_li(this.env.source,'',true)); this.name_input_li.insertAfter(li); } @@ -4612,7 +4540,7 @@ function rcube_webmail() this.reset_add_input(); var key = 'G'+prop.source+prop.id, - li = this.get_folder_li(key), + li = this.get_folder_li(key,'',true), link; // group ID has changed, replace link node and identifiers @@ -4651,8 +4579,8 @@ function rcube_webmail() this.add_contact_group_row = function(prop, li, reloc) { var row, name = prop.name.toUpperCase(), - sibling = this.get_folder_li(prop.source), - prefix = 'rcmliG' + this.html_identifier(prop.source); + sibling = this.get_folder_li(prop.source,'',true), + prefix = 'rcmli' + this.html_identifier('G'+prop.source, true); // When renaming groups, we need to remove it from DOM and insert it in the proper place if (reloc) { @@ -4901,12 +4829,12 @@ function rcube_webmail() .attr('rel', id) .click(function() { return rcmail.command('listsearch', id, this); }) .html(name), - li = $('
  • ').attr({id: 'rcmli' + this.html_identifier(key), 'class': 'contactsearch'}) + li = $('
  • ').attr({ id:'rcmli' + this.html_identifier(key,true), 'class':'contactsearch' }) .append(link), prop = {name:name, id:id, li:li[0]}; this.add_saved_search_row(prop, li); - this.select_folder('S'+id); + this.select_folder(key,'',true); this.enable_command('search-delete', true); this.env.search_id = id; @@ -4960,7 +4888,7 @@ function rcube_webmail() this.remove_search_item = function(id) { var li, key = 'S'+id; - if ((li = this.get_folder_li(key))) { + if ((li = this.get_folder_li(key,'',true))) { this.triggerEvent('search_delete', { id:id, li:li }); li.parentNode.removeChild(li); @@ -4982,7 +4910,7 @@ function rcube_webmail() } this.reset_qsearch(); - this.select_folder('S'+id); + this.select_folder('S'+id, '', true); // reset vars this.env.current_page = 1; diff --git a/program/js/treelist.js b/program/js/treelist.js new file mode 100644 index 000000000..47ac0c1a0 --- /dev/null +++ b/program/js/treelist.js @@ -0,0 +1,425 @@ +/* + +-----------------------------------------------------------------------+ + | Roundcube Treelist widget | + | | + | This file is part of the Roundcube Webmail client | + | Copyright (C) 2013, 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. | + | | + +-----------------------------------------------------------------------+ + | Authors: Thomas Bruederli | + +-----------------------------------------------------------------------+ + | Requires: common.js | + +-----------------------------------------------------------------------+ +*/ + + +/** + * Roundcube Treelist widget class + * @contructor + */ +function rcube_treelist_widget(node, p) +{ + // apply some defaults to p + p = $.extend({ + id_prefix: '', + autoexpand: 1000, + selectable: false, + check_droptarget: function(node){ return !node.virtual } + }, p || {}); + + var container = $(node); + var data = p.data || []; + var indexbyid = {}; + var selection = null; + var drag_active = false; + var box_coords = {}; + var item_coords = []; + var autoexpand_timer; + var autoexpand_item; + var body_scroll_top = 0; + var list_scroll_top = 0; + var me = this; + + + /////// export public members and methods + + this.container = container; + this.expand = expand; + this.collapse = collapse; + this.select = select; + this.render = render; + this.drag_start = drag_start; + this.drag_end = drag_end; + this.intersects = intersects; + + + /////// startup code (constructor) + + // abort if node not found + if (!container.length) + return; + + if (p.data) { + index_data({ children:data }); + } + // load data from DOM + else { + data = walk_list(container); + // console.log(data); + } + + // register click handlers on list + container.on('click', 'div.treetoggle', function(e){ + toggle(dom2id($(this).parent())); + }); + + container.on('click', 'li', function(e){ + var node = p.selectable ? indexbyid[dom2id($(this))] : null; + if (node && !node.virtual) { + select(node.id); + e.stopPropagation(); + } + }); + + + /////// private methods + + /** + * Collaps a the node with the given ID + */ + function collapse(id, recursive, set) + { + var node; + if (node = indexbyid[id]) { + node.collapsed = typeof set == 'undefined' || set; + update_dom(node); + + // Work around a bug in IE6 and IE7, see #1485309 + if (window.bw && (bw.ie6 || bw.ie7) && node.collapsed) { + id2dom(node.id).next().children('ul:visible').hide().show(); + } + + if (recursive && node.children) { + for (var i=0; i < node.children.length; i++) { + collapse(node.children[i].id, recursive, set); + } + } + + me.triggerEvent(node.collapsed ? 'collapse' : 'expand', node); + } + } + + /** + * Expand a the node with the given ID + */ + function expand(id, recursive) + { + collapse(id, recursive, false); + } + + /** + * Toggle collapsed state of a list node + */ + function toggle(id, recursive) + { + var node; + if (node = indexbyid[id]) { + collapse(id, recursive, !node.collapsed); + } + } + + /** + * Select a tree node by it's ID + */ + function select(id) + { + if (selection) { + id2dom(selection).removeClass('selected'); + selection = null; + } + + var li = id2dom(id); + if (li.length) { + li.addClass('selected'); + selection = id; + // TODO: expand all parent nodes if collapsed + scroll_to_node(li); + } + + me.triggerEvent('select', indexbyid[id]); + } + + /** + * Getter for the currently selected node ID + */ + function get_selection() + { + return selection; + } + + /** + * Return the DOM element of the list item with the given ID + */ + function get_item(id) + { + return id2dom(id).get(0); + } + + /** + * Apply the 'collapsed' status of the data node to the corresponding DOM element(s) + */ + function update_dom(node) + { + var li = id2dom(node.id); + li.children('ul').first()[(node.collapsed ? 'hide' : 'show')](); + li.children('div.treetoggle').removeClass('collapsed expanded').addClass(node.collapsed ? 'collapsed' : 'expanded'); + me.triggerEvent('toggle', node); + } + + /** + * Render the tree list from the internal data structure + */ + function render() + { + if (me.triggerEvent('renderBefore', data) === false) + return; + + // remove all child nodes + container.html(''); + + // render child nodes + for (var i=0; i < data.length; i++) { + render_node(data[i], container); + } + + me.triggerEvent('renderAfter', container); + } + + /** + * Render a specific node into the DOM list + */ + function render_node(node, parent) + { + var li = $('
  • ' + node.html + '
  • ') + .attr('id', p.id_prefix + node.id) + .addClass((node.classes || []).join(' ')) + .appendTo(parent); + + if (node.virtual) + li.addClass('virtual'); + if (node.id == selection) + li.addClass('selected'); + + // add child list and toggle icon + if (node.children && node.children.length) { + $('
     
    ').appendTo(li); + var ul = $('
      ').appendTo(li); + if (node.collapsed) + ul.hide(); + + for (var i=0; i < node.children.length; i++) { + render_node(node.children[i], ul); + } + } + } + + /** + * Recursively walk the DOM tree and build an internal data structure + * representing the skeleton of this tree list. + */ + function walk_list(ul) + { + var result = []; + ul.children('li').each(function(i,e){ + var li = $(e); + var node = { + id: dom2id(li), + classes: li.attr('class').split(' '), + virtual: li.hasClass('virtual'), + html: li.children().first().get(0).outerHTML, + children: walk_list(li.children('ul')) + } + + if (node.children.length) { + node.collapsed = li.children('ul').css('display') == 'none'; + } + if (li.hasClass('selected')) { + selection = node.id; + } + + result.push(node); + indexbyid[node.id] = node; + }) + + return result; + } + + /** + * Recursively walk the data tree and index nodes by their ID + */ + function index_data(node) + { + if (node.id) { + indexbyid[node.id] = node; + } + for (var c=0; node.children && c < node.children.length; c++) { + index_data(node.children[c]); + } + } + + /** + * Get the (stripped) node ID from the given DOM element + */ + function dom2id(li) + { + var domid = li.attr('id').replace(new RegExp('^' + (p.id_prefix) || '%'), ''); + return p.id_decode ? p.id_decode(domid) : domid; + } + + /** + * Get the
    • element for the given node ID + */ + function id2dom(id) + { + var domid = p.id_encode ? p.id_encode(id) : id; + return $('#' + p.id_prefix + domid); + } + + /** + * Scroll the parent container to make the given list item visible + */ + function scroll_to_node(li) + { + var scroller = container.parent(); + scroller.scrollTop(li.offset().top - scroller.offset().top + scroller.scrollTop()); + } + + ///// drag & drop support + + /** + * When dragging starts, compute absolute bounding boxes of the list and it's items + * for faster comparisons while mouse is moving + */ + function drag_start() + { + var li, item, height, + pos = container.offset(); + + body_scroll_top = bw.ie ? 0 : window.pageYOffset; + list_scroll_top = container.parent().scrollTop(); + + drag_active = true; + box_coords = { + x1: pos.left, + y1: pos.top, + x2: pos.left + container.width(), + y2: pos.top + container.height() + }; + + item_coords = []; + for (var id in indexbyid) { + li = id2dom(id); + item = li.children().first().get(0); + if (height = item.offsetHeight) { + pos = $(item).offset(); + item_coords[id] = { + x1: pos.left, + y1: pos.top, + x2: pos.left + item.offsetWidth, + y2: pos.top + height, + on: id == autoexpand_item + }; + } + } + } + + /** + * Signal that dragging has stopped + */ + function drag_end() + { + drag_active = false; + + if (autoexpand_timer) { + clearTimeout(autoexpand_timer); + autoexpand_timer = null; + autoexpand_item = null; + } + + $('li.droptarget', container).removeClass('droptarget'); + } + + /** + * Determine if the given mouse coords intersect the list and one if its items + */ + function intersects(mouse, highlight) + { + // offsets to compensate for scrolling while dragging a message + var boffset = bw.ie ? -document.documentElement.scrollTop : body_scroll_top, + moffset = list_scroll_top - container.parent().scrollTop(), + result = null; + + mouse.top = mouse.y + -moffset - boffset; + + // no intersection with list bounding box + if (mouse.x < box_coords.x1 || mouse.x >= box_coords.x2 || mouse.top < box_coords.y1 || mouse.top >= box_coords.y2) { + // TODO: optimize performance for this operation + $('li.droptarget', container).removeClass('droptarget'); + return result; + } + + // check intersection with visible list items + var pos, node; + for (var id in item_coords) { + pos = item_coords[id]; + if (mouse.x >= pos.x1 && mouse.x < pos.x2 && mouse.top >= pos.y1 && mouse.top < pos.y2) { + node = indexbyid[id]; + + // if the folder is collapsed, expand it after the configured time + if (node.children && node.children.length && node.collapsed && p.autoexpand && autoexpand_item != id) { + if (autoexpand_timer) + clearTimeout(autoexpand_timer); + + autoexpand_item = id; + autoexpand_timer = setTimeout(function() { + expand(autoexpand_item); + drag_start(); // re-calculate item coords + autoexpand_item = null; + }, p.autoexpand); + } + else if (autoexpand_timer && autoexpand_item != id) { + clearTimeout(autoexpand_timer); + autoexpand_item = null; + autoexpand_timer = null; + } + + // check if this item is accepted as drop target + if (p.check_droptarget(node)) { + if (highlight) { + id2dom(id).addClass('droptarget'); + pos.on = true; + } + result = id; + } + else { + result = null; + } + } + else if (pos.on) { + id2dom(id).removeClass('droptarget'); + pos.on = false; + } + } + + return result; + } +} + +// use event processing functions from Roundcube's rcube_event_engine +rcube_treelist_widget.prototype.addEventListener = rcube_event_engine.prototype.addEventListener; +rcube_treelist_widget.prototype.removeEventListener = rcube_event_engine.prototype.removeEventListener; +rcube_treelist_widget.prototype.triggerEvent = rcube_event_engine.prototype.triggerEvent; diff --git a/program/steps/addressbook/func.inc b/program/steps/addressbook/func.inc index 7fb862d5e..80631cd61 100644 --- a/program/steps/addressbook/func.inc +++ b/program/steps/addressbook/func.inc @@ -187,7 +187,7 @@ function rcmail_directory_list($attrib) $jsdata = array(); $line_templ = html::tag('li', array( - 'id' => 'rcmli%s', 'class' => '%s'), + 'id' => 'rcmli%s', 'class' => '%s', 'noclose' => true), html::a(array('href' => '%s', 'rel' => '%s', 'onclick' => "return ".JS_OBJECT_NAME.".command('list','%s',this)"), '%s')); @@ -213,7 +213,7 @@ function rcmail_directory_list($attrib) $name = !empty($source['name']) ? $source['name'] : $id; $out .= sprintf($line_templ, - html_identifier($id), + rcube_utils::html_identifier($id, true), $class_name, Q(rcmail_url(null, array('_source' => $id))), $source['id'], @@ -224,10 +224,11 @@ function rcmail_directory_list($attrib) $groupdata = rcmail_contact_groups($groupdata); $jsdata = $groupdata['jsdata']; $out = $groupdata['out']; + $out .= '
    • '; } $line_templ = html::tag('li', array( - 'id' => 'rcmliS%s', 'class' => '%s'), + 'id' => 'rcmli%s', 'class' => '%s'), html::a(array('href' => '#', 'rel' => 'S%s', 'onclick' => "return ".JS_OBJECT_NAME.".command('listsearch', '%s', this)"), '%s')); @@ -245,14 +246,17 @@ function rcmail_directory_list($attrib) $class_name .= ' ' . $source['class_name']; $out .= sprintf($line_templ, - html_identifier($id), + rcube_utils::html_identifier('S'.$id, true), $class_name, $id, $js_id, (!empty($source['name']) ? Q($source['name']) : Q($id))); } $OUTPUT->set_env('contactgroups', $jsdata); + $OUTPUT->set_env('collapsed_abooks', (string)$RCMAIL->config->get('collapsed_abooks','')); $OUTPUT->add_gui_object('folderlist', $attrib['id']); + $OUTPUT->include_script('treelist.js'); + // add some labels to client $OUTPUT->add_label('deletegroupconfirm', 'groupdeleting', 'addingmember', 'removingmember'); @@ -265,18 +269,24 @@ function rcmail_contact_groups($args) global $RCMAIL; $groups = $RCMAIL->get_address_book($args['source'])->list_groups(); + $js_id = $RCMAIL->JQ($args['source']); if (!empty($groups)) { $line_templ = html::tag('li', array( - 'id' => 'rcmliG%s', 'class' => 'contactgroup'), + 'id' => 'rcmli%s', 'class' => 'contactgroup'), html::a(array('href' => '#', 'rel' => '%s:%s', 'onclick' => "return ".JS_OBJECT_NAME.".command('listgroup',{'source':'%s','id':'%s'},this)"), '%s')); + // append collapse/expand toggle and open a new
        + $is_collapsed = strpos($RCMAIL->config->get('collapsed_abooks',''), '&'.rawurlencode($args['source']).'&') !== false; + $args['out'] .= html::div('treetoggle ' . ($is_collapsed ? 'collapsed' : 'expanded'), ' '); + $jsdata = array(); + $groups_html = ''; foreach ($groups as $group) { - $args['out'] .= sprintf($line_templ, - html_identifier($args['source'] . $group['ID']), + $groups_html .= sprintf($line_templ, + rcube_utils::html_identifier('G' . $args['source'] . $group['ID'], true), $args['source'], $group['ID'], $args['source'], $group['ID'], Q($group['name']) ); @@ -286,6 +296,10 @@ function rcmail_contact_groups($args) } } + $args['out'] .= html::tag('ul', + array('class' => 'groups', 'style' => ($is_collapsed ? "display:none;" : null)), + $groups_html); + return $args; } diff --git a/skins/classic/addressbook.css b/skins/classic/addressbook.css index 78314538a..5afa4592f 100644 --- a/skins/classic/addressbook.css +++ b/skins/classic/addressbook.css @@ -118,7 +118,7 @@ #directorylistbox input { - margin: 0px; + margin: 0 0 0 20px; font-size: 11px; width: 90%; } @@ -144,7 +144,8 @@ width: 280px; } -#directorylist +#directorylist, +#directorylist li ul { list-style: none; margin: 0; @@ -152,11 +153,15 @@ background-color: #FFFFFF; } +#directorylist li ul +{ + border-top: 1px solid #EBEBEB; +} + #directorylist li { display: block; font-size: 11px; - background: url(images/icons/folders.png) 5px -108px no-repeat; border-bottom: 1px solid #EBEBEB; white-space: nowrap; } @@ -168,31 +173,37 @@ padding-left: 25px; padding-top: 2px; padding-bottom: 2px; + height: 16px; text-decoration: none; white-space: nowrap; + background: url(images/icons/folders.png) 5px -108px no-repeat; } -#directorylist li.contactgroup +#directorylist li ul li a { - padding-left: 15px; - background-position: 20px -143px; + padding-left: 45px; } -#directorylist li.contactsearch +#directorylist li ul li:last-child { - background-position: 6px -162px; + border-bottom: 0; } -#directorylist li.selected +#directorylist li.contactgroup a { - background-color: #929292; - border-bottom: 1px solid #898989; + background-position: 22px -143px; +} + +#directorylist li.contactsearch a +{ + background-position: 6px -162px; } -#directorylist li.selected a +#directorylist li.selected > a { color: #FFF; font-weight: bold; + background-color: #929292; } #directorylist li.droptarget diff --git a/skins/classic/templates/addressbook.html b/skins/classic/templates/addressbook.html index 404fb2c11..9d959d5ef 100644 --- a/skins/classic/templates/addressbook.html +++ b/skins/classic/templates/addressbook.html @@ -63,8 +63,7 @@
        - - +