Core  3.2
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  * @package FDL
5 */
6 /**
7  * Profil edition
8  *
9  * @author Anakeen
10  * @version $Id: editprof.php,v 1.21 2007/07/27 07:42:31 eric Exp $
11  * @package FDL
12  * @subpackage GED
13  */
14 /**
15  */
16 
17 include_once ("FDL/Class.Doc.php");
18 include_once ("FDL/Class.DocAttr.php");
19 include_once ("FDL/Lib.Dir.php");
20 
21 function editprof(Action & $action)
22 {
23  $dbaccess = $action->dbaccess;
24  $docid = GetHttpVars("id", 0);
25  $createp = GetHttpVars("create", 0); // 1 if use for create profile (only for familly)
26  $action->lay->Set("create", intval($createp));
27 
28  if ($createp) $action->lay->Set("TITLE", _("change creation profile"));
29  else $action->lay->Set("TITLE", _("change profile"));
30  $action->lay->Set("NOCREATE", (!$createp));
31 
33  // build values type array
34  // control view acl
35  $err = $doc->Control("viewacl");
36  if ($err != "") $action->ExitError($err);
37  $action->lay->Set("docid", $doc->id);
38  $action->lay->eSet("doctitle", _("new profile document"));
39 
40  $selectclass = array();
41  if (($doc->usefor != "P") && (strstr($doc->usefor, 'W') === false) && ($doc->fromid != 28)) { // cannot redirect profil document (only normal document) also workflow and iw control
42  if ($createp) {
43  // search from profil of the document family (not the family)
44  $tdoc = createDoc($dbaccess, $doc->id);
45  $tclassdoc = GetProfileDoc($dbaccess, $doc->id, $tdoc->defProfFamId);
46  } else $tclassdoc = GetProfileDoc($dbaccess, $doc->id);
47  if (is_array($tclassdoc)) {
48  foreach ($tclassdoc as $k => $pdoc) {
49  if ($pdoc["id"] != $doc->id) {
50  $selectclass[$k]["idpdoc"] = $pdoc["id"];
51  $selectclass[$k]["profname"] = $pdoc["title"];
52  $selectclass[$k]["selected"] = "";
53  }
54  }
55  }
56  }
57 
58  $nbattr = 0; // if new document
59  // display current values
60  $newelem = array();
61  if ($docid > 0) {
62 
63  $doc->GetFathersDoc();
64  $action->lay->eSet("doctitle", $doc->title);
65 
66  if ($createp) {
67  /*
68  * @var DocFam $doc
69  */
70  $sprofid = abs($doc->cprofid);
71  } else {
72  $sprofid = abs($doc->profid);
73  // select dynamic profil if set
74  if ($doc->dprofid != 0) $sprofid = abs($doc->dprofid);
75  }
76 
77  if ($sprofid == $doc->id) $action->lay->Set("selected_spec", "selected");
78  else {
79  $action->lay->Set("selected_spec", "");
80  // selected the current class document
81  foreach ($selectclass as $k => $pdoc) {
82  // print $doc->doctype." == ".$selectclass[$k]["idcdoc"]."<BR>";
83  if ($sprofid == $selectclass[$k]["idpdoc"]) {
84  $selectclass[$k]["selected"] = "selected";
85  }
86  }
87  }
88 
89  $action->lay->SetBlockData("SELECTPROF", $selectclass);
90  }
91  if ((($doc->doctype != 'C') || $createp) && ($doc->doctype != "P") && (strstr($doc->usefor, 'W') === false) && ($doc->fromid != 28)) {
92 
93  setControlView($action, $doc, $createp);
94  $action->lay->set("CV", true);
95  } else {
96  $action->lay->set("CV", false);
97  }
98 }
99 /**
100  * @param Action $action
101  * @param Doc $doc
102  * @param bool $createp
103  */
104 function setControlView(&$action, &$doc, $createp = false)
105 {
106 
107  $filter = array();
108  $chdoc = $doc->GetFromDoc();
109 
110  $filter[] = GetSqlCond($chdoc, "cv_famid");
111  // if ($doc->doctype=='C') $filter[]="cv_famid=".$doc->id;
112  // else $filter[]="cv_famid=".$doc->fromid;
113  $tcv = internalGetDocCollection($doc->dbaccess, 0, 0, 100, $filter, $action->user->id, "TABLE", "CVDOC");
114 
115  foreach ($tcv as $k => $v) {
116 
117  $tcv[$k]["selcv"] = "";
118 
119  if ($createp) {
120  /*
121  * @var DocFam $doc
122  */
123  if ($v["id"] == $doc->ccvid) $tcv[$k]["selcv"] = "selected";
124  } else {
125  if ($v["id"] == $doc->cvid) $tcv[$k]["selcv"] = "selected";
126  }
127  }
128  $action->lay->SetBlockData("SELECTCV", $tcv);
129 }
$tdoc
global $action
Set($name, &$parent)
setControlView(&$action, &$doc, $createp=false)
Definition: editprof.php:104
$docid
Definition: cleanFamily.php:13
createDoc($dbaccess, $fromid, $control=true, $defaultvalues=true, $temporary=false)
editprof(Action &$action)
Definition: editprof.php:21
internalGetDocCollection($dbaccess, $dirid, $start="0", $slice="ALL", $sqlfilters=array(), $userid=1, $qtype="LIST", $fromid="", $distinct=false, $orderby="title", $latest=true, $trash="", &$debug=null, $folderRecursiveLevel=2, $join= '',\SearchDoc &$searchDoc=null)
Definition: Lib.Dir.php:428
new_Doc($dbaccess, $id= '', $latest=false)
GetSqlCond($Table, $column, $integer=false)
$dbaccess
Definition: checkVault.php:17
if($file) if($subject==""&&$file) if($subject=="") $err
GetProfileDoc($dbaccess, $docid, $defProfFamId="")
Definition: Lib.Dir.php:984
← centre documentaire © anakeen