ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilMStShowUserGUI.php
Go to the documentation of this file.
1<?php
2
4
14{
15 const CMD_INDEX = 'index';
16 const CMD_SHOW_USER = 'showUser';
17
18 const TAB_SHOW_USER = 'show_user';
19 const TAB_SHOW_COURSES = 'show_courses';
20 const TAB_SHOW_CERTIFICATES = 'show_certificates';
21 const TAB_SHOW_COMPETENCES = 'show_competences';
22
26 protected $usr_id;
30 protected $access;
31
32
36 public function __construct()
37 {
38 global $DIC;
39
40 $this->access = ilMyStaffAccess::getInstance();
41
42 $this->usr_id = $DIC->http()->request()->getQueryParams()['usr_id'];
43 $DIC->ctrl()->setParameter($this, 'usr_id', $this->usr_id);
44
45 $DIC->ui()->mainTemplate()->setTitle(ilUserUtil::getNamePresentation($this->usr_id));
46 $DIC->ui()->mainTemplate()->setTitleIcon(ilObjUser::_getPersonalPicturePath($this->usr_id, "xxsmall"));
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 return;
65 } else {
66 ilUtil::sendFailure($DIC->language()->txt("permission_denied"), true);
67 $DIC->ctrl()->redirectByClass(ilDashboardGUI::class, "");
68 }
69 }
70
71
75 public function executeCommand()
76 {
77 global $DIC;
78
79 $this->checkAccessOrFail();
80
81 $cmd = $DIC->ctrl()->getCmd();
82 $next_class = $DIC->ctrl()->getNextClass();
83
84 switch ($next_class) {
85 case strtolower(ilMStShowUserCoursesGUI::class):
86 $this->addTabs(self::TAB_SHOW_COURSES);
87 $gui = new ilMStShowUserCoursesGUI();
88 $DIC->ctrl()->forwardCommand($gui);
89 break;
90 case strtolower(ilUserCertificateGUI::class):
91 $this->addTabs(self::TAB_SHOW_CERTIFICATES);
92 $gui = new ilUserCertificateGUI(
93 null,
94 null,
95 null,
96 new ilObjUser($this->usr_id)
97 );
98 $DIC->ctrl()->forwardCommand($gui);
99 break;
100 case strtolower(ilMStShowUserCompetencesGUI::class):
101 $this->addTabs(self::TAB_SHOW_COMPETENCES);
103 $DIC->ctrl()->forwardCommand($gui);
104 break;
105 default:
106
107 switch ($cmd) {
109 $this->addTabs(self::TAB_SHOW_USER);
110 $this->$cmd();
111 break;
112 default:
113 $this->index();
114 break;
115 }
116 }
117 }
118
119
123 protected function index()
124 {
125 global $DIC;
126 $DIC->ctrl()->redirectByClass(ilMStShowUserCoursesGUI::class);
127 }
128
129
133 protected function showUser()
134 {
135 global $DIC;
136
137 //Redirect if Profile is not public
138 $user = new ilObjUser($this->usr_id);
139 if (!$user->hasPublicProfile()) {
140 $DIC->ctrl()->redirectByClass(self::class, self::CMD_INDEX);
141 }
142
143 $pub_profile = new ilPublicUserProfileGUI($this->usr_id);
144 $DIC->ui()->mainTemplate()->setContent($pub_profile->getEmbeddable());
145 }
146
147
151 public function cancel()
152 {
153 global $DIC;
154
155 $DIC->ctrl()->redirect($this);
156 }
157
158
162 protected function addTabs($active_tab_id)
163 {
164 global $DIC;
165
166 $DIC->tabs()->setBackTarget($DIC->language()->txt('mst_list_users'), $DIC->ctrl()->getLinkTargetByClass(array(
167 ilMyStaffGUI::class,
168 self::class,
169 ilMStListUsersGUI::class,
170 )));
171
172 if ($this->access->hasCurrentUserAccessToMyStaff()) {
173 $DIC->tabs()->addTab(self::TAB_SHOW_COURSES, $DIC->language()->txt('mst_list_courses'), $DIC->ctrl()->getLinkTargetByClass(array(
174 ilMyStaffGUI::class,
175 self::class,
176 ilMStShowUserCoursesGUI::class,
177 )));
178 }
179
180 if ($this->access->hasCurrentUserAccessToCertificates()) {
181 $DIC->tabs()->addTab(self::TAB_SHOW_CERTIFICATES, $DIC->language()->txt('mst_list_certificates'), $DIC->ctrl()->getLinkTargetByClass(array(
182 ilMyStaffGUI::class,
183 self::class,
184 ilUserCertificateGUI::class,
185 )));
186 }
187
188 if ($this->access->hasCurrentUserAccessToCompetences()) {
189 $DIC->tabs()->addTab(self::TAB_SHOW_COMPETENCES, $DIC->language()->txt('mst_list_competences'), $DIC->ctrl()->getLinkTargetByClass(array(
190 ilMyStaffGUI::class,
191 self::class,
192 ilMStShowUserCompetencesGUI::class,
193 )));
194 }
195
196
197 $user = new ilObjUser($this->usr_id);
198 if ($user->hasPublicProfile()) {
199 $DIC->ctrl()->setParameterByClass(self::class, 'usr_id', $this->usr_id);
200 $public_profile_url = $DIC->ctrl()->getLinkTargetByClass(self::class, self::CMD_SHOW_USER);
201 $DIC->tabs()->addTab(self::TAB_SHOW_USER, $DIC->language()->txt('public_profile'), $public_profile_url);
202 }
203
204 if ($active_tab_id) {
205 $DIC->tabs()->activateTab($active_tab_id);
206 }
207 }
208}
An exception for terminatinating execution or to throw for unit testing.
Class ilMStShowUserCompetencesGUI.
Class ilMStShowUserGUI.
static _getPersonalPicturePath( $a_usr_id, $a_size="small", $a_force_pic=false, $a_prevent_no_photo_image=false)
Get path to personal picture.
GUI class for public user profile presentation.
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 sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$DIC
Definition: xapitoken.php:46