diff --git a/livesupport/modules/storageServer/var/Prefs.php b/livesupport/modules/storageServer/var/Prefs.php index f97af3b3b..1f0d2b6e7 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.3 $ + Version : $Revision: 1.4 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/Prefs.php,v $ ------------------------------------------------------------------------------*/ @@ -52,6 +52,7 @@ class Prefs{ } /* ======================================================= public methods */ + /* ----------------------------------------------------- user preferences */ /** * Read preference record by session id * @@ -125,11 +126,75 @@ class Prefs{ return TRUE; } + /* ---------------------------------------------------- group preferences */ + /** + * Read group preference record + * + * @param sessid string, session id + * @param grname string, group name + * @param key string, preference key + * @return string, preference value + */ + function loadGroupPref($sessid, $grname, $key) + { + $subjid = $this->gb->getSubjId($grname); + if(PEAR::isError($subjid)) return $subjid; + if(is_null($subjid)){ + return PEAR::raiseError( + "Prefs::loadGroupPref: invalid group name", ALIBERR_NOTGR); + } + $val = $this->readVal($subjid, $key); + if(PEAR::isError($val)) return $val; + if($val === FALSE){ + return PEAR::raiseError( + "Prefs::loadGroupPref: invalid preference key", GBERR_PREF); + } + return $val; + } + + /** + * Save group preference record + * + * @param sessid string, session id + * @param grname string, group name + * @param key string, preference key + * @param value string, preference value + * @return boolean + */ + function saveGroupPref($sessid, $grname, $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); + } + $gid = $this->gb->getSubjId($grname); + if(PEAR::isError($gid)) return $gid; + if(is_null($gid)){ + return PEAR::raiseError( + "Prefs::saveGroupPref: invalid group name", GBERR_SESS); + } + $memb = $this->gb->isMemberOf($uid, $gid); + if(PEAR::isError($memb)) return $memb; + if(!$memb){ + return PEAR::raiseError( + "Prefs::saveGroupPref: access denied", GBERR_DENY); + } + $r = $this->update($gid, $key, $value); + if(PEAR::isError($r)) return $r; + if($r === FALSE){ + $r = $this->insert($gid, $key, $value); + if(PEAR::isError($r)) return $r; + } + return TRUE; + } + /* ===================================================== gb level methods */ /** * Insert of new preference record * - * @param subjid int, local user id + * @param subjid int, local user/group id * @param keystr string, preference key * @param valstr string, preference value * @return int, local user id @@ -151,7 +216,7 @@ class Prefs{ /** * Read value of preference record * - * @param subjid int, local user id + * @param subjid int, local user/group id * @param keystr string, preference key * @return string, preference value */ @@ -169,7 +234,7 @@ class Prefs{ /** * Update value of preference record * - * @param subjid int, local user id + * @param subjid int, local user/group id * @param keystr string, preference key * @param newvalstr string, new preference value * @return boolean @@ -189,7 +254,7 @@ class Prefs{ /** * Delete preference record * - * @param subjid int, local user id + * @param subjid int, local user/group id * @param keystr string, preference key * @return boolean */ @@ -252,6 +317,9 @@ class Prefs{ ON {$this->prefTable} (subjid, keystr)"); $this->dbc->query("CREATE INDEX {$this->prefTable}_subjid_idx ON {$this->prefTable} (subjid)"); + $stPrefGr = $this->gb->getSubjId('StationPrefs'); + $r = $this->insert($stPrefGr, 'stationName', "Radio Station 1"); + if(PEAR::isError($r)) echo $r->getMessage()."\n"; return TRUE; } diff --git a/livesupport/modules/storageServer/var/conf.php b/livesupport/modules/storageServer/var/conf.php index 590eea080..2790e0bc9 100644 --- a/livesupport/modules/storageServer/var/conf.php +++ b/livesupport/modules/storageServer/var/conf.php @@ -23,7 +23,7 @@ Author : $Author: tomas $ - Version : $Revision: 1.7 $ + Version : $Revision: 1.8 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/conf.php,v $ ------------------------------------------------------------------------------*/ @@ -63,6 +63,7 @@ $config = array( ), 'tblNamePrefix' => 'ls_', 'authCookieName'=> 'lssid', + 'StationPrefsGr'=> 'StationPrefs', 'storageDir' => dirname(getcwd()).'/stor', 'bufferDir' => dirname(getcwd()).'/stor/buffer', 'transDir' => dirname(getcwd()).'/trans', diff --git a/livesupport/modules/storageServer/var/xmlrpc/XR_LocStor.php b/livesupport/modules/storageServer/var/xmlrpc/XR_LocStor.php index 84e11e766..8236ebf60 100644 --- a/livesupport/modules/storageServer/var/xmlrpc/XR_LocStor.php +++ b/livesupport/modules/storageServer/var/xmlrpc/XR_LocStor.php @@ -23,7 +23,7 @@ Author : $Author: tomas $ - Version : $Revision: 1.9 $ + Version : $Revision: 1.10 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/xmlrpc/XR_LocStor.php,v $ ------------------------------------------------------------------------------*/ @@ -1166,9 +1166,14 @@ class XR_LocStor extends LocStor{ * + * (cnt values may be greater than size of arrays - see limit param) * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: @@ -1196,7 +1201,23 @@ class XR_LocStor extends LocStor{ " ".$res->getUserInfo() ); } - return new XML_RPC_Response(XML_RPC_encode($res)); +# return new XML_RPC_Response(XML_RPC_encode($res)); + $xv = new XML_RPC_Value; + $xv->addStruct(array( + 'audioClipCnt' => XML_RPC_encode($res['audioClipCnt']), + 'playlistCnt' => XML_RPC_encode($res['playlistCnt']), + 'audioClipResults' => + (count($res['audioClipResults'])==0 + ? new XML_RPC_Value(array(), 'array') + : XML_RPC_encode($res['audioClipResults']) + ), + 'playlistResults' => + (count($res['playlistResults'])==0 + ? new XML_RPC_Value(array(), 'array') + : XML_RPC_encode($res['playlistResults']) + ), + )); + return $xv; } /* ---------------------------------------------- methods for preferences */ @@ -1351,6 +1372,114 @@ class XR_LocStor extends LocStor{ return new XML_RPC_Response(XML_RPC_encode(array('status'=>$res))); } + /** + * Read group preference record + * + * The XML-RPC name of this method is "locstor.loadGroupPref". + * + * The input parameters are an XML-RPC struct with the following + * fields: + * + * + * On success, returns a XML-RPC struct with single field: + * + * + * On errors, returns an XML-RPC error response. + * The possible error codes and error message are: + * + * + * @param input XMLRPC struct + * @return XMLRPC struct + * @see Pref::loadGroupPref + */ + function xr_loadGroupPref($input) + { + list($ok, $r) = $this->_xr_getPars($input); + if(!$ok) return $r; + require_once '../../../storageServer/var/Prefs.php'; + $pr =& new Prefs(&$this); + $res = $pr->loadGroupPref($r['sessid'], $r['group'], $r['key']); + if(PEAR::isError($res)){ + $ec0 = intval($res->getCode()); + $ec = ( + $ec0 == GBERR_SESS || $ec0 == GBERR_PREF || $ec0==ALIBERR_NOTGR + ? 800+$ec0 : 805 + ); + return new XML_RPC_Response(0, $ec, + "xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo() + + ); + } + return new XML_RPC_Response(XML_RPC_encode(array('value'=>$res))); + } + + /** + * Save group preference record + * + * The XML-RPC name of this method is "locstor.saveGroupPref". + * + * The input parameters are an XML-RPC struct with the following + * fields: + * + * + * On success, returns a XML-RPC struct with single field: + * + * + * On errors, returns an XML-RPC error response. + * The possible error codes and error message are: + * + * + * @param input XMLRPC struct + * @return XMLRPC struct + * @see Pref::saveGroupPref + */ + function xr_saveGroupPref($input) + { + list($ok, $r) = $this->_xr_getPars($input); + if(!$ok) return $r; + require_once '../../../storageServer/var/Prefs.php'; + $pr =& new Prefs(&$this); + $res = $pr->saveGroupPref($r['sessid'], $r['group'], $r['key'], $r['value']); + if(PEAR::isError($res)){ + $ec0 = intval($res->getCode()); + $ec = ($ec0==GBERR_SESS || $ec0==ALIBERR_NOTGR ? 800+$ec0 : 805 ); + return new XML_RPC_Response(0, $ec, + "xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo() + ); + } + return new XML_RPC_Response(XML_RPC_encode(array('status'=>$res))); + } + /* -------------------------------------------- remote repository methods */ /** * Starts upload audioclip to remote archive @@ -1466,7 +1595,8 @@ class XR_LocStor extends LocStor{ *