Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
migrExtendedAcls.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * Generate Php Document Classes
8  *
9  * @author Anakeen
10  * @version $Id: fdl_adoc.php,v 1.20 2008/10/30 17:34:31 eric Exp $
11  * @package FDL
12  * @subpackage
13  */
14 /**
15  */
16 // refreah for a classname
17 // use this only if you have changed title attributes
18 include_once ("FDL/Lib.Attr.php");
19 include_once ("FDL/Class.DocFam.php");
20 
22 $appl->Set("FDL", $core);
23 
24 $dbaccess = $appl->dbaccess;
25 if ($dbaccess == "") {
26  print "Database not found : appl->dbaccess";
27  exit;
28 }
29 $usage = new ApiUsage();
30 $usage->setDefinitionText("Migrate old Acls for workflow and CV to extended acls");
31 $usage->verify();
32 /*
33  * @var Action $action
34  */
35 // First Part: Workflow
36 print "\t === migrate workflows ===\n";
37 $s = new SearchDoc($action->dbaccess, "WDoc");
38 $s->setObjectReturn(true);
39 $s->search();
40 /*
41  * @var WDoc $wdoc
42  */
43 while ($wdoc = $s->getNextDoc()) {
44  print ("\n" . $wdoc->getTitle() . " : #" . $wdoc->id);
45  $tr = $wdoc->transitions;
46  if (is_array($tr)) {
47  // old code compatibility
48  $ka = POS_WF;
49 
50  foreach ($tr as $k => $trans) {
51  $wdoc->dacls[$k] = array(
52  "pos" => $ka,
53  "description" => _($k)
54  );
55  $ka++;
56  }
57 
58  $sql = sprintf("select * from docperm where docid=%d", $wdoc->id);
59  simpleQuery($action->dbaccess, $sql, $acls);
60  foreach ($tr as $tid => $v) {
61  /**
62  * @var $aAcl array
63  */
64  foreach ($acls as $aAcl) {
65  if ($wdoc->controlUp($aAcl["upacl"], $tid) == "") {
66  print "\n\tAdd acl $tid to " . Account::getDisplayName($aAcl["userid"]);
67  $wdoc->addControl($aAcl["userid"], $tid);
68  }
69  }
70  }
71  }
72  print "\n";
73 }
74 // Second Part: View Control
75 print "\n\t === migrate view controller === \n";
76 $s = new SearchDoc($action->dbaccess, "CVDoc");
77 $s->setObjectReturn(true);
78 $s->search();
79 /*
80  * @var CVDoc $cvdoc
81  */
82 while ($cvdoc = $s->getNextDoc()) {
83  print ("\n" . $cvdoc->getTitle() . " : #" . $cvdoc->id);
84  // old code compatibility
85  $ka = POS_WF;
86  $ti = $cvdoc->getMultipleRawValues("CV_IDVIEW");
87  $tl = $cvdoc->getMultipleRawValues("CV_LVIEW");
88 
89  $ka = POS_WF;
90  foreach ($ti as $k => $v) {
91  if ($ti[$k] == "") $cvk = "CV$k";
92  else $cvk = $ti[$k];
93  $cvdoc->dacls[$cvk] = array(
94  "pos" => $ka,
95  "description" => $tl[$k]
96  );
97  $cvdoc->acls[] = $cvk;
98  $ka++;
99  }
100 
101  $sql = sprintf("select * from docperm where docid=%d", $cvdoc->id);
102  simpleQuery($action->dbaccess, $sql, $acls);
103  foreach ($ti as $k => $tid) {
104  /**
105  * @var $aAcl array
106  */
107  foreach ($acls as $aAcl) {
108  if ($cvdoc->controlUp($aAcl["upacl"], $tid) == "") {
109 
110  $err = $cvdoc->addControl($aAcl["userid"], $tid);
111  if ($err) print $err;
112  else print "\n\tAdd acl $tid to " . Account::getDisplayName($aAcl["userid"]);
113  } else {
114  //print "no $tid for ".Account::getDisplayName($aAcl["userid"]);
115 
116  }
117  }
118  }
119 }
120 print "\n";
global $action
if($famId) $s
const POS_WF
static getDisplayName($uid)
print
Definition: checklist.php:49
switch($command) exit
Definition: checkVault.php:46
simpleQuery($dbaccess, $query, &$result=array(), $singlecolumn=false, $singleresult=false, $useStrict=null)
Definition: Lib.Common.php:484
if($file) if($subject==""&&$file) if($subject=="") $err
Verify arguments for wsh programs.
$core
Definition: chgpasswd.php:33
if($dbaccess=="") $usage
← centre documentaire © anakeen