From 38bf401cf88bc88d3b4d96fee8d2166cc2cac8c6 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Sun, 01 Dec 2013 04:55:13 -0500
Subject: [PATCH] Fix performance of listing writeable folders (#1489451)
---
program/include/rcmail.php | 68 +++++++++++++++++++++++++++++-----
1 files changed, 58 insertions(+), 10 deletions(-)
diff --git a/program/include/rcmail.php b/program/include/rcmail.php
index 1c9f3dd..8abe873 100644
--- a/program/include/rcmail.php
+++ b/program/include/rcmail.php
@@ -346,6 +346,44 @@
return $list;
}
+ /**
+ * Getter for compose responses.
+ * These are stored in local config and user preferences.
+ *
+ * @param boolean True to sort the list alphabetically
+ * @param boolean True if only this user's responses shall be listed
+ * @return array List of the current user's stored responses
+ */
+ public function get_compose_responses($sorted = false, $user_only = false)
+ {
+ $responses = array();
+
+ if (!$user_only) {
+ foreach ($this->config->get('compose_responses_static', array()) as $response) {
+ if (empty($response['key']))
+ $response['key'] = substr(md5($response['name']), 0, 16);
+ $response['static'] = true;
+ $response['class'] = 'readonly';
+ $k = $sorted ? '0000-' . strtolower($response['name']) : $response['key'];
+ $responses[$k] = $response;
+ }
+ }
+
+ foreach ($this->config->get('compose_responses', array()) as $response) {
+ if (empty($response['key']))
+ $response['key'] = substr(md5($response['name']), 0, 16);
+ $k = $sorted ? strtolower($response['name']) : $response['key'];
+ $responses[$k] = $response;
+ }
+
+ // sort list by name
+ if ($sorted) {
+ ksort($responses, SORT_LOCALE_STRING);
+ }
+
+ return array_values($responses);
+ }
+
/**
* Init output object for GUI and add common scripts.
@@ -374,6 +412,9 @@
$this->output->set_env('action', $this->action);
$this->output->set_env('comm_path', $this->comm_path);
$this->output->set_charset(RCUBE_CHARSET);
+
+ if ($this->user && $this->user->ID)
+ $this->output->set_env('user_id', $this->user->get_hash());
// add some basic labels to client
$this->output->add_label('loading', 'servererror', 'requesttimedout', 'refreshing');
@@ -481,15 +522,22 @@
$port = $config['default_port'];
}
- /* Modify username with domain if required
- Inspired by Marco <P0L0_notspam_binware.org>
- */
- // Check if we need to add domain
- if (!empty($config['username_domain']) && strpos($username, '@') === false) {
- if (is_array($config['username_domain']) && isset($config['username_domain'][$host]))
- $username .= '@'.rcube_utils::parse_host($config['username_domain'][$host], $host);
- else if (is_string($config['username_domain']))
- $username .= '@'.rcube_utils::parse_host($config['username_domain'], $host);
+ // Check if we need to add/force domain to username
+ if (!empty($config['username_domain'])) {
+ $domain = is_array($config['username_domain']) ? $config['username_domain'][$host] : $config['username_domain'];
+
+ if ($domain = rcube_utils::parse_host((string)$domain, $host)) {
+ $pos = strpos($username, '@');
+
+ // force configured domains
+ if (!empty($config['username_domain_forced']) && $pos !== false) {
+ $username = substr($username, 0, $pos) . '@' . $domain;
+ }
+ // just add domain if not specified
+ else if ($pos === false) {
+ $username .= '@' . $domain;
+ }
+ }
}
if (!isset($config['login_lc'])) {
@@ -954,7 +1002,7 @@
/**
* Write login data (name, ID, IP address) to the 'userlogins' log file.
*/
- public function log_login($user, $failed_login = false, $error_code = 0)
+ public function log_login($user = null, $failed_login = false, $error_code = 0)
{
if (!$this->config->get('log_logins')) {
return;
--
Gitblit v1.9.1