15 include_once (
"FDL/Lib.Attr.php");
16 include_once (
"FDL/Class.DocFam.php");
19 $usage->setDefinitionText(
"Delete family document and its documents");
21 $force =
$usage->addHiddenParameter(
"force",
"force without transaction");
23 $transaction =
$usage->addEmptyParameter(
"transaction",
"abort deletion if one of query failed");
36 $action->exitError(
"Database not found : appl->dbaccess");
43 $action->exitError(sprintf(_(
"family %s not found") .
"\n", $odocid));
56 $resname =
$tdoc[
"name"];
60 if (!
$force) $tsql[] =
"BEGIN;";
62 sprintf(
"DELETE FROM fld WHERE childid IN (SELECT id FROM doc%d);", $resid) ,
63 sprintf(
"DELETE FROM doc%d;", $resid) ,
64 sprintf(
"DELETE FROM docname WHERE name = %s;", pg_escape_literal($resname)) ,
65 sprintf(
"DELETE FROM docfrom WHERE fromid = %d;", $resid) ,
66 sprintf(
"DELETE FROM docattr WHERE docid = %d;", $resid) ,
67 sprintf(
"DELETE FROM docfam WHERE id = %d;", $resid) ,
68 sprintf(
"DROP VIEW IF EXISTS family.%s;", pg_escape_identifier(strtolower($resname))) ,
69 sprintf(
"DROP TABLE IF EXISTS doc%d;", $resid) ,
70 sprintf(
"DROP SEQUENCE IF EXISTS seq_doc%d;", $resid)
72 if (!
$force) $tsql[] =
"COMMIT;";
73 $fdlgen = sprintf(
"FDLGEN/Class.Doc%d.php",
$tdoc[
"id"]);
74 if (file_exists($fdlgen) && is_file($fdlgen)) {
75 if (!unlink($fdlgen)) {
76 $action->exitError(
"Could not delete file '%s'.", $fdlgen);
78 printf(
"Deleted file '%s'.\n", $fdlgen);
82 foreach ($tsql as
$sql) {
84 $res = @pg_query($dbid, $sql);
86 print pg_last_error() .
"\n";
90 if ($res) printf(
"Family %s (id : %d) is destroyed.\n",
$tdoc[
"name"],
$tdoc[
"id"]);
92 $action->exitError(
"cannot destroy $idfam\n");
getTDoc($dbaccess, $id, $sqlfilters=array(), $result=array())
destroyFamily($dbaccess, $idfam, $force=false)
getFamIdFromName($dbaccess, $name)
Verify arguments for wsh programs.