From 715c7961ba8ff72fe40720bb4feaa7865e57e8b9 Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Tue, 01 Mar 2011 16:22:52 -0500
Subject: [PATCH] Don't do exact matches when searching for existing email records
---
program/include/rcube_template.php | 99 +++++++++++++++++++++++++++++++++----------------
1 files changed, 66 insertions(+), 33 deletions(-)
diff --git a/program/include/rcube_template.php b/program/include/rcube_template.php
index e9b2b21..11c290a 100755
--- a/program/include/rcube_template.php
+++ b/program/include/rcube_template.php
@@ -5,7 +5,7 @@
| program/include/rcube_template.php |
| |
| This file is part of the Roundcube Webmail client |
- | Copyright (C) 2006-2010, Roundcube Dev. - Switzerland |
+ | Copyright (C) 2006-2010, The Roundcube Dev Team |
| Licensed under the GNU GPL |
| |
| PURPOSE: |
@@ -30,19 +30,29 @@
*/
class rcube_template extends rcube_html_page
{
- var $app;
- var $config;
- var $framed = false;
- var $pagetitle = '';
- var $message = null;
- var $env = array();
- var $js_env = array();
- var $js_commands = array();
- var $object_handlers = array();
+ private $app;
+ private $config;
+ private $pagetitle = '';
+ private $message = null;
+ private $js_env = array();
+ private $js_commands = array();
+ private $object_handlers = array();
+ private $plugin_skin_path;
public $browser;
+ public $framed = false;
+ public $env = array();
public $type = 'html';
public $ajax_call = false;
+
+ // deprecated names of templates used before 0.5
+ private $deprecated_templates = array(
+ 'contact' => 'showcontact',
+ 'contactadd' => 'addcontact',
+ 'contactedit' => 'editcontact',
+ 'identityedit' => 'editidentity',
+ 'messageprint' => 'printmessage',
+ );
/**
* Constructor
@@ -74,7 +84,7 @@
$this->add_script($javascript, 'head_top');
$this->add_script($javascript_foot, 'foot');
$this->scripts_path = 'program/js/';
- $this->include_script('jquery-1.4.min.js');
+ $this->include_script('jquery-1.5.min.js');
$this->include_script('common.js');
$this->include_script('app.js');
@@ -165,8 +175,7 @@
public function template_exists($name)
{
$filename = $this->config['skin_path'] . '/templates/' . $name . '.html';
-
- return (is_file($filename) && is_readable($filename));
+ return (is_file($filename) && is_readable($filename)) || ($this->deprecated_templates[$name] && $this->template_exists($this->deprecated_templates[$name]));
}
/**
@@ -246,10 +255,8 @@
{
if ($override || !$this->message) {
$this->message = $message;
- $this->command(
- 'display_message',
- rcube_label(array('name' => $message, 'vars' => $vars)),
- $type);
+ $msgtext = rcube_label_exists($message) ? rcube_label(array('name' => $message, 'vars' => $vars)) : $message;
+ $this->command('display_message', $msgtext, $type);
}
}
@@ -365,20 +372,30 @@
{
$skin_path = $this->config['skin_path'];
$plugin = false;
+ $this->plugin_skin_path = null;
$temp = explode(".", $name, 2);
if (count($temp) > 1) {
$plugin = $temp[0];
$name = $temp[1];
$skin_dir = $plugin . '/skins/' . $this->config['skin'];
- $skin_path = $this->app->plugins->dir . $skin_dir;
+ $skin_path = $this->plugin_skin_path = $this->app->plugins->dir . $skin_dir;
if (!is_dir($skin_path)) { // fallback to default skin
$skin_dir = $plugin . '/skins/default';
- $skin_path = $this->app->plugins->dir . $skin_dir;
+ $skin_path = $this->plugin_skin_path = $this->app->plugins->dir . $skin_dir;
}
}
$path = "$skin_path/templates/$name.html";
+
+ if (!is_readable($path) && $this->deprecated_templates[$name]) {
+ $path = "$skin_path/templates/".$this->deprecated_templates[$name].".html";
+ if (is_readable($path))
+ raise_error(array('code' => 502, 'type' => 'php',
+ 'file' => __FILE__, 'line' => __LINE__,
+ 'message' => "Using deprecated template '".$this->deprecated_templates[$name]."' in ".$this->config['skin_path']."/templates. Please rename to '".$name."'"),
+ true, false);
+ }
// read template file
if (($templ = @file_get_contents($path)) === false) {
@@ -507,7 +524,7 @@
*/
private function parse_conditions($input)
{
- $matches = preg_split('/<roundcube:(if|elseif|else|endif)\s+([^>]+)>/is', $input, 2, PREG_SPLIT_DELIM_CAPTURE);
+ $matches = preg_split('/<roundcube:(if|elseif|else|endif)\s+([^>]+)>\n?/is', $input, 2, PREG_SPLIT_DELIM_CAPTURE);
if ($matches && count($matches) == 4) {
if (preg_match('/^(else|endif)$/i', $matches[1])) {
return $matches[0] . $this->parse_conditions($matches[3]);
@@ -515,10 +532,10 @@
$attrib = parse_attrib_string($matches[2]);
if (isset($attrib['condition'])) {
$condmet = $this->check_condition($attrib['condition']);
- $submatches = preg_split('/<roundcube:(elseif|else|endif)\s+([^>]+)>/is', $matches[3], 2, PREG_SPLIT_DELIM_CAPTURE);
+ $submatches = preg_split('/<roundcube:(elseif|else|endif)\s+([^>]+)>\n?/is', $matches[3], 2, PREG_SPLIT_DELIM_CAPTURE);
if ($condmet) {
$result = $submatches[0];
- $result.= ($submatches[1] != 'endif' ? preg_replace('/.*<roundcube:endif\s+[^>]+>/Uis', '', $submatches[3], 1) : $submatches[3]);
+ $result.= ($submatches[1] != 'endif' ? preg_replace('/.*<roundcube:endif\s+[^>]+>\n?/Uis', '', $submatches[3], 1) : $submatches[3]);
}
else {
$result = "<roundcube:$submatches[1] $submatches[2]>" . $submatches[3];
@@ -647,7 +664,9 @@
// include a file
case 'include':
- $path = realpath($this->config['skin_path'].$attrib['file']);
+ if (!$this->plugin_skin_path || !is_file($path = realpath($this->plugin_skin_path . $attrib['file'])))
+ $path = realpath(($attrib['skin_path'] ? $attrib['skin_path'] : $this->config['skin_path']).$attrib['file']);
+
if (is_readable($path)) {
if ($this->config['skin_include_php']) {
$incl = $this->include_php($path);
@@ -975,8 +994,11 @@
$attrib['action'] = './';
// we already have a <form> tag
- if ($attrib['form'])
+ if ($attrib['form']) {
+ if ($this->framed || !empty($_REQUEST['_framed']))
+ $hidden->add(array('name' => '_framed', 'value' => '1'));
return $hidden->show() . $content;
+ }
else
return $this->form_tag($attrib, $hidden->show() . $content);
}
@@ -1010,7 +1032,7 @@
$username = $this->app->user->get_username();
}
- return idn_to_utf8($username);
+ return rcube_idn_to_utf8($username);
}
@@ -1024,6 +1046,7 @@
private function login_form($attrib)
{
$default_host = $this->config['default_host'];
+ $autocomplete = (int) $this->config['login_autocomplete'];
$_SESSION['temp'] = true;
@@ -1032,11 +1055,19 @@
if (empty($url) && !preg_match('/_(task|action)=logout/', $_SERVER['QUERY_STRING']))
$url = $_SERVER['QUERY_STRING'];
- $input_user = new html_inputfield(array('name' => '_user', 'id' => 'rcmloginuser') + $attrib);
- $input_pass = new html_passwordfield(array('name' => '_pass', 'id' => 'rcmloginpwd') + $attrib);
+ // set atocomplete attribute
+ $user_attrib = $autocomplete > 0 ? array() : array('autocomplete' => 'off');
+ $host_attrib = $autocomplete > 0 ? array() : array('autocomplete' => 'off');
+ $pass_attrib = $autocomplete > 1 ? array() : array('autocomplete' => 'off');
+
+ $input_task = new html_hiddenfield(array('name' => '_task', 'value' => 'login'));
$input_action = new html_hiddenfield(array('name' => '_action', 'value' => 'login'));
$input_tzone = new html_hiddenfield(array('name' => '_timezone', 'id' => 'rcmlogintz', 'value' => '_default_'));
$input_url = new html_hiddenfield(array('name' => '_url', 'id' => 'rcmloginurl', 'value' => $url));
+ $input_user = new html_inputfield(array('name' => '_user', 'id' => 'rcmloginuser')
+ + $attrib + $user_attrib);
+ $input_pass = new html_passwordfield(array('name' => '_pass', 'id' => 'rcmloginpwd')
+ + $attrib + $pass_attrib);
$input_host = null;
if (is_array($default_host) && count($default_host) > 1) {
@@ -1058,7 +1089,8 @@
'name' => '_host', 'id' => 'rcmloginhost', 'value' => $host) + $attrib);
}
else if (empty($default_host)) {
- $input_host = new html_inputfield(array('name' => '_host', 'id' => 'rcmloginhost') + $attrib);
+ $input_host = new html_inputfield(array('name' => '_host', 'id' => 'rcmloginhost')
+ + $attrib + $host_attrib);
}
$form_name = !empty($attrib['form']) ? $attrib['form'] : 'form';
@@ -1068,7 +1100,7 @@
$table = new html_table(array('cols' => 2));
$table->add('title', html::label('rcmloginuser', Q(rcube_label('username'))));
- $table->add(null, $input_user->show(get_input_value('_user', RCUBE_INPUT_POST)));
+ $table->add(null, $input_user->show(get_input_value('_user', RCUBE_INPUT_GPC)));
$table->add('title', html::label('rcmloginpwd', Q(rcube_label('password'))));
$table->add(null, $input_pass->show());
@@ -1076,10 +1108,11 @@
// add host selection row
if (is_object($input_host) && !$hide_host) {
$table->add('title', html::label('rcmloginhost', Q(rcube_label('server'))));
- $table->add(null, $input_host->show(get_input_value('_host', RCUBE_INPUT_POST)));
+ $table->add(null, $input_host->show(get_input_value('_host', RCUBE_INPUT_GPC)));
}
- $out = $input_action->show();
+ $out = $input_task->show();
+ $out .= $input_action->show();
$out .= $input_tzone->show();
$out .= $input_url->show();
$out .= $table->show();
@@ -1197,8 +1230,8 @@
'UTF-8' => 'UTF-8 ('.rcube_label('unicode').')',
'US-ASCII' => 'ASCII ('.rcube_label('english').')',
'ISO-8859-1' => 'ISO-8859-1 ('.rcube_label('westerneuropean').')',
- 'ISO-8859-2' => 'ISO-8895-2 ('.rcube_label('easterneuropean').')',
- 'ISO-8859-4' => 'ISO-8895-4 ('.rcube_label('baltic').')',
+ 'ISO-8859-2' => 'ISO-8859-2 ('.rcube_label('easterneuropean').')',
+ 'ISO-8859-4' => 'ISO-8859-4 ('.rcube_label('baltic').')',
'ISO-8859-5' => 'ISO-8859-5 ('.rcube_label('cyrillic').')',
'ISO-8859-6' => 'ISO-8859-6 ('.rcube_label('arabic').')',
'ISO-8859-7' => 'ISO-8859-7 ('.rcube_label('greek').')',
--
Gitblit v1.9.1