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