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