ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
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  $this->setTitleAndIcon();
46  }
47 
48  protected function setTitleAndIcon(): void
49  {
50  global $DIC;
51 
52  $DIC->ui()->mainTemplate()->setTitle(ilUserUtil::getNamePresentation($this->usr_id));
53  $DIC->ui()->mainTemplate()->setTitleIcon(ilObjUser::_getPersonalPicturePath($this->usr_id, "xxsmall"));
54  }
55 
56 
60  protected function checkAccessOrFail()
61  {
62  global $DIC;
63 
64  if (!$this->usr_id) {
65  ilUtil::sendFailure($DIC->language()->txt("permission_denied"), true);
66  $DIC->ctrl()->redirectByClass(ilDashboardGUI::class, "");
67  }
68 
69  if ($this->access->hasCurrentUserAccessToUser($this->usr_id)) {
70  return;
71  } else {
72  ilUtil::sendFailure($DIC->language()->txt("permission_denied"), true);
73  $DIC->ctrl()->redirectByClass(ilDashboardGUI::class, "");
74  }
75  }
76 
77 
81  public function executeCommand()
82  {
83  global $DIC;
84 
85  $this->checkAccessOrFail();
86 
87  $cmd = $DIC->ctrl()->getCmd();
88  $next_class = $DIC->ctrl()->getNextClass();
89 
90  switch ($next_class) {
91  case strtolower(ilMStShowUserCoursesGUI::class):
92  $this->addTabs(self::TAB_SHOW_COURSES);
93  $gui = new ilMStShowUserCoursesGUI();
94  $DIC->ctrl()->forwardCommand($gui);
95  break;
96  case strtolower(ilUserCertificateGUI::class):
97  $this->addTabs(self::TAB_SHOW_CERTIFICATES);
98  $gui = new ilUserCertificateGUI(
99  null,
100  null,
101  null,
102  new ilObjUser($this->usr_id)
103  );
104  $DIC->ctrl()->forwardCommand($gui);
105  $this->setTitleAndIcon();
106  break;
107  case strtolower(ilMStShowUserCompetencesGUI::class):
108  $this->addTabs(self::TAB_SHOW_COMPETENCES);
109  $gui = new ilMStShowUserCompetencesGUI($DIC);
110  $DIC->ctrl()->forwardCommand($gui);
111  break;
112  default:
113 
114  switch ($cmd) {
115  case self::CMD_SHOW_USER:
116  $this->addTabs(self::TAB_SHOW_USER);
117  $this->$cmd();
118  break;
119  default:
120  $this->index();
121  break;
122  }
123  }
124  }
125 
126 
130  protected function index()
131  {
132  global $DIC;
133  $DIC->ctrl()->redirectByClass(ilMStShowUserCoursesGUI::class);
134  }
135 
136 
140  protected function showUser()
141  {
142  global $DIC;
143 
144  //Redirect if Profile is not public
145  $user = new ilObjUser($this->usr_id);
146  if (!$user->hasPublicProfile()) {
147  $DIC->ctrl()->redirectByClass(self::class, self::CMD_INDEX);
148  }
149 
150  $pub_profile = new ilPublicUserProfileGUI($this->usr_id);
151  $DIC->ui()->mainTemplate()->setContent($pub_profile->getEmbeddable());
152  }
153 
154 
158  public function cancel()
159  {
160  global $DIC;
161 
162  $DIC->ctrl()->redirect($this);
163  }
164 
165 
169  protected function addTabs($active_tab_id)
170  {
171  global $DIC;
172 
173  $DIC->tabs()->setBackTarget($DIC->language()->txt('mst_list_users'), $DIC->ctrl()->getLinkTargetByClass(array(
174  ilMyStaffGUI::class,
175  self::class,
176  ilMStListUsersGUI::class,
177  )));
178 
179  if ($this->access->hasCurrentUserAccessToCourseMemberships()) {
180  $DIC->tabs()->addTab(self::TAB_SHOW_COURSES, $DIC->language()->txt('mst_list_courses'), $DIC->ctrl()->getLinkTargetByClass(array(
181  ilMyStaffGUI::class,
182  self::class,
183  ilMStShowUserCoursesGUI::class,
184  )));
185  }
186 
187  if ($this->access->hasCurrentUserAccessToCertificates()) {
188  $DIC->tabs()->addTab(self::TAB_SHOW_CERTIFICATES, $DIC->language()->txt('mst_list_certificates'), $DIC->ctrl()->getLinkTargetByClass(array(
189  ilMyStaffGUI::class,
190  self::class,
191  ilUserCertificateGUI::class,
192  )));
193  }
194 
195  if ($this->access->hasCurrentUserAccessToCompetences()) {
196  $DIC->tabs()->addTab(self::TAB_SHOW_COMPETENCES, $DIC->language()->txt('mst_list_competences'), $DIC->ctrl()->getLinkTargetByClass(array(
197  ilMyStaffGUI::class,
198  self::class,
199  ilMStShowUserCompetencesGUI::class,
200  )));
201  }
202 
203 
204  $user = new ilObjUser($this->usr_id);
205  if ($user->hasPublicProfile()) {
206  $DIC->ctrl()->setParameterByClass(self::class, 'usr_id', $this->usr_id);
207  $public_profile_url = $DIC->ctrl()->getLinkTargetByClass(self::class, self::CMD_SHOW_USER);
208  $DIC->tabs()->addTab(self::TAB_SHOW_USER, $DIC->language()->txt('public_profile'), $public_profile_url);
209  }
210 
211  if ($active_tab_id) {
212  $DIC->tabs()->activateTab($active_tab_id);
213  }
214  }
215 }
Class ilMStShowUserGUI.
GUI class for public user profile presentation.
global $DIC
Definition: goto.php:24
static _getPersonalPicturePath( $a_usr_id, $a_size="small", $a_force_pic=false, $a_prevent_no_photo_image=false, $html_export=false)
Get path to personal picture.
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.
Class ilMStShowUserCompetencesGUI.