Minor changes in exception handling.
Unique constraint for perms added.
This commit is contained in:
parent
3ed796c74d
commit
696bec9e34
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: tomas $
|
Author : $Author: tomas $
|
||||||
Version : $Revision: 1.6 $
|
Version : $Revision: 1.7 $
|
||||||
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 $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -37,7 +37,7 @@ define('ALIBERR_NOTEXISTS', 31);
|
||||||
* authentication/authorization class
|
* authentication/authorization class
|
||||||
*
|
*
|
||||||
* @author $Author: tomas $
|
* @author $Author: tomas $
|
||||||
* @version $Revision: 1.6 $
|
* @version $Revision: 1.7 $
|
||||||
* @see Subjects
|
* @see Subjects
|
||||||
* @see GreenBox
|
* @see GreenBox
|
||||||
*/
|
*/
|
||||||
|
@ -497,6 +497,8 @@ class Alib extends Subjects{
|
||||||
ON {$this->permTable} (permid)");
|
ON {$this->permTable} (permid)");
|
||||||
$this->dbc->query("CREATE INDEX {$this->permTable}_subj_obj_idx
|
$this->dbc->query("CREATE INDEX {$this->permTable}_subj_obj_idx
|
||||||
ON {$this->permTable} (subj, obj)");
|
ON {$this->permTable} (subj, obj)");
|
||||||
|
$this->dbc->query("CREATE UNIQUE INDEX {$this->permTable}_all_idx
|
||||||
|
ON {$this->permTable} (subj, action, obj)");
|
||||||
$this->dbc->createSequence("{$this->permTable}_id_seq");
|
$this->dbc->createSequence("{$this->permTable}_id_seq");
|
||||||
|
|
||||||
$this->dbc->query("CREATE TABLE {$this->sessTable} (
|
$this->dbc->query("CREATE TABLE {$this->sessTable} (
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: tomas $
|
Author : $Author: tomas $
|
||||||
Version : $Revision: 1.3 $
|
Version : $Revision: 1.4 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/alib/var/Attic/mtree.php,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/alib/var/Attic/mtree.php,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -50,7 +50,7 @@ define('ALIBERR_MTREE', 10);
|
||||||
* );
|
* );
|
||||||
* </code></pre>
|
* </code></pre>
|
||||||
* @author $Author: tomas $
|
* @author $Author: tomas $
|
||||||
* @version $Revision: 1.3 $
|
* @version $Revision: 1.4 $
|
||||||
* @see ObjClasses
|
* @see ObjClasses
|
||||||
*/
|
*/
|
||||||
class Mtree{
|
class Mtree{
|
||||||
|
@ -87,7 +87,13 @@ class Mtree{
|
||||||
function addObj($name, $type, $parid=1, $aftid=NULL)
|
function addObj($name, $type, $parid=1, $aftid=NULL)
|
||||||
{
|
{
|
||||||
if($name=='' || $type=='') return PEAR::raiseError(
|
if($name=='' || $type=='') return PEAR::raiseError(
|
||||||
'Mtree::addObj: Wrong name or type', ALIBERR_MTREE
|
"Mtree::addObj: Wrong name or type", ALIBERR_MTREE
|
||||||
|
);
|
||||||
|
if(!is_numeric($parid)) return PEAR::raiseError(
|
||||||
|
"Mtree::addObj: Wrong parid ($parid)", ALIBERR_MTREE
|
||||||
|
);
|
||||||
|
if(!is_numeric($aftid) && !is_null($aftid)) return PEAR::raiseError(
|
||||||
|
"Mtree::addObj: Wrong aftid ($aftid)", ALIBERR_MTREE
|
||||||
);
|
);
|
||||||
$this->dbc->query("BEGIN");
|
$this->dbc->query("BEGIN");
|
||||||
$r = $this->dbc->query("LOCK TABLE {$this->treeTable}");
|
$r = $this->dbc->query("LOCK TABLE {$this->treeTable}");
|
||||||
|
@ -153,6 +159,8 @@ class Mtree{
|
||||||
$o = $this->dbc->getRow("SELECT * FROM {$this->treeTable}
|
$o = $this->dbc->getRow("SELECT * FROM {$this->treeTable}
|
||||||
WHERE id='$id'");
|
WHERE id='$id'");
|
||||||
if(PEAR::isError($o)) return $o;
|
if(PEAR::isError($o)) return $o;
|
||||||
|
$parid = $this->getParent($id);
|
||||||
|
if($newParid == $parid) $o['name'] .= "_copy";
|
||||||
$nid = $this->addObj(
|
$nid = $this->addObj(
|
||||||
$o['name'], $o['type'], $newParid, $after, $o['param']
|
$o['name'], $o['type'], $newParid, $after, $o['param']
|
||||||
);
|
);
|
||||||
|
@ -221,10 +229,12 @@ class Mtree{
|
||||||
function getObjId($name, $parId=NULL)
|
function getObjId($name, $parId=NULL)
|
||||||
{
|
{
|
||||||
if($name=='' && is_null($parId)) $name = $this->rootNodeName;
|
if($name=='' && is_null($parId)) $name = $this->rootNodeName;
|
||||||
return $this->dbc->getOne(
|
$r = $this->dbc->getOne(
|
||||||
"SELECT id FROM {$this->treeTable}
|
"SELECT id FROM {$this->treeTable}
|
||||||
WHERE name='$name' and ".($parId ? "parid='$parId'":"parid is null")
|
WHERE name='$name' and ".(is_null($parId) ? "parid is null" : "parid='$parId'")
|
||||||
);
|
);
|
||||||
|
if(PEAR::isError($r)) return $r;
|
||||||
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -255,7 +265,7 @@ class Mtree{
|
||||||
* Get parent id
|
* Get parent id
|
||||||
*
|
*
|
||||||
* @param oid int
|
* @param oid int
|
||||||
* @return string/err
|
* @return int/err
|
||||||
*/
|
*/
|
||||||
function getParent($oid)
|
function getParent($oid)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue