ILIAS  Release_4_1_x_branch Revision 61804
 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.gif'));
81 
82  $tpl->setContent($confirm->getHTML());
83  }
84 
85  function remove()
86  {
87  global $ilAccess, $ilObjDataCache, $lng;
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  include_once './Modules/Forum/classes/class.ilForumNotification.php';
108  ilForumNotification::checkForumsExistsDelete($this->ref_id, $_POST["usr_id"]);
109 
110  ilUtil::sendSuccess($lng->txt("grp_msg_membership_annulled"));
111  $this->show();
112  }
113 
114  function add()
115  {
116  global $ilErr, $ilObjDataCache, $lng, $ilAccess;
117 
118 
119  if(sizeof($_POST["usrs"]))
120  {
121  if (!$ilAccess->checkAccess("write", "", $_POST["grp_id"]))
122  {
123  ilUtil::sendFailure($lng->txt("permission_denied"), true);
124  $this->show();
125  return;
126  }
127 
128  include_once './Modules/Group/classes/class.ilGroupParticipants.php';
129  $members_obj = ilGroupParticipants::_getInstanceByObjId($ilObjDataCache->lookupObjId($_POST["grp_id"]));
130  foreach ($_POST["usrs"] as $new_member)
131  {
132  if (!$members_obj->add($new_member, IL_GRP_MEMBER))
133  {
134  $ilErr->raiseError("An Error occured while assigning user to group !", $ilErr->MESSAGE);
135  }
136 
137  include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
138  $members_obj->sendNotification(
140  $new_member
141  );
142 
143  include_once './Modules/Forum/classes/class.ilForumNotification.php';
144  ilForumNotification::checkForumsExistsInsert($this->ref_id, $new_member);
145  }
146 
147  ilUtil::sendSuccess($lng->txt("grp_msg_member_assigned"));
148  }
149 
150  $this->show();
151  }
152 }
153 
154 ?>