Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
fusers_list.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  * display users and groups list
9  *
10  * @author Anakeen 2000
11  * @version $Id: fusers_list.php,v 1.12 2008/08/14 09:59:14 eric Exp $
12  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
13  * @package FDL
14  * @subpackage FUSERS
15  */
16 /**
17  */
18 
19 include_once ("FDL/Lib.Dir.php");
20 function fusers_list(&$action)
21 {
22 
23  $action->parent->AddJsRef($action->GetParam("CORE_PUBURL") . "/FDL/Layout/common.js");
24  $action->parent->AddJsRef($action->GetParam("CORE_JSURL") . "/subwindow.js");
25 
26  $action->parent->AddJsRef($action->GetParam("CORE_JSURL") . "/geometry.js");
27  $action->parent->AddJsRef($action->GetParam("CORE_JSURL") . "/AnchorPosition.js");
28 
29  $dbaccess = $action->GetParam("FREEDOM_DB");
30  // create group tree
31  $action->parent->AddJsRef($action->GetParam("CORE_PUBURL") . "/FDL/Layout/mktree.js");
32 
33  $action->lay->set("isMaster", $action->parent->Haspermission("FUSERS_MASTER"));
34 
35  $user = new User();
36  //$ugroup=$user->GetGroupsId();
37  $q2 = new queryDb("", "User");
38  $groups = $q2->Query(0, 0, "TABLE", "select users.*, groups.idgroup, domain.name as domain from users, groups, domain where users.id = groups.iduser and users.iddomain=domain.iddomain and users.isgroup='Y'");
39 
40  $q2 = new queryDb("", "User");
41  $mgroups = $q2->Query(0, 0, "TABLE", "select users.*, domain.name as domain from users,domain where users.iddomain=domain.iddomain and isgroup='Y' and id not in (select iduser from groups)");
42 
43  if ($groups) {
44  foreach ($groups as $k => $v) {
45  $groupuniq[$v["id"]] = $v;
46  $groupuniq[$v["id"]]["checkbox"] = "";
47  //if (in_array($v["id"],$ugroup)) $groupuniq[$v["id"]]["checkbox"]="checked";
48 
49  }
50  }
51  if (!$groups) $groups = array();
52  if ($mgroups) {
54  uasort($mgroups, "cmpgroup");
55  foreach ($mgroups as $k => $v) {
56  $cgroup = fusers_getChildsGroup($v["id"], $groups);
57  $tgroup[$k] = $v;
58  $tgroup[$k]["SUBUL"] = $cgroup;
59  $fid = $v["fid"];
60  if ($fid) {
61  $tdoc = getTDoc($dbaccess, $fid);
62  $icon = $doc->getIcon($tdoc["icon"]);
63  $tgroup[$k]["icon"] = $icon;
64  } else {
65  $tgroup[$k]["icon"] = "Images/igroup.gif";
66  }
67  $groupuniq[$v["id"]] = $v;
68  $groupuniq[$v["id"]]["checkbox"] = "";
69  //if (in_array($v["id"],$ugroup)) $groupuniq[$v["id"]]["checkbox"]="checked";
70 
71  }
72  }
73  $action->lay->setBlockData("LI", $tgroup);
74  $action->lay->setBlockData("SELECTGROUP", $groupuniq);
75 
76  $action->lay->set("expand", (count($groups) < 30));
77  // add button to change categories
78  $tcf = array();
79  foreach (array(
80  "IUSER",
81  "IGROUP"
82  ) as $fid) {
83 
84  $fdoc = new_doc($dbaccess, $fid);
85 
86  $lattr = $fdoc->getNormalAttributes();
87  foreach ($lattr as $k => $a) {
88  if ((($a->type == "enum") || ($a->type == "enumlist")) && (($a->phpfile == "") || ($a->phpfile == "-")) && ($a->getOption("system") != "yes")) {
89 
90  $tcf[] = array(
91  "label" => $a->getLabel() ,
92  "famid" => $a->docid,
93  "ftitle" => $fdoc->getTitle($a->docid) ,
94  "kindid" => $a->id
95  );
96  }
97  }
98  }
99  $action->lay->setBlockData("CATG", $tcf);
100  $filter[] = "grp_isrefreshed = '0'";
101  $tdoc = getChildDoc($dbaccess, 0, 0, "ALL", $filter, 1, "TABLE", "IGROUP");
102  $ngr = count($tdoc);
103  if ($ngr > 0) $action->lay->set("textgroup", sprintf(_("<b>%d group(s) to refresh</b>") , $ngr));
104  else $action->lay->set("textgroup", sprintf(_("No need to refresh group")));
105 }
106 /**
107  * internal function use for choosegroup
108  * use to compute displayed group tree
109  */
110 function fusers_getChildsGroup($id, $groups)
111 {
112  static $dbaccess;
113  static $doc;
114  if (!$dbaccess) $dbaccess = getParam("FREEDOM_DB");
115  if (!$doc) $doc = createTmpDoc($dbaccess, 1);
116  $tlay = array();
117  foreach ($groups as $k => $v) {
118  if ($v["idgroup"] == $id) {
119  $tlay[$k] = $v;
120  $tlay[$k]["SUBUL"] = fusers_getChildsGroup($v["id"], $groups);
121  $fid = $v["fid"];
122  if ($fid) {
123  $tdoc = getTDoc($dbaccess, $fid);
124  $icon = $doc->getIcon($tdoc["icon"]);
125  $tlay[$k]["icon"] = $icon;
126  } else {
127  $tlay[$k]["icon"] = "Images/igroup.gif";
128  }
129  }
130  }
131 
132  if (count($tlay) == 0) return "";
133  global $action;
134  $lay = new Layout("FUSERS/Layout/fusers_ligroup.xml", $action);
135 
136  uasort($tlay, "cmpgroup");
137  $lay->setBlockData("LI", $tlay);
138  return $lay->gen();
139 }
140 function cmpgroup($a, $b)
141 {
142  return strcasecmp($a['lastname'], $b['lastname']);
143 }
144 ?>
← centre documentaire © anakeen - published under CC License - Dynacase