ILIAS  Release_5_0_x_branch Revision 61816
 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, $ilErr, $ilAccess, $lng;
25 
26  if(!$ilAccess->checkAccess('write','',$this->ref_id))
27  {
28  $ilErr->raiseError($lng->txt('permission_denied'),$ilErr->WARNING);
29  }
30 
31  $cmd = $ilCtrl->getCmd();
32  if(!$cmd)
33  {
34  $cmd = "show";
35  }
36  $this->$cmd();
37  }
38 
39  function show()
40  {
41  global $tpl;
42 
43  $tbl_gui = new ilCourseParticipantsGroupsTableGUI($this, "show", $this->ref_id);
44  $tpl->setContent($tbl_gui->getHTML());
45  }
46 
47  function applyFilter()
48  {
49  $tbl_gui = new ilCourseParticipantsGroupsTableGUI($this, "show", $this->ref_id);
50  $tbl_gui->resetOffset();
51  $tbl_gui->writeFilterToSession();
52  $this->show();
53  }
54 
55  function resetFilter()
56  {
57  $tbl_gui = new ilCourseParticipantsGroupsTableGUI($this, "show", $this->ref_id);
58  $tbl_gui->resetOffset();
59  $tbl_gui->resetFilter();
60  $this->show();
61  }
62 
63  function confirmRemove()
64  {
65  global $ilAccess, $ilCtrl, $lng, $tpl;
66 
67  include_once('./Services/Utilities/classes/class.ilConfirmationGUI.php');
68  $confirm = new ilConfirmationGUI();
69  $confirm->setFormAction($ilCtrl->getFormAction($this,'remove'));
70  $confirm->addHiddenItem("grp_id", $_GET["grp_id"]);
71  $confirm->setHeaderText($lng->txt('grp_dismiss_member'));
72  $confirm->setConfirm($lng->txt('confirm'),'remove');
73  $confirm->setCancel($lng->txt('cancel'),'show');
74 
75  include_once './Services/User/classes/class.ilUserUtil.php';
76 
77  $confirm->addItem('usr_id',
78  $_GET["usr_id"],
79  ilUserUtil::getNamePresentation($_GET["usr_id"], false, false, "", true),
80  ilUtil::getImagePath('icon_usr.svg'));
81 
82  $tpl->setContent($confirm->getHTML());
83  }
84 
85  function remove()
86  {
87  global $ilAccess, $ilObjDataCache, $lng, $ilCtrl;
88 
89  if (!$ilAccess->checkAccess("write", "", $_POST["grp_id"]))
90  {
91  ilUtil::sendFailure($lng->txt("permission_denied"), true);
92  $this->show();
93  return;
94  }
95 
96  include_once './Modules/Group/classes/class.ilGroupParticipants.php';
97  $members_obj = ilGroupParticipants::_getInstanceByObjId($ilObjDataCache->lookupObjId($_POST["grp_id"]));
98  $members_obj->delete($_POST["usr_id"]);
99 
100  // Send notification
101  include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
102  $members_obj->sendNotification(
104  $_POST["usr_id"]
105  );
106 
107  ilUtil::sendSuccess($lng->txt("grp_msg_membership_annulled"), true);
108  $ilCtrl->redirect($this, "show");
109  }
110 
111  function add()
112  {
113  global $ilErr, $ilObjDataCache, $lng, $ilAccess;
114 
115 
116  if(sizeof($_POST["usrs"]))
117  {
118  if (!$ilAccess->checkAccess("write", "", $_POST["grp_id"]))
119  {
120  ilUtil::sendFailure($lng->txt("permission_denied"), true);
121  $this->show();
122  return;
123  }
124 
125  include_once './Modules/Group/classes/class.ilGroupParticipants.php';
126  $members_obj = ilGroupParticipants::_getInstanceByObjId($ilObjDataCache->lookupObjId($_POST["grp_id"]));
127  foreach ($_POST["usrs"] as $new_member)
128  {
129  if (!$members_obj->add($new_member, IL_GRP_MEMBER))
130  {
131  $ilErr->raiseError("An Error occured while assigning user to group !", $ilErr->MESSAGE);
132  }
133 
134  include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
135  $members_obj->sendNotification(
137  $new_member
138  );
139 
140  }
141 
142  ilUtil::sendSuccess($lng->txt("grp_msg_member_assigned"));
143  }
144 
145  $this->show();
146  }
147 }
148 
149 ?>