Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
modify_object.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
5  * @package FDL
6 */
7 /**
8  * Generated Header (not documented yet)
9  *
10  * @author Anakeen 2000
11  * @version $Id: modify_object.php,v 1.6 2003/08/18 15:46:41 eric Exp $
12  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
13  * @package FDL
14  * @subpackage ACCESS
15  */
16 /**
17  */
18 // ---------------------------------------------------------------
19 // $Id: modify_object.php,v 1.6 2003/08/18 15:46:41 eric Exp $
20 // $Source: /home/cvsroot/anakeen/freedom/core/Action/Access/modify_object.php,v $
21 // ---------------------------------------------------------------
22 include_once ("Class.QueryDb.php");
23 include_once ("Class.Application.php");
24 include_once ("Class.Acl.php");
25 include_once ("Class.Permission.php");
26 include_once ("Class.ObjectPermission.php");
27 // -----------------------------------
29 {
30  // -----------------------------------
31  // get all parameters
32  $appId = GetHttpVars("appid");
33  $acls = GetHttpVars("acls", array());
34  $coid = GetHttpVars("oid"); // oid for controlled object
35  $returnact = GetHttpVars("returnact");
36  // test if current user can modify ACL
37  $op = new ObjectPermission($action->dbaccess, array(
38  $action->parent->user->id,
39  $coid,
40  $appId
41  ));
42  if (($err = $op->ControlOid($appId, "modifyacl")) != "") {
43  $action->ExitError($err);
44  }
45  // serach ACL of the oid class
46  $acl = new Acl($action->dbaccess);
47  $defacls = $acl->getAclApplication($appId);
48 
49  while (list($userId, $aclon) = each($acls)) {
50  // modif permission for a particular user
51  $p = new ObjectPermission($action->dbaccess, array(
52  $userId,
53  $coid,
54  $appId
55  ));
56  $p->GetGroupPrivileges();
57 
58  $gp = array_unique($p->gprivileges);
59  // delete old permissions
60  $p->Delete();
61  reset($defacls);
62  while (list($k, $acl) = each($defacls)) {
63  // change only if needed :: not already in group privileges
64  if ((in_array($acl->id, $gp)) && (!isset($aclon[$acl->id]))) {
65  // print "moins $p->id_user $acl->id $acl->name<BR>";
66  $p->AddAcl(-$acl->id);
67  } else if ((!in_array($acl->id, $gp)) && (isset($aclon[$acl->id]))) {
68  // print "pluss $userId $acl->id $acl->name<BR>";
69  $p->AddAcl($acl->id);
70  }
71  }
72  $p->Add();
73  }
74 
75  redirect($action, "ACCESS", "EDIT_OBJECT&sole=Y&mod=app&isclass=yes&userid={$action->parent->user->id}&appid=$appId&oid=$coid");
76 }
77 ?>
← centre documentaire © anakeen - published under CC License - Dynacase