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