Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
fdlsearches.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  * function use for specialised searches
9  *
10  * @author Anakeen 2006
11  * @version $Id: fdlsearches.php,v 1.3 2007/08/01 14:08:09 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 function mytagdoc_($start, $slice, $tag, $userid = 0)
19 {
20  include_once ("FDL/Class.DocUTag.php");
21  include_once ("FDL/Lib.Dir.php");
22  $dbaccess = getParam("FREEDOM_DB");
23  if ($userid == 0) $uid = getUserId();
24  else $uid = $userid;
25  $q = new QueryDb($dbaccess, "DocUTag");
26  $q->AddQuery("uid=$uid");
27  $q->AddQuery("tag='$tag'");
28  $q->order_by = "date desc";
29  $lq = $q->Query($start, $slice, "TABLE");
30  $lid = array();
31  if ($q->nb > 0) {
32  foreach ($lq as $k => $v) {
33  $lid[$v["initid"]] = $v["id"];
34  }
35  }
36  //print Doc::getTimeDate(0,true);
37  $ltdoc = getDocsFromIds($dbaccess, $lid);
38  // print "\nc=".count($ltdoc)."\n";
39  //print Doc::getTimeDate(0,true);
40  // print_r2($ltdoc);
41  return $ltdoc;
42 }
43 /**
44  * return document i have deleted
45  */
46 function mytagdoc($start = "0", $slice = "ALL", $tag, $userid = 0)
47 {
48  include_once ("FDL/Class.SearchDoc.php");
49  $dbaccess = getParam("FREEDOM_DB");
50  $s = new searchDoc($dbaccess);
51  $s->join("id = docutag(id)");
52  $s->slice = $slice;
53  $s->start = $start;
54  $s->addFilter("docutag.uid = %d", $userid);
55  $s->addFilter("docutag.tag = '%s'", $tag);
56 
57  return $s->search();
58 }
59 /**
60  * function use for specialised search
61  * return all document tagged TOVIEWDOC for current user
62  *
63  * @param int $start start cursor
64  * @param int $slice offset ("ALL" means no limit)
65  * @param int $userid user system identificator (NOT USE in this function)
66  */
67 function mytoviewdoc($start = "0", $slice = "ALL", $userid = 0)
68 {
69  return mytagdoc($start, $slice, "TOVIEW", $userid);
70 }
71 /**
72  * function use for specialised search
73  * return all document tagged VIEWED for current user
74  *
75  * @param int $start start cursor
76  * @param int $slice offset ("ALL" means no limit)
77  * @param int $userid user system identificator (NOT USE in this function)
78  */
79 function myvieweddoc($start = "0", $slice = "ALL", $userid = 0)
80 {
81  if ($slice == "ALL") $slice = 50;
82  return mytagdoc($start, $slice, "VIEWED", $userid);
83 }
84 /**
85  * function use for specialised search
86  * return all document tagged for current user
87  *
88  * @param int $start start cursor
89  * @param int $slice offset ("ALL" means no limit)
90  * @param int $userid user system identificator (NOT USE in this function)
91  */
92 function myaffecteddoc($start = "0", $slice = "ALL", $userid = 0)
93 {
94  return mytagdoc($start, $slice, "AFFECTED", $userid);
95 }
96 /**
97  * function use for specialised search
98  * return all referenced documents
99  *
100  * @param int $start start cursor
101  * @param int $slice offset ("ALL" means no limit)
102  * @param int $userid user system identificator (NOT USE in this function)
103  * @param int $docid document referenced
104  * @param int $famid family restriction (0 if no restriction)
105  */
106 function relateddoc($start = "0", $slice = "ALL", $userid = 0, $docid = 0, $famid = 0)
107 {
108 
109  $dbaccess = getParam("FREEDOM_DB");
110  if ($docid > 0) {
111  include_once ("FDL/Class.DocRel.php");
112  $lid = array();
114  $idocid = $doc->initid;
115  $rdoc = new DocRel($dbaccess, $idocid);
116  $rdoc->sinitid = $idocid;
117  $trel = $rdoc->getIRelations();
118 
119  foreach ($trel as $k => $v) {
120  $lid[$v["sinitid"]] = $v["sinitid"];
121  $tlay[$v["sinitid"] . '_F'] = array(
122  "iconsrc" => $doc->getIcon($v["sicon"]) ,
123  "initid" => $v["sinitid"],
124  "title" => $v["stitle"],
125  "aid" => $v["type"],
126  "alabel" => _($v["type"]) ,
127  "type" => _("Referenced from")
128  );
129  }
130  $ltdoc = getLatestDocsFromIds($dbaccess, $lid);
131  if ($famid != 0) {
132  if (!is_numeric($famid)) $famid = getFamIdFromName($dbaccess, $famid);
133  if ($famid > 0) {
134  $tfam = $doc->GetChildFam($famid);
135  $tfamids = array_keys($tfam);
136  $tfamids[] = $famid;
137 
138  foreach ($ltdoc as $k => $v) {
139  if (!in_array($v["fromid"], $tfamids)) unset($ltdoc[$k]);
140  }
141  }
142  }
143  }
144  return $ltdoc;
145 }
146 /**
147  * return document i have deleted
148  */
149 function mydeleteddoc($start = "0", $slice = "ALL", $userid = 0)
150 {
151  include_once ("FDL/Class.SearchDoc.php");
152  $dbaccess = getParam("FREEDOM_DB");
153  $s = new searchDoc($dbaccess);
154  $s->trash = 'only';
155  $s->join("id = dochisto(id)");
156  $s->addFilter("dochisto.uid = %d", $userid);
157  $s->addFilter("dochisto.code = 'DELETE'");
158  $s->distinct = true;
159 
160  return $s->search();
161 }
162 ?>
← centre documentaire © anakeen - published under CC License - Dynacase