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