Browse files

add seperate storage class

  • Loading branch information...
1 parent 8df6211 commit 32da781e099ce25f93ec09c073ff6cab1dbd83b4 @JohnDoh committed Apr 8, 2012
Showing with 304 additions and 180 deletions.
  1. +6 −0 CHANGELOG
  2. +4 −5 config.inc.php.dist
  3. +268 −0 include/rcube_sauserprefs_storage.php
  4. +5 −4 package.xml
  5. +21 −171 sauserprefs.php
View
6 CHANGELOG
@@ -1,6 +1,12 @@
Roundcube Webmail SAUserPrefs
=============================
+2012 04 08
+==========
+ * Make storage class to handle SQL work
+ * Add new config option sauserprefs_bayes_delete to seperate function from SQL
+ * Remove sauserprefs_deprecated_prefs config option
+
2012 03 24
==========
* Make username configurable
View
9 config.inc.php.dist
@@ -75,6 +75,10 @@ $rcmail_config['sauserprefs_default_prefs'] = array(
// spam score increment - increment values in the the score threshold drop down by this, from 0 to 10
$rcmail_config['sauserprefs_score_inc'] = 1;
+// allow the user to delete bayesian data
+// please also see sauserprefs_bayes_delete_query option
+$rcmail_config['sauserprefs_bayes_delete'] = false;
+
// delete user bayesian data stored in database
// the query can contain the following macros that will be expanded as follows:
// %u is replaced with the username from the sauserprefs_userid setting above
@@ -86,11 +90,6 @@ $rcmail_config['sauserprefs_score_inc'] = 1;
// );
$rcmail_config['sauserprefs_bayes_delete_query'] = '';
-// Override old or deprecated preferences: 'old name' => 'new name'
-$rcmail_config['sauserprefs_deprecated_prefs'] = array(
- 'required_hits' => 'required_score'
- );
-
// define languages
$rcmail_config['sauserprefs_languages'] = array(
"af" => "Afrikaans",
View
268 include/rcube_sauserprefs_storage.php
@@ -0,0 +1,268 @@
+<?php
+
+/**
+ * SAUserPrefs storage class
+ *
+ * Class to handle the SQL work for SAUserPrefs
+ *
+ * @author Philip Weir
+ */
+class rcube_sauserprefs_storage
+{
+ private $db;
+ private $db_dsnw;
+ private $db_dsnr;
+ private $db_persistent;
+ private $sa_user;
+ private $table_name;
+ private $username_field;
+ private $preference_field;
+ private $value_field;
+ private $bayes_delete_query;
+
+ function __construct($db_dsnw, $db_dsnr, $db_persistent, $sa_user, $table_name, $username_field, $preference_field, $value_field, $bayes_delete_query)
+ {
+ $this->db_dsnw = $db_dsnw;
+ $this->db_dsnr = $db_dsnr;
+ $this->db_persistent = $db_persistent;
+ $this->sa_user = $sa_user;
+ $this->table_name = $table_name;
+ $this->username_field = $username_field;
+ $this->preference_field = $preference_field;
+ $this->value_field = $value_field;
+ $this->bayes_delete_query = $bayes_delete_query;
+ }
+
+ function load_prefs($user)
+ {
+ $this->_db_connect('r');
+ $prefs = array();
+
+ $sql_result = $this->db->query(
+ "SELECT ". $this->preference_field.
+ ", ". $this->value_field.
+ " FROM ". $this->table_name.
+ " WHERE ". $this->username_field ." = ?;",
+ $user);
+
+ while ($sql_result && ($sql_arr = $this->db->fetch_assoc($sql_result))) {
+ $pref_name = $sql_arr[$this->preference_field];
+ $pref_name = sauserprefs::map_pref_name($pref_name, true);
+ $pref_value = $sql_arr[$this->value_field];
+
+ if ($pref_name == 'whitelist_from' || $pref_name == 'blacklist_from' || $pref_name == 'whitelist_to')
+ $prefs['addresses'][] = array('field' => $pref_name, 'value' => $pref_value);
+ else
+ $prefs[$pref_name] = $pref_value;
+
+ // update deprecated prefs in db
+ if ($sql_arr[$this->preference_field] != sauserprefs::map_pref_name($pref_name)) {
+ $this->_db_connect('w');
+
+ $this->db->query(
+ "UPDATE ". $this->table_name.
+ " SET ". $this->preference_field ." = ?".
+ " WHERE ". $this->username_field ." = ?".
+ " AND ". $this->preference_field ." = ?;",
+ sauserprefs::map_pref_name($pref_name),
+ $user,
+ $sql_arr[$this->preference_field]);
+ }
+ }
+
+ return $prefs;
+ }
+
+ function save_prefs($new_prefs, $cur_prefs, $global_prefs)
+ {
+ $this->_db_connect('w');
+ $result = true;
+
+ // save prefs
+ foreach ($new_prefs as $preference => $value) {
+ if ($preference == 'addresses') {
+ foreach ($value as $address) {
+ if ($address['action'] == "DELETE") {
+ $result = false;
+
+ $this->db->query(
+ "DELETE FROM ". $this->table_name.
+ " WHERE ". $this->username_field ." = ?".
+ " AND ". $this->preference_field ." = ?".
+ " AND ". $this->value_field ." = ?;",
+ $this->sa_user,
+ sauserprefs::map_pref_name($address['field']),
+ $address['value']);
+
+ $result = $this->db->affected_rows();
+
+ if (!$result) {
+ write_log('errors', 'sauserprefs error: cannot delete "' . sauserprefs::map_pref_name($prefs[$idx]) . '" = "' . $vals[$idx] . '" for ' . $this->sa_user);
+ break;
+ }
+ }
+ elseif ($address['action'] == "INSERT") {
+ $result = false;
+
+ $this->db->query(
+ "INSERT INTO ". $this->table_name.
+ " (". $this->username_field.
+ ", ". $this->preference_field.
+ ", ". $this->value_field.
+ ") VALUES (?, ?, ?);",
+ $this->sa_user,
+ sauserprefs::map_pref_name($address['field']),
+ $address['value']);
+
+ $result = $this->db->affected_rows();
+
+ if (!$result) {
+ write_log('errors', 'sauserprefs error: cannot insert "' . sauserprefs::map_pref_name($prefs[$idx]) . '" = "' . $vals[$idx] . '" for ' . $this->sa_user);
+ break;
+ }
+ }
+ }
+ }
+ elseif (array_key_exists($preference, $cur_prefs) && ($value == "" || $value == $global_prefs[$preference])) {
+ $result = false;
+
+ $this->db->query(
+ "DELETE FROM ". $this->table_name.
+ " WHERE ". $this->username_field ." = ?".
+ " AND ". $this->preference_field ." = ?;",
+ $this->sa_user,
+ sauserprefs::map_pref_name($preference));
+
+ $result = $this->db->affected_rows();
+
+ if (!$result) {
+ write_log('errors', 'sauserprefs error: cannot delete "' . sauserprefs::map_pref_name($preference) . '" for "' . $this->sa_user);
+ break;
+ }
+ }
+ elseif (array_key_exists($preference, $cur_prefs) && $value != $cur_prefs[$preference]) {
+ $result = false;
+
+ $this->db->query(
+ "UPDATE ". $this->table_name.
+ " SET ". $this->value_field ." = ?".
+ " WHERE ". $this->username_field ." = ?".
+ " AND ". $this->preference_field ." = ?;",
+ $value,
+ $this->sa_user,
+ sauserprefs::map_pref_name($preference));
+
+ $result = $this->db->affected_rows();
+
+ if (!$result) {
+ write_log('errors', 'sauserprefs error: cannot update "' . sauserprefs::map_pref_name($preference) . '" = "' . $value . '" for ' . $this->sa_user);
+ break;
+ }
+ }
+ elseif (!array_key_exists($preference, $cur_prefs) && $value != $global_prefs[$preference]) {
+ $result = false;
+
+ $this->db->query(
+ "INSERT INTO ". $this->table_name.
+ " (". $this->username_field.
+ ", ". $this->preference_field.
+ ", ". $this->value_field.
+ ") VALUES (?, ?, ?);",
+ $this->sa_user,
+ sauserprefs::map_pref_name($preference),
+ $value);
+
+ $result = $this->db->affected_rows();
+
+ if (!$result) {
+ write_log('errors', 'sauserprefs error: cannot insert "' . sauserprefs::map_pref_name($preference) . '" = "' . $value . '" for ' . $this->sa_user);
+ break;
+ }
+ }
+ }
+
+ return $result;
+ }
+
+ function whitelist_add($emails)
+ {
+ $this->_db_connect('w');
+
+ foreach ($emails as $email) {
+ // check address is not already whitelisted
+ $sql_result = $this->db->query(
+ "SELECT ". $this->value_field.
+ " FROM ". $this->table_name.
+ " WHERE ". $this->username_field ." = ?".
+ " AND ". $this->preference_field ." = ?".
+ " AND ". $this->value_field ." = ?;",
+ $this->sa_user,
+ sauserprefs::map_pref_name('whitelist_from'),
+ $email);
+
+ if ($this->db->num_rows($sql_result) == 0)
+ $this->db->query(
+ "INSERT INTO ". $this->table_name.
+ " (". $this->username_field.
+ ", ". $this->preference_field.
+ ", ". $this->value_field.
+ ") VALUES (?, ?, ?);",
+ $this->sa_user,
+ sauserprefs::map_pref_name('whitelist_from'),
+ $email);
+ }
+ }
+
+ function whitelist_delete($emails)
+ {
+ $this->_db_connect('w');
+
+ foreach ($emails as $email)
+ $this->db->query(
+ "DELETE FROM ". $this->table_name.
+ " WHERE ". $this->username_field ." = ?".
+ " AND ". $this->preference_field ." = ?".
+ " AND ". $this->value_field ." = ?;",
+ $this->sa_user,
+ sauserprefs::map_pref_name('whitelist_from'),
+ $email);
+
+ }
+
+ function purge_bayes()
+ {
+ $this->_db_connect('w');
+ $queries = !is_array($this->bayes_delete_query) ? array($this->bayes_delete_query) : $this->bayes_delete_query;
+
+ foreach ($queries as $sql) {
+ $sql = str_replace('%u', $this->db->quote($this->sa_user, 'text'), $sql);
+ $this->db->query($sql);
+
+ if ($this->db->is_error())
+ break;
+ }
+
+ if (!$this->db->is_error())
+ return true;
+ else
+ return false;
+ }
+
+ private function _db_connect($mode)
+ {
+ if (!$this->db)
+ $this->db = new rcube_mdb2($this->db_dsnw, $this->db_dsnr, $this->db_persistent);
+
+ $this->db->db_connect($mode);
+
+ // check DB connections and exit on failure
+ if ($err_str = $this->db->is_error()) {
+ raise_error(array(
+ 'code' => 603,
+ 'type' => 'db',
+ 'message' => $err_str), false, true);
+ }
+ }
+}
+
+?>
View
9 package.xml
@@ -13,11 +13,11 @@
<email>roundcube@tehinterweb.co.uk</email>
<active>yes</active>
</lead>
- <date>2012-01-22</date>
- <time>10:42:53</time>
+ <date>2012-04-08</date>
+ <time>10:19:14</time>
<version>
- <release>1.8</release>
- <api>1.8</api>
+ <release>1.9</release>
+ <api>1.9</api>
</version>
<stability>
<release>stable</release>
@@ -38,6 +38,7 @@
<file name="config.inc.php.dist" role="data"/>
<file name="CHANGELOG" role="data"/>
<file name="README" role="data"/>
+ <file name="include/rcube_sauserprefs_storage.php" role="php"/>
<file name="localization/de_CH.inc" role="data"/>
<file name="localization/de_DE.inc" role="data"/>
<file name="localization/en_GB.inc" role="data"/>
View
192 sauserprefs.php
@@ -11,14 +11,15 @@
class sauserprefs extends rcube_plugin
{
public $task = 'mail|addressbook|settings';
- private $db;
+ private $storage;
private $sections = array();
private $cur_section;
private $global_prefs;
private $user_prefs;
private $addressbook = '0';
private $sa_locales = array('en', 'ja', 'ko', 'ru', 'th', 'zh');
private $sa_user;
+ static $deprecated_prefs = array('required_hits' => 'required_score');
function init()
{
@@ -33,6 +34,12 @@ function init()
$this->sa_user = str_replace('%d', $rcmail->user->get_username('domain'), $this->sa_user);
$this->sa_user = str_replace('%i', $identity, $this->sa_user);
+ // init storage
+ include('include/rcube_sauserprefs_storage.php');
+ $this->storage = new rcube_sauserprefs_storage($rcmail->config->get('sauserprefs_db_dsnw'), $rcmail->config->get('sauserprefs_db_dsnr'), $rcmail->config->get('sauserprefs_db_persistent'),
+ $this->sa_user, $rcmail->config->get('sauserprefs_sql_table_name'), $rcmail->config->get('sauserprefs_sql_username_field'), $rcmail->config->get('sauserprefs_sql_preference_field'),
+ $rcmail->config->get('sauserprefs_sql_value_field'), $rcmail->config->get('sauserprefs_bayes_delete_query'));
+
if ($rcmail->config->get('sauserprefs_whitelist_abook_id', false))
$this->addressbook = $rcmail->config->get('sauserprefs_whitelist_abook_id');
@@ -66,7 +73,6 @@ function init()
function init_html()
{
- $this->_db_connect('r');
$this->_load_global_prefs();
$this->_load_user_prefs();
@@ -156,7 +162,6 @@ function prefs_section_name()
function save()
{
$rcmail = rcmail::get_instance();
- $this->_db_connect('r');
$this->_load_global_prefs();
$this->_load_user_prefs();
@@ -264,96 +269,7 @@ function save()
if (!$data['abort']) {
// save prefs
- foreach ($data['new_prefs'] as $preference => $value) {
- if ($preference == 'addresses') {
- foreach ($value as $address) {
- if ($address['action'] == "DELETE") {
- $result = false;
-
- $this->db->query(
- "DELETE FROM ". $rcmail->config->get('sauserprefs_sql_table_name') ."
- WHERE ". $rcmail->config->get('sauserprefs_sql_username_field') ." = '". $this->sa_user ."'
- AND ". $rcmail->config->get('sauserprefs_sql_preference_field') ." = '". $this->_map_pref_name($address['field']) ."'
- AND ". $rcmail->config->get('sauserprefs_sql_value_field') ." = '". $address['value'] . "';"
- );
-
- $result = $this->db->affected_rows();
-
- if (!$result) {
- write_log('errors', 'sauserprefs error: cannot delete "' . $this->_map_pref_name($prefs[$idx]) . '" = "' . $vals[$idx] . '" for ' . $this->sa_user);
- break;
- }
- }
- elseif ($address['action'] == "INSERT") {
- $result = false;
-
- $this->db->query(
- "INSERT INTO ". $rcmail->config->get('sauserprefs_sql_table_name') ."
- (".$rcmail->config->get('sauserprefs_sql_username_field').", ".$rcmail->config->get('sauserprefs_sql_preference_field').", ".$rcmail->config->get('sauserprefs_sql_value_field').")
- VALUES ('". $this->sa_user ."', '". $this->_map_pref_name($address['field']) ."', '". $address['value'] ."')"
- );
-
- $result = $this->db->affected_rows();
-
- if (!$result) {
- write_log('errors', 'sauserprefs error: cannot insert "' . $this->_map_pref_name($prefs[$idx]) . '" = "' . $vals[$idx] . '" for ' . $this->sa_user);
- break;
- }
- }
- }
- }
- elseif (array_key_exists($preference, $this->user_prefs) && ($value == "" || $value == $this->global_prefs[$preference])) {
- $result = false;
-
- $this->db->query(
- "DELETE FROM ". $rcmail->config->get('sauserprefs_sql_table_name') ."
- WHERE ". $rcmail->config->get('sauserprefs_sql_username_field') ." = '". $this->sa_user ."'
- AND ". $rcmail->config->get('sauserprefs_sql_preference_field') ." = '". $this->_map_pref_name($preference) ."';"
- );
-
- $result = $this->db->affected_rows();
-
- if (!$result) {
- write_log('errors', 'sauserprefs error: cannot delete "' . $this->_map_pref_name($preference) . '" for "' . $this->sa_user);
- break;
- }
- }
- elseif (array_key_exists($preference, $this->user_prefs) && $value != $this->user_prefs[$preference]) {
- $result = false;
-
- $this->db->query(
- "UPDATE ". $rcmail->config->get('sauserprefs_sql_table_name') ."
- SET ". $rcmail->config->get('sauserprefs_sql_value_field') ." = '". $value ."'
- WHERE ". $rcmail->config->get('sauserprefs_sql_username_field') ." = '". $this->sa_user ."'
- AND ". $rcmail->config->get('sauserprefs_sql_preference_field') ." = '". $this->_map_pref_name($preference) ."';"
- );
-
- $result = $this->db->affected_rows();
-
- if (!$result) {
- write_log('errors', 'sauserprefs error: cannot update "' . $this->_map_pref_name($preference) . '" = "' . $value . '" for ' . $this->sa_user);
- break;
- }
- }
- elseif (!array_key_exists($preference, $this->user_prefs) && $value != $this->global_prefs[$preference]) {
- $result = false;
-
- $this->db->query(
- "INSERT INTO ". $rcmail->config->get('sauserprefs_sql_table_name') ."
- (".$rcmail->config->get('sauserprefs_sql_username_field').", ".$rcmail->config->get('sauserprefs_sql_preference_field').", ".$rcmail->config->get('sauserprefs_sql_value_field').")
- VALUES ('". $this->sa_user ."', '". $this->_map_pref_name($preference) ."', '". $value ."')"
- );
-
- $result = $this->db->affected_rows();
-
- if (!$result) {
- write_log('errors', 'sauserprefs error: cannot insert "' . $this->_map_pref_name($preference) . '" = "' . $value . '" for ' . $this->sa_user);
- break;
- }
- }
- }
-
- if ($result)
+ if ($this->storage->save_prefs($data['new_prefs'], $this->user_prefs, $this->global_prefs))
$this->api->output->command('display_message', $this->gettext('sauserprefchanged'), 'confirmation');
else
$this->api->output->command('display_message', $this->gettext('sauserpreffailed'), 'error');
@@ -391,26 +307,15 @@ function purge_bayes()
{
$rcmail = rcmail::get_instance();
- if (strlen($rcmail->config->get('sauserprefs_bayes_delete_query')) == 0) {
+ if ($rcmail->config->get('sauserprefs_bayes_delete', false)) {
$this->api->output->command('display_message', $this->gettext('servererror'), 'error');
return;
}
- $this->_db_connect('w');
- $queries = !is_array($rcmail->config->get('sauserprefs_bayes_delete_query')) ? array($rcmail->config->get('sauserprefs_bayes_delete_query')) : $rcmail->config->get('sauserprefs_bayes_delete_query');
-
- foreach ($queries as $sql) {
- $sql = str_replace('%u', $this->db->quote($this->sa_user, 'text'), $sql);
- $this->db->query($sql);
-
- if ($this->db->is_error())
- break;
- }
-
- if ($this->db->is_error())
- $this->api->output->command('display_message', $this->gettext('servererror'), 'error');
- else
+ if ($this->storage->purge_bayes())
$this->api->output->command('display_message', $this->gettext('done'), 'confirmation');
+ else
+ $this->api->output->command('display_message', $this->gettext('servererror'), 'error');
}
function contact_add($args)
@@ -421,15 +326,8 @@ function contact_add($args)
if ($args['source'] != $this->addressbook && $args['source'] != null)
return;
- $this->_db_connect('w');
$emails = $this->_gen_email_arr($args['record']);
-
- foreach ($emails as $email) {
- // check address is not already whitelisted
- $sql_result = $this->db->query("SELECT value FROM ". $rcmail->config->get('sauserprefs_sql_table_name') ." WHERE ". $rcmail->config->get('sauserprefs_sql_username_field') ." = '". $this->sa_user ."' AND ". $rcmail->config->get('sauserprefs_sql_preference_field') ." = '". $this->_map_pref_name('whitelist_from') ."' AND ". $rcmail->config->get('sauserprefs_sql_value_field') ." = '". $email ."';");
- if ($this->db->num_rows($sql_result) == 0)
- $this->db->query("INSERT INTO ". $rcmail->config->get('sauserprefs_sql_table_name') ." (". $rcmail->config->get('sauserprefs_sql_username_field') .", ". $rcmail->config->get('sauserprefs_sql_preference_field') .", ". $rcmail->config->get('sauserprefs_sql_value_field') .") VALUES ('". $this->sa_user ."', '". $this->_map_pref_name('whitelist_from') ."', '". $email ."');");
- }
+ $this->storage->whitelist_add($emails);
}
function contact_save($args)
@@ -449,33 +347,15 @@ function contact_delete($args)
if (!is_array($args['id']))
$args['id'] = array($args['id']);
- $this->_db_connect('w');
$contacts = $rcmail->get_address_book($this->addressbook);
foreach ($args['id'] as $id) {
$emails = $this->_gen_email_arr($contacts->get_record($id, true));
-
- foreach ($emails as $email)
- $this->db->query("DELETE FROM ". $rcmail->config->get('sauserprefs_sql_table_name') ." WHERE ". $rcmail->config->get('sauserprefs_sql_username_field') ." = '". $this->sa_user ."' AND ". $rcmail->config->get('sauserprefs_sql_preference_field') ." = '". $this->_map_pref_name('whitelist_from') ."' AND ". $rcmail->config->get('sauserprefs_sql_value_field') ." = '". $email ."';");
+ $this->storage->whitelist_delete($emails);
}
$contacts->close();
}
- private function _db_connect($mode)
- {
- $rcmail = rcmail::get_instance();
- $this->db = new rcube_mdb2($rcmail->config->get('sauserprefs_db_dsnw'), $rcmail->config->get('sauserprefs_db_dsnr'), $rcmail->config->get('sauserprefs_db_persistent'));
- $this->db->db_connect($mode);
-
- // check DB connections and exit on failure
- if ($err_str = $this->db->is_error()) {
- raise_error(array(
- 'code' => 603,
- 'type' => 'db',
- 'message' => $err_str), FALSE, TRUE);
- }
- }
-
private function _load_global_prefs()
{
$rcmail = rcmail::get_instance();
@@ -491,36 +371,7 @@ private function _load_user_prefs()
private function _load_prefs($user)
{
$rcmail = rcmail::get_instance();
- $prefs = array();
-
- $sql_result = $this->db->query(
- "SELECT ". $rcmail->config->get('sauserprefs_sql_preference_field') .", ". $rcmail->config->get('sauserprefs_sql_value_field') ."
- FROM ". $rcmail->config->get('sauserprefs_sql_table_name') ."
- WHERE ". $rcmail->config->get('sauserprefs_sql_username_field') ." = '". $user ."';"
- );
-
- while ($sql_result && ($sql_arr = $this->db->fetch_assoc($sql_result))) {
- $pref_name = $sql_arr[$rcmail->config->get('sauserprefs_sql_preference_field')];
- $pref_name = $this->_map_pref_name($pref_name, true);
- $pref_value = $sql_arr[$rcmail->config->get('sauserprefs_sql_value_field')];
-
- if ($pref_name == 'whitelist_from' || $pref_name == 'blacklist_from' || $pref_name == 'whitelist_to') {
- $prefs['addresses'][] = array('field' => $pref_name, 'value' => $pref_value);
- }
- else {
- $prefs[$pref_name] = $pref_value;
- }
-
- // update deprecated prefs in db
- if ($sql_arr[$rcmail->config->get('sauserprefs_sql_preference_field')] != $this->_map_pref_name($pref_name)) {
- $this->db->query(
- "UPDATE ". $rcmail->config->get('sauserprefs_sql_table_name') ."
- SET ". $rcmail->config->get('sauserprefs_sql_preference_field') ." = '". $this->_map_pref_name($pref_name) ."'
- WHERE ". $rcmail->config->get('sauserprefs_sql_username_field') ." = '". $user ."'
- AND ". $rcmail->config->get('sauserprefs_sql_preference_field') ." = '". $sql_arr[$rcmail->config->get('sauserprefs_sql_preference_field')] ."';"
- );
- }
- }
+ $prefs = $this->storage->load_prefs($user);
// sort address rules
$prefs['addresses'] = $this->_subval_sort($prefs['addresses'], 'value');
@@ -801,7 +652,7 @@ private function _prefs_block($part, $attrib)
$input_spamtest = new html_checkbox(array('name' => '_spamusebayes', 'id' => $field_id, 'value' => '1',
'onchange' => JS_OBJECT_NAME . '.sauserprefs_toggle_bayes(this)'));
- if (strlen($rcmail->config->get('sauserprefs_bayes_delete_query')) > 0)
+ if ($rcmail->config->get('sauserprefs_bayes_delete', false))
$delete_link = "&nbsp;&nbsp;&nbsp;" . html::span(array('id' => 'listcontrols'), $this->api->output->button(array('command' => 'plugin.sauserprefs.purge_bayes', 'type' => 'link', 'label' => 'sauserprefs.purgebayes', 'title' => 'sauserprefs.purgebayesexp')));
$table->add('title', html::label($field_id, Q($this->gettext('usebayes'))));
@@ -1027,15 +878,14 @@ private function _address_row($address_table, $field, $value, $attrib)
return $address_table;
}
- private function _map_pref_name($pref, $reverse = false)
+ static function map_pref_name($pref, $reverse = false)
{
- $prefs_map = rcmail::get_instance()->config->get('sauserprefs_deprecated_prefs', array());
if (!$reverse) {
- if (array_key_exists($pref, $prefs_map))
- $pref = $prefs_map[$pref];
+ if (array_key_exists($pref, self::$deprecated_prefs))
+ $pref = self::$deprecated_prefs[$pref];
}
else {
- if (($orig_pref = array_search($pref, $prefs_map)) != FALSE)
+ if (($orig_pref = array_search($pref, self::$deprecated_prefs)) != FALSE)
$pref = $orig_pref;
}

0 comments on commit 32da781

Please sign in to comment.