20 declare(strict_types=1);
47 $this->positionRepo =
$dic[
"repo.Positions"];
48 $this->assignmentRepo =
$dic[
"repo.UserAssignments"];
52 $to_int =
$dic[
'refinery']->kindlyTo()->int();
53 $ref_id =
$dic[
'query']->retrieve(
'ref_id', $to_int);
54 $this->link_factory =
$dic[
'ui.factory']->link();
59 $this->
toolbar = $DIC->toolbar();
60 $this->tpl = $DIC->ui()->mainTemplate();
68 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"permission_denied"),
true);
69 $this->
ctrl->redirectByClass(ilObjOrgUnitGUI::class);
76 ilOrgUnitDefaultPermissionGUI::class,
77 ilOrgUnitUserAssignmentGUI::class,
86 protected function index(): void
88 $url = $this->
ctrl->getLinkTarget($this, self::CMD_ADD);
89 $link = $this->link_factory->standard(
90 $this->
lng->txt(
'add_position'),
93 $this->
toolbar->addComponent($link);
99 protected function add(): void
102 $this->tpl->setContent($form->getHTML());
108 if ($form->saveObject() ===
true) {
109 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_position_created'),
true);
110 $this->
ctrl->redirect($this, self::CMD_INDEX);
113 $this->tpl->setContent($form->getHTML());
116 protected function edit(): void
123 $this->tpl->setContent($form->getHTML());
130 $form->setValuesByPost();
131 if ($form->saveObject() ===
true) {
132 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_position_updated'),
true);
133 $this->
ctrl->redirect($this, self::CMD_INDEX);
136 $this->tpl->setContent($form->getHTML());
142 if ($position->isCorePosition()) {
147 $assignments = $this->assignmentRepo->getByPosition($position->getId());
148 foreach ($assignments as $assignment) {
149 $this->assignmentRepo->store($assignment->withPositionId($employee_position->getId()));
152 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_assignment_to_employee_done'),
true);
158 if ($position->isCorePosition()) {
161 $this->
lng->loadLanguageModule(
'orgu');
162 $position_string = $this->
lng->txt(
"position") .
": ";
163 $authority_string = $this->
lng->txt(
"authorities") .
": ";
164 $user_string = $this->
lng->txt(
"user_assignments") .
": ";
167 $confirmation->setFormAction($this->
ctrl->getFormAction($this));
168 $confirmation->setCancel($this->
lng->txt(self::CMD_CANCEL), self::CMD_CANCEL);
169 $confirmation->setConfirm($this->
lng->txt(self::CMD_DELETE), self::CMD_DELETE);
170 $confirmation->setHeaderText($this->
lng->txt(
'msg_confirm_deletion'));
171 $confirmation->addItem(self::AR_ID, (
string) $position->getId(), $position_string
172 . $position->getTitle());
175 $confirmation->addItem(
'authorities',
'', $authority_string);
178 $userIdsOfPosition = $this->assignmentRepo->getUsersByPosition($position->getId());
180 $usersOfPosition = $ilOrgUnitUserQueries->findAllUsersByUserIds($userIdsOfPosition);
181 $userNames = $ilOrgUnitUserQueries->getAllUserNames($usersOfPosition);
183 $confirmation->addItem(
'users',
'', $user_string . implode(
', ', $userNames));
186 $checkbox_assign_users->setChecked(
true);
187 $checkbox_assign_users->setValue(
'1');
188 $checkbox_assign_users->setOptionTitle(
'Assign affected users to employee role');
189 $confirmation->addItem(
'assign_users',
'', $checkbox_assign_users->render());
191 $this->tpl->setContent($confirmation->getHTML());
194 protected function delete():
void 196 if ($_POST[
'assign_users']) {
200 $this->positionRepo->delete($position->getId());
201 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_deleted'),
true);
202 $this->
ctrl->redirect($this, self::CMD_INDEX);
207 $this->
ctrl->redirect($this, self::CMD_INDEX);
212 return $this->positionRepo->getSingle($this->
int(self::AR_ID),
'id');
218 $this->
ctrl->saveParameter($this,
'arid');
219 $this->
ctrl->saveParameterByClass(ilOrgUnitDefaultPermissionGUI::class,
'arid');
221 ->getLinkTarget($this, self::CMD_EDIT));
223 ->getLinkTargetByClass(
224 ilOrgUnitDefaultPermissionGUI::class,
237 $lang->loadLanguageModule(
'orgu');
246 foreach ($lang_keys as
$key) {
250 $authority_description = [];
251 foreach ($authorities as $authority) {
252 switch ($authority->getOver()) {
254 $over_txt = $t[
"over_" . $authority->getOver()];
257 $over_txt = $this->positionRepo
258 ->getSingle($authority->getOver(),
'id')
263 $authority_description[] =
" " . $t[
"over"] .
" " . $over_txt .
" " . $t[
"in"] .
" " . $t[
"scope_" . $authority->getScope()];
266 return $authority_description;
activeSubTab(string $subtab_id)
const CORE_POSITION_EMPLOYEE
Class ilOrgUnitPositionGUI.
ilOrgUnitPositionDBRepository $positionRepo
pushSubTab(string $subtab_id, string $url)
initRequest(HTTP\Services $http, Refinery\Factory $refinery, ?array $passed_query_params=null, ?array $passed_post_data=null)
Query params and post data parameters are used for testing.
ILIAS UI Component Link Factory $link_factory
trait BaseGUIRequest
Base gui request wrapper.
ilGlobalTemplateInterface $tpl
static _checkAccessPositions(int $ref_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilOrgUnitPositionTableGUI.
const CMD_CONFIRM_DELETION
const SCOPE_SUBSEQUENT_ORGUS
getAuthorityDescription(array $authorities)
Returns descriptions for authorities as an array of strings.
ilOrgUnitUserAssignmentDBRepository $assignmentRepo