ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilEmployeeTalkMyStaffListGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(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 }
repository()
description: > Example for rendering a repository card
Definition: repository.php:33
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)
language()
description: > Example for rendring a language glyph.
Definition: language.php:41