Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
Class.DocVaultIndex.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  * Class.DocVaultIndex.php manages a full index
9  * for files attached to a Freedom document
10  *
11  * @author Anakeen 2000
12  * @version $Id: Class.DocVaultIndex.php,v 1.8 2007/03/07 18:42:24 eric Exp $
13  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
14  * @package FDL
15  */
16 /**
17  */
18 
19 include_once ('Class.DbObj.php');
20 include_once ('Class.QueryDb.php');
21 include_once ('Class.Log.php');
22 include_once ("WHAT/Class.TEClient.php");
23 
24 class DocVaultIndex extends DbObj
25 {
26  var $fields = array(
27  "docid",
28  "vaultid"
29  );
30 
31  var $id_fields = array(
32  "docid",
33  "vaultid"
34  );
35 
36  var $dbtable = "docvaultindex";
37 
38  var $order_by = "docid";
39 
40  var $sqlcreate = "
41 create table docvaultindex ( docid int not null,
42  vaultid int not null
43  );
44 create unique index idx_docvaultindex on docvaultindex (docid, vaultid);";
45  /**
46  * return doc ids from a vault file
47  * @param id $vid vault id
48  * @return array object
49  */
50  function getDocIds($vid)
51  {
52  $t = array();
53  $query = new QueryDb($this->dbaccess, "DocVaultIndex");
54  $query->basic_elem->sup_where = array(
55  "vaultid = $vid"
56  );
57  $t = $query->Query();
58 
59  return $t;
60  }
61  /**
62  * return first doc id from a vault file
63  * @param id $vid vault id
64  * @return int id of document
65  */
66  function getDocId($vid)
67  {
68  $t = array();
69  $query = new QueryDb($this->dbaccess, "DocVaultIndex");
70  $query->AddQuery("vaultid = $vid");
71  $t = $query->Query(0, 1, "TABLE");
72  if (is_array($t)) return $t[0]["docid"];
73  return false;
74  }
75  /**
76  * return vault ids for a document
77  * @param id $docid document id
78  * @return array
79  */
80  function getVaultIds($docid)
81  {
82  $t = array();
83  if (!$docid) return array();
84  $query = new QueryDb($this->dbaccess, "DocVaultIndex");
85  $query->AddQuery("docid = $docid");
86  $t = $query->Query(0, 0, "TABLE");
87  $tvid = array();
88  if (is_array($t)) {
89  foreach ($t as $tv) {
90  $tvid[] = $tv["vaultid"];
91  }
92  }
93  return $tvid;
94  }
95 
96  function DeleteDoc($docid)
97  {
98  $err = $this->exec_query("delete from " . $this->dbtable . " where docid=" . $docid);
99  return $err;
100  }
101 
102  function DeleteVaultId($vid)
103  {
104  $err = $this->exec_query("delete from " . $this->dbtable . " where vaultid=" . $vid);
105  return $err;
106  }
107 }
108 ?>
← centre documentaire © anakeen - published under CC License - Dynacase