ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
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);
107  $gui = new ilMStShowUserCompetencesGUI($DIC);
108  $DIC->ctrl()->forwardCommand($gui);
109  break;
110  case strtolower(ilEmployeeTalkMyStaffUserGUI::class):
111  $this->addTabs(self::TAB_SHOW_TALKS);
112  $gui = new ilEmployeeTalkMyStaffUserGUI();
113  $DIC->ctrl()->forwardCommand($gui);
114  break;
115  default:
116 
117  switch ($cmd) {
118  case self::CMD_SHOW_USER:
119  $this->addTabs(self::TAB_SHOW_USER);
120  $this->$cmd();
121  break;
122  default:
123  $this->index();
124  break;
125  }
126  }
127  }
128 
129  protected function index(): void
130  {
131  global $DIC;
132  $DIC->ctrl()->redirectByClass(ilMStShowUserCoursesGUI::class);
133  }
134 
135  protected function showUser(): void
136  {
137  global $DIC;
138 
139  //Redirect if Profile is not public
140  $user = new ilObjUser($this->usr_id);
141  if (!$user->hasPublicProfile()) {
142  $DIC->ctrl()->redirectByClass(self::class, self::CMD_INDEX);
143  }
144 
145  $pub_profile = new ilPublicUserProfileGUI($this->usr_id);
146  $DIC->ui()->mainTemplate()->setContent($pub_profile->getEmbeddable());
147  }
148 
149  public function cancel(): void
150  {
151  global $DIC;
152 
153  $DIC->ctrl()->redirect($this);
154  }
155 
156  protected function addTabs(string $active_tab_id): void
157  {
158  global $DIC;
159 
160  $DIC->tabs()->setBackTarget($DIC->language()->txt('mst_list_users'), $DIC->ctrl()->getLinkTargetByClass(array(
161  ilMyStaffGUI::class,
162  ilMStListUsersGUI::class,
163  )));
164 
165  if ($this->access->hasCurrentUserAccessToCourseMemberships()) {
166  $DIC->tabs()->addTab(
167  self::TAB_SHOW_COURSES,
168  $DIC->language()->txt('mst_list_courses'),
169  $DIC->ctrl()->getLinkTargetByClass(array(
170  ilMyStaffGUI::class,
171  self::class,
172  ilMStShowUserCoursesGUI::class,
173  ))
174  );
175  }
176 
177  if ($this->access->hasCurrentUserAccessToCertificates()) {
178  $DIC->tabs()->addTab(
179  self::TAB_SHOW_CERTIFICATES,
180  $DIC->language()->txt('mst_list_certificates'),
181  $DIC->ctrl()->getLinkTargetByClass(array(
182  ilMyStaffGUI::class,
183  self::class,
184  ilUserCertificateGUI::class,
185  ))
186  );
187  }
188 
189  if ($this->access->hasCurrentUserAccessToCompetences()) {
190  $DIC->tabs()->addTab(
191  self::TAB_SHOW_COMPETENCES,
192  $DIC->language()->txt('mst_list_competences'),
193  $DIC->ctrl()->getLinkTargetByClass(array(
194  ilMyStaffGUI::class,
195  self::class,
196  ilMStShowUserCompetencesGUI::class,
197  ))
198  );
199  }
200 
201  $user = new ilObjUser($this->usr_id);
202  if ($user->hasPublicProfile()) {
203  $DIC->ctrl()->setParameterByClass(self::class, 'usr_id', $this->usr_id);
204  $public_profile_url = $DIC->ctrl()->getLinkTargetByClass(self::class, self::CMD_SHOW_USER);
205  $DIC->tabs()->addTab(self::TAB_SHOW_USER, $DIC->language()->txt('public_profile'), $public_profile_url);
206  }
207 
208  if ($this->access->hasCurrentUserAccessToTalks()) {
209  $DIC->ctrl()->setParameterByClass(strtolower(self::class), 'usr_id', $this->usr_id);
210  $DIC->tabs()->addTab(self::TAB_SHOW_TALKS, $DIC->language()->txt('etal_talks'), $DIC->ctrl()->getLinkTargetByClass([
211  strtolower(ilMyStaffGUI::class),
212  strtolower(self::class),
213  strtolower(ilEmployeeTalkMyStaffUserGUI::class)
214  ], ControlFlowCommand::INDEX));
215  }
216 
217  if ($active_tab_id) {
218  $DIC->tabs()->activateTab($active_tab_id);
219  }
220  }
221 }
ilUserCertificateGUI: ilAchievementsGUI
addTabs(string $active_tab_id)
Class ilMStShowUserGUI.
GUI class for public user profile presentation.
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:
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:25
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)
ilGlobalTemplateInterface $main_tpl
Class ilMStShowUserCompetencesGUI.