summaryrefslogtreecommitdiff
path: root/program/include
diff options
context:
space:
mode:
Diffstat (limited to 'program/include')
-rw-r--r--program/include/html.php8
-rwxr-xr-xprogram/include/iniset.php2
-rw-r--r--program/include/main.inc147
-rw-r--r--program/include/rcube_config.php41
-rw-r--r--program/include/rcube_json_output.php2
-rwxr-xr-xprogram/include/rcube_template.php5
-rw-r--r--program/include/rcube_user.php39
7 files changed, 104 insertions, 140 deletions
diff --git a/program/include/html.php b/program/include/html.php
index 4ac45da65..4057bd14d 100644
--- a/program/include/html.php
+++ b/program/include/html.php
@@ -571,7 +571,7 @@ class html_table extends html
* @param array Cell attributes
* @param string Cell content
*/
- private function add_header($attr, $cont)
+ public function add_header($attr, $cont)
{
if (is_string($attr))
$attr = array('class' => $attr);
@@ -587,7 +587,7 @@ class html_table extends html
*
* @param array Row attributes
*/
- private function add_row($attr = array())
+ public function add_row($attr = array())
{
$this->rowindex++;
$this->colindex = 0;
@@ -612,7 +612,7 @@ class html_table extends html
if (!empty($this->header)) {
$rowcontent = '';
foreach ($this->header as $c => $col) {
- $rowcontent .= self::tag('th', $col->attrib, $col->content);
+ $rowcontent .= self::tag('td', $col->attrib, $col->content);
}
$thead = self::tag('thead', null, self::tag('tr', null, $rowcontent));
}
@@ -624,7 +624,7 @@ class html_table extends html
}
if ($r < $this->rowindex || count($row->cells)) {
- $tbody .= self::tag('tr', $rows->attrib, $rowcontent);
+ $tbody .= self::tag('tr', $row->attrib, $rowcontent);
}
}
diff --git a/program/include/iniset.php b/program/include/iniset.php
index 5072d636c..5dacf8552 100755
--- a/program/include/iniset.php
+++ b/program/include/iniset.php
@@ -22,7 +22,7 @@
// application constants
-define('RCMAIL_VERSION', '0.1-trunk');
+define('RCMAIL_VERSION', '0.2-trunk');
define('RCMAIL_CHARSET', 'UTF-8');
define('JS_OBJECT_NAME', 'rcmail');
diff --git a/program/include/main.inc b/program/include/main.inc
index cdcc710cc..73b9c4124 100644
--- a/program/include/main.inc
+++ b/program/include/main.inc
@@ -105,51 +105,6 @@ function rcube_label($p)
/**
- * Load virtuser table in array
- *
- * @return array Virtuser table entries
- */
-function rcmail_getvirtualfile()
- {
- global $CONFIG;
- if (empty($CONFIG['virtuser_file']) || !is_file($CONFIG['virtuser_file']))
- return FALSE;
-
- // read file
- $a_lines = file($CONFIG['virtuser_file']);
- return $a_lines;
- }
-
-
-/**
- * Find matches of the given pattern in virtuser table
- *
- * @param string Regular expression to search for
- * @return array Matching entries
- */
-function rcmail_findinvirtual($pattern)
- {
- $result = array();
- $virtual = rcmail_getvirtualfile();
- if ($virtual==FALSE)
- return $result;
-
- // check each line for matches
- foreach ($virtual as $line)
- {
- $line = trim($line);
- if (empty($line) || $line{0}=='#')
- continue;
-
- if (eregi($pattern, $line))
- $result[] = $line;
- }
-
- return $result;
- }
-
-
-/**
* Overwrite action variable
*
* @param string New action value
@@ -574,65 +529,46 @@ function template_exists($name)
*/
function rcube_table_output($attrib, $table_data, $a_show_cols, $id_col)
{
- global $DB;
-
- // allow the following attributes to be added to the <table> tag
- $attrib_str = create_attrib_string($attrib, array('style', 'class', 'id', 'cellpadding', 'cellspacing', 'border', 'summary'));
+ global $RCMAIL;
- $table = '<table' . $attrib_str . ">\n";
+ $table = new html_table(/*array('cols' => count($a_show_cols))*/);
- // add table title
- $table .= "<thead><tr>\n";
-
+ // add table header
foreach ($a_show_cols as $col)
- $table .= '<td class="'.$col.'">' . Q(rcube_label($col)) . "</td>\n";
-
- $table .= "</tr></thead>\n<tbody>\n";
+ $table->add_header($col, Q(rcube_label($col)));
$c = 0;
if (!is_array($table_data))
+ {
+ $db = $RCMAIL->get_dbh();
+ while ($table_data && ($sql_arr = $db->fetch_assoc($table_data)))
{
- while ($table_data && ($sql_arr = $DB->fetch_assoc($table_data)))
- {
- $zebra_class = $c%2 ? 'even' : 'odd';
-
- $table .= sprintf('<tr id="rcmrow%d" class="contact '.$zebra_class.'">'."\n", $sql_arr[$id_col]);
+ $zebra_class = $c % 2 ? 'even' : 'odd';
+ $table->add_row(array('id' => 'rcmrow' . $sql_arr[$id_col], 'class' => "contact $zebra_class"));
// format each col
foreach ($a_show_cols as $col)
- {
- $cont = Q($sql_arr[$col]);
- $table .= '<td class="'.$col.'">' . $cont . "</td>\n";
- }
-
- $table .= "</tr>\n";
+ $table->add($col, Q($sql_arr[$col]));
+
$c++;
- }
}
+ }
else
- {
+ {
foreach ($table_data as $row_data)
- {
- $zebra_class = $c%2 ? 'even' : 'odd';
-
- $table .= sprintf('<tr id="rcmrow%s" class="contact '.$zebra_class.'">'."\n", $row_data[$id_col]);
+ {
+ $zebra_class = $c % 2 ? 'even' : 'odd';
+ $table->add_row(array('id' => 'rcmrow' . $row_data[$id_col], 'class' => "contact $zebra_class"));
// format each col
foreach ($a_show_cols as $col)
- {
- $cont = Q($row_data[$col]);
- $table .= '<td class="'.$col.'">' . $cont . "</td>\n";
- }
-
- $table .= "</tr>\n";
+ $table->add($col, Q($row_data[$col]));
+
$c++;
- }
}
+ }
- // complete message table
- $table .= "</tbody></table>\n";
-
- return $table;
+ return $table->show($attrib);
}
@@ -674,29 +610,6 @@ function rcmail_get_edit_field($col, $value, $attrib, $type='text')
/**
- * Return the mail domain configured for the given host
- *
- * @param string IMAP host
- * @return string Resolved SMTP host
- */
-function rcmail_mail_domain($host)
- {
- global $CONFIG;
-
- $domain = $host;
- if (is_array($CONFIG['mail_domain']))
- {
- if (isset($CONFIG['mail_domain'][$host]))
- $domain = $CONFIG['mail_domain'][$host];
- }
- else if (!empty($CONFIG['mail_domain']))
- $domain = $CONFIG['mail_domain'];
-
- return $domain;
- }
-
-
-/**
* Replace all css definitions with #container [def]
* and remove css-inlined scripting
*
@@ -744,26 +657,6 @@ function rcmail_mod_css_styles($source, $container_id, $base_url = '')
return $styles;
}
-/**
- * Try to autodetect operating system and find the correct line endings
- *
- * @return string The appropriate mail header delimiter
- */
-function rcmail_header_delm()
-{
- global $CONFIG;
-
- // use the configured delimiter for headers
- if (!empty($CONFIG['mail_header_delimiter']))
- return $CONFIG['mail_header_delimiter'];
- else if (strtolower(substr(PHP_OS, 0, 3)=='win'))
- return "\r\n";
- else if (strtolower(substr(PHP_OS, 0, 3)=='mac'))
- return "\r\n";
- else
- return "\n";
-}
-
/**
* Compose a valid attribute string for HTML tags
diff --git a/program/include/rcube_config.php b/program/include/rcube_config.php
index 8e956de1e..5c744ba53 100644
--- a/program/include/rcube_config.php
+++ b/program/include/rcube_config.php
@@ -177,5 +177,46 @@ class rcube_config
}
+ /**
+ * Try to autodetect operating system and find the correct line endings
+ *
+ * @return string The appropriate mail header delimiter
+ */
+ public function header_delimiter()
+ {
+ // use the configured delimiter for headers
+ if (!empty($this->prop['mail_header_delimiter']))
+ return $this->prop['mail_header_delimiter'];
+ else if (strtolower(substr(PHP_OS, 0, 3) == 'win'))
+ return "\r\n";
+ else if (strtolower(substr(PHP_OS, 0, 3) == 'mac'))
+ return "\r\n";
+ else
+ return "\n";
+ }
+
+
+
+ /**
+ * Return the mail domain configured for the given host
+ *
+ * @param string IMAP host
+ * @return string Resolved SMTP host
+ */
+ public function mail_domain($host)
+ {
+ $domain = $host;
+
+ if (is_array($this->prop['mail_domain'])) {
+ if (isset($this->prop['mail_domain'][$host]))
+ $domain = $this->prop['mail_domain'][$host];
+ }
+ else if (!empty($this->prop['mail_domain']))
+ $domain = $this->prop['mail_domain'];
+
+ return $domain;
+ }
+
+
}
diff --git a/program/include/rcube_json_output.php b/program/include/rcube_json_output.php
index a633f8555..678b1948a 100644
--- a/program/include/rcube_json_output.php
+++ b/program/include/rcube_json_output.php
@@ -34,7 +34,6 @@ class rcube_json_output
private $texts = array();
private $commands = array();
- public $task = '';
public $ajax_call = true;
@@ -43,7 +42,6 @@ class rcube_json_output
*/
public function __construct($task)
{
- $this->task = $task;
$this->config = rcmail::get_instance()->config;
}
diff --git a/program/include/rcube_template.php b/program/include/rcube_template.php
index 0c0a9211b..5834e42ab 100755
--- a/program/include/rcube_template.php
+++ b/program/include/rcube_template.php
@@ -32,7 +32,6 @@ class rcube_template extends rcube_html_page
{
var $app;
var $config;
- var $task = '';
var $framed = false;
var $pagetitle = '';
var $env = array();
@@ -56,7 +55,7 @@ class rcube_template extends rcube_html_page
$this->config = $this->app->config->all();
//$this->framed = $framed;
- $this->task = $task;
+ $this->set_env('task', $task);
// add common javascripts
$javascript = 'var '.JS_OBJECT_NAME.' = new rcube_webmail();';
@@ -542,7 +541,7 @@ class rcube_template extends rcube_html_page
return $ver;
}
if ($object=='pagetitle') {
- $task = $this->task;
+ $task = $this->env['task'];
$title = !empty($this->config['product_name']) ? $this->config['product_name'].' :: ' : '';
if (!empty($this->pagetitle)) {
diff --git a/program/include/rcube_user.php b/program/include/rcube_user.php
index c808d079e..5f970ec6a 100644
--- a/program/include/rcube_user.php
+++ b/program/include/rcube_user.php
@@ -362,7 +362,7 @@ class rcube_user
if ($user_id = $dbh->insert_id(get_sequence_name('users')))
{
- $mail_domain = rcmail_mail_domain($host);
+ $mail_domain = $rcmail->config->mail_domain($host);
if ($user_email=='')
$user_email = strpos($user, '@') ? $user : sprintf('%s@%s', $user, $mail_domain);
@@ -420,7 +420,7 @@ class rcube_user
static function email2user($email)
{
$user = $email;
- $r = rcmail_findinvirtual("^$email");
+ $r = self::findinvirtual("^$email");
for ($i=0; $i<count($r); $i++)
{
@@ -446,7 +446,7 @@ class rcube_user
static function user2email($user)
{
$email = "";
- $r = rcmail_findinvirtual("$user$");
+ $r = self::findinvirtual("$user$");
for ($i=0; $i<count($r); $i++)
{
@@ -461,6 +461,39 @@ class rcube_user
return $email;
}
+
+
+ /**
+ * Find matches of the given pattern in virtuser table
+ *
+ * @param string Regular expression to search for
+ * @return array Matching entries
+ */
+ private static function findinvirtual($pattern)
+ {
+ $result = array();
+ $virtual = null;
+
+ if ($virtuser_file = rcmail::get_instance()->config->get('virtuser_file'))
+ $virtual = file($virtuser_file);
+
+ if (empty($virtual))
+ return $result;
+
+ // check each line for matches
+ foreach ($virtual as $line)
+ {
+ $line = trim($line);
+ if (empty($line) || $line{0}=='#')
+ continue;
+
+ if (eregi($pattern, $line))
+ $result[] = $line;
+ }
+
+ return $result;
+ }
+
}