6 # Part of the Collection Workflow Integration System (CWIS)
7 # Copyright 2007-2013 Edward Almasy and Internet Scout Research Group
8 # http://scout.wisc.edu/cwis/
18 # ---- PUBLIC INTERFACE --------------------------------------------------
31 global $G_PrivDescriptions;
33 # if caller requested creation of new entry
36 # get highest current ID
38 $HighestId = $DB->Query(
"SELECT Id FROM CustomPrivileges"
39 .
" ORDER BY Id DESC LIMIT 1",
"Id");
42 $this->
Id = max(100, ($HighestId + 1));
44 # add new entry to database
45 $DB->Query(
"INSERT INTO CustomPrivileges (Id, Name)"
46 .
" VALUES (".$this->
Id.
", '".addslashes($Name).
"')");
52 $this->
Id = intval($Id);
54 # if ID indicates predefined privilege
57 # load privilege info from predefined priv array
58 $this->
Name = $G_PrivDescriptions[$this->Id];
62 # load privilege info from database
64 $this->
Name = $DB->Query(
"SELECT Name FROM CustomPrivileges"
65 .
" WHERE Id = ".$this->
Id,
"Name");
79 $DB->Query(
"DELETE FROM CustomPrivileges"
80 .
" WHERE Id = ".$this->
Id);
90 function Id() {
return $this->Id; }
97 function Name($NewValue = NULL)
102 $DB->Query(
"UPDATE CustomPrivileges"
103 .
" SET Name = '".addslashes($NewValue).
"'"
104 .
" WHERE Id = ".$this->
Id);
105 $this->
Name = $NewValue;
122 return (($Id > 0) && ($Id < 100)) ? TRUE : FALSE;
127 # ---- PRIVATE INTERFACE -------------------------------------------------
User rights management framework allowing custom privege definition.
SQL database abstraction object with smart query caching.
Delete()
Delete this privelege from the DB NOTE: the object should not be used after calling this...
IsPredefined($Id=NULL)
Report whether privilege is predefined or custom Can be called as Privilege::IsPredefind(ID) ...
Name($NewValue=NULL)
Get or set Name.
Privilege($Id, $Name=NULL)
Object Constructor Pass in a value for the name and a NULL id to make a new privilege.