Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
cleanFamilyParameter.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * Generate Php Document Classes
8  *
9  * @author Anakeen
10  * @version $Id: fdl_adoc.php,v 1.20 2008/10/30 17:34:31 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 include_once ("FDL/Class.DocFam.php");
20 
22 $appl->Set("FDL", $core);
23 
24 $dbaccess = $appl->dbaccess;
25 if ($dbaccess == "") {
26  print "Database not found : appl->dbaccess";
27  exit;
28 }
29 $usage = new ApiUsage();
30 $usage->setDefinitionText("Delete parameter values which are not real parameters");
31 $verifyOnly = $usage->addEmptyParameter("verify-only", "only verify, do not changes");
32 $usage->verify();
33 /*
34  * @var Action $action
35  */
36 // First Part: Workflow
37 print "\t === Deleting parasite parameters ===\n";
38 if ($verifyOnly) print "\nJust Verify...\n";
39 $s = new SearchDoc($action->dbaccess, "-1");
40 $s->setObjectReturn(true);
41 $s->search();
42 $deleting = array();
43 /*
44  * @var DocFam $fam
45  */
46 while ($fam = $s->getNextDoc()) {
47  print ("\n" . $fam->getTitle() . " : #" . $fam->id);
48  $pa = $fam->getOwnParams();
49 
50  $before = $fam->param;
51  foreach ($pa as $aid => $val) {
52  $oa = $fam->getAttribute($aid);
53  if (!$oa) {
54  $deleting[] = $aid;
55  $fam->setParam($aid, '', false);
56  } else {
57  if ($oa->usefor != 'Q') {
58  $deleting[] = $aid;
59  $fam->setParam($aid, '', false);
60  } else {
61  // it's a good param
62  $sql = sprintf("select id from docattr where (id='%s' or id=':%s') and docid=%d", $oa->id, $oa->id, $oa->docid);
63  simpleQuery($action->dbaccess, $sql, $dbAttrid, true, true);
64  if (!$dbAttrid) {
65  $deleting[] = $aid;
66  $fam->setParam($aid, '', false);
67  }
68  }
69  }
70  }
71  $after = $fam->param;
72  if ($before != $after) {
73  printf("Change from \n\t%s to \n\t%s", $before, $after);
74  if (!$verifyOnly) {
75  $err = $fam->modify();
76  $err = '';
77  if (!$err) print "changed";
78  else print $err;
79  }
80  } else print ": clean - nothing to do";
81 }
82 //print_r2($deleting);
83 print "\n";
global $action
if($famId) $s
print
Definition: checklist.php:49
switch($command) exit
Definition: checkVault.php:46
simpleQuery($dbaccess, $query, &$result=array(), $singlecolumn=false, $singleresult=false, $useStrict=null)
Definition: Lib.Common.php:484
if($file) if($subject==""&&$file) if($subject=="") $err
if($dbaccess=="") $usage
Verify arguments for wsh programs.
$core
Definition: chgpasswd.php:33
← centre documentaire © anakeen