From 4fe20e1152747120eaf78f56f1387545eceaf7d3 Mon Sep 17 00:00:00 2001 From: jengo Date: Sat, 25 Aug 2001 20:26:22 +0000 Subject: [PATCH] Added dual pass preferences --- phpgwapi/doc/CHANGELOG | 5 ++++ phpgwapi/inc/class.preferences.inc.php | 37 +++++++++++++++++++------- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/phpgwapi/doc/CHANGELOG b/phpgwapi/doc/CHANGELOG index 9441fcdad1..d875fe0ae7 100644 --- a/phpgwapi/doc/CHANGELOG +++ b/phpgwapi/doc/CHANGELOG @@ -11,6 +11,11 @@ behind load balanced proxys. - Merged patch for eventlog, this will show debugging info and warnings to admins. Thanks j3rry + - Created dual pass preferences, this allows admins to force any preference option + on users. (eg, templates, themes, max matchs, etc) + - Created generic preferneces/preferences.php app, which uses hooks to + set user preferences, admins can force preference, or set the defaults + for new accounts. [0.9.12] - Note: These changelogs will only contain changes in the API (preferences, admin, etc) diff --git a/phpgwapi/inc/class.preferences.inc.php b/phpgwapi/inc/class.preferences.inc.php index a82c4c8964..34ff9f1b68 100644 --- a/phpgwapi/inc/class.preferences.inc.php +++ b/phpgwapi/inc/class.preferences.inc.php @@ -35,7 +35,7 @@ /*! @var account_type */ var $account_type; /*! @var data */ - var $data = Array(); + var $data = array(); /*! @var db */ var $db; @@ -50,7 +50,7 @@ function preferences($account_id = '') { global $phpgw, $phpgw_info; - $this->db = $phpgw->db; + $this->db = $phpgw->db; $this->account_id = get_account_id($account_id); } @@ -65,19 +65,38 @@ */ function read_repository() { - $this->db->lock('phpgw_preferences'); - $this->db->query("SELECT preference_value FROM phpgw_preferences WHERE preference_owner='".$this->account_id."'",__LINE__,__FILE__); + $this->db->query("SELECT * FROM phpgw_preferences WHERE " + . "preference_owner='" . $this->account_id . "' or " + . "preference_owner='-1' order by preference_owner desc",__LINE__,__FILE__); $this->db->next_record(); - $pref_info = $this->db->f("preference_value"); - /* echo "Pref_Info = ".$pref_info."
\n"; */ - $this->data = Array(); + + $pref_info = $this->db->f('preference_value'); $this->data = unserialize($pref_info); - $this->db->unlock(); + + if ($this->db->next_record()) + { + $global_defaults = unserialize($this->db->f('preference_value')); + + while (is_array($global_defaults) && list($appname,$values) = each($global_defaults)) + { + while (is_array($values) && list($var,$value) = each($values)) + { + $this->data[$appname][$var] = $value; + } + } + } + /* This is to supress warnings during login */ - if (gettype($this->data) == 'array') + if (is_array($this->data)) { reset ($this->data); } + + // This is to supress warnings durring login + if (is_array($this->data)) + { + reset($this->data); + } return $this->data; }