Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
edit.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: edit.php,v 1.12 2007/02/14 13:22:58 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: edit.php,v 1.12 2007/02/14 13:22:58 eric Exp $
20 // $Source: /home/cvsroot/anakeen/freedom/core/Action/Access/edit.php,v $
21 // ---------------------------------------------------------------
22 // ---------------------------------------------------------------
23 include_once ("Class.SubForm.php");
24 include_once ("Class.Domain.php");
25 include_once ("Class.MailAccount.php");
26 include_once ("Class.User.php");
27 include_once ("Class.ControlObject.php");
28 include_once ("Class.ObjectPermission.php");
29 // -----------------------------------
30 function edit(&$action)
31 {
32  // -----------------------------------
33  $group = (GetHttpVars("group") == "yes");
34  $isclass = (GetHttpVars("isclass") == "yes");
35  $coid = intval(GetHttpVars("oid"));
36  // the modification can come from action user_access or appl_access
37  if (GetHttpVars("mod") == "user") {
38  $appId = GetHttpVars("id");
39  $filteruser = getHttpVars("userfilter");
40  if ($group) {
41  $action->lay->Set("returnact", "GROUP_ACCESS&userfilter=$filteruser");
42  $userId = $action->Read("access_group_id");
43  } else {
44  $action->lay->Set("returnact", "USER_ACCESS&userfilter=$filteruser"); // for return previous page
45  $userId = $action->Read("access_user_id");
46  }
47  } else {
48  $userId = GetHttpVars("id");
49  if ($isclass) {
50  $appId = $action->Read("access_class_id");
51  $action->lay->Set("returnact", "OBJECT_ACCESS&oid=$coid"); // for return previous page
52 
53  } else {
54  $appId = $action->Read("access_appl_id");
55  $action->lay->Set("returnact", "APPL_ACCESS"); // for return previous page
56 
57  }
58  }
59  $action->lay->Set("modifyact", "MODIFY");
60  $action->lay->Set("target", "fbody");
61 
62  if (($isclass) || ($coid > 0)) {
63  // oid list for object class only
64  $action->lay->SetBlockData("OBJECTCLASS", array(
65  array(
66  "zou"
67  )
68  ));
69  }
70  // write title : user name
71  $user = new User($action->GetParam("CORE_DB") , $userId);
72  $action->lay->Set("title", $action->text("user") . " : " . $user->firstname . " " . $user->lastname);
73  edit_main($action, $userId, $appId, $coid);
74 }
75 // -----------------------------------
76 function edit_oid(&$action)
77 {
78  // -----------------------------------
79  $userId = intval(GetHttpVars("userid")); // can be affected by session var
80  $coid = intval(GetHttpVars("oid"));
81  $appId = GetHttpVars("appid");
82 
83  $action->lay->Set("modifyact", "MODIFY");
84  $action->lay->Set("returnact", "OBJECT_ACCESS&oid=$coid&userid=$userId&appid=$appId"); //
85  $action->lay->Set("target", "body");
86 
87  if ($userId == 0) $userId = $action->Read("access_user_id");
88  if ($coid == 0) $coid = $action->Read("access_object_id");
89  // user list for object modification
90  $action->lay->SetBlockData("USERS", array(
91  array(
92  "zou"
93  )
94  ));
95  // write title : oid description
96  $oid = new ControlObject("", array(
97  $coid,
98  $appId
99  ));
100  // register for next time : same parameters
101  $action->Register("access_object_id", $coid);
102  $action->Register("access_class_id", $oid->id_class);
103  $action->Register("access_user_id", $userId);
104 
105  $action->lay->Set("title", $action->text("object") . " : " . $oid->description);
106  edit_main($action, $userId, $oid->id_class, $coid);
107 }
108 // -----------------------------------
109 function edit_main(&$action, $userId, $appId, $coid)
110 {
111  // ------------------------
112  // print "$userId - $appId - $coid";
113  // Get all the params
114  $isclass = (GetHttpVars("isclass") == "yes");
115  //-------------------
116  // contruct object id list
117  if (($isclass) || ($coid > 0)) {
118 
119  $octrl = new ControlObject();
120  $toid = $octrl->GetOids($appId);
121  $oids = array();
122  while (list($k, $v) = each($toid)) {
123 
124  if ($v->id_obj == $coid) $oids[$k]["selectedoid"] = "selected";
125  else $oids[$k]["selectedoid"] = "";
126  $oids[$k]["oid"] = $v->id_obj;
127  $oids[$k]["descoid"] = $v->description;
128  }
129 
130  $action->lay->SetBlockData("OID", $oids);
131  // contruct user id list
132  $ouser = new User();
133  $tiduser = $ouser->GetUserAndGroupList();
134  $userids = array();
135  while (list($k, $v) = each($tiduser)) {
136  if ($v->id == 1) continue; // except admin : don't need privilege
137  if ($v->id == $userId) $userids[$k]["selecteduser"] = "selected";
138  else $userids[$k]["selecteduser"] = "";
139  $userids[$k]["userid"] = $v->id;
140  $userids[$k]["descuser"] = $v->firstname . " " . $v->lastname;
141  }
142 
143  $action->lay->SetBlockData("USER", $userids);
144 
145  $action->lay->Set("nbinput", 5);
146  } else {
147  $action->lay->Set("nbinput", 4);
148  }
149 
150  if (($isclass) && (!($coid > 0))) $coid = $oids[0]["oid"]; // get first if no selected
151  $action->lay->Set("userid", $userId);
152  $action->lay->Set("oid", $coid);
153  $action->lay->Set("appid", $appId);
154  $action->lay->Set("dboperm", "");
155  //-------------------
156  // compute permission
157  $app = new Application($action->dbaccess, $appId);
158  $action->lay->Set("appname", $action->text($app->short_name));
159 
160  if ($coid > 0) {
161  // control view acl permission first
162  $p = new ObjectPermission("", array(
163  $action->parent->user->id,
164  $coid,
165  $appId
166  ));
167  if (preg_match("/dbname=(.*)/", $p->dbaccess, $reg)) {
168  $action->lay->Set("dboperm", $reg[1]);
169  }
170 
171  if (($err = $p->ControlOid($appId, "viewacl")) != "") {
172  $action->ExitError($err);
173  }
174  // compute acl for userId
175  $uperm = new ObjectPermission("", array(
176  $userId,
177  $coid,
178  $appId
179  ));
180  $uperm->GetGroupPrivileges();
181  } else {
182  $uperm = new Permission($action->dbaccess, array(
183  $userId,
184  $appId
185  ));
186  }
187  $acl = new Acl($action->dbaccess);
188 
189  $appacls = $acl->getAclApplication($appId);
190 
191  $tableacl = array();
192  while (list($k, $v) = each($appacls)) {
193 
194  $tableacl[$k]["aclname"] = $v->name;
195  $tableacl[$k]["acldesc"] = " (" . _($v->description) . ")";
196  $tableacl[$k]["aclid"] = $v->id;
197  if ($uperm->HasPrivilege($v->id)) {
198  $tableacl[$k]["selected"] = "checked";
199  } else {
200  $tableacl[$k]["selected"] = "";
201  }
202  $tableacl[$k]["iacl"] = "$k"; // index for table in xml
203  if (in_array($v->id, $uperm->GetUnPrivileges())) {
204  $tableacl[$k]["selectedun"] = "checked";
205  } else {
206  $tableacl[$k]["selectedun"] = "";
207  }
208  if (in_array($v->id, $uperm->GetUpPrivileges())) {
209  $tableacl[$k]["selectedup"] = "checked";
210  } else {
211  $tableacl[$k]["selectedup"] = "";
212  }
213  if (in_array($v->id, $uperm->GetGPrivileges())) {
214  $tableacl[$k]["selectedg"] = "checked";
215  } else {
216  $tableacl[$k]["selectedg"] = "";
217  }
218  }
219 
220  $action->lay->SetBlockData("SELECTACL", $tableacl);
221 }
222 ?>
← centre documentaire © anakeen - published under CC License - Dynacase