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
SetDocVaultIndex.php
Go to the documentation of this file.
1
<?php
2
/**
3
* Construct vault index database
4
*
5
* @author Anakeen 2004
6
* @version $Id: SetDocVaultIndex.php.in,v 1.2 2008/05/07 10:24:02 jerome Exp $
7
* @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
8
* @package FDL
9
* @subpackage
10
*/
11
/**
12
*/
13
ini_set(
"include_path"
,
".:/usr/share/what:/usr/share/what/WHAT:/usr/share/php"
);
14
ini_set(
"max_execution_time"
,
"36000"
);
15
16
include_once(
'Class.Action.php'
);
17
include_once(
'Class.Application.php'
);
18
include_once(
'Class.Session.php'
);
19
include_once(
'Class.Log.php'
);
20
21
include_once(
'FDL/Class.Doc.php'
);
22
include_once(
'FDL/Class.DocVaultIndex.php'
);
23
24
$appl
=
new
Application
();
25
$appl
->Set(
"FDL"
,
$core
);
26
$dbaccess
=
$appl
->GetParam(
"FREEDOM_DB"
);
27
if
(
$dbaccess
==
""
) {
28
print
"Database not found : param FREEDOM_DB"
;
29
exit
;
30
}
31
32
33
$dvi
=
new
DocVaultIndex
(
$dbaccess
);
34
35
$doc
=
new_Doc
(
$dbaccess
);
36
$doc
->exec_query(
"select * from doc where id > 0 and doctype!='Z'"
);
37
$idoc
=
$doc
->numrows();
38
39
loclog
(
"Base $dbaccess, "
.
$idoc
.
" document"
.(
$idoc
?
"s"
:
""
).
" to process"
);
40
$dvi
->exec_query(
"select * from docvaultindex"
);
41
loclog
(
"Doc/Vault Index contains "
.
$dvi
->numrows().
" associations"
);
42
43
44
for
(
$c
=0;
$c
<
$idoc
;
$c
++) {
45
$row =
$doc
->fetch_array(
$c
,PGSQL_ASSOC);
46
$tdoc
=
new_Doc
(
$dbaccess
, $row[
"id"
]);
47
UpdateVaultIndex
(
$c
,
$tdoc
,
$dvi
);
48
unset(
$tdoc
);
49
}
50
$dvi
->exec_query(
"select * from docvaultindex"
);
51
loclog
(
"Doc/Vault Index contains "
.
$dvi
->numrows().
" associations"
);
52
53
exit
;
54
55
56
function
UpdateVaultIndex
($i, &
$doc
, &
$dvi
) {
57
$vl =
""
; $vic=0;
58
$err
=
$dvi
->DeleteDoc(
$doc
->id);
59
$fa =
$doc
->GetFileAttributes();
60
foreach
($fa as $aid=>$oattr) {
61
if
($oattr->inArray()) {
62
$ta
=
$doc
->getTValue($aid);
63
}
else
{
64
$ta
=array(
$doc
->getValue($aid));
65
}
66
foreach
(
$ta
as $k=>$v) {
67
$vid=
""
;
68
if
(preg_match(
"/(.*)\|(.*)/"
, $v, $reg)) {
69
$vid=$reg[2];
70
$dvi
->docid =
$doc
->id;
71
$dvi
->vaultid = $vid;
72
$dvi
->Add();
73
$vl .=
" "
.$vid;
74
$vic++;
75
}
76
}
77
}
78
if
($vic>0)
loclog
(
"[$i] document ["
.
$doc
->id.
"::"
.
$doc
->title.
"] added vault file"
.($vic>1?
"s"
:
""
).
" "
.$vl);
79
80
}
81
82
83
function
loclog
(
$s
) {
84
echo
"SetDocVaultIndex> $s\n"
;
85
}
86
87
?>
← centre documentaire
© anakeen
- published under
CC License
-
Dynacase