Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
SetDocVaultIndex.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * Construct vault index database
8  *
9  * @author Anakeen 2004
10  * @version $Id: SetDocVaultIndex.php.in,v 1.2 2008/05/07 10:24:02 jerome Exp $
11  * @package FDL
12  * @subpackage
13  */
14 /**
15  */
16 
17 include_once ('Class.Action.php');
18 include_once ('Class.Application.php');
19 include_once ('Class.Session.php');
20 include_once ('Class.Log.php');
21 
22 include_once ('FDL/Class.Doc.php');
23 include_once ('FDL/Class.DocVaultIndex.php');
24 
25 $usage = new ApiUsage();
26 $usage->setDefinitionText("Construct vault index database");
27 $usage->verify();
28 
30 $appl->Set("FDL", $core);
31 $dbaccess = $appl->dbaccess;
32 if ($dbaccess == "") {
33  print "Database not found : appl->dbaccess";
34  exit;
35 }
36 
38 
40 $doc->exec_query("select * from doc where id > 0 and doctype!='Z'");
41 $idoc = $doc->numrows();
42 
43 loclog("Base $dbaccess, " . $idoc . " document" . ($idoc ? "s" : "") . " to process");
44 $dvi->exec_query("select * from docvaultindex");
45 loclog("Doc/Vault Index contains " . $dvi->numrows() . " associations");
46 
47 for ($c = 0; $c < $idoc; $c++) {
48  $row = $doc->fetch_array($c, PGSQL_ASSOC);
49  $tdoc = new_Doc($dbaccess, $row["id"]);
51  unset($tdoc);
52 }
53 $dvi->exec_query("select * from docvaultindex");
54 loclog("Doc/Vault Index contains " . $dvi->numrows() . " associations");
55 
57 /**
58  * @param int $i
59  * @param Doc $doc
60  * @param DocVaultIndex $dvi
61  */
62 function UpdateVaultIndex($i, &$doc, &$dvi)
63 {
64  $vl = "";
65  $vic = 0;
66  $err = $dvi->DeleteDoc($doc->id);
67  $fa = $doc->GetFileAttributes();
68  foreach ($fa as $aid => $oattr) {
69  if ($oattr->inArray()) {
70  $ta = $doc->getMultipleRawValues($aid);
71  } else {
72  $ta = array(
73  $doc->getMultipleRawValues($aid)
74  );
75  }
76  foreach ($ta as $k => $v) {
77  $vid = "";
78  if (preg_match(PREGEXPFILE, $v, $reg)) {
79  $vid = $reg[2];
80  $dvi->docid = $doc->id;
81  $dvi->vaultid = $vid;
82  $dvi->Add();
83  $vl.= " " . $vid;
84  $vic++;
85  }
86  }
87  }
88  if ($vic > 0) loclog("[$i] document [" . $doc->id . "::" . $doc->title . "] added vault file" . ($vic > 1 ? "s" : "") . " " . $vl);
89 }
90 
91 function loclog($s)
92 {
93  echo "SetDocVaultIndex> $s\n";
94 }
$tdoc
const PREGEXPFILE
Definition: Class.Doc.php:54
if($dbaccess=="") $dvi
if($famId) $s
loclog($s)
UpdateVaultIndex($i, &$doc, &$dvi)
print
Definition: checklist.php:49
new_Doc($dbaccess, $id= '', $latest=false)
if($file) if($subject==""&&$file) if($subject=="") $err
Verify arguments for wsh programs.
$core
Definition: chgpasswd.php:33
← centre documentaire © anakeen