Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
createthefam.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * Create a new family
8  *
9  * @author Anakeen
10  * @version $Id: createthefam.php,v 1.1 2006/03/31 12:29:30 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.Attr.php");
20 include_once ("FDL/Class.DocFam.php");
21 include_once ("FDL/freedom_util.php");
22 // -----------------------------------
24 {
25  // Get all the params
26  $ftitle = GetHttpVars("ftitle", _("new familly document"));
27  $fname = getHttpVars("fname", "");
28  if (!$fname) {
29  $action->exitError(_("Logical name must not be empty."));
30  }
31 
32  $dbaccess = $action->dbaccess;
33 
34  $doc = new DocFam($dbaccess);
35  //---------------------------
36  // add new freedom familly
37  //---------------------------
38  $doc->title = $ftitle;
39  $doc->owner = $action->user->id;
40  $doc->locked = $action->user->id; // lock for next modification
41  $doc->doctype = 'C'; // it is a new class document
42  $doc->fromid = GetHttpVars("classid"); // inherit from
43  $doc->profid = "0"; // NO PROFILE ACCESS
44  if (GetHttpVars("classid") > 0) {
45  /*
46  * @var DocFam $cdoc
47  */
48  $cdoc = new_Doc($dbaccess, GetHttpVars("classid"));
49  $doc->classname = "";
50  $doc->profid = $cdoc->cprofid; // inherit father profile
51 
52  }
53  $err = $doc->setLogicalName($fname);
54  if ($err != "") {
55  $action->exitError($err);
56  }
57  $err = $doc->Add();
58  if ($err != "") {
59  $action->exitError($err);
60  }
61 
62  $wsh = getWshCmd();
63  $cmd = $wsh . "--userid={$action->user->id} --api=generateDocumentClass --docid=" . $doc->initid;
64 
65  $err = exec($cmd, $out, $ret);
66 
67  $doc->unlock(true);
68  if ($ret) $action->exitError($err);
69 
70  redirect($action, "FDL", "FDL_CARD&id=" . $doc->id, $action->GetParam("CORE_STANDURL"));
71 }
global $action
createthefam(Action &$action)
$ret
exitError($texterr, $exit=true, $code="")
foreach($argv as $arg) $cmd
getWshCmd($nice=false, $userid=0, $sudo=false)
Definition: Lib.Common.php:594
getHttpVars($name, $def="", $scope="all")
Definition: Lib.Http.php:124
new_Doc($dbaccess, $id= '', $latest=false)
$dbaccess
Definition: checkVault.php:17
if($file) if($subject==""&&$file) if($subject=="") $err
← centre documentaire © anakeen