ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilCourseParticipantsGroupsGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once "./Modules/Course/classes/class.ilCourseParticipantsGroupsTableGUI.php";
5 
16 {
17  function __construct($a_ref_id)
18  {
19  $this->ref_id = $a_ref_id;
20  }
21 
22  function executeCommand()
23  {
24  global $ilCtrl;
25 
26  $cmd = $ilCtrl->getCmd();
27  if(!$cmd)
28  {
29  $cmd = "show";
30  }
31  $this->$cmd();
32  }
33 
34  function show()
35  {
36  global $tpl;
37 
38  $tbl_gui = new ilCourseParticipantsGroupsTableGUI($this, "show", $this->ref_id);
39  $tpl->setContent($tbl_gui->getHTML());
40  }
41 
42  function applyFilter()
43  {
44  $tbl_gui = new ilCourseParticipantsGroupsTableGUI($this, "show", $this->ref_id);
45  $tbl_gui->resetOffset();
46  $tbl_gui->writeFilterToSession();
47  $this->show();
48  }
49 
50  function resetFilter()
51  {
52  $tbl_gui = new ilCourseParticipantsGroupsTableGUI($this, "show", $this->ref_id);
53  $tbl_gui->resetOffset();
54  $tbl_gui->resetFilter();
55  $this->show();
56  }
57 
58  function confirmRemove()
59  {
60  global $ilAccess, $ilCtrl, $lng, $tpl;
61 
62  include_once('./Services/Utilities/classes/class.ilConfirmationGUI.php');
63  $confirm = new ilConfirmationGUI();
64  $confirm->setFormAction($ilCtrl->getFormAction($this,'remove'));
65  $confirm->addHiddenItem("grp_id", $_GET["grp_id"]);
66  $confirm->setHeaderText($lng->txt('grp_dismiss_member'));
67  $confirm->setConfirm($lng->txt('confirm'),'remove');
68  $confirm->setCancel($lng->txt('cancel'),'show');
69 
70  include_once './Services/User/classes/class.ilUserUtil.php';
71 
72  $confirm->addItem('usr_id',
73  $_GET["usr_id"],
74  ilUserUtil::getNamePresentation($_GET["usr_id"], false, false, "", true),
75  ilUtil::getImagePath('icon_usr.gif'));
76 
77  $tpl->setContent($confirm->getHTML());
78  }
79 
80  function remove()
81  {
82  global $ilAccess, $ilObjDataCache, $lng;
83 
84  if (!$ilAccess->checkAccess("write", "", $_POST["grp_id"]))
85  {
86  ilUtil::sendFailure($lng->txt("permission_denied"), true);
87  $this->show();
88  return;
89  }
90 
91  include_once './Modules/Group/classes/class.ilGroupParticipants.php';
92  $members_obj = ilGroupParticipants::_getInstanceByObjId($ilObjDataCache->lookupObjId($_POST["grp_id"]));
93  $members_obj->delete($_POST["usr_id"]);
94 
95  // Send notification
96  include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
97  $members_obj->sendNotification(
99  $_POST["usr_id"]
100  );
101 
102  ilUtil::sendSuccess($lng->txt("grp_msg_membership_annulled"));
103  $this->show();
104  }
105 
106  function add()
107  {
108  global $ilErr, $ilObjDataCache, $lng, $ilAccess;
109 
110 
111  if(sizeof($_POST["usrs"]))
112  {
113  if (!$ilAccess->checkAccess("write", "", $_POST["grp_id"]))
114  {
115  ilUtil::sendFailure($lng->txt("permission_denied"), true);
116  $this->show();
117  return;
118  }
119 
120  include_once './Modules/Group/classes/class.ilGroupParticipants.php';
121  $members_obj = ilGroupParticipants::_getInstanceByObjId($ilObjDataCache->lookupObjId($_POST["grp_id"]));
122  foreach ($_POST["usrs"] as $new_member)
123  {
124  if (!$members_obj->add($new_member, IL_GRP_MEMBER))
125  {
126  $ilErr->raiseError("An Error occured while assigning user to group !", $ilErr->MESSAGE);
127  }
128 
129  include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
130  $members_obj->sendNotification(
132  $new_member
133  );
134  }
135 
136  ilUtil::sendSuccess($lng->txt("grp_msg_member_assigned"));
137  }
138 
139  $this->show();
140  }
141 }
142 
143 ?>