Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
faddbook_speedsearch.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  * Freedom Address Book
9  *
10  * @author Anakeen 2000
11  * @version $Id: faddbook_speedsearch.php,v 1.8 2007/09/28 15:24:27 eric Exp $
12  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
13  * @package FDL
14  * @subpackage USERCARD
15  */
16 /**
17  */
18 
19 include_once ("FDL/freedom_util.php");
20 include_once ("FDL/Lib.Dir.php");
21 
23 {
24  $dbaccess = $action->getParam("FREEDOM_DB");
25  $action->parent->AddJsRef($action->GetParam("CORE_JSURL") . "/subwindow.js");
26 
27  $ws = (GetHttpVars("sallf", "") == "on" ? 1 : 0);
28  $vtext = GetHttpVars("vtext", "");
29  if ($vtext == "") {
30  $action->lay->set("vtext", _("search"));
31  $action->lay->set("first", "true");
32  } else {
33  $action->lay->set("vtext", $vtext);
34  $action->lay->set("first", "false");
35  }
36 
37  $searchuser = GetHttpVars("vsuser", 1);
38  $action->lay->set("vsuser", $searchuser);
39  $action->lay->set("USEL", ($searchuser == 1 ? true : false));
40  $searchsoc = GetHttpVars("ssoc", 0);
41  $action->lay->set("ssoc", $searchsoc);
42  $action->lay->set("SOCSEL", ($searchsoc == 1 ? true : false));
43 
44  $sfam1 = GetHttpVars("dfam", $action->getParam("USERCARD_FIRSTFAM"));
45  $action->lay->set("dfam", $sfam1);
46  $fam1 = new_Doc($dbaccess, $sfam1);
47  $action->lay->set("icon1", $fam1->getIcon());
48 
49  $sfam2 = $action->getParam("USERCARD_SECONDFAM");
50  if ($sfam2) {
51  $fam2 = new_Doc($dbaccess, $sfam2);
52  $action->lay->set("icon2", $fam2->getIcon());
53  }
54  $action->lay->set("Result", false);
55  $action->lay->set("bCount", false);
56  $action->lay->set("Count", "-");
57 
58  $searchfam = array();
59  if ($searchuser == 1) $searchfam[] = $sfam1;
60  if ($sfam2 && ($searchsoc == 1)) $searchfam[] = $sfam2;
61 
62  if (count($searchfam) == 0 || $vtext == "") return;
63 
64  $filter = array();
65  if ($ws) $filter[] = "(svalues ~* '" . $vtext . "')";
66  else $filter[] = "(title ~* '" . $vtext . "')";
67  $cu = array();
68  foreach ($searchfam as $ks => $vs) {
69  $rq = getChildDoc($dbaccess, 0, 0, 25, $filter, $action->user->id, "TABLE", $vs, true, "title");
70  foreach ($rq as $k => $v) {
71  $vo = getDocObject($dbaccess, $v);
72  $pzabstract = isset($vo->faddbook_resume) ? $vo->faddbook_resume : "FDL:VIEWTHUMBCARD";
73  $pzcard = (isset($vo->faddbook_card) ? $vo->faddbook_card : $vo->defaultview);
74  $cu[] = array(
75  "id" => $vo->id,
76  "title" => $vo->title,
77  "fabzone" => $pzcard,
78  "resume" => $vo->viewdoc($pzabstract)
79  );
80  }
81  }
82  if (count($cu) > 0) {
83  $action->lay->set("Result", true);
84  $action->lay->set("bCount", true);
85  $action->lay->set("Count", count($cu));
86  }
87  usort($cu, "sortmya");
88  $action->lay->setBlockData("Contacts", $cu);
89 }
90 function sortmya($a, $b)
91 {
92  return strcmp($a["title"], $b["title"]);
93 }
94 ?>
← centre documentaire © anakeen - published under CC License - Dynacase