22 include_once (
'Class.DbObj.php');
23 include_once (
'Class.QueryDb.php');
24 include_once (
'Class.Acl.php');
25 include_once (
'Class.ControlObject.php');
44 create table operm (id_user int ,
46 id_class int not null,
48 create unique index i_operm on operm (id_user, id_obj, id_class); ';
93 if ($octrl->IsAffected()) {
94 $this->classid = $octrl->id_class;
95 $this->description = $octrl->description;
164 if (isset($this->gprivileges))
return ($this->gprivileges);
166 $this->gprivileges = array();
167 $result = pg_exec($this->
init_dbid() ,
"select getprivilege({$this->id_user},{$this->id_obj},{$this->id_class},true)");
168 if (pg_numrows($result) > 0) {
169 $arr = pg_fetch_array($result, 0);
170 $this->gprivileges = explode(
",", substr($arr[0], 1, -1));
176 if ($this->iscomplete)
return ($this->privileges);
178 $this->privileges = array();
179 $this->upprivileges = array();
180 $this->unprivileges = array();
182 $acls = explode(
",", substr($this->ids_acl, 1, -1));
184 while (list($k, $v) = each($acls)) {
185 if ($v > 0) $this->upprivileges[] = $v;
186 else $this->unprivileges[] = - $v;
189 $result = pg_exec($this->
init_dbid() ,
"select getprivilege({$this->id_user},{$this->id_obj},{$this->id_class},false)");
192 if (pg_numrows($result) > 0) {
193 $arr = pg_fetch_array($result, 0);
194 $this->privileges = array_unique(explode(
",", substr($arr[0], 1, -1)));
198 $this->iscomplete =
true;
199 return ($this->privileges);
205 $this->privileges = array_unique(array_merge($this->dprivileges, $this->privileges));
207 $this->privileges = array_diff($this->privileges, $this->unprivileges);
212 if ($this->ids_acl ==
"") $this->ids_acl =
"{" . $idacl .
"}";
213 else $this->ids_acl = str_replace(
"}",
",$idacl}", $this->ids_acl);
218 return (($this->id_user == 1) ||
219 (in_array($idacl, $this->privileges)));
244 if ($this->id_user == 1)
return "";
250 if ($this->id_user ==
"") {
251 return "Object Permission : current user not found";
255 if (!$acl->Set($method, $idclassapp)) {
256 $this->log->warning(
"Acl $method not available for App $idclassapp ");
257 $err =
"Acl $method not available for App $idclassapp ";
263 $err = sprintf(_(
"Object Permission : permission %s needed (%s) - # %d") , _($acl->description) , $this->GetDescription() , $this->id_obj);