Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
fdl_trigger.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * Generated Header (not documented yet)
8  *
9  * @author Anakeen
10  * @version $Id: fdl_trigger.php,v 1.8 2007/05/22 16:06:29 eric Exp $
11  * @package FDL
12  * @subpackage
13  */
14 /**
15  */
16 // refreah for a classname
17 // use this only if you have changed title attributes
18 include_once ("FDL/Lib.Attr.php");
19 
20 $usage = new ApiUsage();
21 
22 $usage->setDefinitionText("Return sql code to inject trigget in base");
23 $docid = $usage->addOptionalParameter("docid", "special docid", null, 0);
24 $trigger = $usage->addOptionalParameter("trigger", "trigger", null, "-");
25 $trig = ($trigger != "-");
26 $drop = ($trigger == "N");
27 
28 $usage->verify();
29 
31 $appl->Set("FDL", $core);
32 
33 $dbaccess = $appl->dbaccess;
34 if ($dbaccess == "") {
35  print "Database not found : appl->dbaccess";
36  exit;
37 }
38 
39 if ($docid != - 1) {
40  $query = new QueryDb($dbaccess, "Doc");
41  $query->AddQuery("doctype='C'");
42 
43  if ($docid > 0) $query->AddQuery("id=$docid");
44 
45  $table1 = $query->Query(0, 0, "TABLE");
46 
47  if ($query->nb > 0) {
48 
50 
51  foreach ($table1 as $k => $v) {
52  $doc = createDoc($dbaccess, $v["id"]);
53 
54  if ($trig) print $doc->sqltrigger($drop) . "\n";
55  else {
56  $triggers = $doc->sqltrigger(false, true);
57 
58  if (is_array($triggers)) {
59  print implode(";\n", $triggers);
60  } else {
61  print $triggers . "\n";
62  }
63  }
64  print implode(' ', $doc->getSqlIndex()) . "\n";
65  }
66  }
67 }
68 
69 if (($docid == - 1) || ($docid == 0)) {
70 
71  include_once ("FDL/Class.DocFam.php");
72  $doc = new DocFam($dbaccess);
73 
74  $doc->doctype = 'C';
75  $doc->fromid = 'fam';
76  if ($trig) print $doc->sqltrigger($drop) . "\n";
77  else if (!empty($doc->sqltcreate)) {
78  if (is_array($doc->sqltcreate)) {
79  print implode(";\n", $doc->sqltcreate);
80  } else {
81  print $doc->sqltcreate . "\n";
82  }
83  }
84 }
$trig
Definition: fdl_trigger.php:25
global $pubdir
Definition: vault_init.php:18
$usage
Definition: fdl_trigger.php:20
$docid
Definition: fdl_trigger.php:23
$trigger
Definition: fdl_trigger.php:24
$drop
Definition: fdl_trigger.php:26
const DEFAULT_PUBDIR
Definition: Lib.Prefix.php:28
$dbaccess
Definition: fdl_trigger.php:33
createDoc($dbaccess, $fromid, $control=true, $defaultvalues=true, $temporary=false)
$appl
Definition: fdl_trigger.php:30
print
Definition: checklist.php:49
switch($command) exit
Definition: checkVault.php:46
if(($docid!==0)&&(!is_numeric($docid))) $query
Verify arguments for wsh programs.
$core
Definition: chgpasswd.php:33
← centre documentaire © anakeen