ILIAS  release_8 Revision v8.24
class.ilMStShowUserGUI.php
Go to the documentation of this file.
1<?php
22
30{
31 public const CMD_INDEX = 'index';
32 public const CMD_SHOW_USER = 'showUser';
33 public const TAB_SHOW_USER = 'show_user';
34 public const TAB_SHOW_COURSES = 'show_courses';
35 public const TAB_SHOW_CERTIFICATES = 'show_certificates';
36 public const TAB_SHOW_COMPETENCES = 'show_competences';
37 public const TAB_SHOW_TALKS = 'show_talks';
38
39 protected int $usr_id;
41 private \ilGlobalTemplateInterface $main_tpl;
42
43 public function __construct()
44 {
45 global $DIC;
46 $this->main_tpl = $DIC->ui()->mainTemplate();
47
48 $this->access = ilMyStaffAccess::getInstance();
49
50 $this->usr_id = $DIC->http()->request()->getQueryParams()['usr_id'];
51 $DIC->ctrl()->setParameter($this, 'usr_id', $this->usr_id);
52
53 $this->setTitleAndIcon();
54 }
55
56 protected function setTitleAndIcon(): void
57 {
58 $this->main_tpl->setTitle(ilUserUtil::getNamePresentation($this->usr_id));
59 $this->main_tpl->setTitleIcon(ilObjUser::_getPersonalPicturePath($this->usr_id, "xxsmall"));
60 }
61
62 protected function checkAccessOrFail(): void
63 {
64 global $DIC;
65
66 if (!$this->usr_id) {
67 $this->main_tpl->setOnScreenMessage('failure', $DIC->language()->txt("permission_denied"), true);
68 $DIC->ctrl()->redirectByClass(ilDashboardGUI::class, "");
69 }
70
71 if ($this->access->hasCurrentUserAccessToUser($this->usr_id)) {
72 return;
73 } else {
74 $this->main_tpl->setOnScreenMessage('failure', $DIC->language()->txt("permission_denied"), true);
75 $DIC->ctrl()->redirectByClass(ilDashboardGUI::class, "");
76 }
77 }
78
79 final public function executeCommand(): void
80 {
81 global $DIC;
82
83 $this->checkAccessOrFail();
84
85 $cmd = $DIC->ctrl()->getCmd();
86 $next_class = $DIC->ctrl()->getNextClass();
87
88 switch ($next_class) {
89 case strtolower(ilMStShowUserCoursesGUI::class):
90 $this->addTabs(self::TAB_SHOW_COURSES);
91 $gui = new ilMStShowUserCoursesGUI();
92 $DIC->ctrl()->forwardCommand($gui);
93 break;
94 case strtolower(ilUserCertificateGUI::class):
95 $this->addTabs(self::TAB_SHOW_CERTIFICATES);
96 $gui = new ilUserCertificateGUI(
97 null,
98 null,
99 null,
100 new ilObjUser($this->usr_id)
101 );
102 $DIC->ctrl()->forwardCommand($gui);
103 $this->setTitleAndIcon();
104 break;
105 case strtolower(ilMStShowUserCompetencesGUI::class):
106 $this->addTabs(self::TAB_SHOW_COMPETENCES);
108 $DIC->ctrl()->forwardCommand($gui);
109 break;
110 case strtolower(ilEmployeeTalkMyStaffUserGUI::class):
111 $this->addTabs(self::TAB_SHOW_TALKS);
113 ilMyStaffAccess::getInstance(),
114 $DIC->ctrl(),
115 $DIC->language(),
116 $DIC->http()->request(),
117 $DIC->ui()->mainTemplate(),
118 $DIC->tabs(),
119 new IliasDBEmployeeTalkRepository($DIC->database()),
120 $DIC->ui(),
122 $DIC->user()
123 );
124 $DIC->ctrl()->forwardCommand($gui);
125 break;
126 default:
127
128 switch ($cmd) {
130 $this->addTabs(self::TAB_SHOW_USER);
131 $this->$cmd();
132 break;
133 default:
134 $this->index();
135 break;
136 }
137 }
138 }
139
140 protected function index(): void
141 {
142 global $DIC;
143 $DIC->ctrl()->redirectByClass(ilMStShowUserCoursesGUI::class);
144 }
145
146 protected function showUser(): void
147 {
148 global $DIC;
149
150 //Redirect if Profile is not public
151 $user = new ilObjUser($this->usr_id);
152 if (!$user->hasPublicProfile()) {
153 $DIC->ctrl()->redirectByClass(self::class, self::CMD_INDEX);
154 }
155
156 $pub_profile = new ilPublicUserProfileGUI($this->usr_id);
157 $DIC->ui()->mainTemplate()->setContent($pub_profile->getEmbeddable());
158 }
159
160 public function cancel(): void
161 {
162 global $DIC;
163
164 $DIC->ctrl()->redirect($this);
165 }
166
167 protected function addTabs(string $active_tab_id): void
168 {
169 global $DIC;
170
171 $DIC->tabs()->setBackTarget($DIC->language()->txt('mst_list_users'), $DIC->ctrl()->getLinkTargetByClass(array(
172 ilMyStaffGUI::class,
173 ilMStListUsersGUI::class,
174 )));
175
176 if ($this->access->hasCurrentUserAccessToCourseMemberships()) {
177 $DIC->tabs()->addTab(
178 self::TAB_SHOW_COURSES,
179 $DIC->language()->txt('mst_list_courses'),
180 $DIC->ctrl()->getLinkTargetByClass(array(
181 ilMyStaffGUI::class,
182 self::class,
183 ilMStShowUserCoursesGUI::class,
184 ))
185 );
186 }
187
188 if ($this->access->hasCurrentUserAccessToCertificates()) {
189 $DIC->tabs()->addTab(
190 self::TAB_SHOW_CERTIFICATES,
191 $DIC->language()->txt('mst_list_certificates'),
192 $DIC->ctrl()->getLinkTargetByClass(array(
193 ilMyStaffGUI::class,
194 self::class,
195 ilUserCertificateGUI::class,
196 ))
197 );
198 }
199
200 if ($this->access->hasCurrentUserAccessToCompetences()) {
201 $DIC->tabs()->addTab(
202 self::TAB_SHOW_COMPETENCES,
203 $DIC->language()->txt('mst_list_competences'),
204 $DIC->ctrl()->getLinkTargetByClass(array(
205 ilMyStaffGUI::class,
206 self::class,
207 ilMStShowUserCompetencesGUI::class,
208 ))
209 );
210 }
211
212 $user = new ilObjUser($this->usr_id);
213 if ($user->hasPublicProfile()) {
214 $DIC->ctrl()->setParameterByClass(self::class, 'usr_id', $this->usr_id);
215 $public_profile_url = $DIC->ctrl()->getLinkTargetByClass(self::class, self::CMD_SHOW_USER);
216 $DIC->tabs()->addTab(self::TAB_SHOW_USER, $DIC->language()->txt('public_profile'), $public_profile_url);
217 }
218
219 if ($this->access->hasCurrentUserAccessToTalks()) {
220 $DIC->ctrl()->setParameterByClass(strtolower(self::class), 'usr_id', $this->usr_id);
221 $DIC->tabs()->addTab(self::TAB_SHOW_TALKS, $DIC->language()->txt('etal_talks'), $DIC->ctrl()->getLinkTargetByClass([
222 strtolower(ilMyStaffGUI::class),
223 strtolower(self::class),
224 strtolower(ilEmployeeTalkMyStaffUserGUI::class)
225 ], ControlFlowCommand::INDEX));
226 }
227
228 if ($active_tab_id) {
229 $DIC->tabs()->activateTab($active_tab_id);
230 }
231 }
232}
Class ilEmployeeTalkMyStaffUserGUI.
Class ilMStShowUserCompetencesGUI.
Class ilMStShowUserGUI.
ilGlobalTemplateInterface $main_tpl
addTabs(string $active_tab_id)
User class.
static _getPersonalPicturePath(int $a_usr_id, string $a_size="small", bool $a_force_pic=false, bool $a_prevent_no_photo_image=false, bool $html_export=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link="", bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
global $DIC
Definition: feed.php:28