Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
editprof.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  * Profil edition
9  *
10  * @author Anakeen 2000
11  * @version $Id: editprof.php,v 1.21 2007/07/27 07:42:31 eric Exp $
12  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
13  * @package FDL
14  * @subpackage GED
15  */
16 /**
17  */
18 
19 include_once ("FDL/Class.Doc.php");
20 include_once ("FDL/Class.DocAttr.php");
21 include_once ("FDL/Lib.Dir.php");
22 
23 function editprof(&$action)
24 {
25  $dbaccess = $action->GetParam("FREEDOM_DB");
26  $docid = GetHttpVars("id", 0);
27  $createp = GetHttpVars("create", 0); // 1 if use for create profile (only for familly)
28  $action->lay->Set("docid", $docid);
29  $action->lay->Set("create", $createp);
30 
31  if ($createp) $action->lay->Set("TITLE", _("change creation profile"));
32  else $action->lay->Set("TITLE", _("change profile"));
33  $action->lay->Set("NOCREATE", (!$createp));
34 
36  // build values type array
37  // control view acl
38  $err = $doc->Control("viewacl");
39  if ($err != "") $action->ExitError($err);
40 
41  $action->lay->Set("doctitle", _("new profile document"));
42 
43  $selectclass = array();
44  if (($doc->usefor != "P") && ($doc->usefor != "W") && ($doc->fromid != 28)) { // cannot redirect profil document (only normal document) also workflow and iw control
45  if ($createp) {
46  // search from profil of the document family (not the family)
47  $tdoc = createDoc($dbaccess, $doc->id);
48  $tclassdoc = GetProfileDoc($dbaccess, $doc->id, $tdoc->defProfFamId);
49  } else $tclassdoc = GetProfileDoc($dbaccess, $doc->id);
50  if (is_array($tclassdoc)) {
51  while (list($k, $pdoc) = each($tclassdoc)) {
52  if ($pdoc["id"] != $doc->id) {
53  $selectclass[$k]["idpdoc"] = $pdoc["id"];
54  $selectclass[$k]["profname"] = $pdoc["title"];
55  $selectclass[$k]["selected"] = "";
56  }
57  }
58  }
59  }
60 
61  $nbattr = 0; // if new document
62  // display current values
63  $newelem = array();
64  if ($docid > 0) {
65 
66  $doc->GetFathersDoc();
67  $action->lay->Set("doctitle", $doc->title);
68 
69  if ($createp) $sprofid = abs($doc->cprofid);
70  else {
71  $sprofid = abs($doc->profid);
72  // select dynamic profil if set
73  if ($doc->dprofid != 0) $sprofid = abs($doc->dprofid);
74  }
75 
76  if ($sprofid == $doc->id) $action->lay->Set("selected_spec", "selected");
77  else {
78  $action->lay->Set("selected_spec", "");
79  // selected the current class document
80  while (list($k, $pdoc) = each($selectclass)) {
81  // print $doc->doctype." == ".$selectclass[$k]["idcdoc"]."<BR>";
82  if ($sprofid == $selectclass[$k]["idpdoc"]) {
83  $selectclass[$k]["selected"] = "selected";
84  }
85  }
86  }
87 
88  $action->lay->SetBlockData("SELECTPROF", $selectclass);
89  }
90  if ((($doc->doctype != 'C') || $createp) && ($doc->doctype != "P") && ($doc->usefor != "W") && ($doc->fromid != 28)) {
91 
92  setControlView($action, $doc, $createp);
93  $action->lay->set("CV", true);
94  } else {
95  $action->lay->set("CV", false);
96  }
97 }
98 
99 function setControlView(&$action, &$doc, $createp = false)
100 {
101 
102  $filter = array();
103  $chdoc = $doc->GetFromDoc();
104 
105  $filter[] = GetSqlCond($chdoc, "cv_famid");
106  // if ($doc->doctype=='C') $filter[]="cv_famid=".$doc->id;
107  // else $filter[]="cv_famid=".$doc->fromid;
108  $tcv = getChildDoc($doc->dbaccess, 0, 0, 100, $filter, $action->user->id, "TABLE", "CVDOC");
109 
110  foreach ($tcv as $k => $v) {
111 
112  $tcv[$k]["selcv"] = "";
113 
114  if ($createp) {
115  if ($v["id"] == $doc->ccvid) $tcv[$k]["selcv"] = "selected";
116  } else {
117  if ($v["id"] == $doc->cvid) $tcv[$k]["selcv"] = "selected";
118  }
119  }
120  $action->lay->SetBlockData("SELECTCV", $tcv);
121 }
122 ?>
← centre documentaire © anakeen - published under CC License - Dynacase