ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjiLincCourseGUI.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 
5 include_once "./Services/Container/classes/class.ilContainerGUI.php";
6 
21 {
22  private $form_gui = null;
23 
28  public function ilObjiLincCourseGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output = false)
29  {
30  $this->type = "icrs";
31  $this->ilContainerGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output);
32 
33  $this->ctrl->saveParameter($this,'ref_id');
34 
35  $this->lng->loadLanguageModule('ilinc');
36  }
37 
43  public function createObject()
44  {
45  global $rbacsystem;
46 
47  $new_type = $_POST['new_type'] ? $_POST['new_type'] : $_GET['new_type'];
48 
49  if(!$rbacsystem->checkAccess('create', $_GET['ref_id'], $new_type))
50  {
51  $this->ilias->raiseError($this->lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
52  }
53 
54  $this->initSettingsForm('create');
55  return $this->tpl->setVariable('ADM_CONTENT', $this->form_gui->getHtml());
56  }
57 
58  public function updateObject()
59  {
60  global $ilAccess;
61 
62  if(!$ilAccess->checkAccess('write', '', (int)$_GET['ref_id']))
63  {
64  $this->ilErr->raiseError($this->lng->txt('permission_denied'), $this->ilErr->MESSAGE);
65  }
66 
67  $this->initSettingsForm('edit');
68  if($this->form_gui->checkInput())
69  {
70  $_POST['Fobject']['title'] = $this->form_gui->getInput('title');
71  $_POST['Fobject']['desc'] = $this->form_gui->getInput('desc');
72  $_POST['Fobject']['activated'] = $this->form_gui->getInput('activated');
73  $_POST['Fobject']['akclassvalue1'] = $this->form_gui->getInput('akclassvalue1');
74  $_POST['Fobject']['akclassvalue2'] = $this->form_gui->getInput('akclassvalue2');
75 
76  $this->object->setTitle(ilUtil::prepareDBString($_POST['Fobject']['title']));
77  $this->object->setDescription(ilUtil::prepareDBString($_POST['Fobject']['desc']));
78  $this->object->activated = ilUtil::tf2yn($_POST['Fobject']['activated']);
79 
80  // update akclassvalues only if iLinc is active
81  if($this->ilias->getSetting('ilinc_akclassvalues_active'))
82  {
83  if($this->object->getAKClassValue1() != $_POST['Fobject']['akclassvalue1'])
84  {
85  $this->object->setAKClassValue1(ilUtil::prepareDBString($_POST['Fobject']['akclassvalue1']));
86  }
87 
88  if($this->object->getAKClassValue2() != $_POST['Fobject']['akclassvalue2'])
89  {
90  $this->object->setAKClassValue2(ilUtil::prepareDBString($_POST['Fobject']['akclassvalue2']));
91  }
92  }
93 
94  // save changes to ilinc server and ilias database
95  $success = $this->object->update();
96  if($success == false)
97  {
98  $this->ilErr->raiseError($this->object->getErrorMsg(), $this->ilErr->MESSAGE);
99  }
100 
101  // update all akclassvalues of classes if akclassvalues has changed
102  if(array_key_exists('akclassvalue1', $_POST['Fobject']) or
103  array_key_exists('akclassvalue2',$_POST['Fobject']))
104  {
105  if(!$this->object->updateClassrooms())
106  {
107  ilUtil::sendInfo($this->lng->txt($this->object->getErrorMsg()));
108  $this->form_gui->setValuesByPost();
109  return $this->tpl->setVariable('ADM_CONTENT', $this->form_gui->getHtml());
110  }
111  }
112 
113  ilUtil::sendInfo($this->lng->txt('msg_obj_modified'));
114  $this->form_gui->setValuesByPost();
115  return $this->tpl->setVariable('ADM_CONTENT', $this->form_gui->getHtml());
116  }
117  else
118  {
119  $this->form_gui->setValuesByPost();
120  return $this->tpl->setVariable('ADM_CONTENT', $this->form_gui->getHtml());
121  }
122  }
123 
128  public function saveObject()
129  {
130  $this->initSettingsForm('create');
131  if($this->form_gui->checkInput())
132  {
133  $_POST['Fobject']['title'] = $this->form_gui->getInput('title');
134  $_POST['Fobject']['desc'] = $this->form_gui->getInput('desc');
135  $_POST['Fobject']['activated'] = $this->form_gui->getInput('activated');
136  $_POST['Fobject']['akclassvalue1'] = $this->form_gui->getInput('akclassvalue1');
137  $_POST['Fobject']['akclassvalue2'] = $this->form_gui->getInput('akclassvalue2');
138 
139  // when creating new ilinc course we first create it on ilinc server
140  include_once 'Modules/ILinc/classes/class.ilnetucateXMLAPI.php';
141  $ilinc = new ilnetucateXMLAPI();
142  $ilinc->addCourse($_POST['Fobject']);
143 
144  $this->iLincAddCourseResponse = $ilinc->sendRequest();
145  if($this->iLincAddCourseResponse->isError())
146  {
147  $this->ilErr->raiseError($this->iLincAddCourseResponse->getErrorMsg(), $this->ilErr->MESSAGE);
148  }
149 
150  // if everything ok
152  }
153  else
154  {
155  $this->form_gui->setValuesByPost();
156  return $this->tpl->setVariable('ADM_CONTENT', $this->form_gui->getHtml());
157  }
158  }
159 
163  protected function afterSave(ilObject $a_new_object)
164  {
165  // save ilinc_id in ILIAS and save data
166  $a_new_object->storeiLincId($this->iLincAddCourseResponse->getFirstID());
167  $a_new_object->saveActivationStatus(ilUtil::tf2yn((bool)$this->form_gui->getInput('activated')));
168  $a_new_object->saveAKClassValues(
169  $this->form_gui->getInput('akclassvalue1'),
170  $this->form_gui->getInput('akclassvalue2')
171  );
172 
173  // ...finally assign icrsadmin role to creator of icrs object
174  $success = $a_new_object->addMember($this->ilias->account, $a_new_object->getDefaultAdminRole(), true);
175 
176  if(!$success)
177  {
178  ilUtil::sendFailure($a_new_object->getErrorMsg(), true);
179  $this->ctrl->returnToParent($this);
180  }
181 
182 // $icrsObj->setRegistrationFlag($_POST["enable_registration"]); //0=no registration, 1=registration enabled 2=passwordregistration
183 // $icrsObj->setPassword($_POST["password"]);
184 // $icrsObj->setExpirationDateTime($_POST["expirationdate"]." ".$_POST["expirationtime"].":00");
185 
186  $this->ilias->account->addDesktopItem($a_new_object->getRefId(), 'icrs');
187 
188  // always send a message
189  ilUtil::sendInfo($this->lng->txt('icrs_added'), true);
190  $this->redirectToRefId((int)$_GET['ref_id']);
191  }
192 
198  public function getTabs(&$tabs_gui)
199  {
200  global $rbacsystem,$ilAccess;
201 
202  $this->ctrl->setParameter($this,'ref_id',$this->ref_id);
203 
204  if($rbacsystem->checkAccess('read',$this->ref_id))
205  {
206  $tabs_gui->addTarget('ilinc_classrooms',
207  $this->ctrl->getLinkTarget($this, ''),
208  array('', 'view', 'editClassroom', 'updateClassroom', 'removeClassroom')
209  );
210  }
211 
212  if($this->ilias->getSetting('ilinc_active'))
213  {
214  if($ilAccess->checkAccess('write', '', $this->ref_id))
215  {
216  $tabs_gui->addTarget('edit_properties',
217  $this->ctrl->getLinkTarget($this, 'edit'), array('edit', 'update', 'save'), get_class($this));
218  }
219 
220  /* if ($rbacsystem->checkAccess('read',$this->ref_id))
221  {
222  $tabs_gui->addTarget("ilinc_involved_users",
223  $this->ctrl->getLinkTarget($this, "members"), array("members","mailMembers","membersGallery","showProfile"), get_class($this));
224  }*/
225 
226  // member list
227  if($ilAccess->checkAccess('write','',$this->ref_id))
228  {
229  $tabs_gui->addTarget("ilinc_involved_users",
230  $this->ctrl->getLinkTarget($this, "members"),
231  array("members","mailMembers","membersGallery","showProfile",'changeMember', 'RemoveMember'),
232  get_class($this));
233  }
234  elseif ($ilAccess->checkAccess('read','',$this->ref_id))
235  {
236  $tabs_gui->addTarget("ilinc_involved_users",
237  $this->ctrl->getLinkTarget($this, "membersGallery"),
238  array("members","mailMembers","membersGallery","showProfile"),
239  get_class($this));
240  }
241 
242  if ($rbacsystem->checkAccess('write',$this->ref_id) and $this->object->isDocent($this->ilias->account))
243  {
244  // testing: display link to ilinc server directly
245  $tabs_gui->addTarget("ilinc_manage_course_documents",
246  $url = $this->object->userLogin($this->ilias->account), "agenda","","_blank");
247  // $tabs_gui->addTarget("ilinc_manage_course_documents",
248  // $this->ctrl->getLinkTarget($this, "agenda"), "agenda", get_class($this),"_blank");
249 
250  }
251  }
252 
253  /*$applications = $this->object->getNewRegistrations();
254 
255  if (is_array($applications) and $this->object->isAdmin($this->ilias->account->getId()))
256  {
257  $tabs_gui->addTarget("ilinc_new_registrations",
258  $this->ctrl->getLinkTarget($this, "ShownewRegistrations"), "ShownewRegistrations", get_class($this));
259  }*/
260 
261  if ($rbacsystem->checkAccess('edit_permission',$this->ref_id))
262  {
263  $tabs_gui->addTarget("perm_settings",
264  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
265  }
266 
267  // show clipboard in repository
268  if ($_GET["baseClass"] == "ilRepositoryGUI" and !empty($_SESSION['il_rep_clipboard']))
269  {
270  $tabs_gui->addTarget("clipboard",
271  $this->ctrl->getLinkTarget($this, "clipboard"), "clipboard", get_class($this));
272  }
273 
274  if ($this->ctrl->getTargetScript() == "adm_object.php")
275  {
276  if ($this->tree->getSavedNodeData($this->ref_id))
277  {
278  $tabs_gui->addTarget("trash",
279  $this->ctrl->getLinkTarget($this, "trash"), "trash", get_class($this));
280  }
281  }
282  }
283 
284  public function __unsetSessionVariables()
285  {
286  unset($_SESSION["grp_delete_member_ids"]);
287  unset($_SESSION["grp_delete_subscriber_ids"]);
288  unset($_SESSION["grp_search_str"]);
289  unset($_SESSION["grp_search_for"]);
290  unset($_SESSION["grp_role"]);
291  unset($_SESSION["grp_group"]);
292  unset($_SESSION["grp_archives"]);
293  }
294 
295  public function __search($a_search_string,$a_search_for)
296  {
297  include_once("./Services/Search/classes/class.ilSearch.php");
298 
299  $this->lng->loadLanguageModule("content");
300  $search =& new ilSearch($_SESSION["AccountId"]);
301  $search->setPerformUpdate(false);
302  $search->setSearchString(ilUtil::stripSlashes($a_search_string));
303  $search->setCombination("and");
304  $search->setSearchFor(array(0 => $a_search_for));
305  $search->setSearchType('new');
306 
307  if($search->validate($message))
308  {
309  $search->performSearch();
310  }
311  else
312  {
313  ilUtil::sendInfo($message,true);
314  $this->ctrl->redirect($this,"searchUserForm");
315  }
316 
317  return $search->getResultByType($a_search_for);
318  }
319 
320  public function __showSearchUserTable($a_result_set,$a_user_ids = NULL, $a_cmd = "search")
321  {
322  $return_to = "searchUserForm";
323 
324  if ($a_cmd == "listUsersRole" or $a_cmd == "listUsersGroup")
325  {
326  $return_to = "search";
327  }
328 
329  $tbl =& $this->__initTableGUI();
330  $tpl =& $tbl->getTemplateObject();
331 
332  // SET FORMACTION
333  $tpl->setCurrentBlock("tbl_form_header");
334  $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
335  $tpl->parseCurrentBlock();
336 
337  $tpl->setCurrentBlock("tbl_action_btn");
338  $tpl->setVariable("BTN_NAME",$return_to);
339  $tpl->setVariable("BTN_VALUE",$this->lng->txt("back"));
340  $tpl->parseCurrentBlock();
341 
342  $tpl->setCurrentBlock("tbl_action_btn");
343  $tpl->setVariable("BTN_NAME","addUser");
344  $tpl->setVariable("BTN_VALUE",$this->lng->txt("add"));
345  $tpl->parseCurrentBlock();
346 
347  if (!empty($a_user_ids))
348  {
349  // set checkbox toggles
350  $tpl->setCurrentBlock("tbl_action_toggle_checkboxes");
351  $tpl->setVariable("JS_VARNAME","user");
352  $tpl->setVariable("JS_ONCLICK",ilUtil::array_php2js($a_user_ids));
353  $tpl->setVariable("TXT_CHECKALL", $this->lng->txt("check_all"));
354  $tpl->setVariable("TXT_UNCHECKALL", $this->lng->txt("uncheck_all"));
355  $tpl->parseCurrentBlock();
356  }
357 
358  $tpl->setCurrentBlock("tbl_action_row");
359  $tpl->setVariable("COLUMN_COUNTS",5);
360  $tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.png"));
361  $tpl->parseCurrentBlock();
362 
363  $tbl->setTitle($this->lng->txt("ilinc_header_edit_users"),"icon_usr_b.png",$this->lng->txt("ilinc_header_edit_users"));
364  $tbl->setHeaderNames(array("",
365  $this->lng->txt("username"),
366  $this->lng->txt("firstname"),
367  $this->lng->txt("lastname"),
368  $this->lng->txt("last_visit")));
369  $tbl->setHeaderVars(array("",
370  "login",
371  "firstname",
372  "lastname",
373  "last_visit"),
374  array("ref_id" => $this->object->getRefId(),
375  "cmd" => $a_cmd,
376  "cmdClass" => "ilobjilinccoursegui",
377  "cmdNode" => $_GET["cmdNode"]));
378 
379  $tbl->setColumnWidth(array("","33%","33%","33%"));
380 
381  $this->__setTableGUIBasicData($tbl,$a_result_set);
382  $tbl->render();
383 
384  $this->tpl->setVariable("SEARCH_RESULT_TABLE",$tbl->tpl->get());
385 
386  return true;
387  }
388 
389  public function __showSearchRoleTable($a_result_set,$a_role_ids = NULL)
390  {
391  $tbl =& $this->__initTableGUI();
392  $tpl =& $tbl->getTemplateObject();
393 
394  $tpl->setCurrentBlock("tbl_form_header");
395  $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
396  $tpl->parseCurrentBlock();
397 
398  $tpl->setCurrentBlock("tbl_action_btn");
399  $tpl->setVariable("BTN_NAME","searchUserForm");
400  $tpl->setVariable("BTN_VALUE",$this->lng->txt("back"));
401  $tpl->parseCurrentBlock();
402 
403  $tpl->setCurrentBlock("tbl_action_btn");
404  $tpl->setVariable("BTN_NAME","listUsersRole");
405  $tpl->setVariable("BTN_VALUE",$this->lng->txt("grp_list_users"));
406  $tpl->parseCurrentBlock();
407 
408  if (!empty($a_role_ids))
409  {
410  // set checkbox toggles
411  $tpl->setCurrentBlock("tbl_action_toggle_checkboxes");
412  $tpl->setVariable("JS_VARNAME","role");
413  $tpl->setVariable("JS_ONCLICK",ilUtil::array_php2js($a_role_ids));
414  $tpl->setVariable("TXT_CHECKALL", $this->lng->txt("check_all"));
415  $tpl->setVariable("TXT_UNCHECKALL", $this->lng->txt("uncheck_all"));
416  $tpl->parseCurrentBlock();
417  }
418 
419  $tpl->setCurrentBlock("tbl_action_row");
420  $tpl->setVariable("COLUMN_COUNTS",5);
421  $tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.png"));
422  $tpl->parseCurrentBlock();
423 
424  $tbl->setTitle($this->lng->txt("ilinc_header_edit_users"),"icon_usr_b.png",$this->lng->txt("ilinc_header_edit_users"));
425  $tbl->setHeaderNames(array("",
426  $this->lng->txt("obj_role"),
427  $this->lng->txt("grp_count_members")));
428  $tbl->setHeaderVars(array("",
429  "title",
430  "nr_members"),
431  array("ref_id" => $this->object->getRefId(),
432  "cmd" => "search",
433  "cmdClass" => "ilobjilincoursegui",
434  "cmdNode" => $_GET["cmdNode"]));
435 
436  $tbl->setColumnWidth(array("","80%","19%"));
437 
438 
439  $this->__setTableGUIBasicData($tbl,$a_result_set,"role");
440  $tbl->render();
441 
442  $this->tpl->setVariable("SEARCH_RESULT_TABLE",$tbl->tpl->get());
443 
444  return true;
445  }
446 
447  public function __showSearchGroupTable($a_result_set,$a_grp_ids = NULL)
448  {
449  $tbl =& $this->__initTableGUI();
450  $tpl =& $tbl->getTemplateObject();
451 
452  $tpl->setCurrentBlock("tbl_form_header");
453  $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
454  $tpl->parseCurrentBlock();
455 
456  $tpl->setCurrentBlock("tbl_action_btn");
457  $tpl->setVariable("BTN_NAME","searchUserForm");
458  $tpl->setVariable("BTN_VALUE",$this->lng->txt("back"));
459  $tpl->parseCurrentBlock();
460 
461  $tpl->setCurrentBlock("tbl_action_btn");
462  $tpl->setVariable("BTN_NAME","listUsersGroup");
463  $tpl->setVariable("BTN_VALUE",$this->lng->txt("grp_list_users"));
464  $tpl->parseCurrentBlock();
465 
466  if (!empty($a_grp_ids))
467  {
468  // set checkbox toggles
469  $tpl->setCurrentBlock("tbl_action_toggle_checkboxes");
470  $tpl->setVariable("JS_VARNAME","group");
471  $tpl->setVariable("JS_ONCLICK",ilUtil::array_php2js($a_grp_ids));
472  $tpl->setVariable("TXT_CHECKALL", $this->lng->txt("check_all"));
473  $tpl->setVariable("TXT_UNCHECKALL", $this->lng->txt("uncheck_all"));
474  $tpl->parseCurrentBlock();
475  }
476 
477  $tpl->setCurrentBlock("tbl_action_row");
478  $tpl->setVariable("COLUMN_COUNTS",5);
479  $tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.png"));
480  $tpl->parseCurrentBlock();
481 
482  $tbl->setTitle($this->lng->txt("ilinc_header_edit_users"),"icon_usr_b.png",$this->lng->txt("ilinc_header_edit_users"));
483  $tbl->setHeaderNames(array("",
484  $this->lng->txt("obj_grp"),
485  $this->lng->txt("grp_count_members")));
486  $tbl->setHeaderVars(array("",
487  "title",
488  "nr_members"),
489  array("ref_id" => $this->object->getRefId(),
490  "cmd" => "search",
491  "cmdClass" => "ilobjilinccoursegui",
492  "cmdNode" => $_GET["cmdNode"]));
493 
494  $tbl->setColumnWidth(array("","80%","19%"));
495 
496 
497  $this->__setTableGUIBasicData($tbl,$a_result_set,"group");
498  $tbl->render();
499 
500  $this->tpl->setVariable("SEARCH_RESULT_TABLE",$tbl->tpl->get());
501 
502  return true;
503  }
504 
505  public function &__initTableGUI()
506  {
507  include_once "./Services/Table/classes/class.ilTableGUI.php";
508 
509  return new ilTableGUI(0,false);
510  }
511 
512  public function __setTableGUIBasicData(&$tbl,&$result_set,$from = "")
513  {
514  switch($from)
515  {
516  case "subscribers":
517  $offset = $_GET["update_subscribers"] ? $_GET["offset"] : 0;
518  $order = $_GET["update_subscribers"] ? $_GET["sort_by"] : 'login';
519  $direction = $_GET["update_subscribers"] ? $_GET["sort_order"] : '';
520  break;
521 
522  case "group":
523  $offset = $_GET["offset"];
524  $order = $_GET["sort_by"] ? $_GET["sort_by"] : "title";
525  $direction = $_GET["sort_order"];
526  break;
527 
528  case "role":
529  $offset = $_GET["offset"];
530  $order = $_GET["sort_by"] ? $_GET["sort_by"] : "title";
531  $direction = $_GET["sort_order"];
532  break;
533 
534  default:
535  $offset = $_GET["offset"];
536  // init sort_by (unfortunatly sort_by is preset with 'title'
537  if ($_GET["sort_by"] == "title" or empty($_GET["sort_by"]))
538  {
539  $_GET["sort_by"] = "login";
540  }
541  $order = $_GET["sort_by"];
542  $direction = $_GET["sort_order"];
543  break;
544  }
545 
546  $tbl->setOrderColumn($order);
547  $tbl->setOrderDirection($direction);
548  $tbl->setOffset($offset);
549  $tbl->setLimit($_GET["limit"]);
550  //$tbl->setMaxCount(count($result_set));
551  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
552  $tbl->setData($result_set);
553  }
554 
555  public function listUsersRoleObject()
556  {
557  global $rbacsystem,$rbacreview;
558 
559  $_SESSION["grp_role"] = $_POST["role"] = $_POST["role"] ? $_POST["role"] : $_SESSION["grp_role"];
560 
561  // MINIMUM ACCESS LEVEL = 'administrate'
562  if(!$rbacsystem->checkAccess("write", $this->object->getRefId()))
563  {
564  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
565  }
566 
567  if(!is_array($_POST["role"]))
568  {
569  ilUtil::sendInfo($this->lng->txt("grp_no_roles_selected"));
570  $this->searchObject();
571 
572  return false;
573  }
574 
575  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.grp_usr_selection.html",
576  "Modules/Group");
577  $this->__showButton("searchUserForm",$this->lng->txt("grp_new_search"));
578 
579  // GET ALL MEMBERS
580  $members = array();
581  foreach($_POST["role"] as $role_id)
582  {
583  $members = array_merge($rbacreview->assignedUsers($role_id),$members);
584  }
585 
586  $members = array_unique($members);
587 
588  // FORMAT USER DATA
589  $counter = 0;
590  $f_result = array();
591  foreach($members as $user)
592  {
593  if(!$tmp_obj = ilObjectFactory::getInstanceByObjId($user,false))
594  {
595  continue;
596  }
597 
598  $user_ids[$counter] = $user;
599 
600  $f_result[$counter][] = ilUtil::formCheckbox(0,"user[]",$user);
601  $f_result[$counter][] = $tmp_obj->getLogin();
602  $f_result[$counter][] = $tmp_obj->getLastname();
603  $f_result[$counter][] = $tmp_obj->getFirstname();
604  $f_result[$counter][] = ilDatePresentation::formatDate(new ilDateTime($tmp_obj->getLastLogin(),IL_CAL_DATETIME));
605 
606  unset($tmp_obj);
607  ++$counter;
608  }
609  $this->__showSearchUserTable($f_result,$user_ids,"listUsersRole");
610 
611  return true;
612  }
613 
614  public function listUsersGroupObject()
615  {
616  global $rbacsystem,$rbacreview,$tree;
617 
618  $_SESSION["grp_group"] = $_POST["group"] = $_POST["group"] ? $_POST["group"] : $_SESSION["grp_group"];
619 
620  // MINIMUM ACCESS LEVEL = 'administrate'
621  if(!$rbacsystem->checkAccess("write", $this->object->getRefId()))
622  {
623  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
624  }
625 
626  if(!is_array($_POST["group"]))
627  {
628  ilUtil::sendInfo($this->lng->txt("grp_no_groups_selected"));
629  $this->searchObject();
630 
631  return false;
632  }
633 
634  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.grp_usr_selection.html",
635  "Modules/Group");
636  $this->__showButton("searchUserForm",$this->lng->txt("grp_new_search"));
637 
638  // GET ALL MEMBERS
639  $members = array();
640  foreach($_POST["group"] as $group_id)
641  {
642  if (!$tree->isInTree($group_id))
643  {
644  continue;
645  }
646  if (!$tmp_obj = ilObjectFactory::getInstanceByRefId($group_id))
647  {
648  continue;
649  }
650 
651  $members = array_merge($tmp_obj->getGroupMemberIds(),$members);
652 
653  unset($tmp_obj);
654  }
655 
656  $members = array_unique($members);
657 
658  // FORMAT USER DATA
659  $counter = 0;
660  $f_result = array();
661  foreach($members as $user)
662  {
663  if(!$tmp_obj = ilObjectFactory::getInstanceByObjId($user,false))
664  {
665  continue;
666  }
667 
668  $user_ids[$counter] = $user;
669 
670  $f_result[$counter][] = ilUtil::formCheckbox(0,"user[]",$user);
671  $f_result[$counter][] = $tmp_obj->getLogin();
672  $f_result[$counter][] = $tmp_obj->getLastname();
673  $f_result[$counter][] = $tmp_obj->getFirstname();
674  $f_result[$counter][] = ilDatePresentation::formatDate(new ilDateTime($tmp_obj->getLastLogin(),IL_CAL_DATETIME));
675 
676  unset($tmp_obj);
677  ++$counter;
678  }
679  $this->__showSearchUserTable($f_result,$user_ids,"listUsersGroup");
680 
681  return true;
682  }
683 
688  public function canceledObject()
689  {
690  $return_location = $_GET["cmd_return_location"];
691  if (strcmp($return_location, "") == 0)
692  {
693  $return_location = "members";
694  }
695 
696  ilUtil::sendInfo($this->lng->txt("action_aborted"),true);
697  $this->ctrl->redirect($this, $return_location);
698  }
699 
704  public function cancelMemberObject()
705  {
706  $return_location = "members";
707 
708  ilUtil::sendInfo($this->lng->txt("action_aborted"),true);
709  ilUtil::redirect($this->ctrl->getLinkTarget($this,$return_location,"",false,false));
710  }
711 
715  public function membersObject()
716  {
717  global $ilAccess, $ilBench, $lng, $ilToolbar, $ilUser;
718 
719  if(!$this->ilias->getSetting('ilinc_active'))
720  {
721  $this->ilias->raiseError($lng->txt('ilinc_server_not_active'), $this->ilias->error_obj->MESSAGE);
722  }
723 
724  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.icrs_members.html','Modules/ILinc');
725  $this->__setSubTabs('members');
726 
727  $this->lng->loadLanguageModule('ilinc');
728 
729  // display member search button
730  $is_admin = (bool)$ilAccess->checkAccess('write', '', $this->object->getRefId());
731  if($is_admin)
732  {
733  $ilToolbar->addButton($this->lng->txt('ilinc_add_user'), $this->ctrl->getLinkTargetByClass('ilRepositorySearchGUI', 'start'));
734  }
735 
736  //if current user is admin he is able to add new members to group
737  $val_contact = "<img src=\"".ilUtil::getImagePath("icon_pencil_b.png")."\" alt=\"".$this->lng->txt("ilinc_mem_send_mail")."\" title=\"".$this->lng->txt("ilinc_mem_send_mail")."\" border=\"0\" vspace=\"0\"/>";
738  $val_change = "<img src=\"".ilUtil::getImagePath("icon_change_b.png")."\" alt=\"".$this->lng->txt("ilinc_mem_change_status")."\" title=\"".$this->lng->txt("ilinc_mem_change_status")."\" border=\"0\" vspace=\"0\"/>";
739  $val_leave = "<img src=\"".ilUtil::getImagePath("icon_group_out_b.png")."\" alt=\"".$this->lng->txt("ilinc_mem_leave")."\" title=\"".$this->lng->txt("ilinc_mem_leave")."\" border=\"0\" vspace=\"0\"/>";
740 
741  // store access checks to improve performance
742  $access_leave = $ilAccess->checkAccess('leave', '', $this->object->getRefId());
743  $access_write = $ilAccess->checkAccess('write', '', $this->object->getRefId());
744 
745  $member_ids = $this->object->getMemberIds();
746 
747  // fetch all user data in one shot to improve performance (from ILIAS db)
748  $members = $this->object->getMemberData($member_ids);
749 
750  // fetch docent or student assignment form all coursemembers from iLinc server
751  $docent_ids = $this->object->getiLincMemberIds(true);
752  $student_ids = $this->object->getiLincMemberIds(false);
753 
754  $counter = 0;
755  $result_set = array();
756  require_once 'Services/Mail/classes/class.ilMailFormCall.php';
757  foreach($members as $mem)
758  {
759  $link_contact = ilMailFormCall::getLinkTarget($this, 'members', array(), array('type' => 'new', 'rcp_to' => $mem['login']));
760  $link_change = $this->ctrl->getLinkTarget($this, 'changeMember').'&mem_id='.$mem['id'];
761  if(($mem['id'] == $ilUser->getId() && $access_leave) || $access_delete)
762  {
763  $link_leave = $this->ctrl->getLinkTarget($this, 'removeMember').'&mem_id='.$mem['id'];
764  }
765 
766  //build functions
767  $member_functions = '';
768  if($access_write)
769  {
770  $member_functions = "<a href=\"$link_change\">$val_change</a>";
771  }
772  if(($mem['id'] == $ilUser->getId() && $access_leave) || $access_write)
773  {
774  $link_leave = $this->ctrl->getLinkTarget($this, 'removeMember').'&mem_id='.$mem['id'];
775  $member_functions .="<a href=\"$link_leave\">$val_leave</a>";
776  }
777 
778  // this is twice as fast than the code above
779  $str_member_roles = $this->object->getMemberRolesTitle($mem['id']);
780 
781  if($access_write)
782  {
783  $result_set[$counter]['checkbox'] = ilUtil::formCheckBox(0, 'user_id[]', $mem['id']);
784  }
785 
786  $status = $this->object->checkiLincMemberStatus($mem['ilinc_id'], $docent_ids, $student_ids);
787  if($status == ILINC_MEMBER_NOTSET)
788  {
789  $status = "<span class='warning'>".$this->lng->txt($status)."</span>";
790  }
791  else
792  {
793  $status = $this->lng->txt($status);
794  }
795 
796  $result_set[$counter]['login'] = $mem['login'];
797  $result_set[$counter]['firstname'] = $mem['firstname'];
798  $result_set[$counter]['lastname'] = $mem['lastname'];
799  $result_set[$counter]['attending_as'] = $status;
800  $result_set[$counter]['role'] = $str_member_roles;
801  $result_set[$counter]['options'] = "<a href=\"$link_contact\">".$val_contact."</a>".$member_functions;
802 
803  ++$counter;
804 
805  unset($member_functions);
806  }
807 
808  include_once 'Modules/ILinc/classes/class.iliLinkMembersTableGUI.php';
809  $oTable = new iliLinkMembersTableGUI($this, $result_set, 'show', 'members', 'members');
810  $oTable->setTitle($this->lng->txt('ilinc_involved_users'), 'icon_usr_b.png', $this->lng->txt('ilinc_involved_users'));
811 
812  return $this->tpl->setVariable('MEMBER_TABLE', $oTable->getHTML());
813  }
814 
815  public function &executeCommand()
816  {
817  global $ilUser,$rbacsystem,$ilAccess,$ilErr;
818 
819  $next_class = $this->ctrl->getNextClass($this);
820  $cmd = $this->ctrl->getCmd();
821  $this->prepareOutput();
822 
823  switch($next_class)
824  {
825  case "ilconditionhandlerinterface":
826  include_once './Services/AccessControl/classes/class.ilConditionHandlerInterface.php';
827 
828  if($_GET['item_id'])
829  {
830  $new_gui =& new ilConditionHandlerInterface($this,(int) $_GET['item_id']);
831  $this->ctrl->saveParameter($this,'item_id',$_GET['item_id']);
832  $this->ctrl->forwardCommand($new_gui);
833  }
834  else
835  {
836  $new_gui =& new ilConditionHandlerInterface($this);
837  $this->ctrl->forwardCommand($new_gui);
838  }
839  break;
840 
841  case 'ilrepositorysearchgui':
842  include_once('./Services/Search/classes/class.ilRepositorySearchGUI.php');
843  $rep_search =& new ilRepositorySearchGUI();
844  $rep_search->setCallback($this,'addUserObject');
845 
846  // Set tabs
847  $this->tabs_gui->setTabActive('members');
848  $this->ctrl->setReturn($this,'members');
849  $ret =& $this->ctrl->forwardCommand($rep_search);
850  $this->__setSubTabs('members');
851  $this->tabs_gui->setSubTabActive('members');
852  break;
853 
854  case "ilobjilincclassroomgui":
855  include_once ('./Modules/ILinc/classes/class.ilObjiLincClassroomGUI.php');
856  $icla_gui = new ilObjiLincClassroomGUI($_GET['class_id'],$this->ref_id);
857  $ret =& $this->ctrl->forwardCommand($icla_gui);
858  break;
859 
860  case 'ilpermissiongui':
861  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
862  $perm_gui =& new ilPermissionGUI($this);
863  $ret =& $this->ctrl->forwardCommand($perm_gui);
864  break;
865 
866  case 'ilpublicuserprofilegui':
867  require_once './Services/User/classes/class.ilPublicUserProfileGUI.php';
868  $profile_gui = new ilPublicUserProfileGUI($_GET["user"]);
869  $html = $this->ctrl->forwardCommand($profile_gui);
870  $this->__setSubTabs('members');
871  $this->tabs_gui->setTabActive('group_members');
872  $this->tabs_gui->setSubTabActive('grp_members_gallery');
873  $this->tpl->setVariable("ADM_CONTENT", $html);
874  break;
875 
876  default:
877  if (!$this->getCreationMode() and !$ilAccess->checkAccess('visible','',$this->object->getRefId(),'icrs'))
878  {
879  $ilErr->raiseError($this->lng->txt("msg_no_perm_read"),$ilErr->MESSAGE);
880  }
881 
882 
883  if(!$cmd)
884  {
885  $cmd = 'view';
886  }
887  $cmd .= 'Object';
888  $this->$cmd();
889  break;
890  }
891  }
892 
893  public function viewObject()
894  {
895  global $ilCtrl, $ilNavigationHistory, $ilAccess;
896 
897  if(!$ilAccess->checkAccess('read', '', $this->object->getRefId()))
898  {
899  $this->ilias->raiseError($this->lng->txt('msg_no_perm_read'), $this->ilias->error_obj->MESSAGE);
900  }
901 
902  // add entry to navigation history
903  if(!$this->getCreationMode() &&
904  $ilAccess->checkAccess('read', '', $this->object->getRefId()))
905  {
906  $ilNavigationHistory->addItem($this->object->getRefId(),
907  'ilias.php?baseClass=ilRepositoryGUI&cmd=view&ref_id='.$this->object->getRefId(), 'icrs');
908  }
909 
910  if(strtolower($_GET['baseClass']) == 'iladministrationgui')
911  {
913  return true;
914  }
915 
916  return $this->renderObject();
917  }
918 
919  public function agendaObject()
920  {
921  // user login
922  $url = $this->object->userLogin($this->ilias->account);
923 
924  if (!$url)
925  {
926  $this->ilias->raiseError($this->object->getErrorMsg(),$this->ilias->error_obj->FATAL);
927  }
928 
929  ilUtil::redirect(trim($url));
930  }
931 
932  public function searchUserFormObject()
933  {
934  global $rbacsystem;
935 
936  $this->lng->loadLanguageModule('search');
937 
938  // MINIMUM ACCESS LEVEL = 'administrate'
939  if(!$rbacsystem->checkAccess("write", $this->object->getRefId()))
940  {
941  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
942  }
943 
944  $this->tpl->addBlockFile("ADM_CONTENT","adm_content","tpl.grp_members_search.html",
945  "Modules/Group");
946 
947  $this->tpl->setVariable("F_ACTION",$this->ctrl->getFormAction($this));
948  $this->tpl->setVariable("SEARCH_ASSIGN_USR",$this->lng->txt("grp_search_members"));
949  $this->tpl->setVariable("SEARCH_SEARCH_TERM",$this->lng->txt("search_search_term"));
950  $this->tpl->setVariable("SEARCH_VALUE",$_SESSION["grp_search_str"] ? $_SESSION["grp_search_str"] : "");
951  $this->tpl->setVariable("SEARCH_FOR",$this->lng->txt("exc_search_for"));
952  $this->tpl->setVariable("SEARCH_ROW_TXT_USER",$this->lng->txt("exc_users"));
953  $this->tpl->setVariable("SEARCH_ROW_TXT_ROLE",$this->lng->txt("exc_roles"));
954  $this->tpl->setVariable("SEARCH_ROW_TXT_GROUP",$this->lng->txt("exc_groups"));
955  $this->tpl->setVariable("BTN2_VALUE",$this->lng->txt("cancel"));
956  $this->tpl->setVariable("BTN1_VALUE",$this->lng->txt("search"));
957 
958  $usr = ($_POST["search_for"] == "usr" || $_POST["search_for"] == "") ? 1 : 0;
959  $grp = ($_POST["search_for"] == "grp") ? 1 : 0;
960  $role = ($_POST["search_for"] == "role") ? 1 : 0;
961 
962  $this->tpl->setVariable("SEARCH_ROW_CHECK_USER",ilUtil::formRadioButton($usr,"search_for","usr"));
963  $this->tpl->setVariable("SEARCH_ROW_CHECK_ROLE",ilUtil::formRadioButton($role,"search_for","role"));
964  $this->tpl->setVariable("SEARCH_ROW_CHECK_GROUP",ilUtil::formRadioButton($grp,"search_for","grp"));
965 
966  $this->__unsetSessionVariables();
967  }
968 
969  function searchObject()
970  {
971  global $rbacsystem,$tree;
972 
973  $_SESSION["grp_search_str"] = $_POST["search_str"] = $_POST["search_str"] ? $_POST["search_str"] : $_SESSION["grp_search_str"];
974  $_SESSION["grp_search_for"] = $_POST["search_for"] = $_POST["search_for"] ? $_POST["search_for"] : $_SESSION["grp_search_for"];
975 
976  // MINIMUM ACCESS LEVEL = 'administrate'
977  if(!$rbacsystem->checkAccess("write", $this->object->getRefId()))
978  {
979  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
980  }
981 
982  if(!isset($_POST["search_for"]) or !isset($_POST["search_str"]))
983  {
984  ilUtil::sendInfo($this->lng->txt("grp_search_enter_search_string"));
985  $this->searchUserFormObject();
986 
987  return false;
988  }
989 
990  if(!count($result = $this->__search(ilUtil::stripSlashes($_POST["search_str"]),$_POST["search_for"])))
991  {
992  ilUtil::sendInfo($this->lng->txt("grp_no_results_found"));
993  $this->searchUserFormObject();
994 
995  return false;
996  }
997 
998  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.grp_usr_selection.html",
999  "Modules/Group");
1000  $this->__showButton("searchUserForm",$this->lng->txt("grp_new_search"));
1001 
1002  $counter = 0;
1003  $f_result = array();
1004 
1005  switch($_POST["search_for"])
1006  {
1007  case "usr":
1008  foreach($result as $user)
1009  {
1010  if(!$tmp_obj = ilObjectFactory::getInstanceByObjId($user["id"],false))
1011  {
1012  continue;
1013  }
1014 
1015  $user_ids[$counter] = $user["id"];
1016 
1017  $f_result[$counter][] = ilUtil::formCheckbox(0,"user[]",$user["id"]);
1018  $f_result[$counter][] = $tmp_obj->getLogin();
1019  $f_result[$counter][] = $tmp_obj->getFirstname();
1020  $f_result[$counter][] = $tmp_obj->getLastname();
1021  $f_result[$counter][] = ilDatePresentation::formatDate(new ilDateTime($tmp_obj->getLastLogin(),IL_CAL_DATETIME));
1022 
1023  unset($tmp_obj);
1024  ++$counter;
1025  }
1026  $this->__showSearchUserTable($f_result,$user_ids);
1027 
1028  return true;
1029 
1030  case "role":
1031  foreach($result as $role)
1032  {
1033  // exclude anonymous role
1034  if ($role["id"] == ANONYMOUS_ROLE_ID)
1035  {
1036  continue;
1037  }
1038 
1039  if(!$tmp_obj = ilObjectFactory::getInstanceByObjId($role["id"],false))
1040  {
1041  continue;
1042  }
1043 
1044  // exclude roles with no users assigned to
1045  if ($tmp_obj->getCountMembers() == 0)
1046  {
1047  continue;
1048  }
1049 
1050  $role_ids[$counter] = $role["id"];
1051 
1052  $f_result[$counter][] = ilUtil::formCheckbox(0,"role[]",$role["id"]);
1053  $f_result[$counter][] = array($tmp_obj->getTitle(),$tmp_obj->getDescription());
1054  $f_result[$counter][] = $tmp_obj->getCountMembers();
1055 
1056  unset($tmp_obj);
1057  ++$counter;
1058  }
1059 
1060  $this->__showSearchRoleTable($f_result,$role_ids);
1061 
1062  return true;
1063 
1064  case "grp":
1065  foreach($result as $group)
1066  {
1067  if(!$tree->isInTree($group["id"]))
1068  {
1069  continue;
1070  }
1071 
1072  if(!$tmp_obj = ilObjectFactory::getInstanceByRefId($group["id"],false))
1073  {
1074  continue;
1075  }
1076 
1077  // exclude myself :-)
1078  if ($tmp_obj->getId() == $this->object->getId())
1079  {
1080  continue;
1081  }
1082 
1083  $grp_ids[$counter] = $group["id"];
1084 
1085  $f_result[$counter][] = ilUtil::formCheckbox(0,"group[]",$group["id"]);
1086  $f_result[$counter][] = array($tmp_obj->getTitle(),$tmp_obj->getDescription());
1087  $f_result[$counter][] = $tmp_obj->getCountMembers();
1088 
1089  unset($tmp_obj);
1090  ++$counter;
1091  }
1092 
1093  if(!count($f_result))
1094  {
1095  ilUtil::sendInfo($this->lng->txt("grp_no_results_found"));
1096  $this->searchUserFormObject();
1097 
1098  return false;
1099  }
1100 
1101  $this->__showSearchGroupTable($f_result,$grp_ids);
1102 
1103  return true;
1104  }
1105  }
1106 
1111  function addUserObject()
1112  {
1113  $user_ids = $_POST["user"];
1114  include_once 'Services/Mail/classes/class.ilMail.php';
1115  $mail = new ilMail($_SESSION["AccountId"]);
1116 
1117  if (empty($user_ids[0]))
1118  {
1119  // TODO: jumps back to grp content. go back to last search result
1120  $this->ilErr->raiseError($this->lng->txt("no_checkbox"),$this->ilErr->MESSAGE);
1121  }
1122 
1123  foreach ($user_ids as $new_member)
1124  {
1125  $user_obj = $this->ilias->obj_factory->getInstanceByObjId($new_member);
1126 
1127  if (!$this->object->addMember($user_obj,$this->object->getDefaultMemberRole(),false))
1128  {
1129  //var_dump($this->object->getErrorMsg());exit;
1130  $this->ilErr->raiseError($this->object->getErrorMsg(),$this->ilErr->MESSAGE);
1131  }
1132 
1133  $user_obj->addDesktopItem($this->object->getRefId(),"icrs");
1134  $mail->sendMail($user_obj->getLogin(),"","",$this->lng->txtlng("common","ilinc_mail_subj_new_subscription",$user_obj->getLanguage()).": ".$this->object->getTitle(),$this->lng->txtlng("common","ilinc_mail_body_new_subscription",$user_obj->getLanguage()),array(),array('normal'));
1135 
1136  unset($user_obj);
1137  }
1138 
1139  //echo "end";exit;
1140 
1141  unset($_SESSION["saved_post"]);
1142 
1143  ilUtil::sendInfo($this->lng->txt("ilinc_msg_member_assigned"),true);
1144  ilUtil::redirect($this->ctrl->getLinkTarget($this,"members","",false,false));
1145  }
1146 
1152  {
1153  global $ilUser, $rbacreview;
1154 
1155  $this->__setSubTabs('members');
1156 
1157  $user_ids = array();
1158 
1159  if(isset($_POST['user_id']))
1160  {
1161  $user_ids = $_POST['user_id'];
1162  }
1163  else if(isset($_GET['mem_id']))
1164  {
1165  $user_ids[] = $_GET['mem_id'];
1166  }
1167  else if(isset($_GET['mem_id_arr']))
1168  {
1169  $user_ids = explode(',', $_GET['mem_id_arr']);
1170  }
1171 
1172  if(empty($user_ids[0]))
1173  {
1174  $this->ilErr->raiseError($this->lng->txt("no_checkbox"), $this->ilErr->MESSAGE);
1175  }
1176 
1177  if(count($user_ids) == 1 && $ilUser->getId() != $user_ids[0])
1178  {
1179  if(!$rbacreview->isAssigned($ilUser->getId(), SYSTEM_ROLE_ID) &&
1180  !in_array($ilUser->getId(), $this->object->getAdminIds()))
1181  {
1182  $this->ilErr->raiseError($this->lng->txt("ilinc_err_no_permission"), $this->ilErr->MESSAGE);
1183  }
1184  }
1185 
1186  //bool value: says if $users_ids contains current user id
1187  $is_dismiss_me = array_search($this->ilias->account->getId(), $user_ids);
1188 
1189  $confirm = "confirmedRemoveMember";
1190  $cancel = "canceled";
1191  $info = ($is_dismiss_me !== false) ? "ilinc_dismiss_myself" : "ilinc_dismiss_member";
1192  $status = "";
1193  $return = "members";
1194 
1195  ilUtil::sendQuestion($this->lng->txt($info));
1196 
1197  $data = array();
1198  if(is_array($user_ids))
1199  {
1200  foreach($user_ids as $id)
1201  {
1202  $obj_data = ilObjectFactory::getInstanceByObjId($id);
1203  $data[$id] = array(
1204  'type' => ilUtil::getImageTagByType($obj_data->getType(), $this->tpl->tplPath),
1205  'title' => $obj_data->getTitle(),
1206  'desc' => $obj_data->getDescription(),
1207  'last_update' => $obj_data->getLastUpdateDate()
1208  );
1209  }
1210  }
1211  else
1212  {
1213  $obj_data = ilObjectFactory::getInstanceByObjId($user_ids);
1214  $data[$user_ids] = array(
1215  'type' => ilUtil::getImageTagByType($obj_data->getType(), $this->tpl->tplPath),
1216  'title' => $obj_data->getTitle(),
1217  'desc' => $obj_data->getDescription(),
1218  'last_update' => $obj_data->getLastUpdateDate(),
1219  );
1220  }
1221 
1222  //write in sessionvariables
1223  if(is_array($user_ids))
1224  {
1225  $_SESSION['saved_post']['user_id'] = $user_ids;
1226  }
1227  else
1228  {
1229  $_SESSION['saved_post']['user_id'][0] = $user_ids;
1230  }
1231 
1232  if(isset($status))
1233  {
1234  $_SESSION['saved_post']['status'] = $status;
1235  }
1236 
1237  include_once 'Modules/ILinc/classes/class.iliLinkConfirmationTableGUI.php';
1238  $this->ctrl->setParameter($this, 'cmd_return_location', $a_cmd_return_location);
1239  $this->ctrl->setParameter($this, 'mem_id_arr', implode(',', $user_ids));
1240  $oTable = new iliLinkConfirmationTableGUI($this, $data, 'removeMember', $return);
1241  $oTable->addCommandButton($cancel, $this->lng->txt('cancel'));
1242  $oTable->addCommandButton($confirm, $this->lng->txt('confirm'));
1243 
1244  return $this->tpl->setContent($oTable->getHTML());
1245  }
1246 
1251  function confirmationObject($user_id = '', $confirm = '', $cancel = '', $info = '', $status = '', $a_cmd_return_location = '', $invokeMethod = '')
1252  {
1253 
1254  }
1255 
1263  {
1264  global $ilCtrl;
1265 
1266  $removed_self = false;
1267  include_once 'Services/Mail/classes/class.ilMail.php';
1268  $mail = new ilMail($_SESSION["AccountId"]);
1269 
1270  //User needs to have administrative rights to remove members...
1271  foreach($_SESSION["saved_post"]["user_id"] as $member_id)
1272  {
1273  $user_obj = new ilObjUser($member_id);
1274 
1275  if (!$this->object->removeMember($user_obj))
1276  {
1277  ilUtil::sendInfo($this->lng->txt($this->object->getErrorMsg()),true);
1278  ilUtil::redirect($this->ctrl->getLinkTarget($this,"members","",false,false));
1279  }
1280 
1281  $user_obj->dropDesktopItem($this->object->getRefId(), "icrs");
1282 
1283  if (!$removed_self and $user_obj->getId() == $this->ilias->account->getId())
1284  {
1285  $removed_self = true;
1286  }
1287  else
1288  {
1289  $mail->sendMail($user_obj->getLogin(),"","",$this->lng->txtlng("common","ilinc_mail_subj_subscription_cancelled",$user_obj->getLanguage()).": ".$this->object->getTitle(),$this->lng->txtlng("common","ilinc_mail_body_subscription_cancelled",$user_obj->getLanguage()),array(),array('normal'));
1290  }
1291  }
1292 
1293  unset($_SESSION["saved_post"]);
1294 
1295  ilUtil::sendInfo($this->lng->txt("ilinc_msg_membership_annulled"),true);
1296 
1297  if ($removed_self)
1298  {
1299  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id",
1300  $this->tree->getParentId($this->ref_id));
1301  $ilCtrl->redirectByClass("ilrepositorygui", "");
1302  }
1303 
1304  ilUtil::redirect($this->ctrl->getLinkTarget($this,"members","",false,false));
1305  }
1306 
1312  {
1313  global $rbacreview, $ilUser;
1314 
1315  $this->__setSubTabs('members');
1316 
1317  $member_ids = array();
1318 
1319  if(isset($_POST['user_id']))
1320  {
1321  $member_ids = $_POST['user_id'];
1322  }
1323  else if(isset($_GET['mem_id']))
1324  {
1325  $member_ids[0] = $_GET['mem_id'];
1326  }
1327  else if(isset($_GET['mem_id_arr']))
1328  {
1329  $member_ids = explode(',', $_GET['mem_id_arr']);
1330  }
1331 
1332  if(empty($member_ids[0]))
1333  {
1334  $this->ilErr->raiseError($this->lng->txt('no_checkbox'), $this->ilErr->MESSAGE);
1335  }
1336 
1337  if(!$rbacreview->isAssigned($ilUser->getId(), SYSTEM_ROLE_ID) &&
1338  !in_array($ilUser->getId(), $this->object->getAdminIds()))
1339  {
1340  $this->ilErr->raiseError($this->lng->txt('grp_err_no_permission'), $this->ilErr->MESSAGE);
1341  }
1342 
1343  $stati = array_flip($this->object->getLocalRoles(true));
1344 
1345  // fetch docent or student assignment form all coursemembers from iLinc server
1346  $docent_ids = $this->object->getiLincMemberIds(true);
1347  $student_ids = $this->object->getiLincMemberIds(false);
1348 
1349  $data = array();
1350 
1351  //build data structure
1352  foreach($member_ids as $member_id)
1353  {
1354  $member = ilObjectFactory::getInstanceByObjId($member_id);
1355  $mem_status = $this->object->getMemberRoles($member_id);
1356 
1357  include_once 'Modules/ILinc/classes/class.ilObjiLincUser.php';
1358  $ilinc_user = new ilObjiLincUser($member);
1359 
1360  $ilinc_status = $this->object->checkiLincMemberStatus($ilinc_user->id, $docent_ids, $student_ids);
1361 
1362  $docent = 0; $student = 0;
1363 
1364  if($ilinc_status == ILINC_MEMBER_DOCENT)
1365  {
1366  $docent = 1;
1367  }
1368  else if($ilinc_status == ILINC_MEMBER_STUDENT)
1369  {
1370  $student = 1;
1371  }
1372 
1373  $radio1 = ilUtil::formRadioButton($docent, 'ilinc_member_status_select['.$member->getId().']['.$ilinc_user->id.']', ILINC_MEMBER_DOCENT);
1374  $radio2 = ilUtil::formRadioButton($student, 'ilinc_member_status_select['.$member->getId().']['.$ilinc_user->id.']', ILINC_MEMBER_STUDENT);
1375 
1376  $data[$member->getId()] = array(
1377  'login' => $member->getLogin(),
1378  'firstname' => $member->getFirstname(),
1379  'lastname' => $member->getLastname(),
1380  'attending_as' => $radio1.' '.$this->lng->txt('ilinc_docent').'<br />'.$radio2.' '.$this->lng->txt('ilinc_student'),
1381  'grp_role' => ilUtil::formSelect($mem_status, 'member_status_select['.$member->getId().'][]', $stati, true, true, 3)
1382  );
1383  }
1384 
1385  unset($member);
1386  unset($ilinc_user);
1387 
1388  include_once 'Modules/ILinc/classes/class.iliLinkMembersTableGUI.php';
1389  $this->ctrl->setParameter($this, 'mem_id_arr', implode(',', $member_ids));
1390  $oTable = new iliLinkMembersTableGUI($this, $data, 'change', 'changeMember', 'changeMember');
1391  $oTable->setTitle($this->lng->txt('grp_mem_change_status'), 'icon_usr_b.png', $this->lng->txt('grp_mem_change_status'));
1392 
1393  return $this->tpl->setContent($oTable->getHTML());
1394  }
1395 
1400  public function updateMemberStatusObject()
1401  {
1402  global $ilAccess;
1403 
1404  if(!$ilAccess->checkAccess('write', '', $this->object->getRefId()))
1405  {
1406  $this->ilErr->raiseError('permission_denied',$this->ilErr->MESSAGE);
1407  }
1408 
1409  if(isset($_POST['member_status_select']))
1410  {
1411  foreach($_POST['member_status_select'] as $key => $value)
1412  {
1413  $this->object->leave($key);
1414  $this->object->join($key,$value);
1415  }
1416  }
1417 
1418  if(isset($_POST['ilinc_member_status_select']))
1419  {
1420  $users_to_add = array();
1421  $users_to_register = array();
1422  $users_to_unregister = array();
1423 
1424  foreach($_POST['ilinc_member_status_select'] as $user_id => $ilinc_arr)
1425  {
1426  $ilinc_user_id = key($ilinc_arr);
1427  $ilinc_user_status = current($ilinc_arr);
1428  //var_dump($user_id,$ilinc_arr,$ilinc_user_id,$ilinc_user_status);
1429 
1430  // if no ilinc user id was passed, there are 3 options:
1431  // 1. user was added by roleassignment and is registered on iLinc server
1432  // 2. user was added by roleassignment and is registered NOT YET on iLinc server
1433  // 3. iLinc server returns an empty response which happens sometimes :-(
1434  if($ilinc_user_id == 0)
1435  {
1436  //echo '0';
1437 
1438  // check if user is already registered on iLinc server
1439  $user_obj = new ilObjUser($user_id);
1440 
1441  include_once 'Modules/ILinc/classes/class.ilObjiLincUser.php';
1442  $ilinc_user = new ilObjiLincUser($user_obj);
1443 
1444  if(!$ilinc_user->id)
1445  {
1446  // not registered. put user on 'add list'
1447  $users_to_add[] =& $user_obj;
1448  }
1449  else
1450  {
1451  $users_to_register[$ilinc_user->id] = ILINC_MEMBER_STUDENT;
1452  }
1453 
1454  continue;
1455  }
1456 
1457  //echo '1';
1458  $users_to_unregister[] = $ilinc_user_id;
1459  $users_to_register[$ilinc_user_id] = $ilinc_user_status;
1460  //var_dump($users_to_unregister,$users_to_register);
1461  }
1462 
1463  if(!$this->object->unregisterUsers($users_to_unregister))
1464  {
1465  //echo '2';
1466  //var_dump($this->object->getErrorMsg());exit;
1467  $this->ilErr->raiseError($this->object->getErrorMsg(),$this->ilErr->MESSAGE);
1468  }
1469 
1470  if(count($users_to_add) > 0)
1471  {
1472  //echo '3';
1473  foreach ($users_to_add as $user)
1474  {
1475  if (!$this->object->addUser($user))
1476  {
1477  //echo '4';
1478  //var_dump($this->object->getErrorMsg());exit;
1479  $this->ilErr->raiseError($this->object->getErrorMsg(),$this->ilErr->MESSAGE);
1480  }
1481  else
1482  {
1483  //echo '5';
1484  include_once 'Modules/ILinc/classes/class.ilObjiLincUser.php';
1485  $ilinc_user = new ilObjiLincUser($user);
1486  $users_to_register[$ilinc_user->id] = ILINC_MEMBER_STUDENT;
1487  }
1488  }
1489  }
1490 
1491  if(!$this->object->registerUsers($users_to_register))
1492  {
1493  //echo '6';
1494  //var_dump($this->object->getErrorMsg());exit;
1495  $this->ilErr->raiseError($this->object->getErrorMsg(),$this->ilErr->MESSAGE);
1496  }
1497  }
1498 
1499  ilUtil::sendInfo($this->lng->txt('msg_obj_modified'), true);
1500  ilUtil::redirect($this->ctrl->getLinkTarget($this, 'members', '', false, false));
1501  }
1502 
1503  public function editObject()
1504  {
1505  if(!$this->ilias->getSetting('ilinc_active'))
1506  {
1507  $this->ilias->raiseError($this->lng->txt('ilinc_server_not_active'), $this->ilias->error_obj->MESSAGE);
1508  }
1509 
1510  $this->initSettingsForm('edit');
1511  $this->getObjectValues();
1512  return $this->tpl->setVariable('ADM_CONTENT', $this->form_gui->getHtml());
1513  }
1514 
1515  protected function getObjectValues()
1516  {
1517  $this->form_gui->setValuesByArray(array(
1518  'title' => $this->object->getTitle(),
1519  'desc' => $this->object->getDescription(),
1520  'activated' => (int)$this->object->activated,
1521  'akclassvalue1' => $this->object->getAKClassValue1(),
1522  'akclassvalue2' => $this->object->getAKClassValue2(),
1523  ));
1524  }
1525 
1526  protected function initSettingsForm($a_mode = 'create')
1527  {
1528  include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
1529 
1530  $this->form_gui = new ilPropertyFormGUI();
1531  $this->form_gui->setTableWidth('600');
1532  if($a_mode == 'create')
1533  {
1534  $this->form_gui->setTitle($this->lng->txt('icrs_new'));
1535  }
1536  else
1537  {
1538  $this->form_gui->setTitle($this->lng->txt('icrs_edit'));
1539  }
1540  $this->form_gui->setTitleIcon(ilUtil::getTypeIconPath('icrs', 0));
1541 
1542  // Title
1543  $text_input = new ilTextInputGUI($this->lng->txt('title'), 'title');
1544  $text_input->setRequired(true);
1545  $this->form_gui->addItem($text_input);
1546 
1547  // Description
1548  $text_area = new ilTextAreaInputGUI($this->lng->txt('desc'), 'desc');
1549  $this->form_gui->addItem($text_area);
1550 
1551  // Access
1552  $text_area = new ilCheckboxInputGUI($this->lng->txt('online'), 'activated');
1553  $this->form_gui->addItem($text_area);
1554 
1555  // AKClassValues
1556  if($this->ilias->getSetting('ilinc_akclassvalues_active'))
1557  {
1558  $section_header = new ilFormSectionHeaderGUI();
1559  $section_header->setTitle($this->lng->txt('akclassvalues'));
1560  $this->form_gui->addItem($section_header);
1561 
1562  $text_input = new ilTextInputGUI($this->lng->txt('akclassvalue1'), 'akclassvalue1');
1563  if($this->ilias->getSetting('ilinc_akclassvalues_required'))
1564  {
1565  $text_input->setRequired(true);
1566  }
1567  $this->form_gui->addItem($text_input);
1568 
1569  $text_input = new ilTextInputGUI($this->lng->txt('akclassvalue2'), 'akclassvalue2');
1570  $this->form_gui->addItem($text_input);
1571  }
1572 
1573  if($this->call_by_reference)
1574  {
1575  $this->ctrl->setParameter($this, 'obj_id', $this->obj_id);
1576  }
1577 
1578  // save and cancel commands
1579  if($a_mode == 'create')
1580  {
1581  $this->ctrl->setParameter($this, 'mode', 'create');
1582  $this->ctrl->setParameter($this, 'new_type', 'icrs');
1583 
1584  $this->form_gui->addCommandButton('save', $this->lng->txt('icrs_add'));
1585  $this->form_gui->addCommandButton('cancel', $this->lng->txt('cancel'));
1586  $this->form_gui->setFormAction($this->ctrl->getFormAction($this, 'save'));
1587  }
1588  else
1589  {
1590  $this->form_gui->addCommandButton('update', $this->lng->txt('save'));
1591  $this->form_gui->addCommandButton('cancel', $this->lng->txt('cancel'));
1592  $this->form_gui->setFormAction($this->ctrl->getFormAction($this, 'update'));
1593  }
1594  }
1595 
1596  public function joinObject()
1597  {
1598  global $ilAccess;
1599 
1600  if(!$ilAccess->checkAccess('join', '', (int)$_GET['ref_id']))
1601  {
1602  $this->ilias->raiseError($this->lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
1603  }
1604 
1605  if(!$this->object->addMember($this->ilias->account, $this->object->getDefaultMemberRole(),false))
1606  {
1607  $this->ilErr->raiseError($this->object->getErrorMsg(), $this->ilErr->MESSAGE);
1608  }
1609 
1610  $this->ilias->account->addDesktopItem($this->object->getRefId(), "icrs");
1611 
1612  ilUtil::sendInfo($this->lng->txt("ilinc_msg_joined"), true);
1613  ilUtil::redirect($this->ctrl->getLinkTarget($this, "view", "", false, false));
1614  }
1615 
1617  {
1618  return false;
1619  }
1620 
1621  public function __setSubTabs($a_tab)
1622  {
1623  global $rbacsystem, $ilUser;
1624 
1625  switch($a_tab)
1626  {
1627  case 'members':
1628  //$this->tabs_gui->addSubTabTarget('ilinc_member_administration',
1629  $this->tabs_gui->addSubTabTarget('members', $this->ctrl->getLinkTarget($this, 'members'), array('members', 'changeMember', 'removeMember'), get_class($this));
1630  $this->tabs_gui->addSubTabTarget('icrs_members_gallery', $this->ctrl->getLinkTarget($this, 'membersGallery'), 'membersGallery', get_class($this));
1631  $this->tabs_gui->addSubTabTarget('mail_members', $this->ctrl->getLinkTarget($this, 'mailMembers'), 'mailMembers', get_class($this));
1632  break;
1633  }
1634  }
1635 
1636  public function mailMembersObject()
1637  {
1638  global $rbacreview, $ilObjDataCache;
1639 
1640  include_once 'Services/AccessControl/classes/class.ilObjRole.php';
1641 
1642  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.mail_members.html','Services/Contact');
1643 
1644  $this->__setSubTabs('members');
1645 
1646  include_once("./Services/Link/classes/class.ilLink.php");
1647  $link_to_seminar = ilLink::_getLink($this->object->getRefId());
1648  include_once 'Services/Mail/classes/class.ilMail.php';
1649  require_once 'Services/Mail/classes/class.ilMailFormCall.php';
1650  $this->tpl->setVariable("MAILACTION", ilMailFormCall::getLinkTarget($this, 'mailMembers', array(), array('type' => 'role')));
1651  $this->tpl->setVariable('ADDITIONAL_MESSAGE_TEXT', $link_to_seminar);
1652  $this->tpl->setVariable('IMG_ARROW', ilUtil::getImagePath('arrow_downright.png'));
1653  $this->tpl->setVariable('OK', $this->lng->txt('ok'));
1654 
1655  $role_folder = $rbacreview->getRoleFolderOfObject( $this->object->getRefId() );
1656  $role_ids = $rbacreview->getRolesOfRoleFolder($role_folder['ref_id'], false);
1657  foreach($role_ids as $role_id)
1658  {
1659  $this->tpl->setCurrentBlock('mailbox_row');
1660  $role_addr = $rbacreview->getRoleMailboxAddress( $role_id );
1661  $this->tpl->setVariable('CHECK_MAILBOX', ilUtil::formCheckbox(1, 'roles[]', htmlspecialchars($role_addr)));
1662  if (ilMail::_usePearMail())
1663  {
1664  // if pear mail is enabled, mailbox addresses are already localized in the language of the user
1665  $this->tpl->setVariable('MAILBOX', $role_addr);
1666  }
1667  else
1668  {
1669  // if pear mail is not enabled, we need to localize mailbox addresses in the language of the user
1670  $this->tpl->setVariable('MAILBOX', ilObjRole::_getTranslation( $ilObjDataCache->lookupTitle( $role_id ) ). ' (' . $role_addr . ')');
1671  }
1672 
1673  $this->tpl->parseCurrentBlock();
1674  }
1675  }
1676 
1682  public function membersGalleryObject()
1683  {
1684  global $rbacsystem;
1685 
1686  $is_admin = (bool) $rbacsystem->checkAccess('write', $this->object->getRefId());
1687 
1688  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.icrs_members_gallery.html','Modules/ILinc');
1689 
1690  $this->__setSubTabs('members');
1691 
1692  $this->lng->loadLanguageModule('ilinc');
1693 
1694  $member_ids = $this->object->getMemberIds();
1695 
1696  // fetch all user data in one shot to improve performance (from ILIAS db)
1697  $members = $this->object->getMemberData($member_ids);
1698 
1699  // fetch docent or student assignment form all coursemembers from iLinc server
1700  $admin_ids = $this->object->getiLincMemberIds(true);
1701 
1702  // MEMBERS
1703  if(count($members))
1704  {
1705  foreach($members as $member)
1706  {
1707  // get user object
1708  if(!($usr_obj = ilObjectFactory::getInstanceByObjId($member['id'],false)))
1709  {
1710  continue;
1711  }
1712 
1713  $public_profile = $usr_obj->getPref('public_profile');
1714 
1715  // SET LINK TARGET FOR USER PROFILE
1716  $this->ctrl->setParameterByClass('ilpublicuserprofilegui', 'user', $member['id']);
1717  $profile_target = $this->ctrl->getLinkTargetByClass('ilpublicuserprofilegui','getHTML');
1718 
1719  // GET USER IMAGE
1720  $file = $usr_obj->getPersonalPicturePath('xsmall');
1721 
1722  switch(in_array($member['ilinc_id'],$admin_ids))
1723  {
1724  //admins
1725  case 1:
1726  if($public_profile == 'y' || $public_profile == 'g')
1727  {
1728  $this->tpl->setCurrentBlock('tutor_linked');
1729  $this->tpl->setVariable('LINK_PROFILE', $profile_target);
1730  $this->tpl->setVariable('SRC_USR_IMAGE', $file);
1731  $this->tpl->parseCurrentBlock();
1732  }
1733  else
1734  {
1735  $this->tpl->setCurrentBlock('tutor_not_linked');
1736  $this->tpl->setVariable('SRC_USR_IMAGE', $file);
1737  $this->tpl->parseCurrentBlock();
1738  }
1739  $this->tpl->setCurrentBlock('tutor');
1740  break;
1741 
1742  case 0:
1743  if($public_profile == 'y' || $public_profile == 'g')
1744  {
1745  $this->tpl->setCurrentBlock('member_linked');
1746  $this->tpl->setVariable('LINK_PROFILE', $profile_target);
1747  $this->tpl->setVariable('SRC_USR_IMAGE', $file);
1748  $this->tpl->parseCurrentBlock();
1749  }
1750  else
1751  {
1752  $this->tpl->setCurrentBlock('member_not_linked');
1753  $this->tpl->setVariable('SRC_USR_IMAGE', $file);
1754  $this->tpl->parseCurrentBlock();
1755  }
1756  $this->tpl->setCurrentBlock('member');
1757  break;
1758  }
1759 
1760  // do not show name, if public profile is not activated
1761  if($public_profile == 'y' || $public_profile == 'g')
1762  {
1763  $this->tpl->setVariable('FIRSTNAME', $member['firstname']);
1764  $this->tpl->setVariable('LASTNAME', $member['lastname']);
1765  }
1766 
1767  $this->tpl->setVariable('LOGIN', $usr_obj->getLogin());
1768  $this->tpl->parseCurrentBlock();
1769  }
1770 
1771  $this->tpl->setCurrentBlock('members');
1772  $this->tpl->setVariable('MEMBERS_TABLE_HEADER',$this->lng->txt('ilinc_involved_users'));
1773  $this->tpl->parseCurrentBlock();
1774  }
1775 
1776  $this->tpl->setVariable('TITLE', $this->lng->txt('icrs_members_print_title'));
1777  $this->tpl->setVariable('CSS_PATH', ilUtil::getStyleSheetLocation());
1778 
1779  $headline = $this->object->getTitle().'<br />'.$this->object->getDescription();
1780  $this->tpl->setVariable('HEADLINE', $headline);
1781 
1782  $this->tpl->show();
1783  exit();
1784  }
1785 
1787  {
1788 
1789  }
1790 
1791  public function showAdministrationPanel($tpl)
1792  {
1793  }
1794 
1795  public static function _goto($a_target)
1796  {
1797  global $ilAccess, $ilErr, $lng;
1798 
1799  if ($ilAccess->checkAccess('read', '', $a_target))
1800  {
1802  }
1803  else
1804  {
1805  $ilErr->raiseError($lng->txt('msg_no_perm_read'), $ilErr->FATAL);
1806  }
1807  }
1808 }
1809 ?>