ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilMStShowUserCoursesGUI.php
Go to the documentation of this file.
1<?php
2
5
17{
18 const CMD_INDEX = 'index';
19 const CMD_RESET_FILTER = 'resetFilter';
20 const CMD_APPLY_FILTER = 'applyFilter';
21 const CMD_GET_ACTIONS = "getActions";
25 protected $usr_id;
29 protected $table;
33 protected $access;
34
35
39 public function __construct()
40 {
41 global $DIC;
42
43 $this->access = ilMyStaffAccess::getInstance();
44
45 $this->usr_id = $DIC->http()->request()->getQueryParams()['usr_id'];
46 $DIC->ctrl()->setParameter($this, 'usr_id', $this->usr_id);
47 }
48
49
53 protected function checkAccessOrFail()
54 {
55 global $DIC;
56
57 if (!$this->usr_id) {
58 ilUtil::sendFailure($DIC->language()->txt("permission_denied"), true);
59 $DIC->ctrl()->redirectByClass(ilDashboardGUI::class, "");
60 }
61
62 if ($this->access->hasCurrentUserAccessToMyStaff()
63 && $this->access->hasCurrentUserAccessToUser($this->usr_id)
64 ) {
65 return;
66 } else {
67 ilUtil::sendFailure($DIC->language()->txt("permission_denied"), true);
68 $DIC->ctrl()->redirectByClass(ilDashboardGUI::class, "");
69 }
70 }
71
72
76 public function executeCommand()
77 {
78 global $DIC;
79
80 $this->checkAccessOrFail();
81
82 $cmd = $DIC->ctrl()->getCmd();
83 $next_class = $DIC->ctrl()->getNextClass();
84
85 switch ($next_class) {
86 case strtolower(ilFormPropertyDispatchGUI::class):
87 $DIC->ctrl()->setReturn($this, self::CMD_INDEX);
88 $this->table = new ilMStShowUserCoursesTableGUI($this, self::CMD_INDEX);
89 $this->table->executeCommand();
90 break;
91 default:
92 switch ($cmd) {
95 case self::CMD_INDEX:
97 $this->$cmd();
98 break;
99 default:
100 $this->index();
101 break;
102 }
103 }
104 }
105
106
110 protected function index()
111 {
112 $this->listUsers();
113 }
114
115
119 protected function listUsers()
120 {
121 global $DIC;
122
123 $this->table = new ilMStShowUserCoursesTableGUI($this, self::CMD_INDEX);
124 $this->table->setTitle(sprintf($DIC->language()->txt('mst_courses_of'), ilObjCourse::_lookupTitle($this->usr_id)));
125
126 $DIC->ui()->mainTemplate()->setContent($this->table->getHTML());
127 }
128
132 protected function applyFilter()
133 {
134 $this->table = new ilMStShowUserCoursesTableGUI($this, self::CMD_APPLY_FILTER);
135 $this->table->writeFilterToSession();
136 $this->table->resetOffset();
137 $this->index();
138 }
139
140
144 protected function resetFilter()
145 {
146 $this->table = new ilMStShowUserCoursesTableGUI($this, self::CMD_RESET_FILTER);
147 $this->table->resetOffset();
148 $this->table->resetFilter();
149 $this->index();
150 }
151
152
156 public function getId()
157 {
158 $this->table = new ilMStShowUserCoursesTableGUI($this, self::CMD_INDEX);
159
160 return $this->table->getId();
161 }
162
163
167 public function cancel()
168 {
169 global $DIC;
170
171 $DIC->ctrl()->redirect($this);
172 }
173
174
178 public function getActions()
179 {
180 global $DIC;
181
182 $mst_co_usr_id = $DIC->http()->request()->getQueryParams()['mst_lco_usr_id'];
183 $mst_lco_crs_ref_id = $DIC->http()->request()->getQueryParams()['mst_lco_crs_ref_id'];
184
185 if ($mst_co_usr_id > 0 && $mst_lco_crs_ref_id > 0) {
186 $selection = new ilAdvancedSelectionListGUI();
187
188 if ($DIC->access()->checkAccess("visible", "", $mst_lco_crs_ref_id)) {
189 $link = ilLink::_getStaticLink($mst_lco_crs_ref_id, ilMyStaffAccess::DEFAULT_CONTEXT);
190 $selection->addItem(ilObject2::_lookupTitle(ilObject2::_lookupObjectId($mst_lco_crs_ref_id)), '', $link);
191 };
192
194 foreach (
195 ilOrgUnitUserAssignment::innerjoin('object_reference', 'orgu_id', 'ref_id')->where(array(
196 'user_id' => $mst_co_usr_id,
197 'object_reference.deleted' => null
198 ), array('user_id' => '=', 'object_reference.deleted' => '!='))->get() as $org_unit_assignment
199 ) {
200 if ($DIC->access()->checkAccess("read", "", $org_unit_assignment->getOrguId())) {
201 $link = ilLink::_getStaticLink($org_unit_assignment->getOrguId(), 'orgu');
202 $selection->addItem($org_units[$org_unit_assignment->getOrguId()], '', $link);
203 }
204 }
205
206 $selection = ilMyStaffGUI::extendActionMenuWithUserActions($selection, $mst_co_usr_id, rawurlencode($DIC->ctrl()
207 ->getLinkTarget($this, self::CMD_INDEX)));
208
209 echo $selection->getHTML(true);
210 }
211 exit;
212 }
213}
static innerjoin($tablename, $on_this, $on_external, $fields=array(' *'), $operator='=', $both_external=false)
An exception for terminatinating execution or to throw for unit testing.
User interface class for advanced drop-down selection lists.
static _lookupTitle($a_id)
lookup object title
static _lookupObjectId($a_ref_id)
lookup object id
static _lookupTitle($a_id)
lookup object title
static getTextRepresentationOfOrgUnits($sort_by_title=true)
Get ref id path array.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
exit
Definition: login.php:29
$DIC
Definition: xapitoken.php:46