Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
modacl.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * Generated Header (not documented yet)
8  *
9  * @author Anakeen
10  * @version $Id: modacl.php,v 1.7 2005/06/28 08:37:46 eric Exp $
11  * @package FDL
12  * @subpackage
13  */
14 /**
15  */
16 // ---------------------------------------------------------------
17 // $Id: modacl.php,v 1.7 2005/06/28 08:37:46 eric Exp $
18 // $Source: /home/cvsroot/anakeen/freedom/freedom/Action/Fdl/modacl.php,v $
19 // ---------------------------------------------------------------
20 include_once ("FDL/Class.Doc.php");
21 // -----------------------------------
22 function modacl(Action & $action)
23 {
24  // -----------------------------------
25  // get all parameters
26  $usage = new ActionUsage($action);
27  $usage->setDefinitionText("modify document acl");
28  $userid = $usage->addRequiredParameter("userid", "user identificator");
29  $aclp = $usage->addOptionalParameter("aclup", "acls to add", function ($argVal, $argName, $apiUsage)
30  {
31  return ActionUsage::isArray($argVal, $argName, $apiUsage);
32  });
33  $docid = $usage->addRequiredParameter("docid", "profil identificator");
34  /*
35  * @var array $aclp
36  */
37  $usage->verify();
38  $dbaccess = $action->dbaccess;
39 
41  // test if current user can modify ACL
42  $err = $doc->Control("modifyacl");
43  if ($err != "") $action->exitError($err);
44 
45  $doc->removeControl($userid);
46  if (is_array($aclp)) {
47  foreach ($aclp as $k => $aclName) {
48  $doc->addControl($userid, $aclName);
49  }
50  }
51 
52  $doc->setViewProfil();
53  // recompute all related profile
54  $doc->recomputeProfiledDocument();
55  if (is_array($aclp) && (count($aclp) > 0)) {
56  $aclName = array();
57  foreach ($doc->dacls as $aclK => $aclInfo) {
58  if (in_array($aclInfo["pos"], $aclp)) {
59  $aclName[] = _($aclK);
60  }
61  }
62 
63  $doc->addHistoryEntry(sprintf(_("Change control for %s user. Set %s privileges") , Account::getDisplayName($userid) , implode(', ', $aclName)));
64  } else {
65  $doc->addHistoryEntry(sprintf(_("Change control for %s user. No one privilege") , Account::getDisplayName($userid)));
66  }
67  redirect($action, "FREEDOM", sprintf("FREEDOM_ACCESS&userid=%d&id=%d", $userid, $docid));
68 }
global $action
exitError($texterr, $exit=true, $code="")
$docid
Definition: cleanFamily.php:13
modacl(Action &$action)
Definition: modacl.php:22
static getDisplayName($uid)
Verify arguments for action function.
new_Doc($dbaccess, $id= '', $latest=false)
$dbaccess
Definition: checkVault.php:17
if($file) if($subject==""&&$file) if($subject=="") $err
static isArray($argVal, $argName, $apiUsage)
$usage
← centre documentaire © anakeen