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