ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilEmployeeTalkMyStaffListGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
24
32{
33 public function getClassPath(): array
34 {
35 return [
36 strtolower(ilDashboardGUI::class),
37 strtolower(ilMyStaffGUI::class),
38 strtolower(ilEmployeeTalkMyStaffListGUI::class)
39 ];
40 }
41
42 protected function hasCurrentUserAccess(): bool
43 {
44 return $this->access->hasCurrentUserAccessToTalks();
45 }
46
47 protected function loadHeader(): void
48 {
49 $this->ui->mainTemplate()->setTitle($this->language->txt('mm_org_etal'));
50 $this->ui->mainTemplate()->setTitleIcon(ilUtil::getImagePath('standard/icon_etal.svg'));
51 }
52
53 protected function loadTabs(): void
54 {
55 $this->tabs->addTab("view_content", "Content", "#");
56 $this->tabs->activateTab("view_content");
57 $this->tabs->setForcePresentationOfSingleTab(true);
58 }
59
60 protected function loadTalkData(): array
61 {
65 $talks = [];
66 if ($this->current_user->getId() === 6) {
67 $talks = $this->repository->findAll();
68 } else {
69 $users = $this->getEmployeeIdsWithValidPermissionRights($this->current_user->getId());
70 $talks = $this->repository->findByUserOrTheirEmployees($this->current_user->getId(), $users);
71 }
72 return $talks;
73 }
74
75 private function getEmployeeIdsWithValidPermissionRights(int $userId): array
76 {
77 $myStaffAccess = ilMyStaffAccess::getInstance();
78 //The user has always access to his own talks
79 $managedUsers = [$userId];
80
84 $managedOrgUnitUsersOfUserByPosition = $myStaffAccess->getUsersForUserPerPosition($userId);
85
86 foreach ($managedOrgUnitUsersOfUserByPosition as $position => $managedOrgUnitUserByPosition) {
87 // Check if the position has any relevant position rights
89 $isAbleToExecuteOperation = array_reduce($permissionSet->getOperations(), function (bool $prev, ilOrgUnitOperation $it) {
90 return $prev || $it->getOperationString() === EmployeeTalkPositionAccessLevel::VIEW;
91 }, false);
92
93 if (!$isAbleToExecuteOperation) {
94 continue;
95 }
96
97 foreach ($managedOrgUnitUserByPosition as $managedOrgUnitUser) {
98 $managedUsers[] = intval($managedOrgUnitUser);
99 }
100 }
101
102 $managedUsers = array_unique($managedUsers, SORT_NUMERIC);
103
104 return $managedUsers;
105 }
106}
@ilCtrl_IsCalledBy ilEmployeeTalkMyStaffListGUI: ilMyStaffGUI @ilCtrl_IsCalledBy ilEmployeeTalkMyStaf...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getTemplateSetForContextName(string $context_name, string $position_id, bool $editable=false)
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)