ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilUserTableGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./Services/Table/classes/class.ilTable2GUI.php");
5 
16 {
17 
21  function __construct($a_parent_obj, $a_parent_cmd)
22  {
23  global $ilCtrl, $lng, $ilAccess, $lng, $rbacsystem;
24 
25  $this->setId("user");
26 
27  parent::__construct($a_parent_obj, $a_parent_cmd);
28 // $this->setTitle($this->lng->txt("users"));
29 
30  $this->addColumn("", "", "1", true);
31  $this->addColumn($this->lng->txt("login"), "login", "17%");
32  $this->addColumn($this->lng->txt("firstname"), "firstname", "17%");
33  $this->addColumn($this->lng->txt("lastname"), "lastname", "17%");
34  $this->addColumn($this->lng->txt("email"), "email", "17%");
35  $this->addColumn($this->lng->txt("access_until"), "access_until", "17%");
36  $this->addColumn($this->lng->txt("last_login"), "last_login", "17%");
37 
38  $this->setExternalSorting(true);
39  $this->setExternalSegmentation(true);
40  $this->setEnableHeader(true);
41  $this->setFormAction($ilCtrl->getFormAction($this->parent_obj, "applyFilter"));
42  $this->setRowTemplate("tpl.user_list_row.html", "Services/User");
43  //$this->disable("footer");
44  $this->setEnableTitle(true);
45  $this->initFilter();
46  $this->setFilterCommand("applyFilter");
47  $this->setDefaultOrderField("login");
48  $this->setDefaultOrderDirection("asc");
49 
50  $this->setSelectAllCheckbox("id[]");
51  $this->setTopCommands(true);
52 
53  if ($rbacsystem->checkAccess('delete', $a_parent_obj->object->getRefId()))
54  {
55  $this->addMultiCommand("deleteUsers", $lng->txt("delete"));
56  }
57  $this->addMultiCommand("activateUsers", $lng->txt("activate"));
58  $this->addMultiCommand("deactivateUsers", $lng->txt("deactivate"));
59  $this->addMultiCommand("restrictAccess", $lng->txt("accessRestrict"));
60  $this->addMultiCommand("freeAccess", $lng->txt("accessFree"));
61  $this->addMultiCommand("exportUsers", $lng->txt("export"));
62  $this->addCommandButton("importUserForm", $lng->txt("import_users"));
63  $this->addCommandButton("addUser", $lng->txt("usr_add"));
64 
65  $this->getItems();
66  }
67 
71  function getItems()
72  {
73  global $lng;
74 
75  $this->determineOffsetAndOrder();
76 
77  include_once("./Services/User/classes/class.ilUserQuery.php");
78 
79  $usr_data = ilUserQuery::getUserListData(
84  $this->filter["query"],
85  $this->filter["activation"],
86  $this->filter["last_login"],
87  $this->filter["limited_access"],
88  $this->filter["no_courses"],
89  $this->filter["course_group"],
90  $this->filter["global_role"]
91  );
92 
93  if (count($usr_data["set"]) == 0 && $this->getOffset() > 0)
94  {
95  $this->resetOffset();
96  $usr_data = ilUserQuery::getUserListData(
100  ilUtil::stripSlashes($this->getLimit()),
101  $this->filter["query"],
102  $this->filter["activation"],
103  $this->filter["last_login"],
104  $this->filter["limited_access"],
105  $this->filter["no_courses"],
106  $this->filter["course_group"],
107  $this->filter["global_role"]
108  );
109  }
110 
111  foreach ($usr_data["set"] as $k => $user)
112  {
113  $current_time = time();
114  if ($user['active'])
115  {
116  if ($user["time_limit_unlimited"])
117  {
118  $txt_access = $lng->txt("access_unlimited");
119  $usr_data["set"][$k]["access_class"] = "smallgreen";
120  }
121  elseif ($user["time_limit_until"] < $current_time)
122  {
123  $txt_access = $lng->txt("access_expired");
124  $usr_data["set"][$k]["access_class"] = "smallred";
125  }
126  else
127  {
128  $txt_access = ilDatePresentation::formatDate(new ilDateTime($user["time_limit_until"],IL_CAL_UNIX));
129  $usr_data["set"][$k]["access_class"] = "small";
130  }
131  }
132  else
133  {
134  $txt_access = $lng->txt("inactive");
135  $usr_data["set"][$k]["access_class"] = "smallred";
136  }
137  $usr_data["set"][$k]["access_until"] = $txt_access;
138  }
139 
140  $this->setMaxCount($usr_data["cnt"]);
141  $this->setData($usr_data["set"]);
142  }
143 
144 
148  function initFilter()
149  {
150  global $lng, $rbacreview, $ilUser;
151 
152  // title/description
153  include_once("./Services/Form/classes/class.ilTextInputGUI.php");
154  $ti = new ilTextInputGUI($lng->txt("login")."/".$lng->txt("email")."/".$lng->txt("name"), "query");
155  $ti->setMaxLength(64);
156  $ti->setSize(20);
157  $ti->setSubmitFormOnEnter(true);
158  $this->addFilterItem($ti);
159  $ti->readFromSession();
160  $this->filter["query"] = $ti->getValue();
161 
162  // activation
163  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
164  $options = array(
165  "" => $lng->txt("user_all"),
166  "active" => $lng->txt("active"),
167  "inactive" => $lng->txt("inactive"),
168  );
169  $si = new ilSelectInputGUI($this->lng->txt("user_activation"), "activation");
170  $si->setOptions($options);
171  $this->addFilterItem($si);
172  $si->readFromSession();
173  $this->filter["activation"] = $si->getValue();
174 
175  // limited access
176  include_once("./Services/Form/classes/class.ilCheckboxInputGUI.php");
177  $cb = new ilCheckboxInputGUI($this->lng->txt("user_limited_access"), "limited_access");
178  $this->addFilterItem($cb);
179  $cb->readFromSession();
180  $this->filter["limited_access"] = $cb->getChecked();
181 
182  // last login
183  include_once("./Services/Form/classes/class.ilDateTimeInputGUI.php");
184  $di = new ilDateTimeInputGUI($this->lng->txt("user_last_login_before"), "last_login");
185  $default_date = new ilDateTime(time(),IL_CAL_UNIX);
186  $default_date->increment(IL_CAL_DAY, 1);
187  $di->setDate($default_date);
188  $this->addFilterItem($di);
189  $di->readFromSession();
190  $this->filter["last_login"] = $di->getDate();
191 
192  // no assigned courses
193  include_once("./Services/Form/classes/class.ilCheckboxInputGUI.php");
194  $cb = new ilCheckboxInputGUI($this->lng->txt("user_no_courses"), "no_courses");
195  $this->addFilterItem($cb);
196  $cb->readFromSession();
197  $this->filter["no_courses"] = $cb->getChecked();
198 
199  // course/group members
200  include_once("./Services/Form/classes/class.ilRepositorySelectorInputGUI.php");
201  $rs = new ilRepositorySelectorInputGUI($lng->txt("user_member_of_course_group"), "course_group");
202  $rs->setSelectText($lng->txt("user_select_course_group"));
203  $rs->setHeaderMessage($lng->txt("user_please_select_course_group"));
204  $rs->setClickableTypes(array("crs", "grp"));
205  $this->addFilterItem($rs);
206  $rs->readFromSession();
207  $this->filter["course_group"] = $rs->getValue();
208 
209  // global roles
210  $options = array(
211  "" => $lng->txt("user_any"),
212  );
213  $roles = $rbacreview->getRolesByFilter(2, $ilUser->getId());
214  foreach ($roles as $role)
215  {
216  $options[$role["rol_id"]] = $role["title"];
217  }
218  $si = new ilSelectInputGUI($this->lng->txt("user_global_role"), "global_role");
219  $si->setOptions($options);
220  $this->addFilterItem($si);
221  $si->readFromSession();
222  $this->filter["global_role"] = $si->getValue();
223  }
224 
228  protected function fillRow($user)
229  {
230  global $ilCtrl, $lng;
231 
232  if ($user["usr_id"] != 6)
233  {
234  $this->tpl->setCurrentBlock("checkb");
235  $this->tpl->setVariable("ID", $user["usr_id"]);
236  $this->tpl->parseCurrentBlock();
237  }
238 
239  $this->tpl->setVariable("VAL_LOGIN", $user["login"]);
240  $this->tpl->setVariable("VAL_FIRSTNAME", $user["firstname"]);
241  $this->tpl->setVariable("VAL_LASTNAME", $user["lastname"]);
242  $this->tpl->setVariable("VAL_EMAIL", $user["email"]);
243  $this->tpl->setVariable("VAL_LAST_LOGIN",
245  $this->tpl->setVariable("VAL_ACCESS_UNTIL", $user["access_until"]);
246  $this->tpl->setVariable("CLASS_ACCESS_UNTIL", $user["access_class"]);
247  $ilCtrl->setParameterByClass("ilobjusergui", "obj_id", $user["usr_id"]);
248  $this->tpl->setVariable("HREF_LOGIN",
249  $ilCtrl->getLinkTargetByClass("ilobjusergui", "view"));
250  $ilCtrl->setParameterByClass("ilobjusergui", "obj_id", "");
251  }
252 
253 }
254 ?>