ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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
4include_once "./Modules/Course/classes/class.ilCourseParticipantsGroupsTableGUI.php";
5
16{
21 private $ref_id = 0;
22
23 public function __construct($a_ref_id)
24 {
25 $this->ref_id = $a_ref_id;
26 }
27
28 public function executeCommand()
29 {
30 global $ilCtrl, $ilErr, $ilAccess, $lng;
31
32 if (!$GLOBALS['DIC']->access()->checkRbacOrPositionPermissionAccess('manage_members', 'manage_members', $this->ref_id)) {
33 $ilErr->raiseError($lng->txt('permission_denied'), $ilErr->WARNING);
34 }
35
36 $cmd = $ilCtrl->getCmd();
37 if (!$cmd) {
38 $cmd = "show";
39 }
40 $this->$cmd();
41 }
42
43 public function show()
44 {
45 global $tpl;
46
47 $tbl_gui = new ilCourseParticipantsGroupsTableGUI($this, "show", $this->ref_id);
48 $tpl->setContent($tbl_gui->getHTML());
49 }
50
51 public function applyFilter()
52 {
53 $tbl_gui = new ilCourseParticipantsGroupsTableGUI($this, "show", $this->ref_id);
54 $tbl_gui->resetOffset();
55 $tbl_gui->writeFilterToSession();
56 $this->show();
57 }
58
59 public function resetFilter()
60 {
61 $tbl_gui = new ilCourseParticipantsGroupsTableGUI($this, "show", $this->ref_id);
62 $tbl_gui->resetOffset();
63 $tbl_gui->resetFilter();
64 $this->show();
65 }
66
67 public function confirmRemove()
68 {
69 global $ilCtrl, $lng, $tpl;
70
71 include_once('./Services/Utilities/classes/class.ilConfirmationGUI.php');
72 $confirm = new ilConfirmationGUI();
73 $confirm->setFormAction($ilCtrl->getFormAction($this, 'remove'));
74 $confirm->addHiddenItem("grp_id", $_GET["grp_id"]);
75 $confirm->setHeaderText($lng->txt('grp_dismiss_member'));
76 $confirm->setConfirm($lng->txt('confirm'), 'remove');
77 $confirm->setCancel($lng->txt('cancel'), 'show');
78
79 include_once './Services/User/classes/class.ilUserUtil.php';
80
81 $confirm->addItem(
82 'usr_id',
83 $_GET["usr_id"],
84 ilUserUtil::getNamePresentation($_GET["usr_id"], false, false, "", true),
85 ilUtil::getImagePath('icon_usr.svg')
86 );
87
88 $tpl->setContent($confirm->getHTML());
89 }
90
98 protected function remove()
99 {
100 global $ilObjDataCache, $lng, $ilCtrl;
101
102 if (!$GLOBALS['DIC']->access()->checkRbacOrPositionPermissionAccess('manage_members', 'manage_members', (int) $_POST['grp_id'])) {
103 ilUtil::sendFailure($lng->txt("permission_denied"), true);
104 $this->show();
105 return;
106 }
107
108 include_once './Modules/Group/classes/class.ilGroupParticipants.php';
109 $members_obj = ilGroupParticipants::_getInstanceByObjId($ilObjDataCache->lookupObjId((int) $_POST["grp_id"]));
110 $members_obj->delete((int) $_POST["usr_id"]);
111
112 // Send notification
113 include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
114 $members_obj->sendNotification(
116 (int) $_POST["usr_id"]
117 );
118
119 ilUtil::sendSuccess($lng->txt("grp_msg_membership_annulled"), true);
120 $ilCtrl->redirect($this, "show");
121 }
122
131 protected function add()
132 {
133 global $ilErr, $ilObjDataCache, $lng, $ilAccess;
134
135 if (sizeof($_POST["usrs"])) {
136 if (!$GLOBALS['DIC']->access()->checkRbacOrPositionPermissionAccess('manage_members', 'manage_members', (int) $_POST['grp_id'])) {
137 ilUtil::sendFailure($lng->txt("permission_denied"), true);
138 $this->show();
139 return;
140 }
141
142 include_once './Modules/Group/classes/class.ilGroupParticipants.php';
143 $members_obj = ilGroupParticipants::_getInstanceByObjId($ilObjDataCache->lookupObjId((int) $_POST["grp_id"]));
144 foreach ($_POST["usrs"] as $new_member) {
145 if (!$members_obj->add($new_member, IL_GRP_MEMBER)) {
146 $ilErr->raiseError("An Error occured while assigning user to group !", $ilErr->MESSAGE);
147 }
148
149 include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
150 $members_obj->sendNotification(
152 $new_member
153 );
154 }
155 ilUtil::sendSuccess($lng->txt("grp_msg_member_assigned"));
156 }
157
158 $this->show();
159 }
160}
$tpl
Definition: ilias.php:10
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
const IL_GRP_MEMBER
Confirmation screen class.
Class ilCourseParticipantsGroupsGUI.
add()
Add user to group @global type $ilErr @global type $ilObjDataCache @global type $lng @global type $il...
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
static getNamePresentation( $a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true, $a_return_data_array=false, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:17
global $ilErr
Definition: raiseError.php:16