diff --git a/livesupport/modules/alib/var/subj.php b/livesupport/modules/alib/var/subj.php index 316c369c1..c4724e876 100644 --- a/livesupport/modules/alib/var/subj.php +++ b/livesupport/modules/alib/var/subj.php @@ -23,7 +23,7 @@ Author : $Author: tomas $ - Version : $Revision: 1.6 $ + Version : $Revision: 1.7 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/alib/var/subj.php,v $ ------------------------------------------------------------------------------*/ @@ -39,7 +39,7 @@ define('ALIBERR_BADSMEMB', 21); * (allow adding users to groups or groups to groups) * * @author $Author: tomas $ - * @version $Revision: 1.6 $ + * @version $Revision: 1.7 $ * @see ObjClasses * @see Alib */ @@ -127,17 +127,20 @@ class Subjects extends ObjClasses{ * Change user password * * @param login string - * @param oldpass string + * @param oldpass string, old password (optional for 'superuser mode') * @param pass string, optional * @return boolean/err */ - function passwd($login, $oldpass, $pass='') + function passwd($login, $oldpass=null, $pass='') { $cpass = md5($pass); - $oldcpass = md5($oldpass); + if(!is_null($oldpass)){ + $oldcpass = md5($oldpass); + $oldpCond = "AND pass='$oldcpass'"; + }else{ $oldpCond = ''; } $this->dbc->query(" UPDATE {$this->subjTable} SET pass='$cpass' - WHERE login='$login' AND pass='$oldcpass' AND type='U' + WHERE login='$login' $oldpCond AND type='U' "); if(PEAR::isError($id)) return $id; return TRUE; diff --git a/livesupport/modules/htmlUI/var/ui_handler.class.php b/livesupport/modules/htmlUI/var/ui_handler.class.php index 9c663051c..466c44cb1 100644 --- a/livesupport/modules/htmlUI/var/ui_handler.class.php +++ b/livesupport/modules/htmlUI/var/ui_handler.class.php @@ -452,7 +452,7 @@ class uiHandler extends uiBase { { if (PEAR::isError( $this->gb->addPerm( - $this->sessid, $subj, $permAction, $id, $allowDeny + $subj, $permAction, $id, $allowDeny, $this->sessid ) )) { $this->_retMsg('Access denied.'); @@ -472,7 +472,7 @@ class uiHandler extends uiBase { */ function removePerm($permid, $oid) { - if (PEAR::isError($this->gb->removePerm($this->sessid, $permid))) { + if (PEAR::isError($this->gb->removePerm($permid, NULL, NULL, $this->sessid))) { $this->_retMsg('Access denied.'); return FALSE; } diff --git a/livesupport/modules/storageServer/var/BasicStor.php b/livesupport/modules/storageServer/var/BasicStor.php index 52b2dd2a9..0fa4062fb 100644 --- a/livesupport/modules/storageServer/var/BasicStor.php +++ b/livesupport/modules/storageServer/var/BasicStor.php @@ -23,7 +23,7 @@ Author : $Author: tomas $ - Version : $Revision: 1.46 $ + Version : $Revision: 1.47 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/BasicStor.php,v $ ------------------------------------------------------------------------------*/ @@ -53,7 +53,7 @@ require_once "Transport.php"; * Core of LiveSupport file storage module * * @author $Author: tomas $ - * @version $Revision: 1.46 $ + * @version $Revision: 1.47 $ * @see Alib */ class BasicStor extends Alib{ @@ -236,7 +236,30 @@ class BasicStor extends Alib{ */ function bsDeleteFile($id, $forced=FALSE) { - $res = $this->removeObj($id, $forced); + // full delete: + if(!$this->config['useTrash'] || $forced){ + $res = $this->removeObj($id, $forced); + return $res; + } + // move to trash: + $did = $this->getObjId($this->config['TrashName'], $this->storId); + if($this->dbc->isError($did)) return $did; + switch($this->getObjType($id)){ + case"audioclip": + case"playlist": + case"webstream": + $ac =& StoredFile::recall($this, $id); + if($this->dbc->isError($ac)) return $ac; + if(is_null($did)){ + return PEAR::raiseError("BasicStor::bsDeleteFile: ". + "trash not found", GBERR_NOTF); + } + $res = $ac->setState('deleted'); + if($this->dbc->isError($res)) return $res; + break; + default: + } + $res = $this->bsMoveFile($id, $did); return $res; } @@ -1311,9 +1334,14 @@ class BasicStor extends Alib{ // if($this->dbc->isError($p = parent::test())) return $p; $this->deleteData(); $this->testData(); + if($this->config['useTrash']){ + $trash = "{$this->config['TrashName']}\n "; + }else{ + $trash = ""; + } if(!$this->config['isArchive']){ $this->test_correct = " StorageRoot - root + {$trash}root test1 file1.mp3 public @@ -1332,7 +1360,7 @@ class BasicStor extends Alib{ "; }else{ $this->test_correct = " StorageRoot - root + {$trash}root test1 file1.mp3 test1_folder1 @@ -1349,9 +1377,9 @@ class BasicStor extends Alib{ $this->test_dump = $this->dumpTree($this->storId, ' ', ' ', '{name}'); if($this->test_dump==$this->test_correct) { $this->test_log.="# BasicStor::test: OK\n"; return true; } - else PEAR::raiseError('BasicStor::test:', 1, PEAR_ERROR_DIE, '%s'. - "
\ncorrect:\n.{$this->test_correct}.\n".
-            "dump:\n.{$this->test_dump}.\n
\n"); + else return PEAR::raiseError( + "BasicStor::test:\ncorrect:\n.{$this->test_correct}.\n". + "dump:\n.{$this->test_dump}.\n", 1, PEAR_ERROR_RETURN); } /** @@ -1365,7 +1393,16 @@ class BasicStor extends Alib{ $this->addObj('StorageRoot', 'Folder', $this->rootId); $rootUid = parent::addSubj('root', $this->config['tmpRootPass']); $res = parent::addPerm($rootUid, '_all', $this->rootId, 'A'); + if($this->dbc->isError($res)) return $res; + $res = parent::addPerm($rootUid, 'subjects', $this->rootId, 'A'); + if($this->dbc->isError($res)) return $res; $fid = $this->bsCreateFolder($this->storId, 'root'); + if($this->dbc->isError($fid)) return $fid; + if($this->config['useTrash']){ + $tfid = $this->bsCreateFolder( + $this->storId, $this->config["TrashName"]); + if($this->dbc->isError($tfid)) return $tfid; + } if(!$this->config['isArchive']){ $stPrefGr = parent::addSubj($this->config['StationPrefsGr']); $this->addSubj2Gr('root', $this->config['StationPrefsGr']); @@ -1377,6 +1414,7 @@ class BasicStor extends Alib{ if($this->dbc->isError($r)) return $r; } } + /** * install - create tables * @@ -1386,6 +1424,7 @@ class BasicStor extends Alib{ *
  • incomplete
  • *
  • ready
  • *
  • edited
  • + *
  • deleted
  • * * file types: diff --git a/livesupport/modules/storageServer/var/DataEngine.php b/livesupport/modules/storageServer/var/DataEngine.php index d1695fccd..8a823754f 100644 --- a/livesupport/modules/storageServer/var/DataEngine.php +++ b/livesupport/modules/storageServer/var/DataEngine.php @@ -23,7 +23,7 @@ Author : $Author: tomas $ - Version : $Revision: 1.8 $ + Version : $Revision: 1.9 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/DataEngine.php,v $ ------------------------------------------------------------------------------*/ @@ -100,7 +100,7 @@ class DataEngine{ $whereArr = array(); if(is_array($conditions)){ foreach($conditions as $cond){ - $catQn = strtolower($cond['cat']); + $catQn = $cond['cat']; $op = strtolower($cond['op']); $value = strtolower($cond['val']); $splittedQn = XML_Util::splitQualifiedName($catQn); @@ -112,7 +112,8 @@ class DataEngine{ $opVal = str_replace("%", "%%", $opVal); $sqlCond = " %s.predicate = '{$cat}' AND". - " %s.objns='_L' AND lower(%s.object) {$opVal}\n"; + " %s.objns='_L' AND %s.predxml='T'". + " AND lower(%s.object) {$opVal}\n"; if(!is_null($catNs)){ $catNs = str_replace("%", "%%", $catNs); $sqlCond = " %s.predns = '{$catNs}' AND $sqlCond"; @@ -140,7 +141,7 @@ class DataEngine{ { $innerBlocks = array(); foreach($whereArr as $i=>$v){ - $whereArr[$i] = sprintf($v, "md$i", "md$i", "md$i", "md$i"); + $whereArr[$i] = sprintf($v, "md$i", "md$i", "md$i", "md$i", "md$i"); $lastTbl = ($i==0 ? "f" : "md".($i-1)); $innerBlocks[] = "INNER JOIN {$this->mdataTable} md$i ON md$i.gunid = $lastTbl.gunid\n"; @@ -149,7 +150,8 @@ class DataEngine{ $sql = "SELECT $fldsPart\nFROM {$this->filesTable} f\n".join("", $innerBlocks); if($browse){ $sql .= "INNER JOIN {$this->mdataTable} br". - "\n ON br.gunid = f.gunid AND br.objns='_L' AND br.predicate='{$brFld}'"; + "\n ON br.gunid = f.gunid AND br.objns='_L'". + " AND br.predicate='{$brFld}' AND br.predxml='T'"; if(!is_null($brFldNs)) $sql .= " AND br.predns='{$brFldNs}'"; $sql .= "\n"; } @@ -178,7 +180,7 @@ class DataEngine{ $fldsPart, $whereArr, $fileCond, $browse, $brFldNs, $brFld); $isectBlocks = array(); foreach($whereArr as $i=>$v){ - $whereArr[$i] = sprintf($v, "md$i", "md$i", "md$i", "md$i"); + $whereArr[$i] = sprintf($v, "md$i", "md$i", "md$i", "md$i", "md$i"); $isectBlocks[] = " SELECT gunid FROM {$this->mdataTable} md$i\n". " WHERE\n {$whereArr[$i]}"; @@ -195,7 +197,7 @@ class DataEngine{ "SELECT $fldsPart\n".$isectBlock; if($browse){ $sql .= "\nINNER JOIN {$this->mdataTable} br ON br.gunid = f.gunid\n". - "WHERE br.objns='_L' AND br.predicate='{$brFld}'"; + "WHERE br.objns='_L' AND br.predxml='T' AND br.predicate='{$brFld}'"; if(!is_null($brFldNs)) $sql .= " AND br.predns='{$brFldNs}'"; $glue = " AND"; }else{ $glue = "WHERE";} @@ -218,15 +220,16 @@ class DataEngine{ function _makeOrSql($fldsPart, $whereArr, $fileCond, $browse, $brFldNs=NULL, $brFld=NULL) { - $whereArr[] = " FALSE\n"; + //$whereArr[] = " FALSE\n"; foreach($whereArr as $i=>$v){ - $whereArr[$i] = sprintf($v, "md", "md", "md", "md"); + $whereArr[$i] = sprintf($v, "md", "md", "md", "md", "md"); } // query construcion: $sql = "SELECT $fldsPart\nFROM {$this->filesTable} f\n"; if($browse){ $sql .= "INNER JOIN {$this->mdataTable} br". - "\n ON br.gunid = f.gunid AND br.objns='_L' AND br.predicate='{$brFld}'"; + "\n ON br.gunid = f.gunid AND br.objns='_L'". + " AND br.predxml='T' AND br.predicate='{$brFld}'"; if(!is_null($brFldNs)) $sql .= " AND br.predns='{$brFldNs}'"; $sql .= "\n"; } @@ -278,8 +281,8 @@ class DataEngine{ $operator = strtolower($criteria['operator']); $desc = (isset($criteria['desc']) ? $criteria['desc'] : NULL); $whereArr = $this->_makeWhereArr($criteria['conditions']); - $orderbyQn = (isset($criteria['orderby']) ? - strtolower($criteria['orderby']) : NULL); + $orderbyQn = + (isset($criteria['orderby']) ? $criteria['orderby'] : NULL); $obSplitQn = XML_Util::splitQualifiedName($orderbyQn); $obNs = $obSplitQn['namespace']; $orderby = $obSplitQn['localPart']; @@ -309,7 +312,8 @@ class DataEngine{ "SELECT to_hex(sq2.gunid)as gunid, m.object\n". "FROM (\n$sql\n)sq2\n". "LEFT JOIN ls_mdata m\n". - " ON m.gunid = sq2.gunid AND m.predicate='$orderby' AND m.objns='_L'". + " ON m.gunid = sq2.gunid AND m.predicate='$orderby'". + " AND m.objns='_L' AND m.predxml='T'". (!is_null($obNs)? " AND m.predns='$obNs'":'')."\n". "ORDER BY m.object".($desc? ' DESC':'')."\n"; } @@ -339,14 +343,14 @@ class DataEngine{ */ function browseCategory($category, $limit=0, $offset=0, $criteria=NULL) { - $category = strtolower($category); + //$category = strtolower($category); $r = XML_Util::splitQualifiedName($category); $catNs = $r['namespace']; $cat = $r['localPart']; if(is_array($criteria) && count($criteria)>0){ return $this->_localGenSearch($criteria, $limit, $offset, $catNs, $cat); } - $sqlCond = "m.predicate='$cat' AND m.objns='_L'"; + $sqlCond = "m.predicate='$cat' AND m.objns='_L' AND m.predxml='T'"; if(!is_null($catNs)){ $sqlCond = "m.predns = '{$catNs}' AND $sqlCond"; } diff --git a/livesupport/modules/storageServer/var/GreenBox.php b/livesupport/modules/storageServer/var/GreenBox.php index 8f24d261c..257c34020 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.57 $ + Version : $Revision: 1.58 $ 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.57 $ + * @version $Revision: 1.58 $ * @see BasicStor */ class GreenBox extends BasicStor{ @@ -222,41 +222,6 @@ class GreenBox extends BasicStor{ return $this->bsDeleteFile($id); } - /* ---------------------------------------------- replicas, versions etc. */ - /** - * Create replica.
    - * TODO: NOT FINISHED - * - * @param id int, virt.file's local id - * @param did int, destination folder local id - * @param replicaName string, name of new replica - * @param sessid string, session id - * @return int, local id of new object - */ - function createReplica($id, $did, $replicaName='', $sessid='') - { - if(($res = $this->_authorize( - array('read', 'write'), array($id, $did), $sessid - )) !== TRUE) return $res; - return $this->bsCreateReplica($id, $did, $replicaName); - } - - /** - * Create version.
    - * TODO: NOT FINISHED - * - * @param id int, virt.file's local id - * @param did int, destination folder local id - * @param versionLabel string, name of new version - * @param sessid string, session id - * @return int, local id of new object - */ - function createVersion($id, $did, $versionLabel, $sessid='') - { - return $this->bsCreateVersion($id, $did, $versionLabel); - } - - /* ------------------------------------------------------------- metadata */ /** @@ -867,17 +832,50 @@ class GreenBox extends BasicStor{ return $pa; } + /** + * Change user password. + * + * ('superuser mode'= superuser is changing some password without + * knowledge of the old password) + * + * @param login string + * @param oldpass string, old password + * (should be null or empty for 'superuser mode') + * @param pass string, optional + * @param sessid string, session id, required for 'superuser mode' + * @return boolean/err + */ + function passwd($login, $oldpass=null, $pass='', $sessid='') + { + if(is_null($oldpass) || $oldpass == ''){ + if(($res = $this->_authorize('subjects', $this->rootId, $sessid)) + !== TRUE + ){ sleep(2); return $res; } + else $oldpass=null; + }else{ + if(FALSE === $this->authenticate($login, $oldpass)){ + sleep(2); + return PEAR::raiseError( + "GreenBox::passwd: access denied (oldpass)", GBERR_DENY); + } + } + return PEAR::raiseError("GreenBox::passwd: OK"); + $res = parent::passwd($login, $oldpass, $pass); + if(PEAR::isError($res)) return $res; + return TRUE; + } + /** * Insert permission record * - * @param sessid string, session id * @param sid int - local user/group id * @param action string * @param oid int - local object id * @param type char - 'A'|'D' (allow/deny) + * @param sessid string, session id * @return int - local permission id */ - function addPerm($sessid, $sid, $action, $oid, $type='A') + function addPerm($sid, $action, $oid, $type='A', $sessid='') { $parid = $this->getParent($oid); if(($res = $this->_authorize('editPerms', $parid, $sessid)) !== TRUE){ @@ -889,20 +887,22 @@ class GreenBox extends BasicStor{ /** * Remove permission record * - * @param sessid string, session id * @param permid int OPT - local permission id * @param subj int OPT - local user/group id * @param obj int OPT - local object id + * @param sessid string, session id * @return boolean/error */ - function removePerm($sessid, $permid=NULL, $subj=NULL, $obj=NULL) + function removePerm($permid=NULL, $subj=NULL, $obj=NULL, $sessid='') { - $oid = $this->_getPermOid($permid); - if(PEAR::isError($oid)) return $oid; - if(!is_null($oid)){ - $parid = $this->getParent($oid); - if(($res = $this->_authorize('editPerms', $parid, $sessid)) !== TRUE) - return $res; + if(!is_null($permid)){ + $oid = $this->_getPermOid($permid); + if(PEAR::isError($oid)) return $oid; + if(!is_null($oid)){ + $parid = $this->getParent($oid); + if(($res = $this->_authorize('editPerms', $parid, $sessid)) !== TRUE) + return $res; + } } $res = parent::removePerm($permid, $subj, $obj); return $res;