ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
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 readonly ilCtrl $ctrl;
46 protected readonly ilObjUser $user;
47 protected readonly ilSetting $settings;
48 protected readonly ilHelpGUI $help;
50 public readonly ilLanguage $lng;
51 protected readonly ContextServices $tool_context;
52 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 $this->tpl = $DIC->ui()->mainTemplate();
68 $this->lng = $DIC->language();
69 $this->ctrl = $DIC->ctrl();
70
71 if ($this->user->getId() === ANONYMOUS_USER_ID) {
72 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_not_available_for_anon'), true);
73 $DIC->ctrl()->redirectToURL('login.php?cmd=force_login');
74 }
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 {
99 $context = $this->tool_context;
100 $context->stack()->desktop();
102
103 $next_class = $this->ctrl->getNextClass();
104 $this->ctrl->setReturn($this, 'show');
105 switch ($next_class) {
106 case strtolower(PersonalProfileGUI::class):
107 $this->getStandardTemplates();
108 $this->setTabs();
109 $profile_gui = new PersonalProfileGUI();
110 $this->ctrl->forwardCommand($profile_gui);
111 break;
112
113 case strtolower(PersonalSettingsGUI::class):
114 $this->getStandardTemplates();
115 $this->setTabs();
116 $settings_gui = new PersonalSettingsGUI();
117 $this->ctrl->forwardCommand($settings_gui);
118 break;
119
120 case strtolower(ilLocalUserPasswordSettingsGUI::class):
121 $this->getStandardTemplates();
122 $this->setTabs();
123 $settings_gui = new ilLocalUserPasswordSettingsGUI();
124 $this->ctrl->forwardCommand($settings_gui);
125 break;
126
127 case strtolower(ilCalendarPresentationGUI::class):
128 $this->getStandardTemplates();
129 $this->displayHeader();
130 $this->tpl->setTitle($this->lng->txt('calendar'));
131 $this->setTabs();
132 $cal = new ilCalendarPresentationGUI();
133 $this->ctrl->forwardCommand($cal);
134 $this->tpl->printToStdout();
135 break;
136
137 case strtolower(ilPDNotesGUI::class):
138 if ($ilSetting->get('disable_notes') && $ilSetting->get('disable_comments')) {
139 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true);
140 ilUtil::redirect('ilias.php?baseClass=ilDashboardGUI');
141 return;
142 }
143
144 $this->getStandardTemplates();
145 $this->setTabs();
146 $pd_notes_gui = new ilPDNotesGUI();
147 $this->ctrl->forwardCommand($pd_notes_gui);
148 break;
149
150 case strtolower(ilPDNewsGUI::class):
151 $this->getStandardTemplates();
152 $this->setTabs();
153 $pd_news_gui = new ilPDNewsGUI();
154 $this->ctrl->forwardCommand($pd_news_gui);
155 break;
156
157 case strtolower(ilColumnGUI::class):
158 if (strtolower($cmdClass = $this->ctrl->getCmdClass()) === strtolower(ilSelectedItemsBlockGUI::class)) {
159 $gui = new $cmdClass();
160 $ret = $this->ctrl->forwardCommand($gui);
161 if ($ret !== '') {
162 $this->tpl->setContent($ret);
163 $this->tpl->printToStdout();
164 }
165 break;
166 }
167 $this->getStandardTemplates();
168 $this->setTabs();
169 $column_gui = new ilColumnGUI('pd');
170 $this->show();
171 break;
172 case strtolower(ilContactGUI::class):
173 if (!ilBuddySystem::getInstance()->isEnabled()) {
174 throw new ilPermissionException($this->lng->txt('msg_no_perm_read'));
175 }
176
177 $this->getStandardTemplates();
178 $this->setTabs();
179 $this->tpl->setTitle($this->lng->txt('mail_addressbook'));
180
181 $this->ctrl->forwardCommand(new ilContactGUI());
182 break;
183
184 case strtolower(ilPersonalWorkspaceGUI::class):
185 $wsgui = new ilPersonalWorkspaceGUI();
186 $this->ctrl->forwardCommand($wsgui);
187 $this->tpl->printToStdout();
188 break;
189
190 case strtolower(ilPortfolioRepositoryGUI::class):
191 $this->getStandardTemplates();
192 $this->setTabs();
193 $pfgui = new ilPortfolioRepositoryGUI();
194 $this->ctrl->forwardCommand($pfgui);
195 $this->tpl->printToStdout();
196 break;
197
198 case strtolower(ilAchievementsGUI::class):
199 $this->getStandardTemplates();
200 $this->setTabs();
201 $achievegui = new ilAchievementsGUI();
202 $this->ctrl->forwardCommand($achievegui);
203 break;
204
205 case strtolower(ilMyStaffGUI::class):
206 $this->getStandardTemplates();
207 $mstgui = new ilMyStaffGUI();
208 $this->ctrl->forwardCommand($mstgui);
209 break;
210 case strtolower(ilGroupUserActionsGUI::class):
211 $this->getStandardTemplates();
212 $this->setTabs();
213 $ggui = new ilGroupUserActionsGUI();
214 $this->ctrl->forwardCommand($ggui);
215 $this->tpl->printToStdout();
216 break;
217 case strtolower(ilDashboardLearningSequenceGUI::class):
218 case strtolower(ilMembershipBlockGUI::class):
219 case strtolower(ilDashboardRecommendedContentGUI::class):
220 case strtolower(ilSelectedItemsBlockGUI::class):
221 case strtolower(ilStudyProgrammeDashboardViewGUI::class):
222 $gui = new $next_class();
223 $ret = $this->ctrl->forwardCommand($gui);
224 if ($ret !== '' && $ret !== null) {
225 $this->tpl->setContent($ret);
226 }
227 $this->tpl->printToStdout();
228 break;
229 case strtolower(ilObjStudyProgrammeGUI::class):
230 $gui = new ilObjStudyProgrammeGUI();
231 $ret = $this->ctrl->forwardCommand($gui);
232 $this->tpl->printToStdout();
233 break;
234 default:
235 $context->current()->addAdditionalData(self::DISENGAGE_MAINBAR, true);
236 $this->getStandardTemplates();
237 $this->setTabs();
238 $cmd = $this->ctrl->getCmd('show');
239 $this->$cmd();
240 break;
241 }
242 }
243
244 public function getStandardTemplates(): void
245 {
246 $this->tpl->loadStandardTemplate();
247 }
248
249 public function show(): void
250 {
252
253 $this->tpl->setTitle($this->lng->txt("dash_dashboard"));
254 $this->tpl->setTitleIcon(ilUtil::getImagePath("standard/icon_dshs.svg"), $this->lng->txt("dash_dashboard"));
255
256 $this->tpl->setVariable('IMG_SPACE', ilUtil::getImagePath('media/spacer.png'));
257
258 $content = '';
259 if (ilDashboardPageGUI::isLanguageAvailable($this->user->getLanguage())) {
260 $content = (new ilDashboardPageGUI($this->user->getLanguage()))->showPage();
261 } elseif (ilDashboardPageGUI::isLanguageAvailable($this->lng->getDefaultLanguage())) {
262 $content = (new ilDashboardPageGUI($this->lng->getDefaultLanguage()))->showPage();
263 }
264 $content .= $this->getCenterColumnHTML();
265
266 $this->tpl->setContent($content);
267 $this->tpl->setRightContent($this->getRightColumnHTML());
268 $this->tpl->printToStdout();
269 }
270
271 public function getCenterColumnHTML(): string
272 {
273 $ilCtrl = $this->ctrl;
274
275 $html = '';
276 $column_gui = new ilColumnGUI('pd', IL_COL_CENTER);
277
278 if ($ilCtrl->getNextClass() == 'ilcolumngui' &&
279 $column_gui->getCmdSide() == IL_COL_CENTER) {
280 $html = $ilCtrl->forwardCommand($column_gui);
281 } else {
282 if (!$ilCtrl->isAsynch()) {
283 if ($column_gui->getScreenMode() != IL_SCREEN_SIDE) {
284 if ($column_gui->getCmdSide() == IL_COL_RIGHT) {
285 $column_gui = new ilColumnGUI('pd', IL_COL_RIGHT);
286 $html = $ilCtrl->forwardCommand($column_gui);
287 }
288 if ($column_gui->getCmdSide() == IL_COL_LEFT) {
289 $column_gui = new ilColumnGUI('pd', IL_COL_LEFT);
290 $html = $ilCtrl->forwardCommand($column_gui);
291 }
292 } else {
293 $html = '';
294
295 $uip = new ilUIHookProcessor(
296 'components/ILIAS/Dashboard',
297 'center_column',
298 ['personal_desktop_gui' => $this]
299 );
300 if (!$uip->replaced()) {
301 $html = $this->getMainContent();
302 }
303 $html = $uip->getHTML($html);
304 }
305 }
306 }
307 return $html;
308 }
309
310 public function getRightColumnHTML(): string
311 {
312 $ilCtrl = $this->ctrl;
313
314 $html = '';
315
316 $column_gui = new ilColumnGUI('pd', IL_COL_RIGHT);
317
318 if ($column_gui->getScreenMode() == IL_SCREEN_FULL) {
319 return '';
320 }
321
322 if ($ilCtrl->getNextClass() == 'ilcolumngui' &&
323 $column_gui->getCmdSide() == IL_COL_RIGHT &&
324 $column_gui->getScreenMode() == IL_SCREEN_SIDE) {
325 $html = $ilCtrl->forwardCommand($column_gui);
326 } else {
327 if (!$ilCtrl->isAsynch()) {
328 $html = '';
329
330 $uip = new ilUIHookProcessor(
331 'components/ILIAS/Dashboard',
332 'right_column',
333 ['personal_desktop_gui' => $this]
334 );
335 if (!$uip->replaced()) {
336 $html = $ilCtrl->getHTML($column_gui);
337 }
338 $html = $uip->getHTML($html);
339 }
340 }
341
342 return $html;
343 }
344
345 public function prepareContentView(): void
346 {
347 $this->tpl->loadStandardTemplate();
348
349 $this->tpl->setTitleIcon(ilUtil::getImagePath('standard/icon_pd.svg'));
350 $this->tpl->setTitle($this->lng->txt('personal_desktop'));
351 $this->tpl->setVariable('IMG_SPACE', ilUtil::getImagePath('media/spacer.png'));
352 }
353
354 public function setTabs(): void
355 {
356 $ilHelp = $this->help;
357
358 $ilHelp->setScreenIdComponent('pd');
359 }
360
361 private function jumpToMemberships(): void
362 {
363 $viewSettings = new ilPDSelectedItemsBlockViewSettings($this->user, $this->requested_view);
364 if ($viewSettings->enabledMemberships()) {
365 $this->ctrl->setParameter($this, 'view', $viewSettings->getMembershipsView());
366 }
367 $this->ctrl->redirect($this, 'show');
368 }
369
370 private function jumpToSelectedItems(): void
371 {
372 $viewSettings = new ilPDSelectedItemsBlockViewSettings($this->user, $this->requested_view);
373 if ($viewSettings->enabledSelectedItems()) {
374 $this->ctrl->setParameter($this, 'view', $viewSettings->getSelectedItemsView());
375 }
376 $this->show();
377 }
378
379 private function jumpToProfile(): void
380 {
381 $this->ctrl->redirectByClass([self::class, PersonalProfileGUI::class]);
382 }
383
384 private function jumpToPortfolio(): void
385 {
386 $cmd = '';
387 if ($this->requested_dsh != '') {
388 $this->ctrl->setParameterByClass(ilPortfolioRepositoryGUI::class, 'shr_id', $this->requested_dsh);
389 $cmd = 'showOther';
390 }
391
392 if ($this->requested_prt_id > 0) {
393 $this->ctrl->setParameterByClass(ilObjPortfolioGUI::class, 'prt_id', $this->requested_prt_id);
394 $this->ctrl->setParameterByClass(ilObjPortfolioGUI::class, 'gtp', $this->requested_gtp);
395 $this->ctrl->redirectByClass([ilPortfolioRepositoryGUI::class, ilObjPortfolioGUI::class], 'preview');
396 } else {
397 $this->ctrl->redirectByClass(ilPortfolioRepositoryGUI::class, $cmd);
398 }
399 }
400
401 private function jumpToSettings(): void
402 {
403 $this->ctrl->redirectByClass(PersonalSettingsGUI::class);
404 }
405
406 private function jumpToNews(): void
407 {
408 $this->ctrl->redirectByClass(ilPDNewsGUI::class);
409 }
410
411 private function jumpToCalendar(): void
412 {
413 global $DIC;
414 $request = $DIC->http()->request();
415
416 $query_params = $request->getQueryParams();
417
418 if (array_key_exists('cal_view', $query_params) && $query_params['cal_view']) {
419 $cal_view = $query_params['cal_view'];
420 $this->ctrl->setParameter($this, 'cal_view', $cal_view);
421 }
422
423 if (!empty($query_params['cal_agenda_per'])) {
424 $cal_period = $query_params['cal_agenda_per'];
425 $this->ctrl->setParameter($this, 'cal_agenda_per', $cal_period);
426 }
427
428 $this->ctrl->redirectByClass(ilCalendarPresentationGUI::class);
429 }
430
431 private function jumpToWorkspace(): void
432 {
433 $cmd = '';
434 if ($this->requested_dsh != '') {
435 $this->ctrl->setParameterByClass(ilPersonalWorkspaceGUI::class, 'shr_id', $this->requested_dsh);
436 $cmd = 'share';
437 }
438
439 if ($this->requested_wsp_id > 0) {
440 $this->ctrl->setParameterByClass(ilPersonalWorkspaceGUI::class, 'wsp_id', $this->requested_wsp_id);
441 }
442
443 if ($this->requested_gtp) {
444 $this->ctrl->setParameterByClass(ilPersonalWorkspaceGUI::class, 'gtp', $this->requested_gtp);
445 }
446
447 $this->ctrl->redirectByClass(ilPersonalWorkspaceGUI::class, $cmd);
448 }
449
450 private function jumpToMyStaff(): void
451 {
452 $this->ctrl->redirectByClass(ilMyStaffGUI::class);
453 }
454
455 private function jumpToBadges(): void
456 {
457 $this->ctrl->redirectByClass([ilAchievementsGUI::class, ilBadgeProfileGUI::class]);
458 }
459
460 private function jumpToSkills(): void
461 {
462 $this->ctrl->redirectByClass(ilPersonalSkillsGUI::class);
463 }
464
465 public function displayHeader(): void
466 {
467 $this->tpl->setTitle($this->lng->txt('dash_dashboard'));
468 }
469
470 protected function toggleHelp(): void
471 {
472 if (ilSession::get('show_help_tool') == '1') {
473 ilSession::set('show_help_tool', '0');
474 } else {
475 ilSession::set('show_help_tool', '1');
476 }
477 $this->ctrl->redirect($this, 'show');
478 }
479
480 protected function getMainContent(): string
481 {
482 $html = '';
483 $tpl = new ilTemplate('tpl.dashboard.html', true, true, 'components/ILIAS/Dashboard');
485
486 foreach ($settings->getViewPositions() as $view_position) {
487 if ($settings->isViewEnabled($view_position)) {
488 $html .= $this->renderView($view_position);
489 }
490 }
491
492
493 $tpl->setVariable('CONTENT', $html);
494
495 return $tpl->get();
496 }
497
498 protected function renderView(int $view): string
499 {
500 switch ($view) {
502 return (new ilSelectedItemsBlockGUI())->getHTML();
504 return (new ilDashboardRecommendedContentGUI())->getHTML();
506 return (new ilMembershipBlockGUI())->getHTML();
508 return (new ilDashboardLearningSequenceGUI())->getHTML();
510 return (new ilStudyProgrammeDashboardViewGUI())->getHTML();
511 default:
512 return '';
513 }
514 }
515}
@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...
readonly ilObjUser $user
readonly ContextServices $tool_context
readonly ilLanguage $lng
readonly ilCtrl $ctrl
readonly ilSetting $settings
readonly ilHelpGUI $help
readonly 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.
@ilCtrl_Calls ilPDNewsGUI: ilNewsTimelineGUI, ilCommonActionDispatcherGUI, ILIAS\User\Profile\PublicP...
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