From c434ad025e2bcd171e4931d4852cdae68fdd47ea Mon Sep 17 00:00:00 2001 From: tomas Date: Thu, 3 Feb 2005 01:10:43 +0000 Subject: [PATCH] Prefs: delGroupPref method added GB: PHP interface for prefs added --- .../modules/storageServer/var/GreenBox.php | 100 +++++++++++++++++- .../modules/storageServer/var/Prefs.php | 58 ++++++++-- 2 files changed, 145 insertions(+), 13 deletions(-) diff --git a/livesupport/modules/storageServer/var/GreenBox.php b/livesupport/modules/storageServer/var/GreenBox.php index e53e05823..a83d6b6eb 100644 --- a/livesupport/modules/storageServer/var/GreenBox.php +++ b/livesupport/modules/storageServer/var/GreenBox.php @@ -23,7 +23,7 @@ Author : $Author: tomas $ - Version : $Revision: 1.27 $ + Version : $Revision: 1.28 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/GreenBox.php,v $ ------------------------------------------------------------------------------*/ @@ -35,7 +35,7 @@ require_once "BasicStor.php"; * LiveSupport file storage module * * @author $Author: tomas $ - * @version $Revision: 1.27 $ + * @version $Revision: 1.28 $ * @see BasicStor */ class GreenBox extends BasicStor{ @@ -298,6 +298,102 @@ class GreenBox extends BasicStor{ return $res; } + /* ---------------------------------------------- methods for preferences */ + + /** + * Read preference record by session id + * + * @param sessid string, session id + * @param key string, preference key + * @return string, preference value + */ + function loadPref($sessid, $key) + { + require_once '../../../storageServer/var/Prefs.php'; + $pr =& new Prefs($this); + $res = $pr->loadPref($sessid, $key); + return $res; + } + + /** + * Save preference record by session id + * + * @param sessid string, session id + * @param key string, preference key + * @param value string, preference value + * @return boolean + */ + function savePref($sessid, $key, $value) + { + require_once '../../../storageServer/var/Prefs.php'; + $pr =& new Prefs($this); + $res = $pr->savePref($sessid, $key, $value); + return $res; + } + + /** + * Delete preference record by session id + * + * @param sessid string, session id + * @param key string, preference key + * @return boolean + */ + function delPref($sessid, $key) + { + require_once '../../../storageServer/var/Prefs.php'; + $pr =& new Prefs($this); + $res = $pr->delPref($sessid, $key); + return $res; + } + + /** + * Read group preference record + * + * @param sessid string, session id + * @param group string, group name + * @param key string, preference key + * @return string, preference value + */ + function loadGroupPref($sessid, $group, $key) + { + require_once '../../../storageServer/var/Prefs.php'; + $pr =& new Prefs($this); + $res = $pr->loadGroupPref($sessid, $group, $key); + return $res; + } + + /** + * Save group preference record + * + * @param sessid string, session id + * @param group string, group name + * @param key string, preference key + * @param value string, preference value + * @return boolean + */ + function saveGroupPref($sessid, $group, $key, $value) + { + require_once '../../../storageServer/var/Prefs.php'; + $pr =& new Prefs($this); + $res = $pr->saveGroupPref($sessid, $group, $key, $value); + return $res; + } + + /** + * Delete group preference record + * + * @param sessid string, session id + * @param group string, group name + * @param key string, preference key + * @return boolean + */ + function delGroupPref($sessid, $group, $key) + { + require_once '../../../storageServer/var/Prefs.php'; + $pr =& new Prefs($this); + $res = $pr->delGroupPref($sessid, $group, $key); + return $res; + } /* --------------------------------------------------------- info methods */ /** diff --git a/livesupport/modules/storageServer/var/Prefs.php b/livesupport/modules/storageServer/var/Prefs.php index 1f0d2b6e7..fa251d6f8 100644 --- a/livesupport/modules/storageServer/var/Prefs.php +++ b/livesupport/modules/storageServer/var/Prefs.php @@ -23,7 +23,7 @@ Author : $Author: tomas $ - Version : $Revision: 1.4 $ + Version : $Revision: 1.5 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/Prefs.php,v $ ------------------------------------------------------------------------------*/ @@ -90,7 +90,7 @@ class Prefs{ $subjid = $this->gb->getSessUserId($sessid); if(PEAR::isError($subjid)) return $subjid; if(is_null($subjid)){ - return PEAR::raiseError("Prefs::loadPref: invalid session id", + return PEAR::raiseError("Prefs::savePref: invalid session id", GBERR_SESS); } $r = $this->update($subjid, $key, $value); @@ -114,7 +114,7 @@ class Prefs{ $subjid = $this->gb->getSessUserId($sessid); if(PEAR::isError($subjid)) return $subjid; if(is_null($subjid)){ - return PEAR::raiseError("Prefs::loadPref: invalid session id", + return PEAR::raiseError("Prefs::delPref: invalid session id", GBERR_SESS); } $r = $this->delete($subjid, $key); @@ -131,13 +131,13 @@ class Prefs{ * Read group preference record * * @param sessid string, session id - * @param grname string, group name + * @param group string, group name * @param key string, preference key * @return string, preference value */ - function loadGroupPref($sessid, $grname, $key) + function loadGroupPref($sessid, $group, $key) { - $subjid = $this->gb->getSubjId($grname); + $subjid = $this->gb->getSubjId($group); if(PEAR::isError($subjid)) return $subjid; if(is_null($subjid)){ return PEAR::raiseError( @@ -156,20 +156,20 @@ class Prefs{ * Save group preference record * * @param sessid string, session id - * @param grname string, group name + * @param group string, group name * @param key string, preference key * @param value string, preference value * @return boolean */ - function saveGroupPref($sessid, $grname, $key, $value) + function saveGroupPref($sessid, $group, $key, $value) { $uid = $this->gb->getSessUserId($sessid); if(PEAR::isError($uid)) return $uid; if(is_null($uid)){ return PEAR::raiseError( - "Prefs::loadGroupPref: invalid session id", GBERR_SESS); + "Prefs::saveGroupPref: invalid session id", GBERR_SESS); } - $gid = $this->gb->getSubjId($grname); + $gid = $this->gb->getSubjId($group); if(PEAR::isError($gid)) return $gid; if(is_null($gid)){ return PEAR::raiseError( @@ -190,7 +190,43 @@ class Prefs{ return TRUE; } - /* ===================================================== gb level methods */ + /** + * Delete group preference record + * + * @param sessid string, session id + * @param group string, group name + * @param key string, preference key + * @return boolean + */ + function delGroupPref($sessid, $group, $key) + { + $uid = $this->gb->getSessUserId($sessid); + if(PEAR::isError($uid)) return $uid; + if(is_null($uid)){ + return PEAR::raiseError( + "Prefs::delGroupPref: invalid session id", GBERR_SESS); + } + $gid = $this->gb->getSubjId($group); + if(PEAR::isError($gid)) return $gid; + if(is_null($gid)){ + return PEAR::raiseError( + "Prefs::delGroupPref: invalid group name", GBERR_SESS); + } + $memb = $this->gb->isMemberOf($uid, $gid); + if(PEAR::isError($memb)) return $memb; + if(!$memb){ + return PEAR::raiseError( + "Prefs::delGroupPref: access denied", GBERR_DENY); + } + $r = $this->delete($gid, $key); + if(PEAR::isError($r)) return $r; + if($r === FALSE){ + return PEAR::raiseError( + "Prefs::delGroupPref: invalid preference key", GBERR_PREF); + } + return TRUE; + } + /* ==================================================== low level methods */ /** * Insert of new preference record *