Platform
3.1
PHP API documentation
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Pages
fdl_deletefamily.php
Go to the documentation of this file.
1
<?php
2
/*
3
* @author Anakeen
4
* @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
5
* @package FDL
6
*/
7
/**
8
* Delete family document and its documents
9
*
10
* @author Anakeen 2000
11
* @version $Id: fdl_adoc.php,v 1.20 2008/10/30 17:34:31 eric Exp $
12
* @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
13
* @package FDL
14
* @subpackage
15
*/
16
/**
17
*/
18
19
include_once (
"FDL/Lib.Attr.php"
);
20
include_once (
"FDL/Class.DocFam.php"
);
21
22
$appl
=
new
Application
();
23
$appl
->Set(
"FDL"
,
$core
);
24
25
$dbaccess
=
$appl
->GetParam(
"FREEDOM_DB"
);
26
if
(
$dbaccess
==
""
) {
27
print
"Database not found : param FREEDOM_DB"
;
28
exit
;
29
}
30
31
$docid
=
GetHttpVars
(
"famid"
, 0);
// special docid
32
$force
= (
GetHttpVars
(
"force"
) ==
"yes"
);
// force
33
if
(!
$docid
) {
34
print sprintf(_(
"usage %s --famid=<family id> [--force=yes]"
) .
"\n"
, $argv[0]);
35
exit
(1);
36
}
37
38
if
((
$docid
!== 0) && (!is_numeric(
$docid
))) {
39
$odocid =
$docid
;
40
$docid
=
getFamIdFromName
(
$dbaccess
,
$docid
);
41
if
(!
$docid
) {
42
print sprintf(_(
"family %s not found"
) .
"\n"
, $odocid);
43
exit
(1);
44
}
45
}
46
47
destroyFamily
(
$dbaccess
,
$docid
,
$force
);
48
49
function
destroyFamily
(
$dbaccess
, $idfam,
$force
=
false
)
50
{
51
$tdoc
=
getTDoc
(
$dbaccess
, $idfam);
52
if
(
$tdoc
) {
53
$resid =
$tdoc
[
"id"
];
54
$resname =
$tdoc
[
"name"
];
55
print
"Destroying ["
.
$tdoc
[
"title"
] .
"("
.
$tdoc
[
"name"
] .
")]\n"
;
56
$dbid
= getDbId(
$dbaccess
);
57
$tsql = array();
58
if
(!
$force
) $tsql[] =
"begin;"
;
59
$tsql+= array(
60
"delete from fld where childid in (select id from doc$resid);"
,
61
"delete from doc$resid;"
,
62
"drop view family.\""
. strtolower($resname) .
"\";"
,
63
"delete from docname where name='$resname'"
,
64
"delete from docfrom where fromid=$resid"
,
65
"drop table doc$resid;"
,
66
"delete from docattr where docid=$resid;"
,
67
"delete from docfam where id=$resid;"
68
);
69
if
(!
$force
) $tsql[] =
"commit;"
;
70
foreach
($tsql as
$sql
) {
71
print
"$sql\n"
;
72
$res = @pg_query(
$dbid
, $sql);
73
if
(!$res) {
74
print pg_last_error() .
"\n"
;
75
if
(!
$force
)
break
;
76
}
77
}
78
if
($res) printf(
"Family %s (id : %d) is destroyed.\n"
,
$tdoc
[
"name"
],
$tdoc
[
"id"
]);
79
}
else
{
80
print
"cannot destroy $idfam"
;
81
}
82
}
83
?>
← centre documentaire
© anakeen
- published under
CC License
-
Dynacase