Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
createprof.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * Create profile
8  *
9  * @author Anakeen
10  * @version $Id: $
11  * @package FDL
12  * @subpackage GED
13  */
14 /**
15  */
16 
17 include_once ("FDL/Class.Doc.php");
18 include_once ("FDL/Class.Dir.php");
19 include_once ("FDL/Class.DocAttr.php");
20 include_once ("FDL/freedom_util.php");
21 
23 {
24  // Get all the params
25  $docid = GetHttpVars("targetid");
26  $famid = GetHttpVars("famid");
27  $attrid = GetHttpVars("attrid");
28  $redirid = GetHttpVars("redirid");
29 
30  if ($docid == 0) $action->exitError(_("the document is not referenced: cannot apply profile access modification"));
31 
32  $dbaccess = $action->dbaccess;
33  // initialise object
35  if ($attrid != "cprofid") {
36  $oa = $doc->getAttribute($attrid);
37  if (!$oa) $action->exitError(sprintf(_("attribut %s not found for document %s [%d]") , $attrid, $doc->getTitle() , $doc->id));
38  }
39  // control modify acl
40  $err = $doc->Control("modifyacl");
41  if ($err != "") $action->ExitError($err);
42 
43  $tmpdoc = createTmpDoc($dbaccess, $famid);
44 
45  switch ($tmpdoc->defDoctype) {
46  case 'D':
47  $pdoc = createDoc($dbaccess, "PDIR");
48  break;
49 
50  case 'S':
51  $pdoc = createDoc($dbaccess, "PSEARCH");
52  break;
53 
54  case 'F':
55  $pdoc = createDoc($dbaccess, "PDOC");
56  break;
57 
58  default:
59  $action->exitError(_("Automatic profil creation not possible for this kind of family"));
60  break;
61  }
62 
63  if (!$pdoc) $action->exitError("not allowed to create profil");
64 
65  $pdoc->setValue("ba_title", sprintf(_("For %s of %s") , $oa ? $oa->getLabel() : _("document creation") , $doc->title));
66  $err = $pdoc->add();
67 
68  if ($err == "") {
69  $err = $pdoc->setControl($pdoc->id); // change profile
70 
71  }
72 
73  if ($err == "") {
74  if ($oa) $doc->setValue($attrid, $pdoc->id);
75  else $doc->$attrid = $pdoc->id;
76  $err = $doc->modify();
77  if ($err == "") $doc->addHistoryEntry(sprintf(_("add new profil %s") , $pdoc->getTitle()));
78  }
79 
80  if ($err != "") $action->exitError($err);
81 
82  if (!$redirid) $redirid = $docid;
83  redirect($action, "FDL", "FDL_CARD&props=Y&id=$redirid", $action->GetParam("CORE_STANDURL"));
84 }
global $action
exitError($texterr, $exit=true, $code="")
$docid
Definition: cleanFamily.php:13
createDoc($dbaccess, $fromid, $control=true, $defaultvalues=true, $temporary=false)
createprof(Action &$action)
Definition: createprof.php:22
new_Doc($dbaccess, $id= '', $latest=false)
$dbaccess
Definition: checkVault.php:17
createTmpDoc($dbaccess, $fromid, $defaultvalue=true)
if($file) if($subject==""&&$file) if($subject=="") $err
← centre documentaire © anakeen