ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilMStShowUserGUI.php
Go to the documentation of this file.
1 <?php
2 
12 {
13  const CMD_INDEX = 'index';
14  const CMD_SHOWUSER = 'showUser';
15  const CMD_RESET_FILTER = 'resetFilter';
16  const CMD_APPLY_FILTER = 'applyFilter';
17  const TAB_SHOW_COURSES = 'show_courses';
18  const TAB_SHOW_USER = 'show_user';
22  protected $usr_id;
26  protected $table;
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(ilPersonalDesktopGUI::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(ilPersonalDesktopGUI::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(ilFormPropertyDispatchGUI::class):
86  $DIC->ctrl()->setReturn($this, self::CMD_INDEX);
87  $this->table = new ilMStShowUserCoursesTableGUI($this, self::CMD_INDEX);
88  $this->table->executeCommand();
89  break;
90  default:
91  switch ($cmd) {
92  case self::CMD_RESET_FILTER:
93  case self::CMD_APPLY_FILTER:
94  case self::CMD_INDEX:
95  $this->addTabs(self::TAB_SHOW_COURSES);
96  $this->$cmd();
97  break;
98  case self::CMD_SHOWUSER:
99  $this->addTabs(self::TAB_SHOW_USER);
100  $this->$cmd();
101  break;
102  default:
103  $this->addTabs(self::TAB_SHOW_COURSES);
104  $this->index();
105  break;
106  }
107  }
108  }
109 
110 
114  protected function index()
115  {
116  $this->listUsers();
117  }
118 
119 
123  protected function listUsers()
124  {
125  global $DIC;
126 
127  $this->table = new ilMStShowUserCoursesTableGUI($this, self::CMD_INDEX);
128  $this->table->setTitle(sprintf($DIC->language()->txt('mst_courses_of'), ilObjCourse::_lookupTitle($this->usr_id)));
129 
130  $DIC->ui()->mainTemplate()->setContent($this->table->getHTML());
131  }
132 
133 
137  protected function showUser()
138  {
139  global $DIC;
140 
141  //Redirect if Profile is not public
142  $user = new ilObjUser($this->usr_id);
143  if (!$user->hasPublicProfile()) {
144  $DIC->ctrl()->redirectByClass(self::class, self::CMD_INDEX);
145  }
146 
147  $pub_profile = new ilPublicUserProfileGUI($this->usr_id);
148  $DIC->ui()->mainTemplate()->setContent($pub_profile->getEmbeddable());
149  }
150 
151 
155  protected function applyFilter()
156  {
157  $this->table = new ilMStShowUserCoursesTableGUI($this, self::CMD_APPLY_FILTER);
158  $this->table->writeFilterToSession();
159  $this->table->resetOffset();
160  $this->index();
161  }
162 
163 
167  protected function resetFilter()
168  {
169  $this->table = new ilMStShowUserCoursesTableGUI($this, self::CMD_RESET_FILTER);
170  $this->table->resetOffset();
171  $this->table->resetFilter();
172  $this->index();
173  }
174 
175 
179  public function getId()
180  {
181  $this->table = new ilMStShowUserCoursesTableGUI($this, self::CMD_INDEX);
182 
183  return $this->table->getId();
184  }
185 
186 
190  public function cancel()
191  {
192  global $DIC;
193 
194  $DIC->ctrl()->redirect($this);
195  }
196 
197 
201  protected function addTabs($active_tab_id)
202  {
203  global $DIC;
204 
205  $DIC->tabs()->setBackTarget($DIC->language()->txt('mst_list_users'), $DIC->ctrl()->getLinkTargetByClass(array(
206  ilMyStaffGUI::class,
207  ilMStListUsersGUI::class,
208  )));
209  $DIC->tabs()->addTab(self::TAB_SHOW_COURSES, $DIC->language()->txt('mst_show_courses'), $DIC->ctrl()->getLinkTargetByClass(array(
210  ilMyStaffGUI::class,
211  self::class,
212  ), self::CMD_INDEX));
213 
214  $user = new ilObjUser($this->usr_id);
215  if ($user->hasPublicProfile()) {
216  $DIC->ctrl()->setParameterByClass(self::class, 'usr_id', $this->usr_id);
217  $public_profile_url = $DIC->ctrl()->getLinkTargetByClass(self::class, self::CMD_SHOWUSER);
218  $DIC->tabs()->addTab(self::TAB_SHOW_USER, $DIC->language()->txt('public_profile'), $public_profile_url);
219  }
220 
221  if ($active_tab_id) {
222  $DIC->tabs()->activateTab($active_tab_id);
223  }
224  }
225 }
global $DIC
Definition: saml.php:7
Class ilMStShowUserGUI.
static _lookupTitle($a_id)
lookup object title
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:
$user
Definition: migrateto20.php:57
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
Class ilMStShowUserCoursesTableGUI.