Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
modprof.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: modprof.php,v 1.17 2007/10/17 12:01:32 eric Exp $
11  * @package FDL
12  * @subpackage GED
13  */
14 /**
15  */
16 // ---------------------------------------------------------------
17 // $Id: modprof.php,v 1.17 2007/10/17 12:01:32 eric Exp $
18 // $Source: /home/cvsroot/anakeen/freedom/freedom/Action/Freedom/modprof.php,v $
19 // ---------------------------------------------------------------
20 include_once ("FDL/Class.Doc.php");
21 include_once ("FDL/Class.Dir.php");
22 include_once ("FDL/Class.DocAttr.php");
23 include_once ("FDL/freedom_util.php");
24 // -----------------------------------
25 function modprof(Action & $action)
26 {
27  // -----------------------------------
28  // Get all the params
29  $docid = GetHttpVars("docid");
30  $createp = GetHttpVars("create", 0); // 1 if use for create profile (only for familly)
31  $profid = GetHttpVars("profid");
32  $cvid = GetHttpVars("cvid");
33  $redirid = GetHttpVars("redirid");
34 
35  if ($docid == 0) $action->exitError(_("the document is not referenced: cannot apply profile access modification"));
36 
37  $dbaccess = $action->dbaccess;
38  // initialise object
39 
40  /*
41  * @var DocFam $doc
42  */
44  // control modify acl
45  $err = $doc->Control("modifyacl");
46  if ($err != "") $action->ExitError($err);
47 
48  $err = $doc->lock(true); // auto lock
49  if ($err != "") $action->ExitError($err);
50  // test object permission before modify values (no access control on values yet)
51  $err = $doc->canEdit();
52  if ($err != "") $action->ExitError($err);
53 
54  if ($profid == "private") {
55  $prof = getMyProfil($dbaccess);
56  if (!$prof) {
57  $doc->unlock(true); // auto lock
58  $action->exitError(_("No privilege to set private profil"));
59  }
60  $profid = $prof->id;
61  }
62 
63  if ($createp) {
64  // change creation profile
65  if ($doc->cprofid != $profid) {
66  $doc->addHistoryEntry(sprintf(_("Change creation profil to %s [%d]") , $doc->getTitle($profid) , $profid));
67  $doc->cprofid = $profid; // new creation profile access
68 
69  }
70  if ($doc->ccvid != $cvid) {
71  $doc->ccvid = $cvid; // default control view for creation
72  $doc->addHistoryEntry(sprintf(_("Change creation view control to %s [%d]") , $doc->getTitle($cvid) , $cvid));
73  }
74  } else {
75 
76  if (($doc->profid == $doc->id) && ($profid == 0)) {
77  // unset control
78  $doc->UnsetControl();
79  }
80  if ($doc->profid != $profid) $doc->addHistoryEntry(sprintf(_("Change profil to %s [%d]") , $doc->getTitle($profid) , $profid));
81  if ($doc->cvid != $cvid) $doc->addHistoryEntry(sprintf(_("Change view control to %s [%d]") , $doc->getTitle($cvid) , $cvid));
82  // specific control
83  $doc->setProfil($profid); // change profile
84  $doc->setCvid($cvid); // change view control
85  if ($doc->profid == $doc->id) {
86  $doc->SetControl();
87  $doc->setProfil($doc->id); // force recompute of view of specific profil itself
88 
89  }
90 
91  $doc->disableEditControl(); // need because new profil is not enable yet
92 
93  }
94  $err = $doc->Modify();
95 
96  if ($err != "") $action->exitError($err);
97 
98  $doc->unlock(true); // auto unlock
99  if ($redirid) $docid = $redirid;
100  redirect($action, "FDL", "FDL_CARD&props=Y&id=$docid", $action->GetParam("CORE_STANDURL"));
101 }
global $action
modprof(Action &$action)
Definition: modprof.php:25
exitError($texterr, $exit=true, $code="")
getMyProfil($dbaccess, $create=true)
$docid
Definition: cleanFamily.php:13
new_Doc($dbaccess, $id= '', $latest=false)
$dbaccess
Definition: checkVault.php:17
if($file) if($subject==""&&$file) if($subject=="") $err
← centre documentaire © anakeen