9 include_once (
"FDL/Class.DocFam.php");
12 $usage->setDefinitionText(
"Delete attributes parameters and values which are not defined in family");
13 $docid =
$usage->addRequiredParameter(
"famid",
"family identifier - 0 means all families");
30 $this->messages = array();
36 $this->dryrun = $justModify;
40 if (!$this->doc)
return;
42 $orphanAttributes = CheckDb::getOrphanAttributes($this->doc->id);
43 if ($orphanAttributes) {
46 foreach ($orphanAttributes as $orphanAttrId) {
47 $sql[] = sprintf(
"alter table doc%d drop column %s cascade; ", $this->doc->id, $orphanAttrId);
49 $this->messages[].=
"Destroy values for \"$orphanAttrId\".";
51 $sql[] = sprintf(
"create view family.\"%s\" as select * from doc%d", strtolower($this->doc->name) , $this->doc->id);
53 foreach (
$sql as $aSql) {
62 $defs = $this->doc->getOwnDefValues();
63 foreach ($defs as $aid => $v) {
64 if (!$this->doc->getAttribute($aid)) {
65 $this->doc->setDefValue($aid,
'',
false);
66 $this->messages[].=
"Clear default value \"$aid\".";
69 $defs = $this->doc->getOwnParams();
70 foreach ($defs as $aid => $v) {
71 $oa = $this->doc->getAttribute($aid);
72 if (!$oa || $oa->usefor !=
'Q') {
73 $this->doc->setParam($aid,
'',
false);
74 $this->messages[].=
"Clear parameter value \"$aid\".";
85 return implode($sep, $this->messages);
92 print "\t === Deleting parasite attributes ===\n";
95 $s->setObjectReturn(
true);
96 $s->setOrder(
"initid");
100 if (!$fam->isAlive()) {
103 if ($fam->doctype !=
'C') {
104 $action->exitError(sprintf(
"%s is not a family reference",
$docid));
106 $s->addFilter(
"id = %d", $fam->id);
110 print "\nJust Verify...\n";
112 printf(
"The suppression of attributes is irreversible.\nConfirm deleting parasites for %s [Y|N] ? ",
$docid ? $fam->name :
"all families");
113 $confirm = strtolower(trim(fgets(STDIN)));
114 if ($confirm !=
"y" && $confirm !=
"yes") {
115 print "\nAborted.\n";
118 print "\nCleaning in progress...\n";
129 while ($fam =
$s->getNextDoc()) {
131 $msg =
$c->getMessage(
"\n\t");
133 printf(
"\n\"%s\" %s cleaning\n", $fam->getTitle() , $fam->name);
136 printf(
"\"%s\" %s is clean. Nothing to do.\n", $fam->getTitle() , $fam->name);
cleanDefaultAndParametersValues()
new_Doc($dbaccess, $id= '', $latest=false)
simpleQuery($dbaccess, $query, &$result=array(), $singlecolumn=false, $singleresult=false, $useStrict=null)
Verify arguments for wsh programs.