ILIAS  trunk Revision v11.0_alpha-1702-gfd3ecb7f852
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilMStShowUserCompetencesGUI.php
Go to the documentation of this file.
1 <?php
2 
21 
28 {
29  public const string CMD_SHOW_SKILLS = 'showSkills';
30  public const string CMD_INDEX = self::CMD_SHOW_SKILLS;
31  public const string SUB_TAB_SKILLS = 'skills';
32  private int $usr_id;
33  protected ilTable2GUI $table;
35  private Container $dic;
36  private \ilGlobalTemplateInterface $main_tpl;
37  protected \ILIAS\Skill\Service\SkillPersonalService $skill_personal_service;
38 
39  public function __construct(Container $dic)
40  {
41  global $DIC;
42  $this->main_tpl = $DIC->ui()->mainTemplate();
43  $this->dic = $dic;
44  $this->access = ilMyStaffAccess::getInstance();
45  $this->skill_personal_service = $DIC->skills()->personal();
46 
47  $this->usr_id = $this->dic->http()->request()->getQueryParams()['usr_id'];
48  $this->dic->ctrl()->setParameter($this, 'usr_id', $this->usr_id);
49  }
50 
51  protected function checkAccessOrFail(): void
52  {
53  if (!$this->usr_id) {
54  $this->main_tpl->setOnScreenMessage('failure', $this->dic->language()->txt("permission_denied"), true);
55  $this->dic->ctrl()->redirectByClass(ilDashboardGUI::class, "");
56  }
57 
58  if ($this->access->hasCurrentUserAccessToUser($this->usr_id)
59  && $this->access->hasCurrentUserAccessToCompetences()
60  ) {
61  return;
62  } else {
63  $this->main_tpl->setOnScreenMessage('failure', $this->dic->language()->txt("permission_denied"), true);
64  $this->dic->ctrl()->redirectByClass(ilDashboardGUI::class, "");
65  }
66  }
67 
68  final public function executeCommand(): void
69  {
70  $this->checkAccessOrFail();
71 
72  $cmd = $this->dic->ctrl()->getCmd();
73  $next_class = $this->dic->ctrl()->getNextClass();
74 
75  switch ($next_class) {
76  default:
77  switch ($cmd) {
78  case self::CMD_INDEX:
79  case self::CMD_SHOW_SKILLS:
80  default:
81  $this->addSubTabs(self::SUB_TAB_SKILLS);
82  $this->showSkills();
83  break;
84  }
85  }
86  }
87 
88  protected function addSubTabs(string $active_sub_tab): void
89  {
90  $this->dic->language()->loadLanguageModule('skmg');
91  $this->dic->tabs()->addSubTab(
92  self::SUB_TAB_SKILLS,
93  $this->dic->language()->txt('skmg_selected_skills'),
94  $this->dic->ctrl()->getLinkTarget($this, self::CMD_SHOW_SKILLS)
95  );
96 
97  $this->dic->tabs()->activateSubTab($active_sub_tab);
98  }
99 
100  protected function showSkills(): void
101  {
102  $skills_gui = new ilPersonalSkillsGUI();
103  $skills = $this->skill_personal_service->getSelectedUserSkills($this->usr_id);
104  $html = '';
105  foreach ($skills as $skill) {
106  $html .= $skills_gui->getSkillHTML($skill->getSkillNodeId(), $this->usr_id);
107  }
108  $this->dic->ui()->mainTemplate()->setContent($html);
109  }
110 }
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:35
Personal skills GUI class.
global $DIC
Definition: shib_login.php:22
ILIAS Skill Service SkillPersonalService $skill_personal_service
Class ilMStShowUserCompetencesGUI.