Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
modify.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.php,v 1.7 2007/02/14 15:13:16 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.php,v 1.7 2007/02/14 15:13:16 eric Exp $
20 // $Source: /home/cvsroot/anakeen/freedom/core/Action/Access/modify.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 // -----------------------------------
28 function modify(&$action)
29 {
30  // -----------------------------------
31  $coid = GetHttpVars("oid"); // oid for controlled object
32  if ($coid > 0) modify_oid($action);
33  else modify_app($action);
34 }
35 // -----------------------------------
36 function modify_app(&$action)
37 {
38  // -----------------------------------
39  // get all parameters
40  $userId = GetHttpVars("userid");
41  $appId = GetHttpVars("appid");
42  $aclp = GetHttpVars("aclup"); // ACL + (more access)
43  $acln = GetHttpVars("aclun"); // ACL - (less access)
44  $returnact = GetHttpVars("returnact");
45  // modif permission for a uncontrolled object
46  $p = new Permission($action->dbaccess, array(
47  $userId,
48  $appId
49  ));
50  if (!$p->IsAffected()) {
51  $p->Affect(array(
52  "id_user" => $userId,
53  "id_application" => $appId
54  ));
55  }
56  // delete old permissions
57  $p->deletePermission($userId, $appId, null, null);
58  $p->deletePermission(null, $appId, null, true);
59 
60  if (is_array($aclp)) {
61  // create new permissions
62  while (list($k, $v) = each($aclp)) {
63  $p->id_acl = $v;
64  $p->computed = false;
65  $p->Add();
66  }
67  }
68 
69  if (is_array($acln)) {
70  // create new permissions
71  while (list($k, $v) = each($acln)) {
72  $p->id_acl = - $v;
73  $p->computed = false;
74  $p->Add();
75  }
76  }
77 
78  $action->parent->session->closeAll();
79  $action->parent->session->set(""); // reset session to save current
80  if ($returnact == "") exit(0);
81  redirect($action, "ACCESS", $returnact . "&uid=" . $userId);
82 }
83 // -----------------------------------
84 function modify_oid(&$action)
85 {
86  // -----------------------------------
87  // get all parameters
88  $userId = GetHttpVars("userid");
89  $appId = GetHttpVars("appid");
90  $aclp = GetHttpVars("aclup"); // ACL + (more access)
91  $acln = GetHttpVars("aclun"); // ACL - (less access)
92  $coid = GetHttpVars("oid"); // oid for controlled object
93  $returnact = GetHttpVars("returnact");
94  // test if current user could modify ACL
95  $p = new ObjectPermission($action->dbaccess, array(
96  $action->parent->user->id,
97  $coid,
98  $appId
99  ));
100  if (($err = $p->ControlOid($appId, "modifyacl")) != "") {
101  $action->ExitError($err);
102  }
103  // modif permission for a particular object
104  $p = new ObjectPermission($action->dbaccess, array(
105  $userId,
106  $coid,
107  $appId
108  ));
109  // delete old permissions
110  $p->Delete();
111 
112  if (is_array($aclp)) {
113  // create new permissions
114  while (list($k, $v) = each($aclp)) {
115  $p->AddAcl($v);
116  }
117  }
118 
119  if (is_array($acln)) {
120  // create new permissions
121  while (list($k, $v) = each($acln)) {
122  $p->AddAcl(-$v);
123  }
124  }
125 
126  $p->Add();
127 
128  if ($returnact == "") exit(0);
129  redirect($action, "ACCESS", $returnact);
130 }
131 ?>
← centre documentaire © anakeen - published under CC License - Dynacase