ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilDashboardGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
37 {
38  public const CMD_JUMP_TO_MY_STAFF = 'jumpToMyStaff';
39  public const DISENGAGE_MAINBAR = 'dash_mb_disengage';
40 
41  protected ilCtrl $ctrl;
42  protected ilObjUser $user;
43  protected ilSetting $settings;
45  protected ilHelpGUI $help;
47  public ilLanguage $lng;
48  public string $cmdClass = '';
50  protected int $requested_view;
51  protected int $requested_prt_id;
52  protected int $requested_gtp;
53  protected string $requested_dsh;
54  protected int $requested_wsp_id;
55 
56  public function __construct()
57  {
58  global $DIC;
59 
60  $this->tool_context = $DIC->globalScreen()->tool()->context();
61  $this->user = $DIC->user();
62  $this->settings = $DIC->settings();
63  $this->rbacsystem = $DIC->rbac()->system();
64  $this->help = $DIC->help();
65  $tpl = $DIC->ui()->mainTemplate();
66  $this->lng = $DIC->language();
67  $this->ctrl = $DIC->ctrl();
68 
69  if ($this->user->getId() === ANONYMOUS_USER_ID) {
70  $DIC->ui()->mainTemplate()->setOnScreenMessage('failure', $this->lng->txt('msg_not_available_for_anon'), true);
71  $DIC->ctrl()->redirectToURL('login.php?cmd=force_login');
72  }
73 
74  $this->tpl = $tpl;
75 
76  $this->ctrl->setContextObject(
77  $this->user->getId(),
78  'user'
79  );
80 
81  $this->lng->loadLanguageModule('pdesk');
82  $this->lng->loadLanguageModule('pd'); // #16813
83  $this->lng->loadLanguageModule('dash');
84  $this->lng->loadLanguageModule('mmbr');
85 
86  $params = $DIC->http()->request()->getQueryParams();
87  $this->cmdClass = ($params['cmdClass'] ?? '');
88  $this->requested_view = (int) ($params['view'] ?? 0);
89  $this->requested_prt_id = (int) ($params['prt_id'] ?? 0);
90  $this->requested_gtp = (int) ($params['gtp'] ?? 0);
91  $this->requested_dsh = (string) ($params['dsh'] ?? null);
92  $this->requested_wsp_id = (int) ($params['wsp_id'] ?? 0);
93 
94  $this->ctrl->saveParameter($this, ['view']);
95  }
96 
97  public function executeCommand(): void
98  {
100  $context->stack()->desktop();
102 
103  $next_class = $this->ctrl->getNextClass();
104  $this->ctrl->setReturn($this, 'show');
105  switch ($next_class) {
106  case strtolower(ilPersonalProfileGUI::class):
107  $this->getStandardTemplates();
108  $this->setTabs();
109  $profile_gui = new ilPersonalProfileGUI();
110  $this->ctrl->forwardCommand($profile_gui);
111  break;
112 
113  case strtolower(ilPersonalSettingsGUI::class):
114  $this->getStandardTemplates();
115  $this->setTabs();
116  $settings_gui = new ilPersonalSettingsGUI();
117  $this->ctrl->forwardCommand($settings_gui);
118  break;
119 
120  case strtolower(ilCalendarPresentationGUI::class):
121  $this->getStandardTemplates();
122  $this->displayHeader();
123  $this->tpl->setTitle($this->lng->txt('calendar'));
124  $this->setTabs();
125  $cal = new ilCalendarPresentationGUI();
126  $this->ctrl->forwardCommand($cal);
127  $this->tpl->printToStdout();
128  break;
129 
130  case strtolower(ilPDNotesGUI::class):
131  if ($ilSetting->get('disable_notes') && $ilSetting->get('disable_comments')) {
132  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true);
133  ilUtil::redirect('ilias.php?baseClass=ilDashboardGUI');
134  return;
135  }
136 
137  $this->getStandardTemplates();
138  $this->setTabs();
139  $pd_notes_gui = new ilPDNotesGUI();
140  $this->ctrl->forwardCommand($pd_notes_gui);
141  break;
142 
143  case strtolower(ilPDNewsGUI::class):
144  $this->getStandardTemplates();
145  $this->setTabs();
146  $pd_news_gui = new ilPDNewsGUI();
147  $this->ctrl->forwardCommand($pd_news_gui);
148  break;
149 
150  case strtolower(ilColumnGUI::class):
151  if (strtolower($cmdClass = $this->ctrl->getCmdClass()) === strtolower(ilSelectedItemsBlockGUI::class)) {
152  $gui = new $cmdClass();
153  $ret = $this->ctrl->forwardCommand($gui);
154  if ($ret !== '') {
155  $this->tpl->setContent($ret);
156  $this->tpl->printToStdout();
157  }
158  break;
159  }
160  $this->getStandardTemplates();
161  $this->setTabs();
162  $column_gui = new ilColumnGUI('pd');
163  $this->show();
164  break;
165  case strtolower(ilContactGUI::class):
166  if (!ilBuddySystem::getInstance()->isEnabled()) {
167  throw new ilPermissionException($this->lng->txt('msg_no_perm_read'));
168  }
169 
170  $this->getStandardTemplates();
171  $this->setTabs();
172  $this->tpl->setTitle($this->lng->txt('mail_addressbook'));
173 
174  $this->ctrl->forwardCommand(new ilContactGUI());
175  break;
176 
177  case strtolower(ilPersonalWorkspaceGUI::class):
178  $wsgui = new ilPersonalWorkspaceGUI();
179  $this->ctrl->forwardCommand($wsgui);
180  $this->tpl->printToStdout();
181  break;
182 
183  case strtolower(ilPortfolioRepositoryGUI::class):
184  $this->getStandardTemplates();
185  $this->setTabs();
186  $pfgui = new ilPortfolioRepositoryGUI();
187  $this->ctrl->forwardCommand($pfgui);
188  $this->tpl->printToStdout();
189  break;
190 
191  case strtolower(ilAchievementsGUI::class):
192  $this->getStandardTemplates();
193  $this->setTabs();
194  $achievegui = new ilAchievementsGUI();
195  $this->ctrl->forwardCommand($achievegui);
196  break;
197 
198  case strtolower(ilMyStaffGUI::class):
199  $this->getStandardTemplates();
200  $mstgui = new ilMyStaffGUI();
201  $this->ctrl->forwardCommand($mstgui);
202  break;
203  case strtolower(ilGroupUserActionsGUI::class):
204  $this->getStandardTemplates();
205  $this->setTabs();
206  $ggui = new ilGroupUserActionsGUI();
207  $this->ctrl->forwardCommand($ggui);
208  $this->tpl->printToStdout();
209  break;
210  case strtolower(ilDashboardLearningSequenceGUI::class):
211  case strtolower(ilMembershipBlockGUI::class):
212  case strtolower(ilDashboardRecommendedContentGUI::class):
213  case strtolower(ilSelectedItemsBlockGUI::class):
214  case strtolower(ilStudyProgrammeDashboardViewGUI::class):
215  $gui = new $next_class();
216  $ret = $this->ctrl->forwardCommand($gui);
217  if ($ret !== '' && $ret !== null) {
218  $this->tpl->setContent($ret);
219  }
220  $this->tpl->printToStdout();
221  break;
222  case strtolower(ilObjStudyProgrammeGUI::class):
223  $gui = new ilObjStudyProgrammeGUI();
224  $ret = $this->ctrl->forwardCommand($gui);
225  $this->tpl->printToStdout();
226  break;
227  default:
228  $context->current()->addAdditionalData(self::DISENGAGE_MAINBAR, true);
229  $this->getStandardTemplates();
230  $this->setTabs();
231  $cmd = $this->ctrl->getCmd('show');
232  $this->$cmd();
233  break;
234  }
235  }
236 
237  public function getStandardTemplates(): void
238  {
239  $this->tpl->loadStandardTemplate();
240  }
241 
242  public function show(): void
243  {
245 
246  $this->tpl->setTitle($this->lng->txt('dash_dashboard'));
247  $this->tpl->setTitleIcon(ilUtil::getImagePath('standard/icon_dshs.svg'), $this->lng->txt('dash_dashboard'));
248  $this->tpl->setVariable('IMG_SPACE', ilUtil::getImagePath('media/spacer.png'));
249 
250  $this->tpl->setContent($this->getCenterColumnHTML());
251  $this->tpl->setRightContent($this->getRightColumnHTML());
252  $this->tpl->printToStdout();
253  }
254 
255  public function getCenterColumnHTML(): string
256  {
257  $ilCtrl = $this->ctrl;
258 
259  $html = '';
260  $column_gui = new ilColumnGUI('pd', IL_COL_CENTER);
261 
262  if ($ilCtrl->getNextClass() == 'ilcolumngui' &&
263  $column_gui->getCmdSide() == IL_COL_CENTER) {
264  $html = $ilCtrl->forwardCommand($column_gui);
265  } else {
266  if (!$ilCtrl->isAsynch()) {
267  if ($column_gui->getScreenMode() != IL_SCREEN_SIDE) {
268  if ($column_gui->getCmdSide() == IL_COL_RIGHT) {
269  $column_gui = new ilColumnGUI('pd', IL_COL_RIGHT);
270  $html = $ilCtrl->forwardCommand($column_gui);
271  }
272  if ($column_gui->getCmdSide() == IL_COL_LEFT) {
273  $column_gui = new ilColumnGUI('pd', IL_COL_LEFT);
274  $html = $ilCtrl->forwardCommand($column_gui);
275  }
276  } else {
277  $html = '';
278 
279  $uip = new ilUIHookProcessor(
280  'Services/Dashboard',
281  'center_column',
282  ['personal_desktop_gui' => $this]
283  );
284  if (!$uip->replaced()) {
285  $html = $this->getMainContent();
286  }
287  $html = $uip->getHTML($html);
288  }
289  }
290  }
291  return $html;
292  }
293 
294  public function getRightColumnHTML(): string
295  {
296  $ilCtrl = $this->ctrl;
297 
298  $html = '';
299 
300  $column_gui = new ilColumnGUI('pd', IL_COL_RIGHT);
301 
302  if ($column_gui->getScreenMode() == IL_SCREEN_FULL) {
303  return '';
304  }
305 
306  if ($ilCtrl->getNextClass() == 'ilcolumngui' &&
307  $column_gui->getCmdSide() == IL_COL_RIGHT &&
308  $column_gui->getScreenMode() == IL_SCREEN_SIDE) {
309  $html = $ilCtrl->forwardCommand($column_gui);
310  } else {
311  if (!$ilCtrl->isAsynch()) {
312  $html = '';
313 
314  $uip = new ilUIHookProcessor(
315  'Services/Dashboard',
316  'right_column',
317  ['personal_desktop_gui' => $this]
318  );
319  if (!$uip->replaced()) {
320  $html = $ilCtrl->getHTML($column_gui);
321  }
322  $html = $uip->getHTML($html);
323  }
324  }
325 
326  return $html;
327  }
328 
329  public function prepareContentView(): void
330  {
331  $this->tpl->loadStandardTemplate();
332 
333  $this->tpl->setTitleIcon(ilUtil::getImagePath('standard/icon_pd.svg'));
334  $this->tpl->setTitle($this->lng->txt('personal_desktop'));
335  $this->tpl->setVariable('IMG_SPACE', ilUtil::getImagePath('media/spacer.png'));
336  }
337 
338  public function setTabs(): void
339  {
340  $ilHelp = $this->help;
341 
342  $ilHelp->setScreenIdComponent('pd');
343  }
344 
345  public function jumpToMemberships(): void
346  {
347  $viewSettings = new ilPDSelectedItemsBlockViewSettings($GLOBALS['DIC']->user(), $this->requested_view);
348  if ($viewSettings->enabledMemberships()) {
349  $this->ctrl->setParameter($this, 'view', $viewSettings->getMembershipsView());
350  }
351  $this->ctrl->redirect($this, 'show');
352  }
353 
354  public function jumpToSelectedItems(): void
355  {
356  $viewSettings = new ilPDSelectedItemsBlockViewSettings($GLOBALS['DIC']->user(), $this->requested_view);
357  if ($viewSettings->enabledSelectedItems()) {
358  $this->ctrl->setParameter($this, 'view', $viewSettings->getSelectedItemsView());
359  }
360  $this->show();
361  }
362 
363  public function jumpToProfile(): void
364  {
365  $this->ctrl->redirectByClass(ilPersonalProfileGUI::class);
366  }
367 
368  public function jumpToPortfolio(): void
369  {
370  $cmd = '';
371  if ($this->requested_dsh != '') {
372  $this->ctrl->setParameterByClass(ilPortfolioRepositoryGUI::class, 'shr_id', $this->requested_dsh);
373  $cmd = 'showOther';
374  }
375 
376  if ($this->requested_prt_id > 0) {
377  $this->ctrl->setParameterByClass(ilObjPortfolioGUI::class, 'prt_id', $this->requested_prt_id);
378  $this->ctrl->setParameterByClass(ilObjPortfolioGUI::class, 'gtp', $this->requested_gtp);
379  $this->ctrl->redirectByClass([ilPortfolioRepositoryGUI::class, ilObjPortfolioGUI::class], 'preview');
380  } else {
381  $this->ctrl->redirectByClass(ilPortfolioRepositoryGUI::class, $cmd);
382  }
383  }
384 
385  public function jumpToSettings(): void
386  {
387  $this->ctrl->redirectByClass(ilPersonalSettingsGUI::class);
388  }
389 
390  public function jumpToNews(): void
391  {
392  $this->ctrl->redirectByClass(ilPDNewsGUI::class);
393  }
394 
395  public function jumpToCalendar(): void
396  {
397  global $DIC;
398  $request = $DIC->http()->request();
399 
400  $query_params = $request->getQueryParams();
401 
402  if (array_key_exists('cal_view', $query_params) && $query_params['cal_view']) {
403  $cal_view = $query_params['cal_view'];
404  $this->ctrl->setParameter($this, 'cal_view', $cal_view);
405  }
406 
407  if (!empty($query_params['cal_agenda_per'])) {
408  $cal_period = $query_params['cal_agenda_per'];
409  $this->ctrl->setParameter($this, 'cal_agenda_per', $cal_period);
410  }
411 
412  $this->ctrl->redirectByClass(ilCalendarPresentationGUI::class);
413  }
414 
415  public function jumpToWorkspace(): void
416  {
417  $cmd = '';
418  if ($this->requested_dsh != '') {
419  $this->ctrl->setParameterByClass(ilPersonalWorkspaceGUI::class, 'shr_id', $this->requested_dsh);
420  $cmd = 'share';
421  }
422 
423  if ($this->requested_wsp_id > 0) {
424  $this->ctrl->setParameterByClass(ilPersonalWorkspaceGUI::class, 'wsp_id', $this->requested_wsp_id);
425  }
426 
427  if ($this->requested_gtp) {
428  $this->ctrl->setParameterByClass(ilPersonalWorkspaceGUI::class, 'gtp', $this->requested_gtp);
429  }
430 
431  $this->ctrl->redirectByClass(ilPersonalWorkspaceGUI::class, $cmd);
432  }
433 
434  protected function jumpToMyStaff(): void
435  {
436  $this->ctrl->redirectByClass(ilMyStaffGUI::class);
437  }
438 
439  public function jumpToBadges(): void
440  {
441  $this->ctrl->redirectByClass([ilAchievementsGUI::class, ilBadgeProfileGUI::class]);
442  }
443 
444  public function jumpToSkills(): void
445  {
446  $this->ctrl->redirectByClass(ilPersonalSkillsGUI::class);
447  }
448 
449  public function displayHeader(): void
450  {
451  $this->tpl->setTitle($this->lng->txt('dash_dashboard'));
452  }
453 
454  protected function toggleHelp(): void
455  {
456  if (ilSession::get('show_help_tool') == '1') {
457  ilSession::set('show_help_tool', '0');
458  } else {
459  ilSession::set('show_help_tool', '1');
460  }
461  $this->ctrl->redirect($this, 'show');
462  }
463 
464  protected function getMainContent(): string
465  {
466  $html = '';
467  $tpl = new ilTemplate('tpl.dashboard.html', true, true, 'Services/Dashboard');
468  $settings = new ilPDSelectedItemsBlockViewSettings($this->user);
469 
470  foreach ($settings->getViewPositions() as $view_position) {
471  if ($settings->isViewEnabled($view_position)) {
472  $html .= $this->renderView($view_position);
473  }
474  }
475 
476 
477  $tpl->setVariable('CONTENT', $html);
478 
479  return $tpl->get();
480  }
481 
482  protected function renderView(int $view): string
483  {
484  switch ($view) {
486  return (new ilSelectedItemsBlockGUI())->getHTML();
488  return (new ilDashboardRecommendedContentGUI())->getHTML();
490  return (new ilMembershipBlockGUI())->getHTML();
492  return (new ilDashboardLearningSequenceGUI())->getHTML();
494  return (new ilStudyProgrammeDashboardViewGUI())->getHTML();
495  default:
496  return '';
497  }
498  }
499 }
static get(string $a_var)
GUI class for personal workspace.
$context
Definition: webdav.php:31
Class ilObjStudyProgrammeGUI class ilObjStudyProgrammeGUI: ilPermissionGUI ilObjStudyProgrammeGUI: ...
const ANONYMOUS_USER_ID
Definition: constants.php:27
ContextServices $tool_context
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:33
Private Notes on PD.
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
Help GUI class.
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
const IL_COL_CENTER
const IL_COL_RIGHT
ilRbacSystem $rbacsystem
setVariable(string $variable, $value='')
Sets the given variable to the given value.
Portfolio repository gui class.
ilGlobalTemplateInterface $tpl
Interface ilCtrlBaseClassInterface describes ilCtrl base classes.
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const IL_SCREEN_FULL
$GLOBALS["DIC"]
Definition: wac.php:31
Column user interface class.
setScreenIdComponent(string $a_comp)
static redirect(string $a_script)
GUI class for personal profile.
global $ilSetting
Definition: privfeed.php:18
static preloadPDBlockSettings()
Preload pd info.
News on PD.
const IL_SCREEN_SIDE
static set(string $a_var, $a_val)
Set a value.
const IL_COL_LEFT