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