Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
opendoc.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * Open Document
8  *
9  * @author Anakeen
10  * @version $Id: $
11  * @package FDL
12  * @subpackage
13  */
14 /**
15  */
16 
17 include_once ("FDL/Class.Doc.php");
18 /**
19  * open in edit mode if can else in view mode
20  * all parameters use in GENERIC_GENERIC_EDIT can be use in edit mode
21  * all parameters use in FDL:FDL_CARD can be use in view mode
22  * @param Action &$action current action
23  * @global id int Http var : document identifier to see
24  * @global mode string Http var : edit or view mode
25  *
26  */
27 function opendoc(Action & $action)
28 {
29  $docid = $action->getArgument("id");
30  $mode = $action->getArgument("mode", "none");
31  $err = '';
32  if ($mode == "none") {
33  if (!$docid) {
34  $famid = $action->getArgument("famid", $action->getArgument("classid"));
35  if ($famid) {
36  $mode = "new";
37  }
38  } else {
39  $dbaccess = $action->dbaccess;
40  $doc = new_doc($dbaccess, $docid, true);
41  if (($err = $doc->control('edit')) == "") {
42  $mode = 'edit';
43  } else if (($err = $doc->control('view')) == "") {
44  $mode = 'view';
45  }
46  }
47  }
48  switch ($mode) {
49  case 'new':
50  case 'edit':
51  $action->parent->set("GENERIC", $action->parent->parent);
52  $action->set("GENERIC_EDIT", $action->parent);
53  $gen = $action->execute();
54  $action->lay->template = $gen;
55  $action->lay->noparse = true;
56  break;
57 
58  case 'view':
59  $action->set("FDL_CARD", $action->parent);
60  $gen = $action->execute();
61  $action->lay->template = $gen;
62  $action->lay->noparse = true;
63  break;
64 
65  default:
66  if ($err) redirectAsGuest($action);
67  }
68  if ($err) $action->exitError($err);
69  }
70 
global $action
redirectAsGuest(Action &$action)
Definition: Lib.Http.php:104
exitError($texterr, $exit=true, $code="")
$docid
Definition: cleanFamily.php:13
static getArgument($k, $def= '')
$dbaccess
Definition: checkVault.php:17
if($file) if($subject==""&&$file) if($subject=="") $err
opendoc(Action &$action)
Definition: opendoc.php:27
← centre documentaire © anakeen