summaryrefslogtreecommitdiff
path: root/program/include
diff options
context:
space:
mode:
Diffstat (limited to 'program/include')
-rw-r--r--program/include/bc.php19
-rw-r--r--program/include/iniset.php4
-rw-r--r--program/include/rcmail.php101
-rw-r--r--program/include/rcmail_html_page.php18
-rw-r--r--program/include/rcmail_output_html.php49
5 files changed, 143 insertions, 48 deletions
diff --git a/program/include/bc.php b/program/include/bc.php
index 5047e0a84..d8356338d 100644
--- a/program/include/bc.php
+++ b/program/include/bc.php
@@ -23,6 +23,7 @@
* Roundcube Webmail deprecated functions
*
* @package Core
+ * @subpackage Legacy
* @author Thomas Bruederli <roundcube@gmail.com>
*/
@@ -204,9 +205,9 @@ function rcmail_quota_content($attrib = null)
return rcmail::get_instance()->quota_content($attrib);
}
-function rcmail_display_server_error($fallback=null, $fallback_args=null)
+function rcmail_display_server_error($fallback=null, $fallback_args=null, $suffix='')
{
- rcmail::get_instance()->display_server_error($fallback, $fallback_args);
+ rcmail::get_instance()->display_server_error($fallback, $fallback_args, $suffix);
}
function rcmail_filetype2classname($mimetype, $filename)
@@ -399,7 +400,19 @@ function get_boolean($str)
return rcube_utils::get_boolean($str);
}
+function enriched_to_html($data)
+{
+ return rcube_enriched::to_html($data);
+}
+
class rcube_html_page extends rcmail_html_page
{
-
+}
+
+class washtml extends rcube_washtml
+{
+}
+
+class html2text extends rcube_html2text
+{
}
diff --git a/program/include/iniset.php b/program/include/iniset.php
index be71fc084..b32ae4e8e 100644
--- a/program/include/iniset.php
+++ b/program/include/iniset.php
@@ -5,7 +5,7 @@
| program/include/iniset.php |
| |
| This file is part of the Roundcube Webmail client |
- | Copyright (C) 2008-2012, The Roundcube Dev Team |
+ | Copyright (C) 2008-2013, The Roundcube Dev Team |
| |
| Licensed under the GNU General Public License version 3 or |
| any later version with exceptions for skins & plugins. |
@@ -21,7 +21,7 @@
*/
// application constants
-define('RCMAIL_VERSION', '0.9-git');
+define('RCMAIL_VERSION', '1.0-git');
define('RCMAIL_START', microtime(true));
$config = array(
diff --git a/program/include/rcmail.php b/program/include/rcmail.php
index 8e01a2155..1bde4034f 100644
--- a/program/include/rcmail.php
+++ b/program/include/rcmail.php
@@ -123,7 +123,7 @@ class rcmail extends rcube
*/
public function set_task($task)
{
- $task = asciiwords($task);
+ $task = asciiwords($task, true);
if ($this->user && $this->user->ID)
$task = !$task ? 'mail' : $task;
@@ -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) : ''));
}
}
@@ -1395,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']);
@@ -1573,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)
- ), '&nbsp;') : ''));
-
- $jslist[$folder_id] = array(
+ html::a($link_attrib, $html_name));
+
+ if (!empty($folder['folders'])) {
+ $out .= html::div('treetoggle ' . ($is_collapsed ? 'collapsed' : 'expanded'), '&nbsp;');
+ }
+
+ $jslist[$folder['id']] = array(
'id' => $folder['id'],
'name' => $foldername,
'virtual' => $folder['virtual']
@@ -1666,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 = 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));
+ return $this->gettext($folder_class) . $delimiter . rcube_charset::convert($name, 'UTF7-IMAP');
+ }
+ }
+ }
+ }
+
if ($folder_class = $this->folder_classname($name)) {
return $this->gettext($folder_class);
}
@@ -1768,32 +1798,51 @@ class rcmail extends rcube
*
* @param string $fallback Fallback message label
* @param array $fallback_args Fallback message label arguments
+ * @param string $suffix Message label suffix
*/
- public function display_server_error($fallback = null, $fallback_args = null)
+ public function display_server_error($fallback = null, $fallback_args = null, $suffix = '')
{
$err_code = $this->storage->get_error_code();
$res_code = $this->storage->get_response_code();
+ $args = array();
if ($res_code == rcube_storage::NOPERM) {
- $this->output->show_message('errornoperm', 'error');
+ $error = 'errornoperm';
}
else if ($res_code == rcube_storage::READONLY) {
- $this->output->show_message('errorreadonly', 'error');
+ $error = 'errorreadonly';
+ }
+ else if ($res_code == rcube_storage::OVERQUOTA) {
+ $error = 'errorroverquota';
}
else if ($err_code && ($err_str = $this->storage->get_error_str())) {
// try to detect access rights problem and display appropriate message
if (stripos($err_str, 'Permission denied') !== false) {
- $this->output->show_message('errornoperm', 'error');
+ $error = 'errornoperm';
+ }
+ // try to detect full mailbox problem and display appropriate message
+ // there can be e.g. "Quota exceeded" or "quotum would exceed"
+ else if (stripos($err_str, 'quot') !== false && stripos($err_str, 'exceed') !== false) {
+ $error = 'erroroverquota';
}
else {
- $this->output->show_message('servererrormsg', 'error', array('msg' => $err_str));
+ $error = 'servererrormsg';
+ $args = array('msg' => $err_str);
}
}
else if ($err_code < 0) {
- $this->output->show_message('storageerror', 'error');
+ $error = 'storageerror';
}
else if ($fallback) {
- $this->output->show_message($fallback, 'error', $fallback_args);
+ $error = $fallback;
+ $args = $fallback_args;
+ }
+
+ if ($error) {
+ if ($suffix && $this->text_exists($error . $suffix)) {
+ $error .= $suffix;
+ }
+ $this->output->show_message($error, 'error', $args);
}
}
diff --git a/program/include/rcmail_html_page.php b/program/include/rcmail_html_page.php
index 2624d590a..5d07b8d04 100644
--- a/program/include/rcmail_html_page.php
+++ b/program/include/rcmail_html_page.php
@@ -5,7 +5,7 @@
| program/include/rcmail_html_page.php |
| |
| This file is part of the Roundcube Webmail client |
- | Copyright (C) 2006-2012, The Roundcube Dev Team |
+ | Copyright (C) 2006-2013, The Roundcube Dev Team |
| |
| Licensed under the GNU General Public License version 3 or |
| any later version with exceptions for skins & plugins. |
@@ -21,7 +21,7 @@
/**
- * Class to create HTML page output using a skin template
+ * Class to create an empty HTML page with some default styles
*
* @package Core
* @subpackage View
@@ -30,7 +30,19 @@ class rcmail_html_page extends rcmail_output_html
{
public function write($contents = '')
{
- self::reset();
+ self::reset(true);
+
+ // load embed.css from skin folder (if exists)
+ if ($embed_css = $this->get_skin_file('/embed.css')) {
+ $this->include_css($embed_css);
+ }
+ else { // set default styles for warning blocks inside the attachment part frame
+ $this->add_header(html::tag('style', array('type' => 'text/css'),
+ ".rcmail-inline-message { font-family: sans-serif; border:2px solid #ffdf0e; background:#fef893; padding:0.6em 1em; margin-bottom:0.6em }\n" .
+ ".rcmail-inline-buttons { margin-bottom:0 }"
+ ));
+ }
+
parent::write($contents);
}
} \ No newline at end of file
diff --git a/program/include/rcmail_output_html.php b/program/include/rcmail_output_html.php
index 795c0b381..f2bdd95a7 100644
--- a/program/include/rcmail_output_html.php
+++ b/program/include/rcmail_output_html.php
@@ -80,6 +80,8 @@ class rcmail_output_html extends rcmail_output
if (!empty($_REQUEST['_extwin']))
$this->set_env('extwin', 1);
+ if ($this->framed || !empty($_REQUEST['_framed']))
+ $this->set_env('framed', 1);
// add common javascripts
$this->add_script('var '.self::JS_OBJECT_NAME.' = new rcube_webmail();', 'head_top');
@@ -164,6 +166,7 @@ class rcmail_output_html extends rcmail_output
}
$this->config->set('skin_path', $skin_path);
+ $this->base_path = $skin_path;
// register skin path(s)
$this->skin_paths = array();
@@ -214,7 +217,7 @@ class rcmail_output_html extends rcmail_output
* @param string Additional path to search in
* @return mixed Relative path to the requested file or False if not found
*/
- public function get_skin_file($file, &$skin_path, $add_path = null)
+ public function get_skin_file($file, &$skin_path = null, $add_path = null)
{
$skin_paths = $this->skin_paths;
if ($add_path)
@@ -304,13 +307,19 @@ class rcmail_output_html extends rcmail_output
/**
* Delete all stored env variables and commands
+ *
+ * @param bool $all Reset all env variables (including internal)
*/
- public function reset()
+ public function reset($all = false)
{
+ $env = $all ? null : array_intersect_key($this->env, array('extwin'=>1, 'framed'=>1));
+
parent::reset();
- $this->js_env = array();
- $this->js_labels = array();
- $this->js_commands = array();
+
+ // let some env variables survive
+ $this->env = $this->js_env = $env;
+ $this->js_labels = array();
+ $this->js_commands = array();
$this->script_files = array();
$this->scripts = array();
$this->header = '';
@@ -355,7 +364,7 @@ class rcmail_output_html extends rcmail_output
$this->parse($templ, false);
}
else {
- $this->framed = $templ == 'iframe' ? true : $this->framed;
+ $this->framed = true;
$this->write();
}
@@ -379,7 +388,7 @@ class rcmail_output_html extends rcmail_output
// unlock interface after iframe load
$unlock = preg_replace('/[^a-z0-9]/i', '', $_REQUEST['_unlock']);
if ($this->framed) {
- array_unshift($this->js_commands, array('set_busy', false, null, $unlock));
+ array_unshift($this->js_commands, array('iframe_loaded', $unlock));
}
else if ($unlock) {
array_unshift($this->js_commands, array('hide_message', $unlock));
@@ -389,9 +398,11 @@ class rcmail_output_html extends rcmail_output
$this->set_env('request_token', $this->app->get_request_token());
// write all env variables to client
- $js = $this->framed ? "if(window.parent) {\n" : '';
- $js .= $this->get_js_commands() . ($this->framed ? ' }' : '');
- $this->add_script($js, 'head_top');
+ if ($commands = $this->get_js_commands()) {
+ $js = $this->framed ? "if (window.parent) {\n" : '';
+ $js .= $commands . ($this->framed ? ' }' : '');
+ $this->add_script($js, 'head_top');
+ }
// send clickjacking protection headers
$iframe = $this->framed || !empty($_REQUEST['_framed']);
@@ -462,6 +473,7 @@ class rcmail_output_html extends rcmail_output
if (is_readable($path)) {
$this->config->set('skin_path', $skin_path);
$this->base_path = preg_replace('!plugins/\w+/!', '', $skin_path); // set base_path to core skin directory (not plugin's skin)
+ $skin_dir = preg_replace('!^plugins/!', '', $skin_path);
break;
}
else {
@@ -643,6 +655,7 @@ class rcmail_output_html extends rcmail_output
protected function file_callback($matches)
{
$file = $matches[3];
+ $file[0] = preg_replace('!^/this/!', '/', $file[0]);
// correct absolute paths
if ($file[0] == '/') {
@@ -665,12 +678,15 @@ class rcmail_output_html extends rcmail_output
*
* @param string $input
* @return string
- * @uses rcube_output_html::parse_xml()
+ * @uses rcmail_output_html::parse_xml()
* @since 0.1-rc1
*/
public function just_parse($input)
{
- return $this->parse_xml($input);
+ $input = $this->parse_conditions($input);
+ $input = $this->parse_xml($input);
+
+ return $input;
}
@@ -888,6 +904,7 @@ class rcmail_output_html extends rcmail_output
// include a file
case 'include':
$old_base_path = $this->base_path;
+ if (!empty($attrib['skin_path'])) $attrib['skinpath'] = $attrib['skin_path'];
if ($path = $this->get_skin_file($attrib['file'], $skin_path, $attrib['skinpath'])) {
$this->base_path = preg_replace('!plugins/\w+/!', '', $skin_path); // set base_path to core skin directory (not plugin's skin)
$path = realpath($path);
@@ -1194,6 +1211,10 @@ class rcmail_output_html extends rcmail_output
$out = sprintf('<a%s>%s</a>', $attrib_str, $btn_content);
}
+ if ($attrib['wrapper']) {
+ $out = html::tag($attrib['wrapper'], null, $out);
+ }
+
return $out;
}
@@ -1576,10 +1597,10 @@ class rcmail_output_html extends rcmail_output
}
}
}
- else if (is_array($default_host) && ($host = array_pop($default_host))) {
+ else if (is_array($default_host) && ($host = key($default_host)) !== null) {
$hide_host = true;
$input_host = new html_hiddenfield(array(
- 'name' => '_host', 'id' => 'rcmloginhost', 'value' => $host) + $attrib);
+ 'name' => '_host', 'id' => 'rcmloginhost', 'value' => is_numeric($host) ? $default_host[$host] : $host) + $attrib);
}
else if (empty($default_host)) {
$input_host = new html_inputfield(array('name' => '_host', 'id' => 'rcmloginhost')