minor change

This commit is contained in:
tomas 2005-02-23 15:54:09 +00:00
parent a609fc8f90
commit c05e76464f
2 changed files with 19 additions and 12 deletions

View File

@ -23,7 +23,7 @@
Author : $Author: tomas $ Author : $Author: tomas $
Version : $Revision: 1.10 $ Version : $Revision: 1.11 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/alib/var/alib.php,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/alib/var/alib.php,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -40,7 +40,7 @@ define('ALIBERR_NOTEXISTS', 31);
* authentication/authorization class * authentication/authorization class
* *
* @author $Author: tomas $ * @author $Author: tomas $
* @version $Revision: 1.10 $ * @version $Revision: 1.11 $
* @see Subjects * @see Subjects
* @see GreenBox * @see GreenBox
*/ */
@ -177,11 +177,13 @@ class Alib extends Subjects{
*/ */
function removePerm($permid=NULL, $subj=NULL, $obj=NULL) function removePerm($permid=NULL, $subj=NULL, $obj=NULL)
{ {
return $this->dbc->query("DELETE FROM {$this->permTable} WHERE 1=1". $ca = array();
($permid ? " AND permid=$permid" : ''). if($permid) $ca[] = "permid=$permid";
($subj ? " AND subj=$subj" : ''). if($subj) $ca[] = "subj=$subj";
($obj ? " AND obj=$obj" : '') if($obj) $ca[] = "obj=$obj";
); $cond = join(" AND ", $ca);
if(!$cond) return TRUE;
return $this->dbc->query("DELETE FROM {$this->permTable} WHERE $cond");
} }
/** /**
@ -296,6 +298,10 @@ class Alib extends Subjects{
function removeSubj($login) function removeSubj($login)
{ {
$uid = $this->getSubjId($login); if(PEAR::isError($uid)) return $uid; $uid = $this->getSubjId($login); if(PEAR::isError($uid)) return $uid;
if(is_null($uid)){
return $this->dbc->raiseError("Alib::removeSubj: Subj not found ($login)",
ALIBERR_NOTEXISTS, PEAR_ERROR_RETURN);
}
$r = $this->removePerm(NULL, $uid); if(PEAR::isError($r)) return $r; $r = $this->removePerm(NULL, $uid); if(PEAR::isError($r)) return $r;
return parent::removeSubj($login, $uid); return parent::removeSubj($login, $uid);
} }

View File

@ -23,7 +23,7 @@
Author : $Author: tomas $ Author : $Author: tomas $
Version : $Revision: 1.35 $ Version : $Revision: 1.36 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/BasicStor.php,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/BasicStor.php,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -52,7 +52,7 @@ require_once "Transport.php";
* Core of LiveSupport file storage module * Core of LiveSupport file storage module
* *
* @author $Author: tomas $ * @author $Author: tomas $
* @version $Revision: 1.35 $ * @version $Revision: 1.36 $
* @see Alib * @see Alib
*/ */
class BasicStor extends Alib{ class BasicStor extends Alib{
@ -859,7 +859,7 @@ class BasicStor extends Alib{
{ {
$uid = parent::addSubj($login, $pass); $uid = parent::addSubj($login, $pass);
if($this->dbc->isError($uid)) return $uid; if($this->dbc->isError($uid)) return $uid;
if(!$this->isGroup($uid)){ if($this->isGroup($uid) !== FALSE){
$fid = $this->bsCreateFolder($this->storId, $login); $fid = $this->bsCreateFolder($this->storId, $login);
if($this->dbc->isError($fid)) return $fid; if($this->dbc->isError($fid)) return $fid;
$res = $this->addPerm($uid, '_all', $fid, 'A'); $res = $this->addPerm($uid, '_all', $fid, 'A');
@ -882,7 +882,7 @@ class BasicStor extends Alib{
return $uid; return $uid;
} }
/** /**
* Remove user and his home folder * Remove user by login or by uid and his home folder
* *
* @param login string * @param login string
* @param uid int OPT * @param uid int OPT
@ -890,10 +890,11 @@ class BasicStor extends Alib{
*/ */
function removeSubj($login, $uid=NULL) function removeSubj($login, $uid=NULL)
{ {
$res = parent::removeSubj($login, $pass); $res = parent::removeSubj($login);
if($this->dbc->isError($res)) return $res; if($this->dbc->isError($res)) return $res;
$id = $this->getObjId($login, $this->storId); $id = $this->getObjId($login, $this->storId);
if($this->dbc->isError($id)) return $id; if($this->dbc->isError($id)) return $id;
// remove home folder:
$res = $this->bsDeleteFile($id); $res = $this->bsDeleteFile($id);
if($this->dbc->isError($res)) return $res; if($this->dbc->isError($res)) return $res;
return TRUE; return TRUE;