ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilLMStatisticsGUI.php
Go to the documentation of this file.
1 <?php
2 
3 
4 /*
5  +-----------------------------------------------------------------------------+
6  | ILIAS open source |
7  +-----------------------------------------------------------------------------+
8  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
9  | |
10  | This program is free software; you can redistribute it and/or |
11  | modify it under the terms of the GNU General Public License |
12  | as published by the Free Software Foundation; either version 2 |
13  | of the License, or (at your option) any later version. |
14  | |
15  | This program is distributed in the hope that it will be useful, |
16  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
17  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18  | GNU General Public License for more details. |
19  | |
20  | You should have received a copy of the GNU General Public License |
21  | along with this program; if not, write to the Free Software |
22  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
23  +-----------------------------------------------------------------------------+
24 */
25 
26 include_once './Services/Tracking/classes/class.ilLearningProgressBaseGUI.php';
27 include_once './Services/Tracking/classes/class.ilLMStatistics.php';
28 
30 
32 
33  function ilLMStatisticsGUI($a_mode, $a_ref_id) {
34  parent :: ilLearningProgressBaseGUI($a_mode, $a_ref_id);
35 
36  $this->lm_statistics = new ilLMStatistics($this->obj_id);
37  }
38 
43  function show() {
44  global $tpl, $lng, $ilias,$ilDB;
45 
46  $q = "SELECT obj_id, type,title FROM object_data WHERE type ='lm' and obj_id=".$ilDB->quote($this->obj_id ,'integer');
47  $result = $ilias->db->query($q);
48  while ($row = $result->fetchRow()) {
49  $Lehrmodulanz ++;
50  $LehrmodulID[$Lehrmodulanz] = $row[0];
51  $rLehrmodulID[$row[0]] = $Lehrmodulanz;
52  $LehrmodulName[$Lehrmodulanz] = $row[2];
53  }
54 
55  $_SESSION["il_track_rlm_id"] = $rLehrmodulID;
56  $_SESSION["il_track_lm_name"] = $LehrmodulName;
57 
58  $q = "SELECT obj_id,title,type,lm_id FROM lm_data WHERE type='pg'";
59  $result = $ilias->db->query($q);
60  while ($row = $result->fetchRow()) {
61  $LMSeitenanz[$rLehrmodulID[$row[3]]]++;
62  }
63 
64  $year = range(2004, date("Y"));
65  $month = range(1, 12);
66  $day = range(1, 31);
67 
68  $tpl->addBlockFile("ADM_CONTENT", "adm_content", "Services/Tracking/templates/default/tpl.lm_statistics_settings.html");
69 
70 // $tpl->setVariable("SEARCH_ACTION", ".php?ref_id=".$_GET["ref_id"]."&cmd=gateway");
71  $tpl->setVariable("SEARCH_ACTION", $this->ctrl->getLinkTargetByClass('illmstatisticsgui',''));
72  $tpl->setVariable("TXT_TRACKING_DATA", $lng->txt("tracking_data"));
73  $tpl->setVariable("TXT_TIME_SEGMENT", $lng->txt("time_segment"));
74  $tpl->setVariable("TXT_STATISTIC", $lng->txt("statistic"));
75  $tpl->setVariable("TXT_STATISTIC_H", $lng->txt("stats_pages_statisics"));
76  $tpl->setVariable("TXT_STATISTIC_D", $lng->txt("stats_chapter_statisics"));
77  $tpl->setVariable("TXT_STATISTIC_O", $lng->txt("stats_sessions_statisics"));
78  $tpl->setVariable("TXT_STATISTIC_U", $lng->txt("stats_navigation"));
79  $tpl->setVariable("TXT_USER_LANGUAGE", $lng->txt("user_language"));
80  $tpl->setVariable("TXT_LM", $lng->txt("lm"));
81  $tpl->setVariable("TXT_SHOW_TR_DATA", $lng->txt("query_data"));
82  $tpl->setVariable("TXT_SHOW_TR_DATA2", $lng->txt("stats_new_selection"));
83  $tpl->setVariable("TXT_TRACKED_OBJECTS", $lng->txt("tracked_objects"));
84  $tpl->setVariable("TXT_TRACKED_USER", $lng->txt("stats_tracked_user"));
85 
86 
87  $tpl->setVariable("TXT_ALLE", $lng->txt("stats_all"));
88  $tpl->setVariable("TXT_AUSWAHL", $lng->txt("stats_choice"));
89 
90  if ($_SESSION["il_track_yearf"] == "") {
91  $_SESSION["il_track_yearf"] = Date("Y");
92  $_SESSION["il_track_yeart"] = Date("Y");
93  $_SESSION["il_track_monthf"] = "1";
94  $_SESSION["il_track_montht"] = Date("n");
95  $_SESSION["il_track_dayf"] = "1";
96  $_SESSION["il_track_dayt"] = Date("j");
97  }
98  if ($_SESSION["il_track_stat"] == "") {
99  $_SESSION["il_track_stat"] = 'h';
100  }
101  $languages = $lng->getInstalledLanguages();
102 
103  $tpl->setCurrentBlock("lm_selection");
104  $_SESSION["il_track_lm"] = $this->obj_id;
105  $tpl->setVariable("LM_ID", $LehrmodulID[1]);
106  $tpl->setVariable("LM_DESC", substr($LehrmodulName[1], 0, 40)." (S:".$LMSeitenanz[1].")");
107  $tpl->parseCurrentBlock();
108 
109  if ($_SESSION["il_track_stat2"] == "choice") {
110  $tpl->setVariable("CHC_CHK", " checked=\"1\" ");
111 
112  } else {
113  $tpl->setVariable("ALL_CHK", " checked=\"1\" ");
114  }
115 
116  $user_IDs = $_SESSION["userSelected_stat"];
117 
118 
119  $tpl->setCurrentBlock("user_selection");
120 
121  if (count($user_IDs) > 0) {
122  foreach ($_SESSION["userSelected_stat"] as $result_id) {
123  $tpl->setVariable("USER1", $result_id);
124  $tpl->setVariable("USER2", $result_id);
125  }
126  } else {
127  $tpl->setCurrentBlock("user_selection");
128  $tpl->setVariable("USER1", "Alle");
129  $tpl->setVariable("USER2", "Alle");
130  }
131 
132  include_once("Services/Tracking/classes/class.ilObjUserTracking.php");
133 
135  $tpl->setVariable ("DISABLED", "disabled");
136  $tpl->setVariable("ALL_CHK", " checked=\"1\" ");
137  $tpl->setVariable("CHC_CHK", "");
138  } else {
139  $tpl->setVariable("INFO1", $lng->txt(stats_current).": ".count($_SESSION["userSelected_stat"])." ".$lng->txt("stats_user_selected"));
140  }
141 
142  $tpl->parseCurrentBlock();
143 
144  //Datum von:
145  foreach ($year as $key) {
146  $tpl->setCurrentBlock("fromyear_selection");
147  $tpl->setVariable("YEARFR", $key);
148  $tpl->setVariable("YEARF", $key);
149  if ($_SESSION["il_track_yearf"] == $key) {
150  $tpl->setVariable("YEARF_SEL", " selected=\"1\" ");
151  }
152  $tpl->parseCurrentBlock();
153  }
154  foreach ($month as $key) {
155  $tpl->setCurrentBlock("frommonth_selection");
156  $tpl->setVariable("MONTHFR", $key);
157  $tpl->setVariable("MONTHF", $key);
158  if ($_SESSION["il_track_monthf"] == $key) {
159  $tpl->setVariable("MONTHF_SEL", " selected=\"1\" ");
160  }
161  $tpl->parseCurrentBlock();
162  }
163  foreach ($day as $key) {
164  $tpl->setCurrentBlock("fromday_selection");
165  $tpl->setVariable("DAYFR", $key);
166  $tpl->setVariable("DAYF", $key);
167  if ($_SESSION["il_track_dayf"] == $key) {
168  $tpl->setVariable("DAYF_SEL", " selected=\"1\" ");
169  }
170  $tpl->parseCurrentBlock();
171  }
172  //Datum nach:
173  foreach ($day as $key) {
174  $tpl->setCurrentBlock("today_selection");
175  $tpl->setVariable("DAYTO", $key);
176  $tpl->setVariable("DAYT", $key);
177  if ($_SESSION["il_track_dayt"] == $key) {
178  $tpl->setVariable("DAYT_SEL", " selected=\"1\" ");
179  }
180  $tpl->parseCurrentBlock();
181  }
182  foreach ($month as $key) {
183  $tpl->setCurrentBlock("tomonth_selection");
184  $tpl->setVariable("MONTHTO", $key);
185  $tpl->setVariable("MONTHT", $key);
186  if ($_SESSION["il_track_montht"] == $key) {
187  $tpl->setVariable("MONTHT_SEL", " selected=\"1\" ");
188  }
189  $tpl->parseCurrentBlock();
190  }
191  foreach ($year as $key) {
192  $tpl->setCurrentBlock("toyear_selection");
193  $tpl->setVariable("YEARTO", $key);
194  $tpl->setVariable("YEART", $key);
195  if ($_SESSION["il_track_yeart"] == $key) {
196  $tpl->setVariable("YEART_SEL", " selected=\"1\" ");
197  }
198  $tpl->parseCurrentBlock();
199  }
200  // language selection
201  $tpl->setCurrentBlock("language_selection");
202  $tpl->setVariable("LANG", $lng->txt("any_language"));
203  $tpl->setVariable("LANGSHORT", "0");
204  $tpl->parseCurrentBlock();
205  foreach ($languages as $lang_key) {
206  $tpl->setCurrentBlock("language_selection");
207  $tpl->setVariable("LANG", $lng->txt("lang_".$lang_key));
208  $tpl->setVariable("LANGSHORT", $lang_key);
209  if ($_SESSION["il_track_language"] == $lang_key) {
210  $tpl->setVariable("LANG_SEL", " selected=\"1\" ");
211  }
212  $tpl->parseCurrentBlock();
213  }
214  // statistic type
215  if ($_SESSION["il_track_stat"] == "d") {
216  $tpl->setVariable("D_CHK", " checked=\"1\" ");
217  }
218  elseif ($_SESSION["il_track_stat"] == "h") {
219  $tpl->setVariable("H_CHK", " checked=\"1\" ");
220  }
221  elseif ($_SESSION["il_track_stat"] == "o") {
222  $tpl->setVariable("O_CHK", " checked=\"1\" ");
223  }
224  elseif ($_SESSION["il_track_stat"] == "u") {
225  $tpl->setVariable("U_CHK", " checked=\"1\" ");
226  }
227  }
228 
233  function outputStatistics() {
234  require_once "./Services/Tracking/classes/class.ilLMStatistics.php";
235 
236  if ($_POST["stat"] == 'u') { //Beobachtungsmodell starten
237  $this->lm_statistics->outputApplet();
238  } else { //Session-,Seiten-,Kapitelstats starten
239  $this->lm_statistics->outputHTML();
240  }
241  }
242 
246  function searchUserForm() {
247  global $rbacsystem;
248 
249  $this->lng->loadLanguageModule('search');
250 
251  // MINIMUM ACCESS LEVEL = 'administrate'
252  if (!$rbacsystem->checkAccess("write", $this->ref_id)) {
253  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"), $this->ilias->error_obj->MESSAGE);
254  }
255 
256  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.grp_members_search.html");
257 
258  $this->tpl->setVariable("F_ACTION", $this->ctrl->getFormAction($this));
259  $this->tpl->setVariable("SEARCH_ASSIGN_USR", $this->lng->txt("grp_search_members"));
260  $this->tpl->setVariable("SEARCH_SEARCH_TERM", $this->lng->txt("search_search_term"));
261  $this->tpl->setVariable("SEARCH_VALUE", $_SESSION["grp_search_str"] ? $_SESSION["grp_search_str"] : "");
262  $this->tpl->setVariable("SEARCH_FOR", $this->lng->txt("exc_search_for"));
263  $this->tpl->setVariable("SEARCH_ROW_TXT_USER", $this->lng->txt("exc_users"));
264  $this->tpl->setVariable("SEARCH_ROW_TXT_ROLE", $this->lng->txt("exc_roles"));
265  $this->tpl->setVariable("SEARCH_ROW_TXT_GROUP", $this->lng->txt("exc_groups"));
266  $this->tpl->setVariable("BTN2_VALUE", $this->lng->txt("cancel"));
267  $this->tpl->setVariable("BTN1_VALUE", $this->lng->txt("search"));
268 
269  $usr = ($_POST["search_for"] == "usr" || $_POST["search_for"] == "") ? 1 : 0;
270  $grp = ($_POST["search_for"] == "grp") ? 1 : 0;
271  $role = ($_POST["search_for"] == "role") ? 1 : 0;
272 
273  $this->tpl->setVariable("SEARCH_ROW_CHECK_USER", ilUtil :: formRadioButton($usr, "search_for", "usr"));
274  $this->tpl->setVariable("SEARCH_ROW_CHECK_ROLE", ilUtil :: formRadioButton($role, "search_for", "role"));
275  $this->tpl->setVariable("SEARCH_ROW_CHECK_GROUP", ilUtil :: formRadioButton($grp, "search_for", "grp"));
276 
277  }
278 
279  function cancelMember() {
280  $return_location = "members";
281 
282  ilUtil :: redirect($this->ctrl->getLinkTarget($this, $return_location));
283  }
284 
285  function members() {
286  $this->show();
287  }
288 
289  function search() {
290  global $rbacsystem, $tree;
291 
292  $_SESSION["grp_search_str"] = $_POST["search_str"] = $_POST["search_str"] ? $_POST["search_str"] : $_SESSION["grp_search_str"];
293  $_SESSION["grp_search_for"] = $_POST["search_for"] = $_POST["search_for"] ? $_POST["search_for"] : $_SESSION["grp_search_for"];
294 
295  // MINIMUM ACCESS LEVEL = 'administrate'
296  if (!$rbacsystem->checkAccess("write", $this->ref_id)) {
297  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"), $this->ilias->error_obj->MESSAGE);
298  }
299 
300  if (!isset ($_POST["search_for"]) or !isset ($_POST["search_str"])) {
301  ilUtil::sendFailure($this->lng->txt("grp_search_enter_search_string"));
302  $this->searchUserForm();
303 
304  return false;
305  }
306 
307  if (!count($result = $this->__search(ilUtil :: stripSlashes($_POST["search_str"]), $_POST["search_for"]))) {
308  ilUtil::sendFailure($this->lng->txt("grp_no_results_found"));
309  $this->searchUserForm();
310 
311  return false;
312  }
313 
314  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.grp_usr_selection.html");
315  $this->__showButton("searchUserForm", $this->lng->txt("grp_new_search"));
316 
317  $counter = 0;
318  $f_result = array ();
319 
320  switch ($_POST["search_for"]) {
321  case "usr" :
322  foreach ($result as $user) {
323  if (!$tmp_obj = ilObjectFactory :: getInstanceByObjId($user["id"], false)) {
324  continue;
325  }
326 
327  $user_ids[$counter] = $user["id"];
328 
329  $f_result[$counter][] = ilUtil :: formCheckbox(0, "user[]", $user["id"]);
330  $f_result[$counter][] = $tmp_obj->getLogin();
331  $f_result[$counter][] = $tmp_obj->getFirstname();
332  $f_result[$counter][] = $tmp_obj->getLastname();
333  $f_result[$counter][] = ilFormat :: formatDate($tmp_obj->getLastLogin());
334 
335  unset ($tmp_obj);
336  ++ $counter;
337  }
338  $this->__showSearchUserTable($f_result, $user_ids);
339 
340  return true;
341 
342  case "role" :
343  foreach ($result as $role) {
344  // exclude anonymous role
345  if ($role["id"] == ANONYMOUS_ROLE_ID) {
346  continue;
347  }
348 
349  if (!$tmp_obj = ilObjectFactory :: getInstanceByObjId($role["id"], false)) {
350  continue;
351  }
352 
353  // exclude roles with no users assigned to
354  if ($tmp_obj->getCountMembers() == 0) {
355  continue;
356  }
357 
358  $role_ids[$counter] = $role["id"];
359 
360  $f_result[$counter][] = ilUtil :: formCheckbox(0, "role[]", $role["id"]);
361  $f_result[$counter][] = array ($tmp_obj->getTitle(), $tmp_obj->getDescription());
362  $f_result[$counter][] = $tmp_obj->getCountMembers();
363 
364  unset ($tmp_obj);
365  ++ $counter;
366  }
367 
368  $this->__showSearchRoleTable($f_result, $role_ids);
369 
370  return true;
371 
372  case "grp" :
373  foreach ($result as $group) {
374  if (!$tree->isInTree($group["id"])) {
375  continue;
376  }
377 
378  if (!$tmp_obj = ilObjectFactory :: getInstanceByRefId($group["id"], false)) {
379  continue;
380  }
381 
382  // exclude myself :-)
383  if ($tmp_obj->getId() == $this->object->getId()) {
384  continue;
385  }
386 
387  $grp_ids[$counter] = $group["id"];
388 
389  $f_result[$counter][] = ilUtil :: formCheckbox(0, "group[]", $group["id"]);
390  $f_result[$counter][] = array ($tmp_obj->getTitle(), $tmp_obj->getDescription());
391  $f_result[$counter][] = $tmp_obj->getCountMembers();
392 
393  unset ($tmp_obj);
394  ++ $counter;
395  }
396 
397  if (!count($f_result)) {
398  ilUtil::sendFailure($this->lng->txt("grp_no_results_found"));
399  $this->searchUserFormObject();
400 
401  return false;
402  }
403 
404  $this->__showSearchGroupTable($f_result, $grp_ids);
405 
406  return true;
407  }
408  }
409  function searchCancelled() {
410  ilUtil :: redirect($this->ctrl->getLinkTarget($this, "members"));
411  }
412  function __search($a_search_string, $a_search_for) {
413  include_once ("classes/class.ilSearch.php");
414 
415  $this->lng->loadLanguageModule("content");
416  $search = & new ilSearch($_SESSION["AccountId"]);
417  $search->setPerformUpdate(false);
418  $search->setSearchString(ilUtil :: stripSlashes($a_search_string));
419  $search->setCombination("and");
420  $search->setSearchFor(array (0 => $a_search_for));
421  $search->setSearchType('new');
422 
423  if ($search->validate($message))
424  {
425  $search->performSearch();
426  }
427  else
428  {
429  ilUtil::sendFailure($message, true);
430  $this->ctrl->redirect($this, "searchUserForm");
431  }
432 
433  return $search->getResultByType($a_search_for);
434  }
435 
436  function __showSearchUserTable($a_result_set, $a_user_ids = NULL, $a_cmd = "search") {
437  $return_to = "searchUserForm";
438 
439  if ($a_cmd == "listUsersRole" or $a_cmd == "listUsersGroup") {
440  $return_to = "search";
441  }
442 
443  $tbl = & $this->__initTableGUI();
444  $tpl = & $tbl->getTemplateObject();
445 
446  // SET FORMACTION
447  $tpl->setCurrentBlock("tbl_form_header");
448  $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
449  $tpl->parseCurrentBlock();
450 
451  $tpl->setCurrentBlock("tbl_action_btn");
452  $tpl->setVariable("BTN_NAME", $return_to);
453  $tpl->setVariable("BTN_VALUE", $this->lng->txt("back"));
454  $tpl->parseCurrentBlock();
455 
456  $tpl->setCurrentBlock("tbl_action_btn");
457  $tpl->setVariable("BTN_NAME", "addUser");
458  $tpl->setVariable("BTN_VALUE", $this->lng->txt("add"));
459  $tpl->parseCurrentBlock();
460 
461  if (!empty ($a_user_ids)) {
462  // set checkbox toggles
463  $tpl->setCurrentBlock("tbl_action_toggle_checkboxes");
464  $tpl->setVariable("JS_VARNAME", "user");
465  $tpl->setVariable("JS_ONCLICK", ilUtil :: array_php2js($a_user_ids));
466  $tpl->setVariable("TXT_CHECKALL", $this->lng->txt("check_all"));
467  $tpl->setVariable("TXT_UNCHECKALL", $this->lng->txt("uncheck_all"));
468  $tpl->parseCurrentBlock();
469  }
470 
471  $tpl->setCurrentBlock("tbl_action_row");
472  $tpl->setVariable("COLUMN_COUNTS", 5);
473  $tpl->setVariable("IMG_ARROW", ilUtil :: getImagePath("arrow_downright.gif"));
474  $tpl->parseCurrentBlock();
475 
476  $tbl->setTitle($this->lng->txt("grp_header_edit_members"), "icon_usr_b.gif", $this->lng->txt("grp_header_edit_members"));
477  $tbl->setHeaderNames(array ("", $this->lng->txt("username"), $this->lng->txt("firstname"), $this->lng->txt("lastname"), $this->lng->txt("last_visit")));
478  $tbl->setHeaderVars(array ("", "login", "firstname", "lastname", "last_visit"), array ("ref_id" => $this->ref_id, "cmd" => $a_cmd, "cmdClass" => "ilobjgroupgui", "cmdNode" => $_GET["cmdNode"]));
479 
480  $tbl->setColumnWidth(array ("", "33%", "33%", "33%"));
481 
482  $this->__setTableGUIBasicData($tbl, $a_result_set);
483  $tbl->render();
484 
485  $this->tpl->setVariable("SEARCH_RESULT_TABLE", $tbl->tpl->get());
486 
487  return true;
488  }
489 
490  function __showSearchRoleTable($a_result_set, $a_role_ids = NULL) {
491  $tbl = & $this->__initTableGUI();
492  $tpl = & $tbl->getTemplateObject();
493 
494  $tpl->setCurrentBlock("tbl_form_header");
495  $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
496  $tpl->parseCurrentBlock();
497 
498  $tpl->setCurrentBlock("tbl_action_btn");
499  $tpl->setVariable("BTN_NAME", "searchUserForm");
500  $tpl->setVariable("BTN_VALUE", $this->lng->txt("back"));
501  $tpl->parseCurrentBlock();
502 
503  $tpl->setCurrentBlock("tbl_action_btn");
504  $tpl->setVariable("BTN_NAME", "listUsersRole");
505  $tpl->setVariable("BTN_VALUE", $this->lng->txt("grp_list_users"));
506  $tpl->parseCurrentBlock();
507 
508  if (!empty ($a_role_ids)) {
509  // set checkbox toggles
510  $tpl->setCurrentBlock("tbl_action_toggle_checkboxes");
511  $tpl->setVariable("JS_VARNAME", "role");
512  $tpl->setVariable("JS_ONCLICK", ilUtil :: array_php2js($a_role_ids));
513  $tpl->setVariable("TXT_CHECKALL", $this->lng->txt("check_all"));
514  $tpl->setVariable("TXT_UNCHECKALL", $this->lng->txt("uncheck_all"));
515  $tpl->parseCurrentBlock();
516  }
517 
518  $tpl->setCurrentBlock("tbl_action_row");
519  $tpl->setVariable("COLUMN_COUNTS", 5);
520  $tpl->setVariable("IMG_ARROW", ilUtil :: getImagePath("arrow_downright.gif"));
521  $tpl->parseCurrentBlock();
522 
523  $tbl->setTitle($this->lng->txt("grp_header_edit_members"), "icon_usr_b.gif", $this->lng->txt("grp_header_edit_members"));
524  $tbl->setHeaderNames(array ("", $this->lng->txt("obj_role"), $this->lng->txt("grp_count_members")));
525  $tbl->setHeaderVars(array ("", "title", "nr_members"), array ("ref_id" => $this->ref_id, "cmd" => "search", "cmdClass" => "ilobjgroupgui", "cmdNode" => $_GET["cmdNode"]));
526 
527  $tbl->setColumnWidth(array ("", "80%", "19%"));
528 
529  $this->__setTableGUIBasicData($tbl, $a_result_set, "role");
530  $tbl->render();
531 
532  $this->tpl->setVariable("SEARCH_RESULT_TABLE", $tbl->tpl->get());
533 
534  return true;
535  }
536 
542  function __setTableGUIBasicData(&$tbl,&$result_set,$a_from = "")
543  {
544  switch ($a_from)
545  {
546  case "clipboardObject":
547  $offset = $_GET["offset"];
548  $order = $_GET["sort_by"];
549  $direction = $_GET["sort_order"];
550  $tbl->disable("footer");
551  break;
552 
553  default:
554  $offset = $_GET["offset"];
555  $order = $_GET["sort_by"];
556  $direction = $_GET["sort_order"];
557  break;
558  }
559 
560  $tbl->setOrderColumn($order);
561  $tbl->setOrderDirection($direction);
562  $tbl->setOffset($offset);
563  $tbl->setLimit($_GET["limit"]);
564  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
565  $tbl->setData($result_set);
566  }
567 
568  function __showSearchGroupTable($a_result_set, $a_grp_ids = NULL) {
569  $tbl = & $this->__initTableGUI();
570  $tpl = & $tbl->getTemplateObject();
571 
572  $tpl->setCurrentBlock("tbl_form_header");
573  $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
574  $tpl->parseCurrentBlock();
575 
576  $tpl->setCurrentBlock("tbl_action_btn");
577  $tpl->setVariable("BTN_NAME", "searchUserForm");
578  $tpl->setVariable("BTN_VALUE", $this->lng->txt("back"));
579  $tpl->parseCurrentBlock();
580 
581  $tpl->setCurrentBlock("tbl_action_btn");
582  $tpl->setVariable("BTN_NAME", "listUsersGroup");
583  $tpl->setVariable("BTN_VALUE", $this->lng->txt("grp_list_users"));
584  $tpl->parseCurrentBlock();
585 
586  if (!empty ($a_grp_ids)) {
587  // set checkbox toggles
588  $tpl->setCurrentBlock("tbl_action_toggle_checkboxes");
589  $tpl->setVariable("JS_VARNAME", "group");
590  $tpl->setVariable("JS_ONCLICK", ilUtil :: array_php2js($a_grp_ids));
591  $tpl->setVariable("TXT_CHECKALL", $this->lng->txt("check_all"));
592  $tpl->setVariable("TXT_UNCHECKALL", $this->lng->txt("uncheck_all"));
593  $tpl->parseCurrentBlock();
594  }
595 
596  $tpl->setCurrentBlock("tbl_action_row");
597  $tpl->setVariable("COLUMN_COUNTS", 5);
598  $tpl->setVariable("IMG_ARROW", ilUtil :: getImagePath("arrow_downright.gif"));
599  $tpl->parseCurrentBlock();
600 
601  $tbl->setTitle($this->lng->txt("grp_header_edit_members"), "icon_usr_b.gif", $this->lng->txt("grp_header_edit_members"));
602  $tbl->setHeaderNames(array ("", $this->lng->txt("obj_grp"), $this->lng->txt("grp_count_members")));
603  $tbl->setHeaderVars(array ("", "title", "nr_members"), array ("ref_id" => $this->ref_id, "cmd" => "search", "cmdClass" => "ilobjgroupgui", "cmdNode" => $_GET["cmdNode"]));
604 
605  $tbl->setColumnWidth(array ("", "80%", "19%"));
606 
607  $this->__setTableGUIBasicData($tbl, $a_result_set, "group");
608  $tbl->render();
609 
610  $this->tpl->setVariable("SEARCH_RESULT_TABLE", $tbl->tpl->get());
611 
612  return true;
613  }
614  function listUsersRole() {
615  global $rbacsystem, $rbacreview;
616 
617  $_SESSION["grp_role"] = $_POST["role"] = $_POST["role"] ? $_POST["role"] : $_SESSION["grp_role"];
618 
619  // MINIMUM ACCESS LEVEL = 'administrate'
620  if (!$rbacsystem->checkAccess("write", $this->ref_id)) {
621  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"), $this->ilias->error_obj->MESSAGE);
622  }
623 
624  if (!is_array($_POST["role"])) {
625  ilUtil::sendFailure($this->lng->txt("grp_no_roles_selected"));
626  $this->searchObject();
627 
628  return false;
629  }
630 
631  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.grp_usr_selection.html");
632  $this->__showButton("searchUserForm", $this->lng->txt("grp_new_search"));
633 
634  // GET ALL MEMBERS
635  $members = array ();
636  foreach ($_POST["role"] as $role_id) {
637  $members = array_merge($rbacreview->assignedUsers($role_id), $members);
638  }
639 
640  $members = array_unique($members);
641 
642  // FORMAT USER DATA
643  $counter = 0;
644  $f_result = array ();
645  foreach ($members as $user) {
646  if (!$tmp_obj = ilObjectFactory :: getInstanceByObjId($user, false)) {
647  continue;
648  }
649 
650  if (!$tmp_obj->active) {
651  continue;
652  }
653 
654  $user_ids[$counter] = $user;
655 
656  $f_result[$counter][] = ilUtil :: formCheckbox(0, "user[]", $user);
657  $f_result[$counter][] = $tmp_obj->getLogin();
658  $f_result[$counter][] = $tmp_obj->getLastname();
659  $f_result[$counter][] = $tmp_obj->getFirstname();
660  $f_result[$counter][] = ilFormat :: formatDate($tmp_obj->getLastLogin());
661 
662  unset ($tmp_obj);
663  ++ $counter;
664  }
665  $this->__showSearchUserTable($f_result, $user_ids, "listUsersRole");
666 
667  return true;
668  }
669 
670  function listUsersGroup() {
671  global $rbacsystem, $rbacreview, $tree;
672 
673  $_SESSION["grp_group"] = $_POST["group"] = $_POST["group"] ? $_POST["group"] : $_SESSION["grp_group"];
674 
675  // MINIMUM ACCESS LEVEL = 'administrate'
676  if (!$rbacsystem->checkAccess("write", $this->ref_id)) {
677  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"), $this->ilias->error_obj->MESSAGE);
678  }
679 
680  if (!is_array($_POST["group"])) {
681  ilUtil::sendFailure($this->lng->txt("grp_no_groups_selected"));
682  $this->searchObject();
683 
684  return false;
685  }
686 
687  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.grp_usr_selection.html");
688  $this->__showButton("searchUserForm", $this->lng->txt("grp_new_search"));
689 
690  // GET ALL MEMBERS
691  $members = array ();
692  foreach ($_POST["group"] as $group_id) {
693  if (!$tree->isInTree($group_id)) {
694  continue;
695  }
696  if (!$tmp_obj = ilObjectFactory :: getInstanceByRefId($group_id)) {
697  continue;
698  }
699 
700  $members = array_merge($tmp_obj->getGroupMemberIds(), $members);
701 
702  unset ($tmp_obj);
703  }
704 
705  $members = array_unique($members);
706 
707  // FORMAT USER DATA
708  $counter = 0;
709  $f_result = array ();
710  foreach ($members as $user) {
711  if (!$tmp_obj = ilObjectFactory :: getInstanceByObjId($user, false)) {
712  continue;
713  }
714 
715  $user_ids[$counter] = $user;
716 
717  $f_result[$counter][] = ilUtil :: formCheckbox(0, "user[]", $user);
718  $f_result[$counter][] = $tmp_obj->getLogin();
719  $f_result[$counter][] = $tmp_obj->getLastname();
720  $f_result[$counter][] = $tmp_obj->getFirstname();
721  $f_result[$counter][] = ilFormat :: formatDate($tmp_obj->getLastLogin());
722 
723  unset ($tmp_obj);
724  ++ $counter;
725  }
726  $this->__showSearchUserTable($f_result, $user_ids, "listUsersGroup");
727 
728  return true;
729  }
730 
731  function addUser() {
732  //echo "addUserObject() ausgefuehrt;";
733  $user_ids = $_POST["user"];
734 
735  if (empty ($user_ids[0])) {
736  //echo "...nix weitergeleitet...";
737  // TODO: jumps back to grp content. go back to last search result
738  $this->ilErr->raiseError($this->lng->txt("no_checkbox"), $this->ilErr->MESSAGE);
739  } else {
740  //echo "...Daten weitergeleitet...";
741  }
742  $_SESSION["il_track_stat2"] = "choice";
743  $_SESSION["userSelected_stat"] = $_POST["user"];
744  $this->show();
745 
746  }
747 
751  function & executeCommand() {
752  if (isset($_POST["cmd"]["searchUserForm"]))
753  {
754  $cmd = "searchUserForm";
755  } elseif (isset($_POST["cmd"]["outputStatistics"]))
756  {
757  $cmd = "outputStatistics";
758  } else switch ($this->ctrl->getNextClass()) {
759  default :
760  $cmd = $this->__getDefaultCommand();
761  }
762  $this-> $cmd ();
763  return true;
764  }
765 
766 }
767 ?>