ILIAS  Release_3_10_x_branch Revision 61812
 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;
45 
46  $q = "SELECT obj_id, type,title FROM object_data WHERE type ='lm' and obj_id=".$this->obj_id;
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 = array (2004, 2005, 2006, 2007, 2008, 2009, 2010);
65  $month = array (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
66  $day = array (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 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::sendInfo($this->lng->txt("action_aborted"), true);
283  ilUtil :: redirect($this->ctrl->getLinkTarget($this, $return_location));
284  }
285 
286  function members() {
287  $this->show();
288  }
289 
290  function search() {
291  global $rbacsystem, $tree;
292 
293  $_SESSION["grp_search_str"] = $_POST["search_str"] = $_POST["search_str"] ? $_POST["search_str"] : $_SESSION["grp_search_str"];
294  $_SESSION["grp_search_for"] = $_POST["search_for"] = $_POST["search_for"] ? $_POST["search_for"] : $_SESSION["grp_search_for"];
295 
296  // MINIMUM ACCESS LEVEL = 'administrate'
297  if (!$rbacsystem->checkAccess("write", $this->ref_id)) {
298  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"), $this->ilias->error_obj->MESSAGE);
299  }
300 
301  if (!isset ($_POST["search_for"]) or !isset ($_POST["search_str"])) {
302  ilUtil::sendInfo($this->lng->txt("grp_search_enter_search_string"));
303  $this->searchUserForm();
304 
305  return false;
306  }
307 
308  if (!count($result = $this->__search(ilUtil :: stripSlashes($_POST["search_str"]), $_POST["search_for"]))) {
309  ilUtil::sendInfo($this->lng->txt("grp_no_results_found"));
310  $this->searchUserForm();
311 
312  return false;
313  }
314 
315  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.grp_usr_selection.html");
316  $this->__showButton("searchUserForm", $this->lng->txt("grp_new_search"));
317 
318  $counter = 0;
319  $f_result = array ();
320 
321  switch ($_POST["search_for"]) {
322  case "usr" :
323  foreach ($result as $user) {
324  if (!$tmp_obj = ilObjectFactory :: getInstanceByObjId($user["id"], false)) {
325  continue;
326  }
327 
328  $user_ids[$counter] = $user["id"];
329 
330  $f_result[$counter][] = ilUtil :: formCheckbox(0, "user[]", $user["id"]);
331  $f_result[$counter][] = $tmp_obj->getLogin();
332  $f_result[$counter][] = $tmp_obj->getFirstname();
333  $f_result[$counter][] = $tmp_obj->getLastname();
334  $f_result[$counter][] = ilFormat :: formatDate($tmp_obj->getLastLogin());
335 
336  unset ($tmp_obj);
337  ++ $counter;
338  }
339  $this->__showSearchUserTable($f_result, $user_ids);
340 
341  return true;
342 
343  case "role" :
344  foreach ($result as $role) {
345  // exclude anonymous role
346  if ($role["id"] == ANONYMOUS_ROLE_ID) {
347  continue;
348  }
349 
350  if (!$tmp_obj = ilObjectFactory :: getInstanceByObjId($role["id"], false)) {
351  continue;
352  }
353 
354  // exclude roles with no users assigned to
355  if ($tmp_obj->getCountMembers() == 0) {
356  continue;
357  }
358 
359  $role_ids[$counter] = $role["id"];
360 
361  $f_result[$counter][] = ilUtil :: formCheckbox(0, "role[]", $role["id"]);
362  $f_result[$counter][] = array ($tmp_obj->getTitle(), $tmp_obj->getDescription());
363  $f_result[$counter][] = $tmp_obj->getCountMembers();
364 
365  unset ($tmp_obj);
366  ++ $counter;
367  }
368 
369  $this->__showSearchRoleTable($f_result, $role_ids);
370 
371  return true;
372 
373  case "grp" :
374  foreach ($result as $group) {
375  if (!$tree->isInTree($group["id"])) {
376  continue;
377  }
378 
379  if (!$tmp_obj = ilObjectFactory :: getInstanceByRefId($group["id"], false)) {
380  continue;
381  }
382 
383  // exclude myself :-)
384  if ($tmp_obj->getId() == $this->object->getId()) {
385  continue;
386  }
387 
388  $grp_ids[$counter] = $group["id"];
389 
390  $f_result[$counter][] = ilUtil :: formCheckbox(0, "group[]", $group["id"]);
391  $f_result[$counter][] = array ($tmp_obj->getTitle(), $tmp_obj->getDescription());
392  $f_result[$counter][] = $tmp_obj->getCountMembers();
393 
394  unset ($tmp_obj);
395  ++ $counter;
396  }
397 
398  if (!count($f_result)) {
399  ilUtil::sendInfo($this->lng->txt("grp_no_results_found"));
400  $this->searchUserFormObject();
401 
402  return false;
403  }
404 
405  $this->__showSearchGroupTable($f_result, $grp_ids);
406 
407  return true;
408  }
409  }
410  function searchCancelled() {
411  ilUtil::sendInfo($this->lng->txt("action_aborted"), true);
412  ilUtil :: redirect($this->ctrl->getLinkTarget($this, "members"));
413  }
414  function __search($a_search_string, $a_search_for) {
415  include_once ("classes/class.ilSearch.php");
416 
417  $this->lng->loadLanguageModule("content");
418  $search = & new ilSearch($_SESSION["AccountId"]);
419  $search->setPerformUpdate(false);
420  $search->setSearchString(ilUtil :: stripSlashes($a_search_string));
421  $search->setCombination("and");
422  $search->setSearchFor(array (0 => $a_search_for));
423  $search->setSearchType('new');
424 
425  if ($search->validate($message)) {
426  $search->performSearch();
427  } else {
428  ilUtil::sendInfo($message, true);
429  $this->ctrl->redirect($this, "searchUserForm");
430  }
431 
432  return $search->getResultByType($a_search_for);
433  }
434 
435  function __showSearchUserTable($a_result_set, $a_user_ids = NULL, $a_cmd = "search") {
436  $return_to = "searchUserForm";
437 
438  if ($a_cmd == "listUsersRole" or $a_cmd == "listUsersGroup") {
439  $return_to = "search";
440  }
441 
442  $tbl = & $this->__initTableGUI();
443  $tpl = & $tbl->getTemplateObject();
444 
445  // SET FORMACTION
446  $tpl->setCurrentBlock("tbl_form_header");
447  $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
448  $tpl->parseCurrentBlock();
449 
450  $tpl->setCurrentBlock("tbl_action_btn");
451  $tpl->setVariable("BTN_NAME", $return_to);
452  $tpl->setVariable("BTN_VALUE", $this->lng->txt("back"));
453  $tpl->parseCurrentBlock();
454 
455  $tpl->setCurrentBlock("tbl_action_btn");
456  $tpl->setVariable("BTN_NAME", "addUser");
457  $tpl->setVariable("BTN_VALUE", $this->lng->txt("add"));
458  $tpl->parseCurrentBlock();
459 
460  if (!empty ($a_user_ids)) {
461  // set checkbox toggles
462  $tpl->setCurrentBlock("tbl_action_toggle_checkboxes");
463  $tpl->setVariable("JS_VARNAME", "user");
464  $tpl->setVariable("JS_ONCLICK", ilUtil :: array_php2js($a_user_ids));
465  $tpl->setVariable("TXT_CHECKALL", $this->lng->txt("check_all"));
466  $tpl->setVariable("TXT_UNCHECKALL", $this->lng->txt("uncheck_all"));
467  $tpl->parseCurrentBlock();
468  }
469 
470  $tpl->setCurrentBlock("tbl_action_row");
471  $tpl->setVariable("COLUMN_COUNTS", 5);
472  $tpl->setVariable("IMG_ARROW", ilUtil :: getImagePath("arrow_downright.gif"));
473  $tpl->parseCurrentBlock();
474 
475  $tbl->setTitle($this->lng->txt("grp_header_edit_members"), "icon_usr_b.gif", $this->lng->txt("grp_header_edit_members"));
476  $tbl->setHeaderNames(array ("", $this->lng->txt("username"), $this->lng->txt("firstname"), $this->lng->txt("lastname"), $this->lng->txt("last_visit")));
477  $tbl->setHeaderVars(array ("", "login", "firstname", "lastname", "last_visit"), array ("ref_id" => $this->ref_id, "cmd" => $a_cmd, "cmdClass" => "ilobjgroupgui", "cmdNode" => $_GET["cmdNode"]));
478 
479  $tbl->setColumnWidth(array ("", "33%", "33%", "33%"));
480 
481  $this->__setTableGUIBasicData($tbl, $a_result_set);
482  $tbl->render();
483 
484  $this->tpl->setVariable("SEARCH_RESULT_TABLE", $tbl->tpl->get());
485 
486  return true;
487  }
488 
489  function __showSearchRoleTable($a_result_set, $a_role_ids = NULL) {
490  $tbl = & $this->__initTableGUI();
491  $tpl = & $tbl->getTemplateObject();
492 
493  $tpl->setCurrentBlock("tbl_form_header");
494  $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
495  $tpl->parseCurrentBlock();
496 
497  $tpl->setCurrentBlock("tbl_action_btn");
498  $tpl->setVariable("BTN_NAME", "searchUserForm");
499  $tpl->setVariable("BTN_VALUE", $this->lng->txt("back"));
500  $tpl->parseCurrentBlock();
501 
502  $tpl->setCurrentBlock("tbl_action_btn");
503  $tpl->setVariable("BTN_NAME", "listUsersRole");
504  $tpl->setVariable("BTN_VALUE", $this->lng->txt("grp_list_users"));
505  $tpl->parseCurrentBlock();
506 
507  if (!empty ($a_role_ids)) {
508  // set checkbox toggles
509  $tpl->setCurrentBlock("tbl_action_toggle_checkboxes");
510  $tpl->setVariable("JS_VARNAME", "role");
511  $tpl->setVariable("JS_ONCLICK", ilUtil :: array_php2js($a_role_ids));
512  $tpl->setVariable("TXT_CHECKALL", $this->lng->txt("check_all"));
513  $tpl->setVariable("TXT_UNCHECKALL", $this->lng->txt("uncheck_all"));
514  $tpl->parseCurrentBlock();
515  }
516 
517  $tpl->setCurrentBlock("tbl_action_row");
518  $tpl->setVariable("COLUMN_COUNTS", 5);
519  $tpl->setVariable("IMG_ARROW", ilUtil :: getImagePath("arrow_downright.gif"));
520  $tpl->parseCurrentBlock();
521 
522  $tbl->setTitle($this->lng->txt("grp_header_edit_members"), "icon_usr_b.gif", $this->lng->txt("grp_header_edit_members"));
523  $tbl->setHeaderNames(array ("", $this->lng->txt("obj_role"), $this->lng->txt("grp_count_members")));
524  $tbl->setHeaderVars(array ("", "title", "nr_members"), array ("ref_id" => $this->ref_id, "cmd" => "search", "cmdClass" => "ilobjgroupgui", "cmdNode" => $_GET["cmdNode"]));
525 
526  $tbl->setColumnWidth(array ("", "80%", "19%"));
527 
528  $this->__setTableGUIBasicData($tbl, $a_result_set, "role");
529  $tbl->render();
530 
531  $this->tpl->setVariable("SEARCH_RESULT_TABLE", $tbl->tpl->get());
532 
533  return true;
534  }
535 
541  function __setTableGUIBasicData(&$tbl,&$result_set,$a_from = "")
542  {
543  switch ($a_from)
544  {
545  case "clipboardObject":
546  $offset = $_GET["offset"];
547  $order = $_GET["sort_by"];
548  $direction = $_GET["sort_order"];
549  $tbl->disable("footer");
550  break;
551 
552  default:
553  $offset = $_GET["offset"];
554  $order = $_GET["sort_by"];
555  $direction = $_GET["sort_order"];
556  break;
557  }
558 
559  $tbl->setOrderColumn($order);
560  $tbl->setOrderDirection($direction);
561  $tbl->setOffset($offset);
562  $tbl->setLimit($_GET["limit"]);
563  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
564  $tbl->setData($result_set);
565  }
566 
567  function __showSearchGroupTable($a_result_set, $a_grp_ids = NULL) {
568  $tbl = & $this->__initTableGUI();
569  $tpl = & $tbl->getTemplateObject();
570 
571  $tpl->setCurrentBlock("tbl_form_header");
572  $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
573  $tpl->parseCurrentBlock();
574 
575  $tpl->setCurrentBlock("tbl_action_btn");
576  $tpl->setVariable("BTN_NAME", "searchUserForm");
577  $tpl->setVariable("BTN_VALUE", $this->lng->txt("back"));
578  $tpl->parseCurrentBlock();
579 
580  $tpl->setCurrentBlock("tbl_action_btn");
581  $tpl->setVariable("BTN_NAME", "listUsersGroup");
582  $tpl->setVariable("BTN_VALUE", $this->lng->txt("grp_list_users"));
583  $tpl->parseCurrentBlock();
584 
585  if (!empty ($a_grp_ids)) {
586  // set checkbox toggles
587  $tpl->setCurrentBlock("tbl_action_toggle_checkboxes");
588  $tpl->setVariable("JS_VARNAME", "group");
589  $tpl->setVariable("JS_ONCLICK", ilUtil :: array_php2js($a_grp_ids));
590  $tpl->setVariable("TXT_CHECKALL", $this->lng->txt("check_all"));
591  $tpl->setVariable("TXT_UNCHECKALL", $this->lng->txt("uncheck_all"));
592  $tpl->parseCurrentBlock();
593  }
594 
595  $tpl->setCurrentBlock("tbl_action_row");
596  $tpl->setVariable("COLUMN_COUNTS", 5);
597  $tpl->setVariable("IMG_ARROW", ilUtil :: getImagePath("arrow_downright.gif"));
598  $tpl->parseCurrentBlock();
599 
600  $tbl->setTitle($this->lng->txt("grp_header_edit_members"), "icon_usr_b.gif", $this->lng->txt("grp_header_edit_members"));
601  $tbl->setHeaderNames(array ("", $this->lng->txt("obj_grp"), $this->lng->txt("grp_count_members")));
602  $tbl->setHeaderVars(array ("", "title", "nr_members"), array ("ref_id" => $this->ref_id, "cmd" => "search", "cmdClass" => "ilobjgroupgui", "cmdNode" => $_GET["cmdNode"]));
603 
604  $tbl->setColumnWidth(array ("", "80%", "19%"));
605 
606  $this->__setTableGUIBasicData($tbl, $a_result_set, "group");
607  $tbl->render();
608 
609  $this->tpl->setVariable("SEARCH_RESULT_TABLE", $tbl->tpl->get());
610 
611  return true;
612  }
613  function listUsersRole() {
614  global $rbacsystem, $rbacreview;
615 
616  $_SESSION["grp_role"] = $_POST["role"] = $_POST["role"] ? $_POST["role"] : $_SESSION["grp_role"];
617 
618  // MINIMUM ACCESS LEVEL = 'administrate'
619  if (!$rbacsystem->checkAccess("write", $this->ref_id)) {
620  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"), $this->ilias->error_obj->MESSAGE);
621  }
622 
623  if (!is_array($_POST["role"])) {
624  ilUtil::sendInfo($this->lng->txt("grp_no_roles_selected"));
625  $this->searchObject();
626 
627  return false;
628  }
629 
630  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.grp_usr_selection.html");
631  $this->__showButton("searchUserForm", $this->lng->txt("grp_new_search"));
632 
633  // GET ALL MEMBERS
634  $members = array ();
635  foreach ($_POST["role"] as $role_id) {
636  $members = array_merge($rbacreview->assignedUsers($role_id), $members);
637  }
638 
639  $members = array_unique($members);
640 
641  // FORMAT USER DATA
642  $counter = 0;
643  $f_result = array ();
644  foreach ($members as $user) {
645  if (!$tmp_obj = ilObjectFactory :: getInstanceByObjId($user, false)) {
646  continue;
647  }
648 
649  if (!$tmp_obj->active) {
650  continue;
651  }
652 
653  $user_ids[$counter] = $user;
654 
655  $f_result[$counter][] = ilUtil :: formCheckbox(0, "user[]", $user);
656  $f_result[$counter][] = $tmp_obj->getLogin();
657  $f_result[$counter][] = $tmp_obj->getLastname();
658  $f_result[$counter][] = $tmp_obj->getFirstname();
659  $f_result[$counter][] = ilFormat :: formatDate($tmp_obj->getLastLogin());
660 
661  unset ($tmp_obj);
662  ++ $counter;
663  }
664  $this->__showSearchUserTable($f_result, $user_ids, "listUsersRole");
665 
666  return true;
667  }
668 
669  function listUsersGroup() {
670  global $rbacsystem, $rbacreview, $tree;
671 
672  $_SESSION["grp_group"] = $_POST["group"] = $_POST["group"] ? $_POST["group"] : $_SESSION["grp_group"];
673 
674  // MINIMUM ACCESS LEVEL = 'administrate'
675  if (!$rbacsystem->checkAccess("write", $this->ref_id)) {
676  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"), $this->ilias->error_obj->MESSAGE);
677  }
678 
679  if (!is_array($_POST["group"])) {
680  ilUtil::sendInfo($this->lng->txt("grp_no_groups_selected"));
681  $this->searchObject();
682 
683  return false;
684  }
685 
686  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.grp_usr_selection.html");
687  $this->__showButton("searchUserForm", $this->lng->txt("grp_new_search"));
688 
689  // GET ALL MEMBERS
690  $members = array ();
691  foreach ($_POST["group"] as $group_id) {
692  if (!$tree->isInTree($group_id)) {
693  continue;
694  }
695  if (!$tmp_obj = ilObjectFactory :: getInstanceByRefId($group_id)) {
696  continue;
697  }
698 
699  $members = array_merge($tmp_obj->getGroupMemberIds(), $members);
700 
701  unset ($tmp_obj);
702  }
703 
704  $members = array_unique($members);
705 
706  // FORMAT USER DATA
707  $counter = 0;
708  $f_result = array ();
709  foreach ($members as $user) {
710  if (!$tmp_obj = ilObjectFactory :: getInstanceByObjId($user, false)) {
711  continue;
712  }
713 
714  $user_ids[$counter] = $user;
715 
716  $f_result[$counter][] = ilUtil :: formCheckbox(0, "user[]", $user);
717  $f_result[$counter][] = $tmp_obj->getLogin();
718  $f_result[$counter][] = $tmp_obj->getLastname();
719  $f_result[$counter][] = $tmp_obj->getFirstname();
720  $f_result[$counter][] = ilFormat :: formatDate($tmp_obj->getLastLogin());
721 
722  unset ($tmp_obj);
723  ++ $counter;
724  }
725  $this->__showSearchUserTable($f_result, $user_ids, "listUsersGroup");
726 
727  return true;
728  }
729 
730  function addUser() {
731  //echo "addUserObject() ausgefuehrt;";
732  $user_ids = $_POST["user"];
733 
734  if (empty ($user_ids[0])) {
735  //echo "...nix weitergeleitet...";
736  // TODO: jumps back to grp content. go back to last search result
737  $this->ilErr->raiseError($this->lng->txt("no_checkbox"), $this->ilErr->MESSAGE);
738  } else {
739  //echo "...Daten weitergeleitet...";
740  }
741  $_SESSION["il_track_stat2"] = "choice";
742  $_SESSION["userSelected_stat"] = $_POST["user"];
743  $this->show();
744 
745  }
746 
750  function & executeCommand() {
751  if (isset($_POST["cmd"]["searchUserForm"]))
752  {
753  $cmd = "searchUserForm";
754  } elseif (isset($_POST["cmd"]["outputStatistics"]))
755  {
756  $cmd = "outputStatistics";
757  } else switch ($this->ctrl->getNextClass()) {
758  default :
759  $cmd = $this->__getDefaultCommand();
760  }
761  $this-> $cmd ();
762  return true;
763  }
764 
765 }
766 ?>