Started to convert code to PHP5 using public/private/protected/static and __construct() method, got rid of =& when constructing objects. Improved documentation in many places.
This commit is contained in:
parent
bed878246d
commit
d7062149ea
|
@ -10,19 +10,33 @@ define('ALIBERR_NOTEXISTS', 31);
|
||||||
*
|
*
|
||||||
* Authentication/authorization class
|
* Authentication/authorization class
|
||||||
*
|
*
|
||||||
* @author $Author$
|
* @author Tomas Hlava <th@red2head.com>
|
||||||
|
* @author Paul Baranowski <paul@paulbaranowski.org>
|
||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
* @package Campcaster
|
* @package Campcaster
|
||||||
* @subpackage Alib
|
* @subpackage Alib
|
||||||
* @see Subjects
|
* @copyright 2006 MDLF, Inc.
|
||||||
* @see GreenBox
|
* @license http://www.gnu.org/licenses/gpl.txt
|
||||||
|
* @link http://www.campware.org
|
||||||
*/
|
*/
|
||||||
class Alib extends Subjects {
|
class Alib extends Subjects {
|
||||||
var $permTable;
|
/**
|
||||||
var $sessTable;
|
* The name of a database table.
|
||||||
var $login=NULL;
|
*
|
||||||
var $userid=NULL;
|
* @var string
|
||||||
var $sessid=NULL;
|
*/
|
||||||
|
public $permTable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of a database table.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $sessTable;
|
||||||
|
|
||||||
|
//var $login = NULL;
|
||||||
|
//var $userid = NULL;
|
||||||
|
public $sessid = NULL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
@ -30,9 +44,9 @@ class Alib extends Subjects{
|
||||||
* @param DB $dbc
|
* @param DB $dbc
|
||||||
* @param array $config
|
* @param array $config
|
||||||
*/
|
*/
|
||||||
function Alib(&$dbc, $config)
|
public function __construct(&$dbc, $config)
|
||||||
{
|
{
|
||||||
parent::Subjects($dbc, $config);
|
parent::__construct($dbc, $config);
|
||||||
$this->permTable = $config['tblNamePrefix'].'perms';
|
$this->permTable = $config['tblNamePrefix'].'perms';
|
||||||
$this->sessTable = $config['tblNamePrefix'].'sess';
|
$this->sessTable = $config['tblNamePrefix'].'sess';
|
||||||
} // constructor
|
} // constructor
|
||||||
|
@ -47,10 +61,9 @@ class Alib extends Subjects{
|
||||||
*
|
*
|
||||||
* @param string $login
|
* @param string $login
|
||||||
* @param string $pass
|
* @param string $pass
|
||||||
* @return mixed
|
* @return boolean|sessionId|PEAR_Error
|
||||||
* boolean/sessionId/err
|
|
||||||
*/
|
*/
|
||||||
function login($login, $pass)
|
public function login($login, $pass)
|
||||||
{
|
{
|
||||||
if (FALSE === $this->authenticate($login, $pass)) {
|
if (FALSE === $this->authenticate($login, $pass)) {
|
||||||
$this->setTimeStamp($login, TRUE);
|
$this->setTimeStamp($login, TRUE);
|
||||||
|
@ -67,9 +80,9 @@ class Alib extends Subjects{
|
||||||
if (PEAR::isError($r)) {
|
if (PEAR::isError($r)) {
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
$this->login = $login;
|
//$this->login = $login;
|
||||||
$this->userid = $userid;
|
//$this->userid = $userid;
|
||||||
$this->sessid = $sessid;
|
//$this->sessid = $sessid;
|
||||||
$this->setTimeStamp($login, FALSE);
|
$this->setTimeStamp($login, FALSE);
|
||||||
return $sessid;
|
return $sessid;
|
||||||
} // fn login
|
} // fn login
|
||||||
|
@ -79,9 +92,9 @@ class Alib extends Subjects{
|
||||||
* Logout and destroy session
|
* Logout and destroy session
|
||||||
*
|
*
|
||||||
* @param string $sessid
|
* @param string $sessid
|
||||||
* @return true/err
|
* @return true|PEAR_Error
|
||||||
*/
|
*/
|
||||||
function logout($sessid)
|
public function logout($sessid)
|
||||||
{
|
{
|
||||||
$ct = $this->checkAuthToken($sessid);
|
$ct = $this->checkAuthToken($sessid);
|
||||||
if ($ct === FALSE) {
|
if ($ct === FALSE) {
|
||||||
|
@ -96,9 +109,9 @@ class Alib extends Subjects{
|
||||||
if (PEAR::isError($r)) {
|
if (PEAR::isError($r)) {
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
$this->login = NULL;
|
//$this->login = NULL;
|
||||||
$this->userid = NULL;
|
//$this->userid = NULL;
|
||||||
$this->sessid = NULL;
|
//$this->sessid = NULL;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
} // fn logout
|
} // fn logout
|
||||||
|
@ -108,9 +121,9 @@ class Alib extends Subjects{
|
||||||
* Return true if the token is valid
|
* Return true if the token is valid
|
||||||
*
|
*
|
||||||
* @param string $sessid
|
* @param string $sessid
|
||||||
* @return boolean/err
|
* @return boolean|PEAR_Error
|
||||||
*/
|
*/
|
||||||
function checkAuthToken($sessid)
|
private function checkAuthToken($sessid)
|
||||||
{
|
{
|
||||||
$sql = "SELECT count(*) as cnt FROM {$this->sessTable}
|
$sql = "SELECT count(*) as cnt FROM {$this->sessTable}
|
||||||
WHERE sessid='$sessid'";
|
WHERE sessid='$sessid'";
|
||||||
|
@ -123,17 +136,20 @@ class Alib extends Subjects{
|
||||||
* Set valid token in alib object
|
* Set valid token in alib object
|
||||||
*
|
*
|
||||||
* @param string $sessid
|
* @param string $sessid
|
||||||
* @return boolean/err
|
* @return TRUE|PEAR_Error
|
||||||
*/
|
*/
|
||||||
function setAuthToken($sessid)
|
// public function setAuthToken($sessid)
|
||||||
{
|
// {
|
||||||
$r = checkAuthToken($sessid);
|
// $r = $this->checkAuthToken($sessid);
|
||||||
if(PEAR::isError($r)) return $r;
|
// if (PEAR::isError($r)) {
|
||||||
if(!$r)
|
// return $r;
|
||||||
return PEAR::raiseError("ALib::setAuthToken: invalid token ($sessid)");
|
// }
|
||||||
$this->sessid = $sessid;
|
// if (!$r) {
|
||||||
return TRUE;
|
// return PEAR::raiseError("ALib::setAuthToken: invalid token ($sessid)");
|
||||||
} // fn setAuthToken
|
// }
|
||||||
|
// //$this->sessid = $sessid;
|
||||||
|
// return TRUE;
|
||||||
|
// } // fn setAuthToken
|
||||||
|
|
||||||
|
|
||||||
/* -------------------------------------------------------- authorization */
|
/* -------------------------------------------------------- authorization */
|
||||||
|
@ -150,7 +166,7 @@ class Alib extends Subjects{
|
||||||
* @return int
|
* @return int
|
||||||
* local permission id
|
* local permission id
|
||||||
*/
|
*/
|
||||||
function addPerm($sid, $action, $oid, $type='A')
|
public function addPerm($sid, $action, $oid, $type='A')
|
||||||
{
|
{
|
||||||
$permid = $this->dbc->nextId("{$this->permTable}_id_seq");
|
$permid = $this->dbc->nextId("{$this->permTable}_id_seq");
|
||||||
$sql = "INSERT INTO {$this->permTable} (permid, subj, action, obj, type)
|
$sql = "INSERT INTO {$this->permTable} (permid, subj, action, obj, type)
|
||||||
|
@ -167,14 +183,14 @@ class Alib extends Subjects{
|
||||||
* Remove permission record
|
* Remove permission record
|
||||||
*
|
*
|
||||||
* @param int $permid
|
* @param int $permid
|
||||||
* (optional) local permission id
|
* local permission id
|
||||||
* @param int $subj
|
* @param int $subj
|
||||||
* (optional) local user/group id
|
* local user/group id
|
||||||
* @param int $obj
|
* @param int $obj
|
||||||
* (optional) local object id
|
* local object id
|
||||||
* @return boolean/error
|
* @return boolean|PEAR_Error
|
||||||
*/
|
*/
|
||||||
function removePerm($permid=NULL, $subj=NULL, $obj=NULL)
|
public function removePerm($permid=NULL, $subj=NULL, $obj=NULL)
|
||||||
{
|
{
|
||||||
$ca = array();
|
$ca = array();
|
||||||
if ($permid) {
|
if ($permid) {
|
||||||
|
@ -203,7 +219,7 @@ class Alib extends Subjects{
|
||||||
* @return int
|
* @return int
|
||||||
* local object id
|
* local object id
|
||||||
*/
|
*/
|
||||||
function _getPermOid($permid)
|
protected function _getPermOid($permid)
|
||||||
{
|
{
|
||||||
$sql = "SELECT obj FROM {$this->permTable} WHERE permid=$permid";
|
$sql = "SELECT obj FROM {$this->permTable} WHERE permid=$permid";
|
||||||
$res = $this->dbc->getOne($sql);
|
$res = $this->dbc->getOne($sql);
|
||||||
|
@ -234,7 +250,7 @@ class Alib extends Subjects{
|
||||||
* @return mixed
|
* @return mixed
|
||||||
* boolean/err
|
* boolean/err
|
||||||
*/
|
*/
|
||||||
function checkPerm($sid, $action, $oid=NULL)
|
public function checkPerm($sid, $action, $oid=NULL)
|
||||||
{
|
{
|
||||||
if (!is_numeric($sid)) {
|
if (!is_numeric($sid)) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -322,10 +338,9 @@ class Alib extends Subjects{
|
||||||
* Remove all permissions on object and then remove object itself
|
* Remove all permissions on object and then remove object itself
|
||||||
*
|
*
|
||||||
* @param int $id
|
* @param int $id
|
||||||
* @return mixed
|
* @return void|PEAR_Error
|
||||||
* void/error
|
|
||||||
*/
|
*/
|
||||||
function removeObj($id)
|
public function removeObj($id)
|
||||||
{
|
{
|
||||||
$r = $this->removePerm(NULL, NULL, $id);
|
$r = $this->removePerm(NULL, NULL, $id);
|
||||||
if (PEAR::isError($r)) {
|
if (PEAR::isError($r)) {
|
||||||
|
@ -340,10 +355,9 @@ class Alib extends Subjects{
|
||||||
* Remove all permissions of subject and then remove subject itself
|
* Remove all permissions of subject and then remove subject itself
|
||||||
*
|
*
|
||||||
* @param string $login
|
* @param string $login
|
||||||
* @return mixed
|
* @return void|PEAR_Error
|
||||||
* void/error
|
|
||||||
*/
|
*/
|
||||||
function removeSubj($login)
|
public function removeSubj($login)
|
||||||
{
|
{
|
||||||
$uid = $this->getSubjId($login);
|
$uid = $this->getSubjId($login);
|
||||||
if (PEAR::isError($uid)) {
|
if (PEAR::isError($uid)) {
|
||||||
|
@ -366,9 +380,9 @@ class Alib extends Subjects{
|
||||||
* Get login from session id (token)
|
* Get login from session id (token)
|
||||||
*
|
*
|
||||||
* @param string $sessid
|
* @param string $sessid
|
||||||
* @return string/error
|
* @return string|PEAR_Error
|
||||||
*/
|
*/
|
||||||
function getSessLogin($sessid)
|
public function getSessLogin($sessid)
|
||||||
{
|
{
|
||||||
$sql = "SELECT login FROM {$this->sessTable} WHERE sessid='$sessid'";
|
$sql = "SELECT login FROM {$this->sessTable} WHERE sessid='$sessid'";
|
||||||
$r = $this->dbc->getOne($sql);
|
$r = $this->dbc->getOne($sql);
|
||||||
|
@ -388,9 +402,9 @@ class Alib extends Subjects{
|
||||||
* Get user id from session id.
|
* Get user id from session id.
|
||||||
*
|
*
|
||||||
* @param string $sessid
|
* @param string $sessid
|
||||||
* @return int/error
|
* @return int|PEAR_Error
|
||||||
*/
|
*/
|
||||||
function getSessUserId($sessid)
|
public function getSessUserId($sessid)
|
||||||
{
|
{
|
||||||
$sql = "SELECT userid FROM {$this->sessTable} WHERE sessid='$sessid'";
|
$sql = "SELECT userid FROM {$this->sessTable} WHERE sessid='$sessid'";
|
||||||
$r = $this->dbc->getOne($sql);
|
$r = $this->dbc->getOne($sql);
|
||||||
|
@ -411,9 +425,9 @@ class Alib extends Subjects{
|
||||||
* Get all permissions on object.
|
* Get all permissions on object.
|
||||||
*
|
*
|
||||||
* @param int $id
|
* @param int $id
|
||||||
* @return array/null/err
|
* @return array|null|PEAR_Error
|
||||||
*/
|
*/
|
||||||
function getObjPerms($id)
|
public function getObjPerms($id)
|
||||||
{
|
{
|
||||||
$sql = "SELECT s.login, p.* FROM {$this->permTable} p, {$this->subjTable} s
|
$sql = "SELECT s.login, p.* FROM {$this->permTable} p, {$this->subjTable} s
|
||||||
WHERE s.id=p.subj AND p.obj=$id";
|
WHERE s.id=p.subj AND p.obj=$id";
|
||||||
|
@ -427,7 +441,7 @@ class Alib extends Subjects{
|
||||||
* @param int $sid
|
* @param int $sid
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function getSubjPerms($sid)
|
public function getSubjPerms($sid)
|
||||||
{
|
{
|
||||||
$sql = "
|
$sql = "
|
||||||
SELECT t.name, t.type as otype , p.*
|
SELECT t.name, t.type as otype , p.*
|
||||||
|
@ -460,7 +474,7 @@ class Alib extends Subjects{
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function getAllActions()
|
public function getAllActions()
|
||||||
{
|
{
|
||||||
return $this->config['allActions'];
|
return $this->config['allActions'];
|
||||||
} // fn getAllActions
|
} // fn getAllActions
|
||||||
|
@ -472,7 +486,7 @@ class Alib extends Subjects{
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function getAllowedActions($type)
|
public function getAllowedActions($type)
|
||||||
{
|
{
|
||||||
return $this->config['allowedActions'][$type];
|
return $this->config['allowedActions'][$type];
|
||||||
} // fn getAllowedActions
|
} // fn getAllowedActions
|
||||||
|
@ -485,7 +499,7 @@ class Alib extends Subjects{
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _createSessid()
|
private function _createSessid()
|
||||||
{
|
{
|
||||||
for ($c=1; $c>0;){
|
for ($c=1; $c>0;){
|
||||||
$sessid = md5(uniqid(rand()));
|
$sessid = md5(uniqid(rand()));
|
||||||
|
@ -511,7 +525,7 @@ class Alib extends Subjects{
|
||||||
* actual indentation
|
* actual indentation
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function dumpPerms($indstr=' ', $ind='')
|
public function dumpPerms($indstr=' ', $ind='')
|
||||||
{
|
{
|
||||||
$arr = $this->dbc->getAll("
|
$arr = $this->dbc->getAll("
|
||||||
SELECT s.login, p.action, p.type
|
SELECT s.login, p.action, p.type
|
||||||
|
@ -536,7 +550,7 @@ class Alib extends Subjects{
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function deleteData()
|
public function deleteData()
|
||||||
{
|
{
|
||||||
$this->dbc->query("DELETE FROM {$this->permTable}");
|
$this->dbc->query("DELETE FROM {$this->permTable}");
|
||||||
$this->dbc->query("DELETE FROM {$this->sessTable}");
|
$this->dbc->query("DELETE FROM {$this->sessTable}");
|
||||||
|
@ -549,7 +563,7 @@ class Alib extends Subjects{
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function testData()
|
public function testData()
|
||||||
{
|
{
|
||||||
parent::testData();
|
parent::testData();
|
||||||
$t =& $this->tdata['tree'];
|
$t =& $this->tdata['tree'];
|
||||||
|
@ -585,9 +599,9 @@ class Alib extends Subjects{
|
||||||
/**
|
/**
|
||||||
* Make basic test
|
* Make basic test
|
||||||
*
|
*
|
||||||
* @return boolean/error
|
* @return boolean|PEAR_Error
|
||||||
*/
|
*/
|
||||||
function test()
|
public function test()
|
||||||
{
|
{
|
||||||
if (PEAR::isError($p = parent::test())) {
|
if (PEAR::isError($p = parent::test())) {
|
||||||
return $p;
|
return $p;
|
||||||
|
@ -646,7 +660,7 @@ class Alib extends Subjects{
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function install()
|
public function install()
|
||||||
{
|
{
|
||||||
parent::install();
|
parent::install();
|
||||||
$this->dbc->query("CREATE TABLE {$this->permTable} (
|
$this->dbc->query("CREATE TABLE {$this->permTable} (
|
||||||
|
@ -684,7 +698,7 @@ class Alib extends Subjects{
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function uninstall()
|
public function uninstall()
|
||||||
{
|
{
|
||||||
$this->dbc->query("DROP TABLE {$this->permTable}");
|
$this->dbc->query("DROP TABLE {$this->permTable}");
|
||||||
$this->dbc->dropSequence("{$this->permTable}_id_seq");
|
$this->dbc->dropSequence("{$this->permTable}_id_seq");
|
||||||
|
|
|
@ -6,27 +6,39 @@ require_once "m2tree.php";
|
||||||
*
|
*
|
||||||
* A class for 'object classes' handling - i.e. groups of object in tree
|
* A class for 'object classes' handling - i.e. groups of object in tree
|
||||||
*
|
*
|
||||||
* @author $Author$
|
* @author Tomas Hlava <th@red2head.com>
|
||||||
|
* @author Paul Baranowski <paul@paulbaranowski.org>
|
||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
* @package Campcaster
|
* @package Campcaster
|
||||||
* @subpackage Alib
|
* @subpackage Alib
|
||||||
* @see Mtree
|
* @copyright 2006 MDLF, Inc.
|
||||||
* @see Subj
|
* @license http://www.gnu.org/licenses/gpl.txt
|
||||||
|
* @link http://www.campware.org
|
||||||
*/
|
*/
|
||||||
class ObjClasses extends M2tree {
|
class ObjClasses extends M2tree {
|
||||||
var $classTable;
|
/**
|
||||||
var $cmembTable;
|
* The name of the database table ("PREFIXclasses")
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $classTable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* The name of a database table ("PREFIXcmemb")
|
||||||
*
|
*
|
||||||
* @param dbc object
|
* @var string
|
||||||
* @param config array
|
*/
|
||||||
|
public $cmembTable;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param object $dbc
|
||||||
|
* @param array $config
|
||||||
* @return this
|
* @return this
|
||||||
*/
|
*/
|
||||||
function ObjClasses(&$dbc, $config)
|
public function __construct(&$dbc, $config)
|
||||||
{
|
{
|
||||||
parent::M2Tree($dbc, $config);
|
parent::__construct($dbc, $config);
|
||||||
$this->classTable = $config['tblNamePrefix'].'classes';
|
$this->classTable = $config['tblNamePrefix'].'classes';
|
||||||
$this->cmembTable = $config['tblNamePrefix'].'cmemb';
|
$this->cmembTable = $config['tblNamePrefix'].'cmemb';
|
||||||
}
|
}
|
||||||
|
@ -37,10 +49,10 @@ class ObjClasses extends M2tree{
|
||||||
/**
|
/**
|
||||||
* Add new class of objects
|
* Add new class of objects
|
||||||
*
|
*
|
||||||
* @param cname string
|
* @param string $cname
|
||||||
* @return id/error
|
* @return id/error
|
||||||
*/
|
*/
|
||||||
function addClass($cname)
|
public function addClass($cname)
|
||||||
{
|
{
|
||||||
$id = $this->dbc->nextId("{$this->treeTable}_id_seq");
|
$id = $this->dbc->nextId("{$this->treeTable}_id_seq");
|
||||||
if (PEAR::isError($id)) {
|
if (PEAR::isError($id)) {
|
||||||
|
@ -60,10 +72,10 @@ class ObjClasses extends M2tree{
|
||||||
/**
|
/**
|
||||||
* Remove class by name
|
* Remove class by name
|
||||||
*
|
*
|
||||||
* @param cname string
|
* @param string $cname
|
||||||
* @return boolean/err
|
* @return boolean/err
|
||||||
*/
|
*/
|
||||||
function removeClass($cname)
|
public function removeClass($cname)
|
||||||
{
|
{
|
||||||
$cid = $this->getClassId($cname);
|
$cid = $this->getClassId($cname);
|
||||||
if (PEAR::isError($cid)) {
|
if (PEAR::isError($cid)) {
|
||||||
|
@ -76,10 +88,10 @@ class ObjClasses extends M2tree{
|
||||||
/**
|
/**
|
||||||
* Remove class by id
|
* Remove class by id
|
||||||
*
|
*
|
||||||
* @param cid int
|
* @param int $cid
|
||||||
* @return boolean/err
|
* @return boolean/err
|
||||||
*/
|
*/
|
||||||
function removeClassById($cid)
|
public function removeClassById($cid)
|
||||||
{
|
{
|
||||||
$r = $this->dbc->query("DELETE FROM {$this->cmembTable}
|
$r = $this->dbc->query("DELETE FROM {$this->cmembTable}
|
||||||
WHERE cid=$cid");
|
WHERE cid=$cid");
|
||||||
|
@ -98,11 +110,11 @@ class ObjClasses extends M2tree{
|
||||||
/**
|
/**
|
||||||
* Add object to class
|
* Add object to class
|
||||||
*
|
*
|
||||||
* @param cid int
|
* @param int $cid
|
||||||
* @param oid int
|
* @param int $oid
|
||||||
* @return boolean/err
|
* @return boolean/err
|
||||||
*/
|
*/
|
||||||
function addObj2Class($cid, $oid)
|
public function addObj2Class($cid, $oid)
|
||||||
{
|
{
|
||||||
$r = $this->dbc->query("INSERT INTO {$this->cmembTable} (cid, objid)
|
$r = $this->dbc->query("INSERT INTO {$this->cmembTable} (cid, objid)
|
||||||
VALUES ($cid, $oid)");
|
VALUES ($cid, $oid)");
|
||||||
|
@ -116,11 +128,11 @@ class ObjClasses extends M2tree{
|
||||||
/**
|
/**
|
||||||
* Remove object from class
|
* Remove object from class
|
||||||
*
|
*
|
||||||
* @param oid int
|
* @param int $oid
|
||||||
* @param cid int, optional, default: remove obj from all classes
|
* @param int $cid, optional, default: remove obj from all classes
|
||||||
* @return boolean/err
|
* @return boolean/err
|
||||||
*/
|
*/
|
||||||
function removeObjFromClass($oid, $cid=NULL)
|
public function removeObjFromClass($oid, $cid=NULL)
|
||||||
{
|
{
|
||||||
$r = $this->dbc->query("DELETE FROM {$this->cmembTable}
|
$r = $this->dbc->query("DELETE FROM {$this->cmembTable}
|
||||||
WHERE objid=$oid".(is_null($cid)? '':" AND cid=$cid"));
|
WHERE objid=$oid".(is_null($cid)? '':" AND cid=$cid"));
|
||||||
|
@ -136,10 +148,10 @@ class ObjClasses extends M2tree{
|
||||||
/**
|
/**
|
||||||
* Remove object from all classes and remove object itself
|
* Remove object from all classes and remove object itself
|
||||||
*
|
*
|
||||||
* @param id int
|
* @param int $id
|
||||||
* @return boolean/err
|
* @return boolean/err
|
||||||
*/
|
*/
|
||||||
function removeObj($id)
|
public function removeObj($id)
|
||||||
{
|
{
|
||||||
$r = $this->removeObjFromClass($id);
|
$r = $this->removeObjFromClass($id);
|
||||||
if (PEAR::isError($r)) {
|
if (PEAR::isError($r)) {
|
||||||
|
@ -154,10 +166,10 @@ class ObjClasses extends M2tree{
|
||||||
/**
|
/**
|
||||||
* Get class id from name
|
* Get class id from name
|
||||||
*
|
*
|
||||||
* @param cname string
|
* @param string $cname
|
||||||
* @return int/err
|
* @return int/err
|
||||||
*/
|
*/
|
||||||
function getClassId($cname)
|
public function getClassId($cname)
|
||||||
{
|
{
|
||||||
$cname = pg_escape_string($cname);
|
$cname = pg_escape_string($cname);
|
||||||
return $this->dbc->getOne($query = "SELECT id FROM {$this->classTable}
|
return $this->dbc->getOne($query = "SELECT id FROM {$this->classTable}
|
||||||
|
@ -168,10 +180,10 @@ class ObjClasses extends M2tree{
|
||||||
/**
|
/**
|
||||||
* Get class name from id
|
* Get class name from id
|
||||||
*
|
*
|
||||||
* @param id int
|
* @param int $id
|
||||||
* @return string/err
|
* @return string/err
|
||||||
*/
|
*/
|
||||||
function getClassName($id)
|
public function getClassName($id)
|
||||||
{
|
{
|
||||||
return $this->dbc->getOne(
|
return $this->dbc->getOne(
|
||||||
$query = "SELECT cname FROM {$this->classTable} WHERE id=$id");
|
$query = "SELECT cname FROM {$this->classTable} WHERE id=$id");
|
||||||
|
@ -181,10 +193,10 @@ class ObjClasses extends M2tree{
|
||||||
/**
|
/**
|
||||||
* Return true is object is class
|
* Return true is object is class
|
||||||
*
|
*
|
||||||
* @param id int
|
* @param int $id
|
||||||
* @return boolean/err
|
* @return boolean/err
|
||||||
*/
|
*/
|
||||||
function isClass($id)
|
public function isClass($id)
|
||||||
{
|
{
|
||||||
$r = $this->dbc->getOne("SELECT count(*) FROM {$this->classTable}
|
$r = $this->dbc->getOne("SELECT count(*) FROM {$this->classTable}
|
||||||
WHERE id=$id");
|
WHERE id=$id");
|
||||||
|
@ -200,7 +212,7 @@ class ObjClasses extends M2tree{
|
||||||
*
|
*
|
||||||
* @return array/err
|
* @return array/err
|
||||||
*/
|
*/
|
||||||
function getClasses()
|
public function getClasses()
|
||||||
{
|
{
|
||||||
return $this->dbc->getAll("SELECT * FROM {$this->classTable}");
|
return $this->dbc->getAll("SELECT * FROM {$this->classTable}");
|
||||||
}
|
}
|
||||||
|
@ -209,10 +221,10 @@ class ObjClasses extends M2tree{
|
||||||
/**
|
/**
|
||||||
* Return all objects in class
|
* Return all objects in class
|
||||||
*
|
*
|
||||||
* @param id int
|
* @param int $id
|
||||||
* @return array/err
|
* @return array/err
|
||||||
*/
|
*/
|
||||||
function listClass($id)
|
public function listClass($id)
|
||||||
{
|
{
|
||||||
return $this->dbc->getAll("
|
return $this->dbc->getAll("
|
||||||
SELECT t.* FROM {$this->cmembTable} cm, {$this->treeTable} t
|
SELECT t.* FROM {$this->cmembTable} cm, {$this->treeTable} t
|
||||||
|
@ -223,13 +235,15 @@ class ObjClasses extends M2tree{
|
||||||
/* =============================================== test and debug methods */
|
/* =============================================== test and debug methods */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump all classes fot debug
|
* Dump all classes for debug
|
||||||
*
|
*
|
||||||
* @param indstr string // indentation string
|
* @param string $indstr
|
||||||
* @param ind string // aktual indentation
|
* indentation string
|
||||||
|
* @param string $ind
|
||||||
|
* actual indentation
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function dumpClasses($indstr=' ', $ind='')
|
public function dumpClasses($indstr=' ', $ind='')
|
||||||
{
|
{
|
||||||
$r = $ind.join(', ', array_map(
|
$r = $ind.join(', ', array_map(
|
||||||
create_function('$v', 'return "{$v[\'cname\']} ({$v[\'cnt\']})";'),
|
create_function('$v', 'return "{$v[\'cname\']} ({$v[\'cnt\']})";'),
|
||||||
|
@ -245,9 +259,9 @@ class ObjClasses extends M2tree{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete all classes and membeship records
|
* Delete all classes and membeship records
|
||||||
*
|
* @return void
|
||||||
*/
|
*/
|
||||||
function deleteData()
|
public function deleteData()
|
||||||
{
|
{
|
||||||
$this->dbc->query("DELETE FROM {$this->cmembTable}");
|
$this->dbc->query("DELETE FROM {$this->cmembTable}");
|
||||||
$this->dbc->query("DELETE FROM {$this->classTable}");
|
$this->dbc->query("DELETE FROM {$this->classTable}");
|
||||||
|
@ -259,7 +273,7 @@ class ObjClasses extends M2tree{
|
||||||
* Insert test data
|
* Insert test data
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function testData()
|
public function testData()
|
||||||
{
|
{
|
||||||
parent::testData();
|
parent::testData();
|
||||||
$o['cl_sa'] = $this->addClass('Sections a');
|
$o['cl_sa'] = $this->addClass('Sections a');
|
||||||
|
@ -276,7 +290,7 @@ class ObjClasses extends M2tree{
|
||||||
* Make basic test
|
* Make basic test
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function test()
|
public function test()
|
||||||
{
|
{
|
||||||
if (PEAR::isError($p = parent::test())) {
|
if (PEAR::isError($p = parent::test())) {
|
||||||
return $p;
|
return $p;
|
||||||
|
@ -306,7 +320,7 @@ class ObjClasses extends M2tree{
|
||||||
* Create tables + initialize
|
* Create tables + initialize
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function install()
|
public function install()
|
||||||
{
|
{
|
||||||
parent::install();
|
parent::install();
|
||||||
$this->dbc->query("CREATE TABLE {$this->classTable} (
|
$this->dbc->query("CREATE TABLE {$this->classTable} (
|
||||||
|
@ -331,7 +345,7 @@ class ObjClasses extends M2tree{
|
||||||
* Drop tables etc.
|
* Drop tables etc.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function uninstall()
|
public function uninstall()
|
||||||
{
|
{
|
||||||
$this->dbc->query("DROP TABLE {$this->classTable}");
|
$this->dbc->query("DROP TABLE {$this->classTable}");
|
||||||
$this->dbc->query("DROP TABLE {$this->cmembTable}");
|
$this->dbc->query("DROP TABLE {$this->cmembTable}");
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @author $Author$
|
|
||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once "alib_h.php";
|
require_once("alib_h.php");
|
||||||
require_once "alibExTestAuth.php";
|
require_once("alibExTestAuth.php");
|
||||||
|
|
||||||
if (isset($_GET['id']) && is_numeric($_GET['id'])) {
|
if (isset($_GET['id']) && is_numeric($_GET['id'])) {
|
||||||
$id = $_GET['id'];
|
$id = $_GET['id'];
|
||||||
|
@ -36,7 +35,7 @@ if(!$alib->isClass($id)){
|
||||||
}
|
}
|
||||||
$d['msg'] = $_SESSION['alertMsg']; unset($_SESSION['alertMsg']);
|
$d['msg'] = $_SESSION['alertMsg']; unset($_SESSION['alertMsg']);
|
||||||
|
|
||||||
require_once "alib_f.php";
|
require_once("alib_f.php");
|
||||||
// template follows:
|
// template follows:
|
||||||
?>
|
?>
|
||||||
<html><head>
|
<html><head>
|
||||||
|
|
|
@ -27,5 +27,5 @@ function errCallback($err)
|
||||||
|
|
||||||
$dbc = DB::connect($config['dsn'], TRUE);
|
$dbc = DB::connect($config['dsn'], TRUE);
|
||||||
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||||
$alib =& new Alib($dbc, $config);
|
$alib = new Alib($dbc, $config);
|
||||||
?>
|
?>
|
|
@ -29,7 +29,7 @@ $dbc->setErrorHandling(PEAR_ERROR_RETURN);
|
||||||
#$$dbc->setErrorHandling(PEAR_ERROR_DIE, "%s<hr>\n");
|
#$$dbc->setErrorHandling(PEAR_ERROR_DIE, "%s<hr>\n");
|
||||||
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||||
|
|
||||||
$alib =& new Alib($dbc, $config);
|
$alib = new Alib($dbc, $config);
|
||||||
|
|
||||||
echo "\n\n======\n".
|
echo "\n\n======\n".
|
||||||
"This is Alib standalone installation script, it is NOT needed to run ".
|
"This is Alib standalone installation script, it is NOT needed to run ".
|
||||||
|
|
|
@ -28,7 +28,7 @@ if(PEAR::isError($dbc)){
|
||||||
#PEAR::setErrorHandling(PEAR_ERROR_PRINT, "%s<hr>\n");
|
#PEAR::setErrorHandling(PEAR_ERROR_PRINT, "%s<hr>\n");
|
||||||
$dbc->setErrorHandling(PEAR_ERROR_RETURN);
|
$dbc->setErrorHandling(PEAR_ERROR_RETURN);
|
||||||
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||||
$alib =& new Alib($dbc, $config);
|
$alib = new Alib($dbc, $config);
|
||||||
|
|
||||||
# $dbc->setErrorHandling(PEAR_ERROR_RETURN);
|
# $dbc->setErrorHandling(PEAR_ERROR_RETURN);
|
||||||
echo "Trying to uninstall all ...\n";
|
echo "Trying to uninstall all ...\n";
|
||||||
|
|
|
@ -22,10 +22,14 @@ define('ALIBERR_MTREE', 10);
|
||||||
* );
|
* );
|
||||||
* </code></pre>
|
* </code></pre>
|
||||||
*
|
*
|
||||||
* @author $Author$
|
* @author Tomas Hlava <th@red2head.com>
|
||||||
|
* @author Paul Baranowski <paul@paulbaranowski.org>
|
||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
* @package Campcaster
|
* @package Campcaster
|
||||||
* @subpackage Alib
|
* @subpackage Alib
|
||||||
|
* @copyright 2006 MDLF, Inc.
|
||||||
|
* @license http://www.gnu.org/licenses/gpl.txt
|
||||||
|
* @link http://www.campware.org
|
||||||
* @see ObjClasses
|
* @see ObjClasses
|
||||||
*
|
*
|
||||||
* Original author Tom Hlava
|
* Original author Tom Hlava
|
||||||
|
@ -34,27 +38,27 @@ class M2tree {
|
||||||
/**
|
/**
|
||||||
* Database object container
|
* Database object container
|
||||||
*/
|
*/
|
||||||
var $dbc;
|
public $dbc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration tree
|
* Configuration tree
|
||||||
*/
|
*/
|
||||||
var $config;
|
public $config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tree table name
|
* Tree table name
|
||||||
*/
|
*/
|
||||||
var $treeTable;
|
protected $treeTable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Structure table name
|
* Structure table name
|
||||||
*/
|
*/
|
||||||
var $structTable;
|
protected $structTable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Root node name
|
* Root node name
|
||||||
*/
|
*/
|
||||||
var $rootNodeName;
|
private $rootNodeName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
@ -62,9 +66,9 @@ class M2tree {
|
||||||
* @param DB $dbc
|
* @param DB $dbc
|
||||||
* @param array $config
|
* @param array $config
|
||||||
*/
|
*/
|
||||||
function M2tree(&$dbc, $config)
|
public function __construct(&$dbc, $config)
|
||||||
{
|
{
|
||||||
$this->dbc =& $dbc;
|
$this->dbc = $dbc;
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
$this->treeTable = $config['tblNamePrefix'].'tree';
|
$this->treeTable = $config['tblNamePrefix'].'tree';
|
||||||
$this->structTable = $config['tblNamePrefix'].'struct';
|
$this->structTable = $config['tblNamePrefix'].'struct';
|
||||||
|
@ -86,7 +90,7 @@ class M2tree {
|
||||||
* @return mixed
|
* @return mixed
|
||||||
* int/err - new id of inserted object or PEAR::error
|
* int/err - new id of inserted object or PEAR::error
|
||||||
*/
|
*/
|
||||||
function addObj($name, $type, $parid = NULL)
|
public function addObj($name, $type, $parid = NULL)
|
||||||
{
|
{
|
||||||
if ( ($name == '') || ($type == '') ) {
|
if ( ($name == '') || ($type == '') ) {
|
||||||
return $this->dbc->raiseError("M2tree::addObj: Wrong name or type", ALIBERR_MTREE);
|
return $this->dbc->raiseError("M2tree::addObj: Wrong name or type", ALIBERR_MTREE);
|
||||||
|
@ -154,7 +158,7 @@ class M2tree {
|
||||||
* @return mixed
|
* @return mixed
|
||||||
* boolean/err - TRUE or PEAR::error
|
* boolean/err - TRUE or PEAR::error
|
||||||
*/
|
*/
|
||||||
function removeObj($oid)
|
public function removeObj($oid)
|
||||||
{
|
{
|
||||||
if ($oid == $this->getRootNode()) {
|
if ($oid == $this->getRootNode()) {
|
||||||
return $this->dbc->raiseError(
|
return $this->dbc->raiseError(
|
||||||
|
@ -202,7 +206,7 @@ class M2tree {
|
||||||
* @return mixed
|
* @return mixed
|
||||||
* int/err - new id of inserted object or PEAR::error
|
* int/err - new id of inserted object or PEAR::error
|
||||||
*/
|
*/
|
||||||
function copyObj($oid, $newParid, $after=NULL)
|
protected function copyObj($oid, $newParid, $after=NULL)
|
||||||
{
|
{
|
||||||
if (TRUE === ($r = $this->isChildOf($newParid, $oid, TRUE))) {
|
if (TRUE === ($r = $this->isChildOf($newParid, $oid, TRUE))) {
|
||||||
return $this->dbc->raiseError(
|
return $this->dbc->raiseError(
|
||||||
|
@ -264,7 +268,7 @@ class M2tree {
|
||||||
* dummy argument for back-compatibility
|
* dummy argument for back-compatibility
|
||||||
* @return boolean/err
|
* @return boolean/err
|
||||||
*/
|
*/
|
||||||
function moveObj($oid, $newParid, $after=NULL)
|
public function moveObj($oid, $newParid, $after=NULL)
|
||||||
{
|
{
|
||||||
if (TRUE === (
|
if (TRUE === (
|
||||||
$r = $this->isChildOf($newParid, $oid, TRUE)
|
$r = $this->isChildOf($newParid, $oid, TRUE)
|
||||||
|
@ -325,7 +329,7 @@ class M2tree {
|
||||||
* new name
|
* new name
|
||||||
* @return TRUE/PEAR_Error
|
* @return TRUE/PEAR_Error
|
||||||
*/
|
*/
|
||||||
function renameObj($oid, $newName)
|
public function renameObj($oid, $newName)
|
||||||
{
|
{
|
||||||
// get parent id:
|
// get parent id:
|
||||||
$parid = $this->getParent($oid);
|
$parid = $this->getParent($oid);
|
||||||
|
@ -365,7 +369,7 @@ class M2tree {
|
||||||
* @return mixed
|
* @return mixed
|
||||||
* int/null/err - child id (if found) or null or PEAR::error
|
* int/null/err - child id (if found) or null or PEAR::error
|
||||||
*/
|
*/
|
||||||
function getObjId($name, $parId = null)
|
public function getObjId($name, $parId = null)
|
||||||
{
|
{
|
||||||
if ( ($name == '') && is_null($parId)) {
|
if ( ($name == '') && is_null($parId)) {
|
||||||
$name = $this->rootNodeName;
|
$name = $this->rootNodeName;
|
||||||
|
@ -394,7 +398,7 @@ class M2tree {
|
||||||
* @return mixed
|
* @return mixed
|
||||||
* string/err
|
* string/err
|
||||||
*/
|
*/
|
||||||
function getObjName($oid, $fld='name')
|
public function getObjName($oid, $fld='name')
|
||||||
{
|
{
|
||||||
$r = $this->dbc->getOne("
|
$r = $this->dbc->getOne("
|
||||||
SELECT $fld FROM {$this->treeTable}
|
SELECT $fld FROM {$this->treeTable}
|
||||||
|
@ -410,7 +414,7 @@ class M2tree {
|
||||||
* @param int $oid
|
* @param int $oid
|
||||||
* @return string/err
|
* @return string/err
|
||||||
*/
|
*/
|
||||||
function getObjType($oid)
|
public function getObjType($oid)
|
||||||
{
|
{
|
||||||
return $this->getObjName($oid, 'type');
|
return $this->getObjName($oid, 'type');
|
||||||
} // fn getObjType
|
} // fn getObjType
|
||||||
|
@ -422,7 +426,7 @@ class M2tree {
|
||||||
* @param int $oid
|
* @param int $oid
|
||||||
* @return int/err
|
* @return int/err
|
||||||
*/
|
*/
|
||||||
function getParent($oid)
|
public function getParent($oid)
|
||||||
{
|
{
|
||||||
$r = $this->dbc->getOne("
|
$r = $this->dbc->getOne("
|
||||||
SELECT parid FROM {$this->structTable}
|
SELECT parid FROM {$this->structTable}
|
||||||
|
@ -441,7 +445,7 @@ class M2tree {
|
||||||
* flag for include specified object to the path
|
* flag for include specified object to the path
|
||||||
* @return array/err
|
* @return array/err
|
||||||
*/
|
*/
|
||||||
function getPath($oid, $flds='id', $withSelf=TRUE)
|
public function getPath($oid, $flds='id', $withSelf=TRUE)
|
||||||
{
|
{
|
||||||
$path = $this->dbc->getAll("
|
$path = $this->dbc->getAll("
|
||||||
SELECT $flds
|
SELECT $flds
|
||||||
|
@ -477,7 +481,7 @@ class M2tree {
|
||||||
* fieldname for order by clause
|
* fieldname for order by clause
|
||||||
* @return array/err
|
* @return array/err
|
||||||
*/
|
*/
|
||||||
function getDir($oid, $flds='id', $order='name')
|
public function getDir($oid, $flds='id', $order='name')
|
||||||
{
|
{
|
||||||
$r = $this->dbc->getAll("
|
$r = $this->dbc->getAll("
|
||||||
SELECT $flds
|
SELECT $flds
|
||||||
|
@ -502,7 +506,7 @@ class M2tree {
|
||||||
* (if NULL - use root of whole tree)
|
* (if NULL - use root of whole tree)
|
||||||
* @return hash-array with field name/value pairs
|
* @return hash-array with field name/value pairs
|
||||||
*/
|
*/
|
||||||
function getObjLevel($oid, $flds='level', $rootId=NULL)
|
public function getObjLevel($oid, $flds='level', $rootId=NULL)
|
||||||
{
|
{
|
||||||
if (is_null($rootId)) {
|
if (is_null($rootId)) {
|
||||||
$rootId = $this->getRootNode();
|
$rootId = $this->getRootNode();
|
||||||
|
@ -533,7 +537,7 @@ class M2tree {
|
||||||
* @return mixed
|
* @return mixed
|
||||||
* array/err
|
* array/err
|
||||||
*/
|
*/
|
||||||
function getSubTree($oid=NULL, $withRoot=FALSE, $rootId=NULL)
|
public function getSubTree($oid=NULL, $withRoot=FALSE, $rootId=NULL)
|
||||||
{
|
{
|
||||||
if (is_null($oid)) $oid = $this->getRootNode();
|
if (is_null($oid)) $oid = $this->getRootNode();
|
||||||
if (is_null($rootId)) $rootId = $oid;
|
if (is_null($rootId)) $rootId = $oid;
|
||||||
|
@ -575,7 +579,7 @@ class M2tree {
|
||||||
* test indirect or only direct relation
|
* test indirect or only direct relation
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function isChildOf($oid, $parid, $indirect=FALSE)
|
public function isChildOf($oid, $parid, $indirect=FALSE)
|
||||||
{
|
{
|
||||||
if (!$indirect) {
|
if (!$indirect) {
|
||||||
$paridD = $this->getParent($oid);
|
$paridD = $this->getParent($oid);
|
||||||
|
@ -603,7 +607,7 @@ class M2tree {
|
||||||
*
|
*
|
||||||
* @return int/err
|
* @return int/err
|
||||||
*/
|
*/
|
||||||
function getRootNode()
|
public function getRootNode()
|
||||||
{
|
{
|
||||||
return $this->getObjId($this->rootNodeName);
|
return $this->getObjId($this->rootNodeName);
|
||||||
} // fn getRootNode
|
} // fn getRootNode
|
||||||
|
@ -614,7 +618,7 @@ class M2tree {
|
||||||
*
|
*
|
||||||
* @return array/err
|
* @return array/err
|
||||||
*/
|
*/
|
||||||
function getAllObjects()
|
public function getAllObjects()
|
||||||
{
|
{
|
||||||
return $this->dbc->getAll(
|
return $this->dbc->getAll(
|
||||||
"SELECT * FROM {$this->treeTable}"
|
"SELECT * FROM {$this->treeTable}"
|
||||||
|
@ -634,7 +638,7 @@ class M2tree {
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function getAllowedChildTypes($type)
|
public function getAllowedChildTypes($type)
|
||||||
{
|
{
|
||||||
return $this->config['objtypes'][$type];
|
return $this->config['objtypes'][$type];
|
||||||
} // fn getAllowedChildTypes
|
} // fn getAllowedChildTypes
|
||||||
|
@ -650,7 +654,7 @@ class M2tree {
|
||||||
* object id
|
* object id
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function _cutSubtree($oid)
|
private function _cutSubtree($oid)
|
||||||
{
|
{
|
||||||
$lvl = $this->getObjLevel($oid);
|
$lvl = $this->getObjLevel($oid);
|
||||||
if ($this->dbc->isError($lvl)) {
|
if ($this->dbc->isError($lvl)) {
|
||||||
|
@ -684,7 +688,7 @@ class M2tree {
|
||||||
* destination object id
|
* destination object id
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function _pasteSubtree($oid, $newParid)
|
private function _pasteSubtree($oid, $newParid)
|
||||||
{
|
{
|
||||||
$dataArr = array();
|
$dataArr = array();
|
||||||
// build data ($dataArr) for INSERT:
|
// build data ($dataArr) for INSERT:
|
||||||
|
@ -720,7 +724,7 @@ class M2tree {
|
||||||
* error object or error message
|
* error object or error message
|
||||||
* @return err
|
* @return err
|
||||||
*/
|
*/
|
||||||
function _dbRollback($r)
|
private function _dbRollback($r)
|
||||||
{
|
{
|
||||||
$this->dbc->query("ROLLBACK");
|
$this->dbc->query("ROLLBACK");
|
||||||
if ($this->dbc->isError($r)) {
|
if ($this->dbc->isError($r)) {
|
||||||
|
@ -747,7 +751,7 @@ class M2tree {
|
||||||
* actual indentation
|
* actual indentation
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function dumpTree($oid=NULL, $indstr=' ', $ind='',
|
public function dumpTree($oid=NULL, $indstr=' ', $ind='',
|
||||||
$format='{name}({id})', $withRoot=TRUE)
|
$format='{name}({id})', $withRoot=TRUE)
|
||||||
{
|
{
|
||||||
$r='';
|
$r='';
|
||||||
|
@ -768,7 +772,7 @@ class M2tree {
|
||||||
* Create tables + initialize root node
|
* Create tables + initialize root node
|
||||||
* @return err/void
|
* @return err/void
|
||||||
*/
|
*/
|
||||||
function install()
|
public function install()
|
||||||
{
|
{
|
||||||
$r = $this->dbc->query("BEGIN");
|
$r = $this->dbc->query("BEGIN");
|
||||||
if (PEAR::isError($r)) {
|
if (PEAR::isError($r)) {
|
||||||
|
@ -871,7 +875,7 @@ class M2tree {
|
||||||
* Drop all tables and sequences.
|
* Drop all tables and sequences.
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function uninstall()
|
public function uninstall()
|
||||||
{
|
{
|
||||||
$this->dbc->query("DROP TABLE {$this->structTable}");
|
$this->dbc->query("DROP TABLE {$this->structTable}");
|
||||||
$this->dbc->dropSequence("{$this->structTable}_id_seq");
|
$this->dbc->dropSequence("{$this->structTable}_id_seq");
|
||||||
|
@ -884,7 +888,7 @@ class M2tree {
|
||||||
* Uninstall and install.
|
* Uninstall and install.
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function reinstall()
|
public function reinstall()
|
||||||
{
|
{
|
||||||
$this->uninstall();
|
$this->uninstall();
|
||||||
$this->install();
|
$this->install();
|
||||||
|
@ -895,7 +899,7 @@ class M2tree {
|
||||||
* Clean up tree - delete all except the root node.
|
* Clean up tree - delete all except the root node.
|
||||||
* @return err/void
|
* @return err/void
|
||||||
*/
|
*/
|
||||||
function reset()
|
public function reset()
|
||||||
{
|
{
|
||||||
$rid = $this->getRootNode();
|
$rid = $this->getRootNode();
|
||||||
if ($this->dbc->isError($rid)) {
|
if ($this->dbc->isError($rid)) {
|
||||||
|
@ -918,10 +922,10 @@ class M2tree {
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function test()
|
public function test()
|
||||||
{
|
{
|
||||||
require_once "m2treeTest.php";
|
require_once "m2treeTest.php";
|
||||||
$mt = &new M2treeTest($this->dbc, $this->config);
|
$mt = new M2treeTest($this->dbc, $this->config);
|
||||||
$r = $mt->_test();
|
$r = $mt->_test();
|
||||||
return $r;
|
return $r;
|
||||||
} // fn test
|
} // fn test
|
||||||
|
@ -933,7 +937,7 @@ class M2tree {
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function testData()
|
public function testData()
|
||||||
{
|
{
|
||||||
$o['root'] = $this->getRootNode();
|
$o['root'] = $this->getRootNode();
|
||||||
$o['pa'] = $this->addObj('Publication A', 'Publication', $o['root']);
|
$o['pa'] = $this->addObj('Publication A', 'Publication', $o['root']);
|
||||||
|
|
|
@ -20,7 +20,7 @@ function errCallback($err)
|
||||||
$dbc = DB::connect($config['dsn'], TRUE);
|
$dbc = DB::connect($config['dsn'], TRUE);
|
||||||
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||||
|
|
||||||
$m2 = &new M2treeTest($dbc, $config);
|
$m2 = new M2treeTest($dbc, $config);
|
||||||
#$m2->uninstall();
|
#$m2->uninstall();
|
||||||
#exit;
|
#exit;
|
||||||
#$r = $m2->install(); if($dbc->isError($r)){ echo $r->getMessage()."\n".$r->getUserInfo()."\n"; exit; }
|
#$r = $m2->install(); if($dbc->isError($r)){ echo $r->getMessage()."\n".$r->getUserInfo()."\n"; exit; }
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
require_once "class.php";
|
require_once("class.php");
|
||||||
define('ALIBERR_NOTGR', 20);
|
define('ALIBERR_NOTGR', 20);
|
||||||
define('ALIBERR_BADSMEMB', 21);
|
define('ALIBERR_BADSMEMB', 21);
|
||||||
|
|
||||||
|
@ -10,16 +10,32 @@ define('ALIBERR_BADSMEMB', 21);
|
||||||
* with "linearized recursive membership" ;)
|
* with "linearized recursive membership" ;)
|
||||||
* (allow adding users to groups or groups to groups)
|
* (allow adding users to groups or groups to groups)
|
||||||
*
|
*
|
||||||
* @author $Author$
|
* @author Tomas Hlava <th@red2head.com>
|
||||||
|
* @author Paul Baranowski <paul@paulbaranowski.org>
|
||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
* @package Campcaster
|
* @package Campcaster
|
||||||
* @subpackage Alib
|
* @subpackage Alib
|
||||||
|
* @copyright 2006 MDLF, Inc.
|
||||||
|
* @license http://www.gnu.org/licenses/gpl.txt
|
||||||
|
* @link http://www.campware.org
|
||||||
* @see ObjClasses
|
* @see ObjClasses
|
||||||
* @see Alib
|
* @see Alib
|
||||||
*/
|
*/
|
||||||
class Subjects extends ObjClasses {
|
class Subjects extends ObjClasses {
|
||||||
var $subjTable;
|
/**
|
||||||
var $smembTable;
|
* The name of the 'Subjects' database table.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $subjTable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of a database table.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $smembTable;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
@ -28,9 +44,9 @@ class Subjects extends ObjClasses {
|
||||||
* @param array $config
|
* @param array $config
|
||||||
* @return this
|
* @return this
|
||||||
*/
|
*/
|
||||||
function Subjects(&$dbc, $config)
|
public function __construct(&$dbc, $config)
|
||||||
{
|
{
|
||||||
parent::ObjClasses($dbc, $config);
|
parent::__construct($dbc, $config);
|
||||||
$this->subjTable = $config['tblNamePrefix'].'subjs';
|
$this->subjTable = $config['tblNamePrefix'].'subjs';
|
||||||
$this->smembTable = $config['tblNamePrefix'].'smemb';
|
$this->smembTable = $config['tblNamePrefix'].'smemb';
|
||||||
} // constructor
|
} // constructor
|
||||||
|
@ -43,14 +59,12 @@ class Subjects extends ObjClasses {
|
||||||
*
|
*
|
||||||
* @param string $login
|
* @param string $login
|
||||||
* @param string $pass
|
* @param string $pass
|
||||||
* optional
|
|
||||||
* @param string $realname
|
* @param string $realname
|
||||||
* optional
|
|
||||||
* @param boolean $passenc
|
* @param boolean $passenc
|
||||||
* optional, password already encrypted if true
|
* password already encrypted if true
|
||||||
* @return int/err
|
* @return int/err
|
||||||
*/
|
*/
|
||||||
function addSubj($login, $pass=NULL, $realname='', $passenc=FALSE)
|
public function addSubj($login, $pass=NULL, $realname='', $passenc=FALSE)
|
||||||
{
|
{
|
||||||
if(!$login) {
|
if(!$login) {
|
||||||
return $this->dbc->raiseError(get_class($this)."::addSubj: empty login");
|
return $this->dbc->raiseError(get_class($this)."::addSubj: empty login");
|
||||||
|
@ -82,7 +96,7 @@ class Subjects extends ObjClasses {
|
||||||
* optional, default: null
|
* optional, default: null
|
||||||
* @return boolean/err
|
* @return boolean/err
|
||||||
*/
|
*/
|
||||||
function removeSubj($login, $uid=NULL)
|
public function removeSubj($login, $uid=NULL)
|
||||||
{
|
{
|
||||||
if (is_null($uid)) {
|
if (is_null($uid)) {
|
||||||
$uid = $this->getSubjId($login);
|
$uid = $this->getSubjId($login);
|
||||||
|
@ -114,7 +128,7 @@ class Subjects extends ObjClasses {
|
||||||
* optional
|
* optional
|
||||||
* @return boolean/int/err
|
* @return boolean/int/err
|
||||||
*/
|
*/
|
||||||
function authenticate($login, $pass='')
|
public function authenticate($login, $pass='')
|
||||||
{
|
{
|
||||||
$cpass = md5($pass);
|
$cpass = md5($pass);
|
||||||
$sql = "SELECT id FROM {$this->subjTable}
|
$sql = "SELECT id FROM {$this->subjTable}
|
||||||
|
@ -135,7 +149,7 @@ class Subjects extends ObjClasses {
|
||||||
* true=> set lastfail, false=> set lastlogin
|
* true=> set lastfail, false=> set lastlogin
|
||||||
* @return boolean/int/err
|
* @return boolean/int/err
|
||||||
*/
|
*/
|
||||||
function setTimeStamp($login, $failed=FALSE)
|
public function setTimeStamp($login, $failed=FALSE)
|
||||||
{
|
{
|
||||||
$fld = ($failed ? 'lastfail' : 'lastlogin');
|
$fld = ($failed ? 'lastfail' : 'lastlogin');
|
||||||
$sql = "UPDATE {$this->subjTable} SET $fld=now()
|
$sql = "UPDATE {$this->subjTable} SET $fld=now()
|
||||||
|
@ -160,7 +174,7 @@ class Subjects extends ObjClasses {
|
||||||
* optional, password already encrypted if true
|
* optional, password already encrypted if true
|
||||||
* @return boolean/err
|
* @return boolean/err
|
||||||
*/
|
*/
|
||||||
function passwd($login, $oldpass=null, $pass='', $passenc=FALSE)
|
public function passwd($login, $oldpass=null, $pass='', $passenc=FALSE)
|
||||||
{
|
{
|
||||||
if (!$passenc) {
|
if (!$passenc) {
|
||||||
$cpass = md5($pass);
|
$cpass = md5($pass);
|
||||||
|
@ -193,7 +207,7 @@ class Subjects extends ObjClasses {
|
||||||
* @param string $gname
|
* @param string $gname
|
||||||
* @return int/err
|
* @return int/err
|
||||||
*/
|
*/
|
||||||
function addSubj2Gr($login, $gname)
|
public function addSubj2Gr($login, $gname)
|
||||||
{
|
{
|
||||||
$uid = $this->getSubjId($login);
|
$uid = $this->getSubjId($login);
|
||||||
if (PEAR::isError($uid)) {
|
if (PEAR::isError($uid)) {
|
||||||
|
@ -238,7 +252,7 @@ class Subjects extends ObjClasses {
|
||||||
* @param string $gname
|
* @param string $gname
|
||||||
* @return boolean/err
|
* @return boolean/err
|
||||||
*/
|
*/
|
||||||
function removeSubjFromGr($login, $gname)
|
public function removeSubjFromGr($login, $gname)
|
||||||
{
|
{
|
||||||
$uid = $this->getSubjId($login);
|
$uid = $this->getSubjId($login);
|
||||||
if (PEAR::isError($uid)) {
|
if (PEAR::isError($uid)) {
|
||||||
|
@ -279,7 +293,7 @@ class Subjects extends ObjClasses {
|
||||||
* @param string $login
|
* @param string $login
|
||||||
* @return int/err
|
* @return int/err
|
||||||
*/
|
*/
|
||||||
function getSubjId($login)
|
public function getSubjId($login)
|
||||||
{
|
{
|
||||||
$sql = "SELECT id FROM {$this->subjTable}
|
$sql = "SELECT id FROM {$this->subjTable}
|
||||||
WHERE login='$login'";
|
WHERE login='$login'";
|
||||||
|
@ -294,7 +308,7 @@ class Subjects extends ObjClasses {
|
||||||
* @param string $fld
|
* @param string $fld
|
||||||
* @return string/err
|
* @return string/err
|
||||||
*/
|
*/
|
||||||
function getSubjName($id, $fld='login')
|
public function getSubjName($id, $fld='login')
|
||||||
{
|
{
|
||||||
$sql = "SELECT $fld FROM {$this->subjTable}
|
$sql = "SELECT $fld FROM {$this->subjTable}
|
||||||
WHERE id='$id'";
|
WHERE id='$id'";
|
||||||
|
@ -305,10 +319,10 @@ class Subjects extends ObjClasses {
|
||||||
/**
|
/**
|
||||||
* Get all subjects
|
* Get all subjects
|
||||||
*
|
*
|
||||||
* @param string $flds, optional
|
* @param string $flds
|
||||||
* @return array/err
|
* @return array/err
|
||||||
*/
|
*/
|
||||||
function getSubjects($flds='id, login')
|
public function getSubjects($flds='id, login')
|
||||||
{
|
{
|
||||||
$sql = "SELECT $flds FROM {$this->subjTable}";
|
$sql = "SELECT $flds FROM {$this->subjTable}";
|
||||||
return $this->dbc->getAll($sql);
|
return $this->dbc->getAll($sql);
|
||||||
|
@ -320,7 +334,7 @@ class Subjects extends ObjClasses {
|
||||||
*
|
*
|
||||||
* @return array/err
|
* @return array/err
|
||||||
*/
|
*/
|
||||||
function getSubjectsWCnt()
|
public function getSubjectsWCnt()
|
||||||
{
|
{
|
||||||
$sql = "
|
$sql = "
|
||||||
SELECT count(m.uid)as cnt, s.id, s.login, s.type
|
SELECT count(m.uid)as cnt, s.id, s.login, s.type
|
||||||
|
@ -339,7 +353,7 @@ class Subjects extends ObjClasses {
|
||||||
* @param int $gid
|
* @param int $gid
|
||||||
* @return boolean/err
|
* @return boolean/err
|
||||||
*/
|
*/
|
||||||
function isGroup($gid)
|
public function isGroup($gid)
|
||||||
{
|
{
|
||||||
$sql = "SELECT type FROM {$this->subjTable}
|
$sql = "SELECT type FROM {$this->subjTable}
|
||||||
WHERE id='$gid'";
|
WHERE id='$gid'";
|
||||||
|
@ -357,7 +371,7 @@ class Subjects extends ObjClasses {
|
||||||
* @param int $gid
|
* @param int $gid
|
||||||
* @return array/err
|
* @return array/err
|
||||||
*/
|
*/
|
||||||
function listGroup($gid)
|
public function listGroup($gid)
|
||||||
{
|
{
|
||||||
$sql = "SELECT s.id, s.login, s.type
|
$sql = "SELECT s.id, s.login, s.type
|
||||||
FROM {$this->smembTable} m, {$this->subjTable} s
|
FROM {$this->smembTable} m, {$this->subjTable} s
|
||||||
|
@ -375,7 +389,7 @@ class Subjects extends ObjClasses {
|
||||||
* local group id
|
* local group id
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function isMemberOf($uid, $gid)
|
public function isMemberOf($uid, $gid)
|
||||||
{
|
{
|
||||||
$sql = "
|
$sql = "
|
||||||
SELECT count(*)as cnt
|
SELECT count(*)as cnt
|
||||||
|
@ -398,12 +412,10 @@ class Subjects extends ObjClasses {
|
||||||
* @param int $uid
|
* @param int $uid
|
||||||
* @param int $gid
|
* @param int $gid
|
||||||
* @param int $level
|
* @param int $level
|
||||||
* optional
|
|
||||||
* @param int $mid
|
* @param int $mid
|
||||||
* optional
|
|
||||||
* @return int/err
|
* @return int/err
|
||||||
*/
|
*/
|
||||||
function _addMemb($uid, $gid, $level=0, $mid='null')
|
private function _addMemb($uid, $gid, $level=0, $mid='null')
|
||||||
{
|
{
|
||||||
if($uid == $gid) {
|
if($uid == $gid) {
|
||||||
return PEAR::raiseError("Subjects::_addMemb: uid==gid ($uid)", ALIBERR_BADSMEMB);
|
return PEAR::raiseError("Subjects::_addMemb: uid==gid ($uid)", ALIBERR_BADSMEMB);
|
||||||
|
@ -447,9 +459,9 @@ class Subjects extends ObjClasses {
|
||||||
* Remove membership record
|
* Remove membership record
|
||||||
*
|
*
|
||||||
* @param int $mid
|
* @param int $mid
|
||||||
* @return null/err
|
* @return null|PEAR_Error
|
||||||
*/
|
*/
|
||||||
function _removeMemb($mid)
|
private function _removeMemb($mid)
|
||||||
{
|
{
|
||||||
$sql = "DELETE FROM {$this->smembTable}
|
$sql = "DELETE FROM {$this->smembTable}
|
||||||
WHERE id='$mid'";
|
WHERE id='$mid'";
|
||||||
|
@ -462,10 +474,9 @@ class Subjects extends ObjClasses {
|
||||||
*
|
*
|
||||||
* @param int $gid
|
* @param int $gid
|
||||||
* @param int $uid
|
* @param int $uid
|
||||||
* optional
|
* @return array|PEAR_Error
|
||||||
* @return array/err
|
|
||||||
*/
|
*/
|
||||||
function _listMemb($gid, $uid=NULL)
|
private function _listMemb($gid, $uid=NULL)
|
||||||
{
|
{
|
||||||
$sql = "
|
$sql = "
|
||||||
SELECT id, uid, level FROM {$this->smembTable}
|
SELECT id, uid, level FROM {$this->smembTable}
|
||||||
|
@ -479,10 +490,9 @@ class Subjects extends ObjClasses {
|
||||||
*
|
*
|
||||||
* @param int $gid
|
* @param int $gid
|
||||||
* @param int $uid
|
* @param int $uid
|
||||||
* optional
|
|
||||||
* @return array/err
|
* @return array/err
|
||||||
*/
|
*/
|
||||||
function _listRMemb($uid, $gid=NULL)
|
private function _listRMemb($uid, $gid=NULL)
|
||||||
{
|
{
|
||||||
$sql = "
|
$sql = "
|
||||||
SELECT id, gid, level FROM {$this->smembTable}
|
SELECT id, gid, level FROM {$this->smembTable}
|
||||||
|
@ -497,10 +507,10 @@ class Subjects extends ObjClasses {
|
||||||
* @param int $uid
|
* @param int $uid
|
||||||
* @param int $gid
|
* @param int $gid
|
||||||
* @param int $level
|
* @param int $level
|
||||||
* @param int $rmid //
|
* @param int $rmid
|
||||||
* @return int/err
|
* @return int|PEAR_Error
|
||||||
*/
|
*/
|
||||||
function _plainAddSubj2Gr($uid, $gid, $level=0, $rmid='null')
|
private function _plainAddSubj2Gr($uid, $gid, $level=0, $rmid='null')
|
||||||
{
|
{
|
||||||
$mid = $this->_addMemb($uid, $gid, $level, $rmid);
|
$mid = $this->_addMemb($uid, $gid, $level, $rmid);
|
||||||
if (PEAR::isError($mid)) {
|
if (PEAR::isError($mid)) {
|
||||||
|
@ -526,9 +536,9 @@ class Subjects extends ObjClasses {
|
||||||
* Rebuild indirect membership records<br>
|
* Rebuild indirect membership records<br>
|
||||||
* it's probably more complicated to do removing without rebuild ...
|
* it's probably more complicated to do removing without rebuild ...
|
||||||
*
|
*
|
||||||
* @return true/err
|
* @return true|PEAR_Error
|
||||||
*/
|
*/
|
||||||
function _rebuildRels()
|
private function _rebuildRels()
|
||||||
{
|
{
|
||||||
$this->dbc->query("BEGIN");
|
$this->dbc->query("BEGIN");
|
||||||
$r = $this->dbc->query("LOCK TABLE {$this->smembTable}");
|
$r = $this->dbc->query("LOCK TABLE {$this->smembTable}");
|
||||||
|
@ -575,7 +585,7 @@ class Subjects extends ObjClasses {
|
||||||
* actual indentation
|
* actual indentation
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function dumpSubjects($indstr=' ', $ind='')
|
public function dumpSubjects($indstr=' ', $ind='')
|
||||||
{
|
{
|
||||||
$r = $ind.join(', ', array_map(
|
$r = $ind.join(', ', array_map(
|
||||||
create_function('$v', 'return "{$v[\'login\']}({$v[\'cnt\']})";'),
|
create_function('$v', 'return "{$v[\'login\']}({$v[\'cnt\']})";'),
|
||||||
|
@ -590,7 +600,7 @@ class Subjects extends ObjClasses {
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function deleteData()
|
public function deleteData()
|
||||||
{
|
{
|
||||||
$this->dbc->query("DELETE FROM {$this->subjTable}");
|
$this->dbc->query("DELETE FROM {$this->subjTable}");
|
||||||
$this->dbc->query("DELETE FROM {$this->smembTable}");
|
$this->dbc->query("DELETE FROM {$this->smembTable}");
|
||||||
|
@ -603,7 +613,7 @@ class Subjects extends ObjClasses {
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function testData()
|
public function testData()
|
||||||
{
|
{
|
||||||
parent::testData();
|
parent::testData();
|
||||||
$o['root'] = $this->addSubj('root', 'q');
|
$o['root'] = $this->addSubj('root', 'q');
|
||||||
|
@ -631,7 +641,7 @@ class Subjects extends ObjClasses {
|
||||||
* Make basic test
|
* Make basic test
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function test()
|
public function test()
|
||||||
{
|
{
|
||||||
if (PEAR::isError($p = parent::test())) {
|
if (PEAR::isError($p = parent::test())) {
|
||||||
return $p;
|
return $p;
|
||||||
|
@ -665,7 +675,7 @@ class Subjects extends ObjClasses {
|
||||||
* Create tables + initialize
|
* Create tables + initialize
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function install()
|
public function install()
|
||||||
{
|
{
|
||||||
parent::install();
|
parent::install();
|
||||||
$this->dbc->query("CREATE TABLE {$this->subjTable} (
|
$this->dbc->query("CREATE TABLE {$this->subjTable} (
|
||||||
|
@ -701,7 +711,7 @@ class Subjects extends ObjClasses {
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function uninstall()
|
public function uninstall()
|
||||||
{
|
{
|
||||||
$this->dbc->query("DROP TABLE {$this->subjTable}");
|
$this->dbc->query("DROP TABLE {$this->subjTable}");
|
||||||
$this->dbc->dropSequence("{$this->subjTable}_id_seq");
|
$this->dbc->dropSequence("{$this->subjTable}_id_seq");
|
||||||
|
|
|
@ -87,7 +87,7 @@ class XR_Alib extends Alib{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$alib = &new XR_Alib($dbc, $config);
|
$alib = new XR_Alib($dbc, $config);
|
||||||
|
|
||||||
$s=new xmlrpc_server( array(
|
$s=new xmlrpc_server( array(
|
||||||
"alib.xrTest" => array(
|
"alib.xrTest" => array(
|
||||||
|
|
Loading…
Reference in New Issue