From 010a789b9bf5c7db644842e30cc4e0c4a3c14984 Mon Sep 17 00:00:00 2001 From: skeeter Date: Thu, 18 Jan 2001 05:14:59 +0000 Subject: [PATCH] changes for locking while reading/saving preferences --- admin/newgroup.php | 2 +- phpgwapi/inc/class.accounts_shared.inc.php | 2 +- phpgwapi/inc/class.preferences.inc.php | 12 +++++++++--- phpgwapi/inc/functions.inc.php | 1 - 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/admin/newgroup.php b/admin/newgroup.php index 65c75c8f1e..9f27466a95 100755 --- a/admin/newgroup.php +++ b/admin/newgroup.php @@ -33,7 +33,7 @@ } if (! $error) { - $phpgw->db->lock(array("accounts","groups","preferences")); + $phpgw->db->lock(array("accounts","groups")); $phpgw->accounts->add_app($n_group_permissions); $apps = $phpgw->accounts->add_app("",True); diff --git a/phpgwapi/inc/class.accounts_shared.inc.php b/phpgwapi/inc/class.accounts_shared.inc.php index aa9de0359a..fffd47efff 100644 --- a/phpgwapi/inc/class.accounts_shared.inc.php +++ b/phpgwapi/inc/class.accounts_shared.inc.php @@ -34,7 +34,7 @@ $phpgw->accounts->phpgw_fillarray(); if(!$phpgw->preferences->account_id) { - $phpgw->preferences = new preferences($phpgw_info["user"]["account_id"]); + $phpgw->preferences = CreateObject('phpgwapi.preferences',$phpgw_info["user"]["account_id"]); } $phpgw_info["user"]["preferences"] = $phpgw->preferences->get_preferences(); $this->groups = $this->read_groups($phpgw_info["user"]["userid"]); diff --git a/phpgwapi/inc/class.preferences.inc.php b/phpgwapi/inc/class.preferences.inc.php index 9d673500f6..90ac0dd4d1 100644 --- a/phpgwapi/inc/class.preferences.inc.php +++ b/phpgwapi/inc/class.preferences.inc.php @@ -55,12 +55,13 @@ //echo "Account ID (After Initializing) = ".$this->account_id."
\n"; if ($load_pref) { - $db2->query("SELECT preference_value FROM preferences WHERE preference_owner='" - . $this->account_id . "'",__LINE__,__FILE__); + $db2->lock("preferences"); + $db2->query("SELECT preference_value FROM preferences WHERE preference_owner=".$this->account_id,__LINE__,__FILE__); $db2->next_record(); $pref_info = $db2->f("preference_value"); $this->preference = unserialize($pref_info); // echo "Preferences = ".$this->get_preferences()."
\n"; + $db2->unlock(); } } @@ -73,6 +74,8 @@ if ($this->account_id) { $db = $phpgw->db; + $db->lock("preferences"); + $db->query("delete from preferences where preference_owner=" . $this->account_id,__LINE__,__FILE__); if ($PHP_VERSION < "4.0.0") { @@ -84,6 +87,9 @@ $db->query("insert into preferences (preference_owner,preference_value) values (" . $this->account_id . ",'" . $pref_info . "')",__LINE__,__FILE__); + $db->unlock(); + + if ($phpgw_info["user"]["account_id"] == $this->account_id) { $phpgw->preferences->preference = $this->get_preferences(); $phpgw->accounts->sync(__LINE__,__FILE__); @@ -124,4 +130,4 @@ return $this->preference; } } //end of preferences class -?> \ No newline at end of file +?> diff --git a/phpgwapi/inc/functions.inc.php b/phpgwapi/inc/functions.inc.php index 162403efbd..73729040f5 100644 --- a/phpgwapi/inc/functions.inc.php +++ b/phpgwapi/inc/functions.inc.php @@ -244,7 +244,6 @@ $preferences_update = True; } if ($preferences_update) { - echo "Committing new preferences
\n"; $phpgw->preferences->commit(__LINE__,__FILE__); } unset($preferences_update);