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