ILIAS  release_8 Revision v8.24
class.ilEmployeeTalkMyStaffUserGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
22use Psr\Http\Message\RequestInterface;
27
39{
40 private int $usrId;
42 private ilCtrl $ctrl;
44 private RequestInterface $request;
48 private UIServices $ui;
51
63 public function __construct(
67 RequestInterface $request,
72 ilObjEmployeeTalkAccess $employeeTalkAccess,
74 ) {
75 $this->access = $access;
76 $this->ctrl = $ctrl;
77 $this->language = $language;
78 $this->request = $request;
79 $this->template = $template;
80 $this->tabs = $tabs;
81 $this->repository = $repository;
82 $this->ui = $ui;
83 $this->talkAccess = $employeeTalkAccess;
84 $this->currentUser = $currentUser;
85
86 $this->usrId = intval($this->request->getQueryParams()['usr_id']);
87 $this->ctrl->setParameter($this, 'usr_id', $this->usrId);
88 $this->language->loadLanguageModule('etal');
89 }
90
94 private function checkAccessOrFail(): void
95 {
96 if (!$this->usrId) {
97 $this->template->setOnScreenMessage('failure', $this->language->txt("permission_denied"), true);
98 $this->ctrl->redirectByClass(ilDashboardGUI::class, "");
99 }
100
101 if (!$this->access->hasCurrentUserAccessToTalks() || !$this->access->hasCurrentUserAccessToUser($this->usrId)) {
102 $this->template->setOnScreenMessage('failure', $this->language->txt("permission_denied"), true);
103 $this->ctrl->redirectByClass(ilDashboardGUI::class, "");
104 }
105 }
106
107
111 public function executeCommand(): void
112 {
113 $this->checkAccessOrFail();
114
115 $cmd = $this->ctrl->getCmd();
116 $nextClass = $this->ctrl->getNextClass();
117
118 switch ($nextClass) {
119 case strtolower(ilObjEmployeeTalkGUI::class):
120 $gui = new ilObjEmployeeTalkGUI();
121 $this->ctrl->redirect($gui, ControlFlowCommand::INDEX);
122 break;
123 case strtolower(ilFormPropertyDispatchGUI::class):
124 $this->ctrl->setReturn($this, ControlFlowCommand::INDEX);
125 $table = new ilEmployeeTalkTableGUI($this, ControlFlowCommand::INDEX);
126 $table->executeCommand();
127 break;
128 case strtolower(ilObjEmployeeTalkSeriesGUI::class):
129 $gui = new ilObjEmployeeTalkSeriesGUI();
130 $this->ctrl->saveParameter($gui, 'template');
131 $this->ctrl->saveParameter($gui, 'new_type');
132 $this->ctrl->saveParameter($gui, 'usr_id');
133 $this->ctrl->redirectByClass([
134 strtolower(ilDashboardGUI::class),
135 strtolower(ilMyStaffGUI::class),
136 strtolower(ilEmployeeTalkMyStaffListGUI::class),
137 strtolower(ilObjEmployeeTalkSeriesGUI::class)
138 ], $cmd);
139 break;
140 default:
141 switch ($cmd) {
142 case ControlFlowCommand::INDEX:
143 $this->view();
144 break;
145 case ControlFlowCommand::APPLY_FILTER:
146 $this->applyFilter();
147 break;
148 case ControlFlowCommand::RESET_FILTER:
149 $this->resetFilter();
150 break;
151 default:
152 $this->ctrl->redirectByClass(ilDashboardGUI::class, "");
153 break;
154 }
155 }
156 }
157
158 private function applyFilter(): void
159 {
160 $table = new ilEmployeeTalkTableGUI($this, ControlFlowCommand::APPLY_FILTER);
161 $table->writeFilterToSession();
162 $table->resetOffset();
163 $this->view();
164 }
165
166
167 private function resetFilter(): void
168 {
169 $table = new ilEmployeeTalkTableGUI($this, ControlFlowCommand::RESET_FILTER);
170 $table->resetOffset();
171 $table->resetFilter();
172 $this->view();
173 }
174
175 private function view(): void
176 {
177 $this->loadActionBar();
178 $table = new ilEmployeeTalkTableGUI($this, ControlFlowCommand::INDEX);
179 $userId = intval($this->usrId);
180
181 $talks = null;
182 if ($this->talkAccess->hasPermissionToReadUnownedTalksOfUser($userId)) {
183 $talks = $this->repository->findByEmployee($userId);
184 } else {
185 $talks = $this->repository->findTalksBetweenEmployeeAndOwner($userId, $this->currentUser->getId());
186 }
187 $table->setTalkData($talks);
188 $this->template->setContent($table->getHTML());
189 }
190
191 private function loadActionBar(): void
192 {
193 $gl = new ilGroupedListGUI();
194 $gl->setAsDropDown(true, false);
195
196 $templates = new CallbackFilterIterator(
197 new ArrayIterator(ilObject::_getObjectsByType("talt")),
198 function (array $item) {
199 return
200 (
201 $item['offline'] === "0" ||
202 $item['offline'] === null
203 ) && ilObjTalkTemplate::_hasUntrashedReference(intval($item['obj_id']));
204 }
205 );
206
207 foreach ($templates as $item) {
208 $type = $item["type"];
209
210 $path = ilObject::_getIcon(0, 'tiny', $type);
211 $icon = ($path != "")
212 ? ilUtil::img($path, "") . " "
213 : "";
214
215 $this->ctrl->setParameterByClass(
216 ilObjEmployeeTalkSeriesGUI::class,
217 "new_type",
219 );
220 $url = $this->ctrl->getLinkTargetByClass(strtolower(ilObjEmployeeTalkSeriesGUI::class), ControlFlowCommand::CREATE);
221 //$url = $this->ctrl->appendRequestTokenParameterString($base_url . "&new_type=" . ilObjEmployeeTalkSeries::TYPE);
222 $refId = ilObject::_getAllReferences(intval($item['obj_id']));
223
224 // Templates only have one ref id
225 $url .= "&template=" . array_pop($refId);
227 $url .= '&usr_id=' . $this->usrId;
228
229 $ttip = ilHelp::getObjCreationTooltipText("tals");
230
231 $gl->addEntry(
232 $icon . $item["title"],
233 $url,
234 "_top",
235 "",
236 "",
237 $type,
238 $ttip,
239 "bottom center",
240 "top center",
241 false
242 );
243 }
244
245 $adv = new ilAdvancedSelectionListGUI();
246 $adv->setListTitle($this->language->txt("etal_add_new_item"));
247 //$gl->getHTML();
248 $adv->setGroupedList($gl);
250 //$this->toolbar->addDropDown($this->language->txt("cntr_add_new_item"), $adv->getHTML());
251 $this->ui->mainTemplate()->setVariable("SELECT_OBJTYPE_REPOS", $adv->getHTML());
252 }
253}
Provides fluid interface to RBAC services.
Definition: UIServices.php:24
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilCtrl provides processing control methods.
Class ilEmployeeTalkMyStaffUserGUI.
__construct(ilMyStaffAccess $access, ilCtrl $ctrl, ilLanguage $language, RequestInterface $request, ilGlobalTemplateInterface $template, ilTabsGUI $tabs, EmployeeTalkRepository $repository, UIServices $ui, ilObjEmployeeTalkAccess $employeeTalkAccess, ilObjUser $currentUser)
ilEmployeeTalkMyStaffUserGUI constructor.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getObjCreationTooltipText(string $a_type)
Get object_creation tooltip tab text.
language handling
Class ilObjEmployeeTalkGUI.
User class.
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
static _getObjectsByType(string $obj_type="", int $owner=null)
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
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static img(string $a_src, ?string $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$path
Definition: ltiservices.php:32
$type
$url
$refId
Definition: xapitoken.php:58