17 include_once (
'Class.DbObj.php');
18 include_once (
'Class.QueryDb.php');
19 include_once (
'Class.Application.php');
20 include_once (
'Class.User.php');
45 create table acl (id int not null,
46 id_application int not null,
48 grant_level int not null,
51 create index acl_idx1 on acl(id);
52 create index acl_idx2 on acl(id_application);
53 create index acl_idx3 on acl(name);
54 create sequence SEQ_ID_ACL;
60 $query->basic_elem->sup_where = array(
62 "id_application=$id_app"
64 $query->Query(0, 0,
"TABLE");
67 $this->Affect(
$query->list[0]);
80 if ($this->
Exists($this->
name, $this->id_application))
return "Acl {$this->name} already exists...";
81 $msg_res = $this->
exec_query(
"select nextval ('seq_id_acl')");
83 $this->
id = $arr[
"nextval"];
88 if ($this->dbid == - 1)
return FALSE;
95 $query->basic_elem->sup_where = array(
97 "id_application=$id_app"
99 $query->Query(0, 0,
"TABLE");
106 $query->basic_elem->sup_where = array(
114 foreach (
$list as $v) {
119 $permission =
new Permission($this->dbaccess);
120 $permission->DelAppPerm(
$id);
125 if (
sizeof($app_acl) == 0) {
126 $this->log->debug(
"No acl available");
130 $default_grant_level_found =
false;
131 if (isset($app_acl[0][
"grant_level"])) $oldacl =
true;
132 else $oldacl =
false;
134 $default_user_acl = array();
135 $default_acl =
false;
136 $smalestgrant = null;
137 foreach ($app_acl as $k => $tab) {
138 $acl =
new Acl($this->dbaccess);
139 if ($acl->Exists($tab[
"name"],
$app->id)) {
140 $acl->Set($tab[
"name"],
$app->id);
142 $acl->id_application =
$app->id;
143 $acl->name = $tab[
"name"];
144 if (isset($tab[
"description"])) {
145 $acl->description = $tab[
"description"];
147 if (isset($tab[
"grant_level"])) {
148 $acl->grant_level = $tab[
"grant_level"];
150 $acl->grant_level = 1;
153 if ((isset($tab[
"group_default"])) && ($tab[
"group_default"] ==
"Y")) {
155 $default_grant_level = $tab[
"grant_level"];
156 $default_grant_level_found =
true;
158 $acl->group_default =
"Y";
161 $acl->group_default =
"N";
164 if ((!$default_grant_level_found) && ((!isset($smalestgrant)) || ($tab[
"grant_level"] < $smalestgrant)) && (!((isset($tab[
"admin"]) && $tab[
"admin"])))) {
166 $smalestgrant = $tab[
"grant_level"];
171 if ($acl->Exists($acl->name, $acl->id_application)) {
172 $this->log->info(
"Acl Modify : {$acl->name}, {$acl->description}");
175 $this->log->info(
"Acl Add : {$acl->name}, {$acl->description}");
178 if (isset($tab[
"admin"]) && $tab[
"admin"]) {
179 $permission =
new Permission($this->dbaccess);
180 $permission->id_user = 1;
181 $permission->id_application =
$app->id;
182 $permission->id_acl = $acl->id;
183 if ($permission->Exists($permission->id_user,
$app->id, $permission->id_acl)) {
184 $this->log->info(
"Modify admin permission : {$acl->name}");
185 $permission->Modify();
187 $this->log->info(
"Create admin permission : {$acl->name}");
192 $default_user_acl[] = $acl->id;
193 $default_acl =
false;
197 if (count($default_user_acl) == 0) {
198 if (isset($smalestgrant)) {
199 $default_user_acl[] = $smalestgrant;
200 $default_grant_level = $smalestgrant;
208 if (isset($default_grant_level)) {
210 $query->AddQuery(
"id_application = " .
$app->id);
211 $query->AddQuery(
"grant_level < $default_grant_level");
212 if ($qacl =
$query->Query()) {
213 foreach ($qacl as $k2 => $acl) {
214 if (!in_array($acl->id, $default_user_acl)) {
215 $default_user_acl[] = $acl->id;
222 reset($default_user_acl);
223 foreach ($default_user_acl as $ka => $aclid) {
225 $defaultacl =
new Acl($this->dbaccess, $aclid);
226 $defaultacl->group_default =
"Y";
227 $defaultacl->Modify();
231 $permission =
new Permission($this->dbaccess);
232 $permission->id_user = 2;
233 $permission->id_application =
$app->id;
234 $permission->id_acl = $aclid;
235 if (!$permission->Exists($permission->id_user,
$app->id, $permission->id_acl)) {
278 $query->AddQuery(
"id_application = $idapp");
279 $query->AddQuery(
"group_default = 'Y'");
280 if ($qacl =
$query->Query()) {
281 foreach ($qacl as $k2 => $acl) {
282 $aclids[] = $acl->id;
292 $query->AddQuery(
"id_application = $idapp");
293 if ($qacl =
$query->Query())
return $qacl;
exec_query($sql, $lvl=0, $prepare=false)
print $fam getTitle() $fam name
getAclApplication($idapp)
fetch_array($c, $type=PGSQL_ASSOC)
Init($app, $app_acl, $update=FALSE)
if(($docid!==0)&&(!is_numeric($docid))) $query