ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilEmployeeTalkMyStaffBaseGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
28
30{
31 protected UIServices $ui;
33 protected ilTabsGUI $tabs;
35 protected ilCtrl $ctrl;
39
40 public function __construct()
41 {
42 global $DIC;
43
44 $DIC->language()->loadLanguageModule('etal');
45 $DIC->language()->loadLanguageModule('orgu');
46 $this->language = $DIC->language();
47 $this->talk_access = new ilObjEmployeeTalkAccess();
48 $this->access = ilMyStaffAccess::getInstance();
49
50 $this->tabs = $DIC->tabs();
51 $this->ui = $DIC->ui();
52 $this->ctrl = $DIC->ctrl();
53 $this->current_user = $DIC->user();
54 $this->repository = new IliasDBEmployeeTalkRepository($DIC->database());
55 }
56
57 final public function executeCommand(): void
58 {
59 $next_class = $this->ctrl->getNextClass();
60 $command = $this->ctrl->getCmd(ControlFlowCommand::DEFAULT);
61 $link_to_this = $this->ctrl->getLinkTargetByClass($this->getClassPath());
62
63 switch ($next_class) {
64 case strtolower(ilObjEmployeeTalkSeriesGUI::class):
65 $gui = new ilObjEmployeeTalkSeriesGUI();
66 $gui->setLinkToParentGUI($link_to_this);
67 $this->ctrl->forwardCommand($gui);
68 break;
69 case strtolower(ilObjEmployeeTalkGUI::class):
70 $gui = new ilObjEmployeeTalkGUI();
71 if ($this->access->hasCurrentUserAccessToTalks()) {
72 $this->tabs->setBackTarget(
73 $this->language->txt('etal_talks'),
74 $this->ctrl->getLinkTarget($this, ControlFlowCommand::INDEX)
75 );
76 }
77 $gui->setLinkToParentGUI($link_to_this);
78 $this->ctrl->forwardCommand($gui);
79 break;
80 case strtolower(ilFormPropertyDispatchGUI::class):
81 $this->ctrl->setReturn($this, ControlFlowCommand::INDEX);
82 $table = new ilEmployeeTalkTableGUI($this, ControlFlowCommand::INDEX);
83 $table->executeCommand();
84 break;
85 default:
86 switch ($command) {
87 case ControlFlowCommand::APPLY_FILTER:
88 $this->applyFilter();
89 break;
90 case ControlFlowCommand::RESET_FILTER:
91 $this->resetFilter();
92 break;
93 case ControlFlowCommand::INDEX:
94 default:
95 $this->view();
96 }
97 }
98 }
99
100 abstract protected function hasCurrentUserAccess(): bool;
101
102 private function checkAccessOrFail(): void
103 {
104 if (!$this->hasCurrentUserAccess()) {
105 $this->ui->mainTemplate()->setOnScreenMessage(
106 'failure',
107 $this->language->txt("permission_denied"),
108 true
109 );
110 $this->ctrl->redirectByClass(ilDashboardGUI::class, "");
111 }
112 }
113
117 abstract public function getClassPath(): array;
118
119 private function applyFilter(): void
120 {
121 $table = new ilEmployeeTalkTableGUI($this, ControlFlowCommand::APPLY_FILTER);
122 $table->writeFilterToSession();
123 $table->resetOffset();
124 $this->view();
125 }
126
127 private function resetFilter(): void
128 {
129 $table = new ilEmployeeTalkTableGUI($this, ControlFlowCommand::RESET_FILTER);
130 $table->resetOffset();
131 $table->resetFilter();
132 $this->view();
133 }
134
135 private function view(): void
136 {
137 $this->loadActionBar();
138 $this->loadTabs();
139 $this->loadHeader();
140 $this->ui->mainTemplate()->setContent($this->loadTable()->getHTML());
141 }
142
143 abstract protected function loadHeader(): void;
144
145 abstract protected function loadTabs(): void;
146
147 private function loadActionBar(): void
148 {
149 if (!$this->talk_access->canCreate()) {
150 return;
151 }
152
153 $templates = new CallbackFilterIterator(
154 new ArrayIterator(ilObject::_getObjectsByType("talt")),
155 function (array $item) {
156 return
157 (
158 $item['offline'] === "0" ||
159 $item['offline'] === 0 ||
160 $item['offline'] === null
161 ) && ilObjTalkTemplate::_hasUntrashedReference(intval($item['obj_id']));
162 }
163 );
164
165 $buttons = [];
166 $talk_class = strtolower(ilObjEmployeeTalkSeriesGUI::class);
167 foreach ($templates as $item) {
168 $objId = intval($item['obj_id']);
170
171 // Templates only have one ref id
172 $this->ctrl->setParameterByClass($talk_class, 'new_type', ilObjEmployeeTalkSeries::TYPE);
173 $this->ctrl->setParameterByClass($talk_class, 'template', array_pop($refId));
174 $this->ctrl->setParameterByClass($talk_class, 'ref_id', ilObjTalkTemplateAdministration::getRootRefId());
175 $url = $this->ctrl->getLinkTargetByClass($talk_class, ControlFlowCommand::CREATE);
176 $this->ctrl->clearParametersByClass($talk_class);
177
178 $buttons[] = $this->ui->factory()->link()->standard(
179 (string) $item["title"],
180 $url
181 );
182 }
183
184 $dropdown = $this->ui->factory()->dropdown()->standard($buttons)->withLabel(
185 $this->language->txt('etal_add_new_item')
186 );
187 $this->ui->mainTemplate()->setVariable(
188 'SELECT_OBJTYPE_REPOS',
189 $this->ui->renderer()->render($dropdown)
190 );
191 }
192
196 abstract protected function loadTalkData(): array;
197
199 {
201 $table->setTalkData($this->loadTalkData());
202
203 return $table;
204 }
205}
Provides fluid interface to RBAC services.
Definition: UIServices.php:25
Class ilCtrl provides processing control methods.
language handling
Class ilObjEmployeeTalkGUI.
User class.
static _hasUntrashedReference(int $obj_id)
checks whether an object has at least one reference that is not in trash
static _getAllReferences(int $id)
get all reference ids for object ID
static _getObjectsByType(string $obj_type="", ?int $owner=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:26
$url
Definition: shib_logout.php:68
$objId
Definition: xapitoken.php:57
$refId
Definition: xapitoken.php:58