Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
Lib.Dir.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * Generated Header (not documented yet)
8  *
9  * @author Anakeen
10  * @version $Id: Lib.Dir.php,v 1.149 2008/11/13 16:46:48 eric Exp $
11  * @package FDL
12  * @subpackage
13  */
14 /**
15  */
16 
17 include_once ('FDL/Class.Dir.php');
18 include_once ('FDL/Class.DocSearch.php');
19 include_once ('FDL/Class.DocRead.php');
20 include_once ('FDL/Class.DocFam.php');
21 
23 {
24  // query to find first directories
25  $qsql = "select id from only doc2 where (doctype='D') order by id LIMIT 1;";
26 
27  $query = new QueryDb($dbaccess, "Doc");
28 
29  $tableq = $query->Query(0, 0, "TABLE", $qsql);
30  if ($query->nb > 0) {
31 
32  return $tableq[0]["id"];
33  }
34 
35  return (0);
36 }
37 
38 function getChildDir($dbaccess, $userid, $dirid, $notfldsearch = false, $restype = "LIST")
39 {
40  // query to find child directories (no recursive - only in the specified folder)
41  if (!($dirid > 0)) return array();
42  // search classid and appid to test privilege
43  if ($notfldsearch) {
44  // just folder no serach
45  return internalGetDocCollection($dbaccess, $dirid, "0", "ALL", array() , $userid, $restype, 2, false, "title");
46  } else {
47  $folders = array();
48  $searches = array();
49  // with folder and searches
50  try {
51  $folders = internalGetDocCollection($dbaccess, $dirid, "0", "ALL", array(
52  "doctype='D'"
53  ) , $userid, $restype, 2, false, "title");
54  }
55  catch(Exception $e) {
56  }
57  try {
58  $searches = internalGetDocCollection($dbaccess, $dirid, "0", "ALL", array(
59  "doctype='S'"
60  ) , $userid, $restype, 5, false, "title");
61  }
62  catch(Exception $e) {
63  }
64  return array_merge($folders, $searches);
65  }
66 }
67 
68 function isSimpleFilter($sqlfilters)
69 {
70  if (!is_array($sqlfilters)) return true;
71  static $props = false;
72 
73  if (!$props) {
74  $d = new Doc();
75  $props = $d->fields;
76  $props = array_merge($props, $d->sup_fields);
77  $props[] = "fulltext";
78  $props[] = "svalues";
79  }
80 
81  foreach ($sqlfilters as $k => $v) {
82  $tok = ltrim($v, "(");
83  $tok = ltrim($tok, " ");
84  $tok = strtok($tok, " !=~@");
85  if (!(strpos($tok, '.') > 0)) { // join is not in main table
86  //if ($tok == "fulltext") return true;
87  if (($tok !== false) && ($tok !== "true") && ($tok !== "false") && (!in_array(ltrim($tok, "(") , $props))) return false;
88  }
89  }
90  return true;
91 }
92 /**
93  * compose query to serach document
94  *
95  * @param string $dbaccess database specification
96  * @param array $dirid the array of id or single id of folder where search document (0 => in all DB)
97  * @param string $fromid for a specific familly (0 => all familly) (<0 strict familly)
98  * @param array $sqlfilters array of sql filter
99  * @param bool $distinct
100  * @param bool $latest set false if search in all revised doc
101  * @param string $trash (no|only|also) search in trash or not
102  * @param bool $simplesearch set false if search is about specific attributes
103  * @param int $folderRecursiveLevel
104  * @param string $join defined a join table like "id = dochisto(id)"
105  * @param string $only set "only" to have only family (not descandent);
106  * @return array|bool|string
107  */
108 function getSqlSearchDoc($dbaccess, $dirid, $fromid, $sqlfilters = array() , $distinct = false, // if want distinct without locked
109 $latest = true, // only latest document
110 $trash = "", $simplesearch = false, $folderRecursiveLevel = 2, $join = '', $only = "")
111 {
112 
113  if (($fromid != "") && (!is_numeric($fromid))) {
114  preg_match('/^(?P<sign>-?)(?P<fromid>.+)$/', trim($fromid) , $m);
115  $fromid = $m['sign'] . getFamIdFromName($dbaccess, $m['fromid']);
116  }
117  $table = "doc";
118  $qsql = array();
119  if ($trash == "only") $distinct = true;
120  if ($fromid == - 1) $table = "docfam";
121  elseif ($simplesearch) $table = "docread";
122  elseif ($fromid < 0) {
123  $only = "only";
124  $fromid = - $fromid;
125  $table = "doc$fromid";
126  } else {
127  if ($fromid != 0) {
128  if (isSimpleFilter($sqlfilters) && (familyNeedDocread($dbaccess, $fromid))) {
129  $table = "docread";
130  $fdoc = new_doc($dbaccess, $fromid);
131  $sqlfilters[-4] = GetSqlCond(array_merge(array(
132  $fromid
133  ) , array_keys($fdoc->GetChildFam())) , "fromid", true);
134  } else {
135  $table = "doc$fromid";
136  }
137  } elseif ($fromid == 0) {
138  if (isSimpleFilter($sqlfilters)) $table = "docread";
139  }
140  }
141  $maintable = $table; // can use join only on search
142  if ($join) {
143  if (preg_match('/([a-z0-9_\-:]+)\s*(=|<|>|<=|>=)\s*([a-z0-9_\-:]+)\(([^\)]*)\)/', $join, $reg)) {
144  $joinid = getFamIdFromName($dbaccess, $reg[3]);
145  $jointable = ($joinid) ? "doc" . $joinid : $reg[3];
146 
147  $sqlfilters[] = sprintf("%s.%s %s %s.%s", $table, $reg[1], $reg[2], $jointable, $reg[4]); // "id = dochisto(id)";
148  $maintable = $table;
149  $table.= ", " . $jointable;
150  } else {
151  addWarningMsg(sprintf(_("search join syntax error : %s") , $join));
152  return false;
153  }
154  }
155  $maintabledot = ($maintable && $dirid == 0) ? $maintable . '.' : '';
156 
157  if ($distinct) {
158  $selectfields = "distinct on ($maintable.initid) $maintable.*";
159  } else {
160  $selectfields = "$maintable.*";
161  $sqlfilters[-2] = $maintabledot . "doctype != 'T'";
162  ksort($sqlfilters);
163  }
164  $sqlcond = "true";
165  ksort($sqlfilters);
166  if (count($sqlfilters) > 0) $sqlcond = " (" . implode(") and (", $sqlfilters) . ")";
167 
168  if ($dirid == 0) {
169  //-------------------------------------------
170  // search in all Db
171  //-------------------------------------------
172  if (strpos(implode(",", $sqlfilters) , "archiveid") === false) $sqlfilters[-4] = $maintabledot . "archiveid is null";
173 
174  if ($trash == "only") {
175  $sqlfilters[-3] = $maintabledot . "doctype = 'Z'";
176  if ($latest) {
177  $sqlfilters[] = $maintabledot . "lmodify = 'D'";
178  }
179  } elseif ($trash == "also") {
180  $sqlfilters[-3] = sprintf("(%slocked != -1 or %slmodify='D')", $maintabledot, $maintabledot);
181  } else if (!$fromid) {
182  $sqlfilters[-3] = $maintabledot . "doctype != 'Z'";
183  }
184 
185  if (($latest) && (($trash == "no") || (!$trash))) {
186  $sqlfilters[-1] = $maintabledot . "locked != -1";
187  }
188  ksort($sqlfilters);
189  if (count($sqlfilters) > 0) $sqlcond = " (" . implode(") and (", $sqlfilters) . ")";
190  $qsql = "select $selectfields " . "from $only $table " . "where " . $sqlcond;
191  } else {
192  //-------------------------------------------
193  // in a specific folder
194  //-------------------------------------------
195  $fld = null;
196  if (!is_array($dirid)) $fld = new_Doc($dbaccess, $dirid);
197  if ((is_array($dirid)) || ($fld && $fld->defDoctype != 'S')) {
198  $hasFilters = false;
199  if ($fld && method_exists($fld, "getSpecificFilters")) {
200  /*
201  * @var DocCollection $fld
202  */
203  $specFilters = $fld->getSpecificFilters();
204  if (is_array($specFilters) && (count($specFilters) > 0)) {
205  $sqlfilters = array_merge($sqlfilters, $specFilters);
206  $hasFilters = true;
207  }
208  }
209  if (strpos(implode(",", $sqlfilters) , "archiveid") === false) $sqlfilters[-4] = $maintabledot . "archiveid is null";
210  //if ($fld->getRawValue("se_trash")!="yes") $sqlfilters[-3] = "doctype != 'Z'";
211  if ($trash == "only") {
212  $sqlfilters[-1] = "locked = -1";
213  if ($latest) {
214  $sqlfilters[] = $maintabledot . "lmodify = 'D'";
215  }
216  } elseif ($latest) $sqlfilters[-1] = "locked != -1";
217  ksort($sqlfilters);
218  if (count($sqlfilters) > 0) $sqlcond = " (" . implode(") and (", $sqlfilters) . ")";
219 
220  if (is_array($dirid)) {
221  $sqlfld = GetSqlCond($dirid, "dirid", true);
222  $qsql = "select $selectfields " . "from (select childid from fld where $sqlfld) as fld2 inner join $table on (initid=childid) " . "where $sqlcond ";
223  } else {
224  $sqlfld = "dirid=$dirid and qtype='S'";
225  if ($fromid == 2) $sqlfld.= " and doctype='D'";
226  if ($fromid == 5) $sqlfld.= " and doctype='S'";
227  if ($hasFilters) {
228  $sqlcond = " (" . implode(") and (", $sqlfilters) . ")";
229  $qsql = "select $selectfields from $only $table where $sqlcond ";
230  } else {
231  $q = new QueryDb($dbaccess, "QueryDir");
232  $q->AddQuery($sqlfld);
233  $tfld = $q->Query(0, 0, "TABLE");
234  if ($q->nb > 0) {
235  $tfldid = array();
236  foreach ($tfld as $onefld) {
237  $tfldid[] = $onefld["childid"];
238  }
239  if (count($tfldid) > 1000) {
240  $qsql = "select $selectfields " . "from $table where initid in (select childid from fld where $sqlfld) " . "and $sqlcond ";
241  } else {
242  $sfldids = implode(",", $tfldid);
243  if ($table == "docread") {
244  /*$qsql= "select $selectfields ".
245  "from $table where initid in (select childid from fld where $sqlfld) ".
246  "and $sqlcond "; */
247  $qsql = "select $selectfields " . "from $table where initid in ($sfldids) " . "and $sqlcond ";
248  } else {
249  /*$qsql= "select $selectfields ".
250  "from (select childid from fld where $sqlfld) as fld2 inner join $table on (initid=childid) ".
251  "where $sqlcond ";*/
252  $qsql = "select $selectfields " . "from $only $table where initid in ($sfldids) " . "and $sqlcond ";
253  }
254  }
255  }
256  }
257  //$qsql= "select $selectfields "."from $table where $dirid = any(fldrels) and "." $sqlcond ";
258 
259  }
260  } else {
261  //-------------------------------------------
262  // search familly
263  //-------------------------------------------
264  $docsearch = new QueryDb($dbaccess, "QueryDir");
265  $docsearch->AddQuery("dirid=$dirid");
266  $docsearch->AddQuery("qtype = 'M'");
267  $ldocsearch = $docsearch->Query(0, 0, "TABLE");
268  // for the moment only one query search
269  if (($docsearch->nb) > 0) {
270  switch ($ldocsearch[0]["qtype"]) {
271  case "M": // complex query
272  // $sqlM=$ldocsearch[0]["query"];
273 
274  /*
275  * @var DocSearch $fld
276  */
277  $fld = new_Doc($dbaccess, $dirid);
278  if ($trash) $fld->setValue("se_trash", $trash);
279  else $trash = $fld->getRawValue("se_trash");
280  $fld->folderRecursiveLevel = $folderRecursiveLevel;
281  $tsqlM = $fld->getQuery();
282  foreach ($tsqlM as $sqlM) {
283  if ($sqlM != false) {
284  if (!preg_match("/doctype[ ]*=[ ]*'Z'/", $sqlM, $reg)) {
285  if (($trash != "also") && ($trash != "only")) $sqlfilters[-3] = "doctype != 'Z'"; // no zombie if no trash
286  ksort($sqlfilters);
287  foreach ($sqlfilters as $kf => $sf) { // suppress doubles
288  if (strstr($sqlM, $sf)) {
289  unset($sqlfilters[$kf]);
290  }
291  }
292  if (count($sqlfilters) > 0) $sqlcond = " (" . implode(") and (", $sqlfilters) . ")";
293  else $sqlcond = "";
294  }
295  if ($fromid > 0) $sqlM = str_replace("from doc ", "from $only $table ", $sqlM);
296  if ($sqlcond) $qsql[] = $sqlM . " and " . $sqlcond;
297  else $qsql[] = $sqlM;
298  }
299  }
300  break;
301  }
302  } else {
303  return false; // no query avalaible
304 
305  }
306  }
307  }
308  if (is_array($qsql)) return $qsql;
309  return array(
310  $qsql
311  );
312  }
313  /**
314  * get possibles errors before request of getChildDoc
315  * @param string $dbaccess database specification
316  * @param array|int $dirid the array of id or single id of folder where search document
317  * @return array error codes
318  */
320  { // in a specific folder (0 => in all DB)
321  $terr = array();
322 
323  if ($dirid == 0) {
324  //-------------------------------------------
325  // search in all Db
326  //-------------------------------------------
327 
328  } else {
329  //-------------------------------------------
330  // in a specific folder
331  //-------------------------------------------
332  $fld = null;
333  if (!is_array($dirid)) {
334  $fld = new_Doc($dbaccess, $dirid);
335  if ($fld->getRawValue("se_phpfunc") != "") return $terr;
336  }
337 
338  if ((is_array($dirid)) || ($fld->defDoctype != 'S')) {
339  } else {
340  //-------------------------------------------
341  // search familly
342  //-------------------------------------------
343 
344  /*
345  * @var int $dirid
346  */
347  $docsearch = new QueryDb($dbaccess, "QueryDir");
348  $docsearch->AddQuery("dirid=$dirid");
349 
350  $docsearch->AddQuery("qtype = 'M'");
351  $ldocsearch = $docsearch->Query(0, 0, "TABLE");
352  // for the moment only one query search
353  if (($docsearch->nb) > 0) {
354  switch ($ldocsearch[0]["qtype"]) {
355  case "M": // complex query
356 
357  /*
358  * @var DocSearch $fld
359  */
360  $fld = new_Doc($dbaccess, $dirid);
361  $tsqlM = $fld->getQuery();
362  foreach ($tsqlM as $sqlM) {
363 
364  if ($sqlM == false) $terr[$dirid] = _("uncomplete request"); // uncomplete
365 
366  }
367  break;
368  }
369  } else {
370  $terr[$dirid] = _("request not found"); // not found
371 
372  }
373  }
374  }
375  return $terr;
376  }
377  /**
378  * return array of documents
379  *
380  * @param string $dbaccess database specification
381  * @param array $dirid the array of id or single id of folder where search document
382  * @param string $start the start index
383  * @param string $slice the maximum number of returned document
384  * @param array $sqlfilters array of sql filter
385  * @param int $userid the current user id
386  * @param string $qtype LIST|TABLE the kind of return : list of object or list or values array
387  * @param int|string $fromid identifier of family document
388  * @param bool $distinct if true all revision of the document are returned else only latest
389  * @param string $orderby field order
390  * @param bool $latest if true only latest else all revision
391  * @param string $trash (no|only|also) search in trash or not
392  * @param null $debug
393  * @param int $folderRecursiveLevel
394  * @param string $join
395  * @param \SearchDoc $searchDoc the SearchDoc object when getChildDoc is used by a SearchDoc object
396  * @deprecated use {@link SearchDoc} instead
397  * @see SearchDoc
398  * @return array/Doc
399  */
400  function getChildDoc($dbaccess, $dirid, $start = "0", $slice = "ALL", $sqlfilters = array() , $userid = 1, $qtype = "LIST", $fromid = "", $distinct = false, $orderby = "title", $latest = true, $trash = "", &$debug = null, $folderRecursiveLevel = 2, $join = '', \SearchDoc & $searchDoc = null)
401  {
403  return internalGetDocCollection($dbaccess, $dirid, $start, $slice, $sqlfilters, $userid, $qtype, $fromid, $distinct, $orderby, $latest, $trash, $debug, $folderRecursiveLevel, $join, $searchDoc);
404  }
405  /**
406  * system only - used by core return array of documents
407  *
408  * @param string $dbaccess database specification
409  * @param array $dirid the array of id or single id of folder where search document
410  * @param string $start the start index
411  * @param string $slice the maximum number of returned document
412  * @param array $sqlfilters array of sql filter
413  * @param int $userid the current user id
414  * @param string $qtype LIST|TABLE the kind of return : list of object or list or values array
415  * @param int|string $fromid identifier of family document
416  * @param bool $distinct if false all revision of the document are returned else only latest
417  * @param string $orderby field order
418  * @param bool $latest if true only latest else all revision
419  * @param string $trash (no|only|also) search in trash or not
420  * @param bool $debug
421  * @param int $folderRecursiveLevel
422  * @param string $join
423  * @param \SearchDoc $searchDoc the SearchDoc object when getChildDoc is used by a SearchDoc object
424  * @internal use searchDoc to get document collection
425  * @see SearchDoc
426  * @return array
427  */
428  function internalGetDocCollection($dbaccess, $dirid, $start = "0", $slice = "ALL", $sqlfilters = array() , $userid = 1, $qtype = "LIST", $fromid = "", $distinct = false, $orderby = "title", $latest = true, $trash = "", &$debug = null, $folderRecursiveLevel = 2, $join = '', \SearchDoc & $searchDoc = null)
429  {
430  return _internalGetDocCollection(false, $dbaccess, $dirid, $start, $slice, $sqlfilters, $userid, $qtype, $fromid, $distinct, $orderby, $latest, $trash, $debug, $folderRecursiveLevel, $join, $searchDoc);
431  }
432  function _internalGetDocCollection($returnSqlOnly = false, $dbaccess, $dirid, $start = "0", $slice = "ALL", $sqlfilters = array() , $userid = 1, $qtype = "LIST", $fromid = "", $distinct = false, $orderby = "title", $latest = true, $trash = "", &$debug = null, $folderRecursiveLevel = 2, $join = '', \SearchDoc & $searchDoc = null)
433  {
434  // query to find child documents
435  if (($fromid != "") && (!is_numeric($fromid))) $fromid = getFamIdFromName($dbaccess, $fromid);
436  if ($fromid == 0) $fromid = "";
437  if (($fromid == "") && ($dirid != 0) && ($qtype == "TABLE")) {
438  /*
439  * @var DocCollection $fld
440  */
441  $fld = new_Doc($dbaccess, $dirid);
442 
443  if ($fld->fromid == getFamIdFromName($dbaccess, "SSEARCH")) {
444  /**
445  * @var \Dcp\Family\SSEARCH $fld
446  */
447  return $fld->getDocList($start, $slice, $qtype, $userid);
448  }
449 
450  if ($fld->defDoctype != 'S') {
451  // try optimize containt of folder
452  if (!$fld->hasSpecificFilters()) {
453  $td = getFldDoc($dbaccess, $dirid, $sqlfilters);
454  if (is_array($td)) return $td;
455  }
456  } else {
457  if ($fld->getRawValue("se_famid")) {
458  $fromid = $fld->getRawValue("se_famid");
459  $fdoc = new_Doc($dbaccess, abs($fromid) , true);
460  if (!is_object($fdoc) || !$fdoc->isAlive() || $fdoc->defDoctype != 'C') {
461  throw new \Dcp\Exception(sprintf(_('Family [%s] not found') , abs($fromid)));
462  }
463  unset($fdoc);
464  }
465  }
466  } elseif ($dirid != 0) {
467  $fld = new_Doc($dbaccess, $dirid);
468  if (($fld->defDoctype == 'S') && ($fld->getRawValue("se_famid"))) {
469  $fromid = $fld->getRawValue("se_famid");
470  $fdoc = new_Doc($dbaccess, abs($fromid) , true);
471  if (!is_object($fdoc) || !$fdoc->isAlive() || $fdoc->defDoctype != 'C') {
472  throw new \Dcp\Exception(sprintf(_('Family [%s] not found') , abs($fromid)));
473  }
474  unset($fdoc);
475  }
476  }
477  if ($trash == "only") $distinct = true;
478  // xdebug_var_dump(xdebug_get_function_stack());
479  if ($searchDoc) {
480  $tqsql = $searchDoc->getQueries();
481  } else {
482  $tqsql = getSqlSearchDoc($dbaccess, $dirid, $fromid, $sqlfilters, $distinct, $latest, $trash, false, $folderRecursiveLevel, $join);
483  }
484 
485  $tretdocs = array();
486  if ($tqsql) {
487  foreach ($tqsql as $k => & $qsql) {
488  if ($qsql == false) unset($tqsql[$k]);
489  }
490  $isgroup = (count($tqsql) > 1);
491  foreach ($tqsql as & $qsql) {
492  if ($fromid != - 1) { // not families
493  if ($fromid != 0) {
494  if (preg_match('/from\s+docread/', $qsql) || $isgroup) {
495  $fdoc = new DocRead($dbaccess);
496  } else {
497  $fdoc = createDoc($dbaccess, abs($fromid) , false, false);
498  if ($fdoc === false) {
499  throw new \Dcp\Exception(sprintf(_('Family [%s] not found') , abs($fromid)));
500  }
501  }
502  } else {
503  $fdoc = new DocRead($dbaccess);
504  }
505  $tsqlfields = null;
506  if ($searchDoc) {
507  $tsqlfields = $searchDoc->getReturnsFields();
508  }
509  if ($tsqlfields == null) {
510  $tsqlfields = array();
511  if (isset($fdoc->fields) && is_array($fdoc->fields)) {
512  $tsqlfields = array_merge($tsqlfields, $fdoc->fields);
513  }
514  if (isset($fdoc->sup_fields) && is_array($fdoc->sup_fields)) {
515  $tsqlfields = array_merge($tsqlfields, $fdoc->sup_fields);
516  }
517  }
518  $maintable = '';
519  if (!$join && preg_match('/from\s+([a-z0-9])*,/', $qsql)) {
520  $join = true;
521  }
522  if ($join) {
523  if (preg_match('/from\s+([a-z0-9]*)/', $qsql, $reg)) {
524  $maintable = $reg[1];
525  $if = 0;
526  if ($maintable) {
527  foreach ($tsqlfields as $kf => $vf) {
528  if ($if++ > 0) $tsqlfields[$kf] = $maintable . '.' . $vf;
529  }
530  }
531  }
532  }
533  $maintabledot = ($maintable) ? $maintable . '.' : '';
534  $sqlfields = implode(", ", $tsqlfields);
535  if ($userid > 1) { // control view privilege
536  // $qsql.= " and (${maintabledot}profid <= 0 or hasviewprivilege($userid, ${maintabledot}profid))";
537  $qsql.= sprintf(" and (%sviews && '%s')", $maintabledot, searchDoc::getUserViewVector($userid));
538  // no compute permission here, just test it
539  $qsql = str_replace("* from ", "$sqlfields from ", $qsql);
540  } else {
541 
542  $qsql = str_replace("* from ", "$sqlfields from ", $qsql);
543  }
544  if ((!$distinct) && strstr($qsql, "distinct")) $distinct = true;
545  if ($start == "") $start = "0";
546  if ($distinct) {
547  if ($join || $maintable) {
548  $qsql.= " ORDER BY $maintable.initid, $maintable.id desc";
549  } else {
550  $qsql.= " ORDER BY initid, id desc";
551  }
552  if (!$isgroup) $qsql.= " LIMIT $slice OFFSET $start";
553  } else {
554  if (($fromid == "") && $orderby == "") $orderby = "title";
555  elseif (substr($qsql, 0, 12) == "select doc.*") $orderby = "title";
556  if ($orderby == "" && (!$isgroup)) $qsql.= " LIMIT $slice OFFSET $start;";
557  else {
558  if ($searchDoc) {
559  $orderby = $searchDoc->orderby;
560  }
561  if (!$isgroup) {
562  if ($orderby != '') {
563  $qsql.= " ORDER BY $orderby LIMIT $slice OFFSET $start;";
564  } else {
565  $qsql.= " LIMIT $slice OFFSET $start;";
566  }
567  }
568  }
569  }
570  } else {
571  // families
572  if ($userid > 1) { // control view privilege
573  //$qsql.= " and (profid <= 0 or hasviewprivilege($userid, profid))";
574  $qsql.= sprintf(" and (views && '%s')", searchDoc::getUserViewVector($userid));
575  // and get permission
576  //$qsql = str_replace("* from ", "* ,getuperm($userid,profid) as uperm from ", $qsql);
577 
578  }
579  $qsql.= " ORDER BY $orderby LIMIT $slice OFFSET $start;";
580  }
581  if ($fromid != "") {
582  if ($fromid == - 1) {
583  include_once "FDL/Class.DocFam.php";
584  $fromid = "Fam";
585  } else {
586  $fromid = abs($fromid);
587  if ($fromid > 0) {
588  $GEN = getGen($dbaccess);
589  include_once "FDL$GEN/Class.Doc$fromid.php";
590  }
591  }
592  }
593  }
594  if (count($tqsql) > 0) {
595  if (count($tqsql) == 1) {
596  $usql = isset($tqsql[0]) ? $tqsql[0] : "";
597  $query = new QueryDb($dbaccess, "Doc$fromid");
598  } else {
599  $usql = '(' . implode($tqsql, ") union (") . ')';
600  if ($orderby) $usql.= " ORDER BY $orderby LIMIT $slice OFFSET $start;";
601  else $usql.= " LIMIT $slice OFFSET $start;";
602  $query = new QueryDb($dbaccess, "Doc");
603  }
604  if ($returnSqlOnly) {
605  /*
606  * Strip any "ORDER BY ..." trailing part and any trailing semi-colon
607  */
608  $usql = preg_replace('/\s+ORDER\s+BY\s+.*?$/i', '', $usql);
609  $usql = preg_replace('/;+\s*$/', '', $usql);
610  return $usql;
611  }
612  $mb = microtime();
613  $tableq = $query->Query(0, 0, $qtype, $usql);
614 
615  if ($query->nb > 0) {
616  if ($qtype == "ITEM") {
617  $tretdocs[] = $tableq;
618  } else $tretdocs = array_merge($tretdocs, $tableq);
619  }
620  // print "<HR><br><div style=\"border:red 1px inset;background-color:lightyellow;color:black\">".$query->LastQuery; print " - $qtype<B> [".$query->nb.']'.sprintf("%.03fs",microtime_diff(microtime(),$mb))."</B><b style='color:red'>".$query->basic_elem->msg_err."</b></div>";
621  if ($query->basic_elem->msg_err != "") {
622  addLogMsg($query->basic_elem->msg_err, 200);
623  addLogMsg(array(
624  "query" => $query->LastQuery,
625  "err" => $query->basic_elem->msg_err
626  ));
627  // print_r2(array_pop(debug_backtrace()));
628 
629  }
630  if ($debug !== null) {
631  $debug["count"] = $query->nb;
632  $debug["query"] = $query->LastQuery;
633  $debug["error"] = $query->basic_elem->msg_err;
634  $debug["delay"] = sprintf("%.03fs", microtime_diff(microtime() , $mb));
635  if (!empty($debug["log"])) {
636  addLogMsg($query->basic_elem->msg_err, 200);
637  addLogMsg($debug);
638  }
639  } elseif ($query->basic_elem->msg_err != "") {
640  $debug["query"] = $query->LastQuery;
641  $debug["error"] = $query->basic_elem->msg_err;
642  addLogMsg($debug);
643  }
644  } else {
645  if ($returnSqlOnly) {
646  return "";
647  }
648  }
649  } else {
650  if ($returnSqlOnly) {
651  return "";
652  }
653  }
654 
655  reset($tretdocs);
656 
657  return ($tretdocs);
658  }
659  /**
660  * optimization for getChildDoc
661  * @param int $limit if -1 no limit
662  * @param bool $reallylimit if false don't return false if limit is reached
663  */
664  function getFldDoc($dbaccess, $dirid, $sqlfilters = array() , $limit = 100, $reallylimit = true)
665  {
666 
667  if (is_array($dirid)) {
668  $sqlfld = GetSqlCond($dirid, "dirid", true);
669  } else {
670  $sqlfld = "fld.dirid=$dirid";
671  }
672 
673  $mc = microtime();
674 
675  $q = new QueryDb($dbaccess, "QueryDir");
676  $q->AddQuery($sqlfld);
677  $q->AddQuery("qtype='S'");
678 
679  if ($limit > 0) {
680  $tfld = $q->Query(0, $limit + 1, "TABLE");
681  // use always this mode because is more quickly
682  if (($reallylimit) && ($q->nb > $limit)) return false;
683  } else {
684  $tfld = $q->Query(0, $limit + 1, "TABLE");
685  }
686  $t = array();
687  if ($q->nb > 0) {
688  foreach ($tfld as $k => $v) {
689  $t[$v["childid"]] = getLatestTDoc($dbaccess, $v["childid"], $sqlfilters, ($v["doctype"] == "C") ? -1 : $v["fromid"]);
690  if ($t[$v["childid"]] == false) unset($t[$v["childid"]]);
691  elseif ($t[$v["childid"]]["archiveid"]) unset($t[$v["childid"]]);
692  else {
693  if ((getCurrentUser()->id != 1) && ($t[$v["childid"]]["uperm"] & (1 << POS_VIEW)) == 0) { // control view
694  unset($t[$v["childid"]]);
695  }
696  }
697  }
698  }
699  uasort($t, "sortbytitle");
700  // print "<HR><br><div style=\"border:red 1px inset;background-color:orange;color:black\">"; print " - getFldDoc $dirid [nbdoc:".count($tfld)."]<B>".microtime_diff(microtime(),$mc)."</B></div>";
701  return $t;
702  }
703  function sortbytitle($td1, $td2)
704  {
705  return strcasecmp($td1["title"], $td2["title"]);
706  }
707  /**
708  * optimization for getChildDoc in case of grouped searches
709  * not used
710  */
711  function getMSearchDoc($dbaccess, $dirid, $start = "0", $slice = "ALL", $sqlfilters = array() , $userid = 1, $qtype = "LIST", $fromid = "", $distinct = false, $orderby = "title", $latest = true)
712  {
713 
714  $sdoc = new_Doc($dbaccess, $dirid);
715 
716  $tidsearch = $sdoc->getMultipleRawValues("SEG_IDCOND");
717  $tdoc = array();
718  foreach ($tidsearch as $k => $v) {
719  $tdoc = array_merge(internalGetDocCollection($dbaccess, $v, $start, $slice, $sqlfilters, $userid, $qtype, $fromid, $distinct, $orderby, $latest) , $tdoc);
720  }
721  return $tdoc;
722  }
723  /**
724  * return array of documents
725  *
726  * based on {@see getChildDoc()} it return document with enum attribute condition
727  * return document which the $aid attribute has the value $kid
728  *
729  * @param string $dbaccess database specification
730  * @param string $famname internal name of family document
731  * @param string $aid the attribute identifier
732  * @param string $kid the key for enum value to search
733  * @param string $name additionnal filter on the title
734  * @param array $sqlfilters array of sql filter
735  * @param int $limit max document returned
736  * @param string $qtype LIST|TABLE the kind of return : list of object or list or values array
737  * @param int $userid the current user id
738  * @return array/Doc
739  */
740  function getKindDoc($dbaccess, $famname, $aid, $kid, $name = "", // filter on title
741  $sqlfilter = array() , $limit = 100, $qtype = "TABLE", $userid = 0)
742  {
743 
744  global $action;
745 
746  if ($userid == 0) $userid = $action->user->id;
747 
748  $famid = getFamIdFromName($dbaccess, $famname);
749  $fdoc = new_Doc($dbaccess, $famid);
750  // searches for all fathers kind
751 
752  /*
753  * @var NormalAttribute $a
754  */
755  $a = $fdoc->getAttribute($aid);
756  if ($a) {
757  $tkids = array();;
758  $enum = $a->getEnum();
759  foreach ($enum as $k => $v) {
760  if (in_array($kid, explode(".", $k))) {
761  $tkids[] = substr($k, strrpos("." . $k, '.'));
762  }
763  }
764 
765  if ($a->type == "enum") {
766  if ($a->repeat) {
767  $sqlfilter[] = "in_textlist($aid,'" . implode("') or in_textlist($aid,'", $tkids) . "')";
768  } else {
769  $sqlfilter[] = "$aid='" . implode("' or $aid='", $tkids) . "'";
770  }
771  }
772  }
773 
774  if ($name != "") $sqlfilter[] = "title ~* '$name'";
775 
776  return internalGetDocCollection($dbaccess, 0, 0, $limit, $sqlfilter, $userid, "TABLE", getFamIdFromName($dbaccess, $famname) , false, "title");
777  }
778  function sqlval2array($sqlvalue)
779  {
780  // return values in comprehensive structure
781  $rt = array();
782  if ($sqlvalue != "") {
783  $vals = explode("][", substr($sqlvalue, 1, -1));
784  foreach ($vals as $k1 => $v1) {
785  list($aname, $aval) = explode(";;", $v1);
786  $rt[$aname] = $aval;
787  }
788  }
789  return $rt;
790  }
791  /**
792  * query to find child directories (no recursive - only in the specified folder)
793  * @param string $dbaccess database specification
794  * @param int $dirid the id of folder where search subfolders
795  * @return array
796  */
798  {
799  $tableid = array();
800 
801  $tdir = internalGetDocCollection($dbaccess, $dirid, "0", "ALL", array() , $userid = 1, "TABLE", 2);
802 
803  foreach ($tdir as $k => $v) {
804  $tableid[] = $v["id"];
805  }
806 
807  return ($tableid);
808  }
809  // --------------------------------------------------------------------
810 
811  /**
812  * return array of subfolder id until sublevel 2 (RECURSIVE)
813  *
814  * @param string $dbaccess database specification
815  * @param int $dirid the id of folder where search subfolders
816  * @param array $rchilds use for recursion (dont't set anything)
817  * @param int $level use for recursion (dont't set anything)
818  * @param int $levelmax max recursion level (default 2)
819  * @return array/int
820  * @see getChildDir()
821  */
822  function getRChildDirId($dbaccess, $dirid, $rchilds = array() , $level = 0, $levelmax = 2)
823  {
824  global $action;
825 
826  if ($level > $levelmax) {
827  // $action->addWarningMsg("getRChildDirId::Max dir deep [$level levels] reached");
828  return ($rchilds);
829  }
830 
831  $rchilds[] = $dirid;
832 
833  $childs = getChildDirId($dbaccess, $dirid);
834 
835  if (count($childs) > 0) {
836  foreach ($childs as $k => $v) {
837  if (!in_array($v, $rchilds)) {
838  $t = array_merge($rchilds, getRChildDirId($dbaccess, $v, $rchilds, $level + 1, $levelmax));
839  if (is_array($t)) $rchilds = array_values(array_unique($t));
840  }
841  }
842  }
843  return ($rchilds);
844  }
845 
847  {
848  // return true id docid is in dirid
849  $query = new QueryDb($dbaccess, "QueryDir");
850  $query->AddQuery("dirid=" . $dirid);
851  $query->AddQuery("childid=" . $docid);
852 
853  $query->Query(0, 0, "TABLE");
854  return ($query->nb > 0);
855  }
856  /**
857  * return true if dirid has one or more child dir
858  * @param string $dbaccess database specification
859  * @param int $dirid folder id
860  * @return bool
861  */
862  function hasChildFld($dbaccess, $dirid, $issearch = false)
863  {
864 
865  if ($issearch) {
866  $query = new QueryDb($dbaccess, "QueryDir");
867  $query->AddQuery("qtype='M'");
868  $query->AddQuery("dirid=$dirid");
869  $list = $query->Query(0, 1, "TABLE");
870 
871  if ($list) {
872  $oquery = $list[0]["query"];
873  if (preg_match("/select (.+) from (.+)/", $oquery, $reg)) {
874  if (preg_match("/doctype( *)=/", $reg[2], $treg)) return false; // do not test if special doctype searches
875  $nq = sprintf("select count(%s) from %s and ((doctype='D')or(doctype='S')) limit 1", $reg[1], $reg[2]);
876  try {
877  $count = $query->Query(0, 0, "TABLE", $nq);
878  if (($query->nb > 0) && (is_array($count)) && ($count[0]["count"] > 0)) return true;
879  }
880  catch(Exception $e) {
881  return false;
882  }
883  }
884  }
885  } else {
886  $qfld = new QueryDb($dbaccess, "QueryDir");
887  $qfld->AddQuery("qtype='S'");
888  $qfld->AddQuery(sprintf("fld.dirid=%d", $dirid));
889  $qfld->AddQuery("doctype='D' or doctype='S'");
890  $lq = $qfld->Query(0, 1, "TABLE");
891 
892  $qids = array();
893  if (!is_array($lq)) return false;
894  return ($qfld->nb > 0);
895  }
896  return false;
897  }
898  /**
899  * return families with the same usefor
900  * @param string $dbaccess database specification
901  * @param int $userid identifier of the user
902  * @param int $classid the reference family to find by usefor (if 0 all families) can be an array of id
903  * @param string $qtype [TABLE|LIST] use TABLE if you can because LIST cost too many memory
904  * @return array the families
905  */
906  function GetClassesDoc($dbaccess, $userid, $classid = 0, $qtype = "LIST", $extraFilters = array())
907  // --------------------------------------------------------------------
908 
909  {
910  $query = new QueryDb($dbaccess, "DocFam");
911 
912  $query->AddQuery("doctype='C'");
913 
914  if (is_array($classid)) {
915  $use = array();
916  foreach ($classid as $fid) {
917  $tcdoc = getTDoc($dbaccess, $fid);
918  $use[] = $tcdoc["usefor"];
919  }
920  $query->AddQuery(GetSqlCond($use, "usefor"));
921  } else if ($classid > 0) {
922  $cdoc = new DocFam($dbaccess, $classid);
923  $query->AddQuery("usefor = '" . $cdoc->usefor . "'");
924  }
925  // if ($userid > 1) $query->AddQuery("hasviewprivilege(" . $userid . ",docfam.profid)");
926  if ($userid > 1) $query->AddQuery(sprintf("views && '%s'", searchDoc::getUserViewVector($userid)));
927  if (is_array($extraFilters) && count($extraFilters) > 0) {
928  foreach ($extraFilters as $filter) {
929  $query->AddQuery($filter);
930  }
931  }
932  if ($qtype == "TABLE") {
933  $t = $query->Query(0, 0, $qtype);
934  foreach ($t as $k => $v) {
935  $t[$k]["title"] = ucfirst(getFamTitle($v));
936  }
937  usort($t, "cmpfamtitle");
938  return $t;
939  } else {
940  $query->order_by = "lower(title)";
941  return $query->Query(0, 0, $qtype);
942  }
943  }
944  /**
945  * Return non-system families
946  *
947  * @param string $dbaccess database specification
948  * @param int $userid identifier of the user
949  * @param string $qtype result format "TABLE" | "LIST" (Avoid using "LIST" as it's memory hungry)(default is "TABLE")
950  * @return array the families
951  */
952  function getNonSystemFamilies($dbaccess, $userid, $qtype = "TABLE")
953  {
954  return GetClassesDoc($dbaccess, $userid, 0, $qtype, array(
955  "usefor !~ '^S'"
956  ));
957  }
958  /**
959  * Return system families
960  *
961  * @param string $dbaccess database specification
962  * @param int $userid identifier of the user
963  * @param string $qtype result format "TABLE" | "LIST" (Avoid using "LIST" as it's memory hungry)(default is "TABLE")
964  * @return array the families
965  */
966  function getSystemFamilies($dbaccess, $userid, $qtype = "TABLE")
967  {
968  return GetClassesDoc($dbaccess, $userid, 0, $qtype, array(
969  "usefor ~ '^S'"
970  ));
971  }
972  function cmpfamtitle($a, $b)
973  {
974  return strcasecmp(unaccent($a["title"]) , unaccent($b["title"]));
975  }
976  /**
977  * return array of possible profil for profile type
978  *
979  * @param string $dbaccess database specification
980  * @param int $famid the id of family document
981  * @return array/Doc
982  * @see getChildDir()
983  */
984  function GetProfileDoc($dbaccess, $docid, $defProfFamId = "")
985  {
986  global $action;
987  $filter = array();
988 
990  $chdoc = $doc->GetFromDoc();
991  if ($defProfFamId == "") $defProfFamId = $doc->defProfFamId;
992 
993  $cond = GetSqlCond($chdoc, "dpdoc_famid");
994  if ($cond != "") $filter[] = "dpdoc_famid is null or (" . GetSqlCond($chdoc, "dpdoc_famid") . ")";
995  else $filter[] = "dpdoc_famid is null";
996  $filter[] = "fromid=" . $defProfFamId;
997  $tcv = internalGetDocCollection($dbaccess, 0, 0, "ALL", $filter, $action->user->id, "TABLE", $defProfFamId);
998 
999  return $tcv;
1000  }
1001  /**
1002  * get array of family id that the user can create interactivaly
1003  *
1004  * @param string $dbaccess database specification
1005  * @param int $uid user identifier
1006  * @param array $tfid restriction of this set of family id
1007  * @return array of family identificators
1008  */
1009  function getFamilyCreationIds($dbaccess, $uid, $tfid = array())
1010  {
1011 
1012  $query = new QueryDb($dbaccess, "DocFam");
1013  if (count($tfid) > 0) {
1014  $query->AddQuery(GetSqlCond($tfid, "id"));
1015  }
1016  if ($uid != 1) {
1017  $perm = (2 << (POS_CREATE - 1)) + (2 << (POS_ICREATE - 1));
1018  $query->AddQuery(sprintf("((profid = 0) OR hasaprivilege('%s', profid, %d))", DocPerm::getMemberOfVector($uid) , $perm));
1019  }
1020  $l = $query->Query(0, 0, "TABLE");
1021 
1022  $lid = array();
1023  if ($query->nb > 0) {
1024  foreach ($l as $k => $v) {
1025  $lid[] = $v["id"];
1026  }
1027  }
1028  return $lid;
1029  }
1030  /**
1031  * get array of document values from array od document id
1032  * @param string $dbaccess database specification
1033  */
1034  function getDocsFromIds($dbaccess, $ids, $userid = 0)
1035  {
1036  $tdoc = array();
1037  foreach ($ids as $k => $id) {
1038  $tdoc1 = getTDoc($dbaccess, $id);
1039  if ((($userid == 1) || controlTdoc($tdoc1, "view")) && ($tdoc1["doctype"] != 'Z')) $tdoc[$id] = $tdoc1;
1040  }
1041  return $tdoc;
1042  }
1043  /**
1044  * get array of document values from array od document id
1045  * @param string $dbaccess database specification
1046  */
1047  function getLatestDocsFromIds($dbaccess, $ids, $userid = 0)
1048  {
1049  $tdoc = array();
1050  foreach ($ids as $k => $id) {
1051  $tdoc1 = getLatestTDoc($dbaccess, $id);
1052  if (($tdoc1 !== false) && (($userid == 1) || controlTdoc($tdoc1, "view")) && ($tdoc1["doctype"] != 'Z')) $tdoc[$id] = $tdoc1;
1053  }
1054  return $tdoc;
1055  }
1056  /**
1057  * get array of document values from array od document id
1058  * @param string $dbaccess database specification
1059  * @param string $ids array of init id -only initid-
1060  * @param string $userid the user where search visibility
1061  */
1062  function getVisibleDocsFromIds($dbaccess, $ids, $userid)
1063  {
1064 
1065  $query = new QueryDb($dbaccess, "DocRead");
1066  $query->AddQuery("initid in (" . implode(",", $ids) . ')');
1067  $query->AddQuery("locked != -1");
1068  // if ($userid > 1) $query->AddQuery("hasviewprivilege(" . $userid . ",profid)");
1069  if ($userid > 1) $query->AddQuery(sprintf("views && '%s'", searchDoc::getUserViewVector($userid)));
1070 
1071  $tdoc = $query->Query(0, 0, "TABLE");
1072 
1073  return $tdoc;
1074  }
1075  /**
1076  * return true for optimization select
1077  * @param string $dbaccess database specification
1078  * @param int $id identifier of the document family
1079  *
1080  * @return int false if error occured
1081  */
1083  {
1084  if (!is_numeric($id)) $id = getFamIdFromName($dbaccess, $id);
1085  $id = abs(intval($id));
1086  if ($id == 0) return false;
1087  $dbid = getDbid($dbaccess);
1088  $fromid = false;
1089  $result = pg_query($dbid, "select id from docfam where id=$id and usedocread=1");
1090  if (pg_numrows($result) > 0) {
1091  $result = pg_query($dbid, "select fromid from docfam where fromid=$id;");
1092  if (pg_numrows($result) > 0) {
1093  return true;
1094  }
1095  }
1096 
1097  return false;
1098  }
1099 
getSystemFamilies($dbaccess, $userid, $qtype="TABLE")
Definition: Lib.Dir.php:966
static getMemberOfVector($uid=0, $strict=false)
$tdoc
if($_POST["login"]=="")
Definition: chgpasswd.php:19
getTDoc($dbaccess, $id, $sqlfilters=array(), $result=array())
global $action
getMSearchDoc($dbaccess, $dirid, $start="0", $slice="ALL", $sqlfilters=array(), $userid=1, $qtype="LIST", $fromid="", $distinct=false, $orderby="title", $latest=true)
Definition: Lib.Dir.php:711
getSqlSearchDoc($dbaccess, $dirid, $fromid, $sqlfilters=array(), $distinct=false, $latest=true, $trash="", $simplesearch=false, $folderRecursiveLevel=2, $join= '', $only="")
Definition: Lib.Dir.php:108
print< H1 > Check Database< i > $dbaccess</i ></H1 > $a
Definition: checklist.php:45
cmpfamtitle($a, $b)
Definition: Lib.Dir.php:972
getDocsFromIds($dbaccess, $ids, $userid=0)
Definition: Lib.Dir.php:1034
familyNeedDocread($dbaccess, $id)
Definition: Lib.Dir.php:1082
getNonSystemFamilies($dbaccess, $userid, $qtype="TABLE")
Definition: Lib.Dir.php:952
addWarningMsg($msg)
Definition: Lib.Common.php:95
const POS_CREATE
getFldDoc($dbaccess, $dirid, $sqlfilters=array(), $limit=100, $reallylimit=true)
Definition: Lib.Dir.php:664
controlTdoc(&$tdoc, $aclname)
getLatestDocsFromIds($dbaccess, $ids, $userid=0)
Definition: Lib.Dir.php:1047
isInDir($dbaccess, $dirid, $docid)
Definition: Lib.Dir.php:846
$d
Definition: dav.php:77
getLatestTDoc($dbaccess, $initid, $sqlfilters=array(), $fromid=false)
$docid
Definition: cleanFamily.php:13
GetClassesDoc($dbaccess, $userid, $classid=0, $qtype="LIST", $extraFilters=array())
Definition: Lib.Dir.php:906
if($real||$full) else
getChildDocError($dbaccess, $dirid)
Definition: Lib.Dir.php:319
getFirstDir($dbaccess)
Definition: Lib.Dir.php:22
getChildDir($dbaccess, $userid, $dirid, $notfldsearch=false, $restype="LIST")
Definition: Lib.Dir.php:38
hasChildFld($dbaccess, $dirid, $issearch=false)
Definition: Lib.Dir.php:862
getFamTitle(&$tdoc)
getDbid($dbaccess)
Definition: Lib.Common.php:353
createDoc($dbaccess, $fromid, $control=true, $defaultvalues=true, $temporary=false)
microtime_diff($a, $b)
Definition: Lib.Common.php:302
isSimpleFilter($sqlfilters)
Definition: Lib.Dir.php:68
getChildDirId($dbaccess, $dirid)
Definition: Lib.Dir.php:797
internalGetDocCollection($dbaccess, $dirid, $start="0", $slice="ALL", $sqlfilters=array(), $userid=1, $qtype="LIST", $fromid="", $distinct=false, $orderby="title", $latest=true, $trash="", &$debug=null, $folderRecursiveLevel=2, $join= '',\SearchDoc &$searchDoc=null)
Definition: Lib.Dir.php:428
getFamilyCreationIds($dbaccess, $uid, $tfid=array())
Definition: Lib.Dir.php:1009
getFamIdFromName($dbaccess, $name)
getKindDoc($dbaccess, $famname, $aid, $kid, $name="", $sqlfilter=array(), $limit=100, $qtype="TABLE", $userid=0)
Definition: Lib.Dir.php:740
getRChildDirId($dbaccess, $dirid, $rchilds=array(), $level=0, $levelmax=2)
Definition: Lib.Dir.php:822
getChildDoc($dbaccess, $dirid, $start="0", $slice="ALL", $sqlfilters=array(), $userid=1, $qtype="LIST", $fromid="", $distinct=false, $orderby="title", $latest=true, $trash="", &$debug=null, $folderRecursiveLevel=2, $join= '',\SearchDoc &$searchDoc=null)
Definition: Lib.Dir.php:400
deprecatedFunction($msg= '')
Definition: Lib.Common.php:86
getCurrentUser()
Definition: Lib.Common.php:250
new_Doc($dbaccess, $id= '', $latest=false)
GetSqlCond($Table, $column, $integer=false)
$vf
Definition: geticon.php:28
sortbytitle($td1, $td2)
Definition: Lib.Dir.php:703
$dbaccess
Definition: checkVault.php:17
unaccent($s)
Definition: Lib.Util.php:569
if(($docid!==0)&&(!is_numeric($docid))) $query
GetProfileDoc($dbaccess, $docid, $defProfFamId="")
Definition: Lib.Dir.php:984
const POS_VIEW
const POS_ICREATE
getVisibleDocsFromIds($dbaccess, $ids, $userid)
Definition: Lib.Dir.php:1062
sqlval2array($sqlvalue)
Definition: Lib.Dir.php:778
$latest
getGen($dbaccess)
Definition: Lib.Util.php:27
← centre documentaire © anakeen