22 $DIC->ctrl()->redirectByClass(ilObjOrgUnitGUI::class);
33 ilOrgUnitDefaultPermissionGUI::class,
34 ilOrgUnitUserAssignmentGUI::class,
50 self::initAuthoritiesRenderer();
52 $b->setUrl($this->ctrl()->getLinkTarget($this, self::CMD_ADD));
53 $b->setCaption(
'add_position');
54 $this->dic()->toolbar()->addButtonInstance(
$b);
61 protected function add()
64 $this->tpl()->setContent($form->getHTML());
71 if ($form->saveObject()) {
72 ilUtil::sendSuccess($this->txt(
'msg_position_created'),
true);
73 $this->ctrl()->redirect($this, self::CMD_INDEX);
76 $this->tpl()->setContent($form->getHTML());
87 $this->tpl()->setContent($form->getHTML());
95 $form->setValuesByPost();
96 if ($form->saveObject()) {
97 ilUtil::sendSuccess($this->txt(
'msg_position_updated'),
true);
98 $this->ctrl()->redirect($this, self::CMD_INDEX);
101 $this->tpl()->setContent($form->getHTML());
108 if ($position->isCorePosition()) {
112 $assignments = $ilOrgUnitUserAssignmentQueries->getUserAssignmentsOfPosition($position->getId());
116 foreach ($assignments as $assignment) {
118 $assignment->delete();
121 ilUtil::sendSuccess($this->txt(
'msg_assignment_to_employee_done'),
true);
128 if ($position->isCorePosition()) {
131 self::initAuthoritiesRenderer();
132 $this->dic()->language()->loadLanguageModule(
'orgu');
133 $position_string = $this->dic()->language()->txt(
"position") .
": ";
134 $authority_string = $this->dic()->language()->txt(
"authorities") .
": ";
135 $user_string = $this->dic()->language()->txt(
"user_assignments") .
": ";
139 $confirmation->setFormAction($this->ctrl()->getFormAction($this));
140 $confirmation->setCancel($this->txt(self::CMD_CANCEL), self::CMD_CANCEL);
141 $confirmation->setConfirm($this->txt(self::CMD_DELETE), self::CMD_DELETE);
142 $confirmation->setHeaderText($this->txt(
'msg_confirm_deletion'));
143 $confirmation->addItem(self::AR_ID, $position->getId(), $position_string
144 . $position->getTitle());
146 $authority_string .= implode(
", ", $position->getAuthorities());
147 $confirmation->addItem(
'authorities',
true, $authority_string);
150 $userIdsOfPosition = $ilOrgUnitUserAssignmentQueries->getUserIdsOfPosition($position->getId());
152 $usersOfPosition = $ilOrgUnitUserQueries->findAllUsersByUserIds($userIdsOfPosition);
153 $userNames = $ilOrgUnitUserQueries->getAllUserNames($usersOfPosition);
155 $confirmation->addItem(
'users',
true, $user_string . implode(
', ', $userNames));
158 $checkbox_assign_users->setChecked(
true);
159 $checkbox_assign_users->setValue(1);
160 $checkbox_assign_users->setOptionTitle(
'Assign affected users to employee role');
161 $confirmation->addItem(
'assign_users',
'', $checkbox_assign_users->render());
163 $this->tpl()->setContent($confirmation->getHTML());
167 protected function delete()
169 if (
$_POST[
'assign_users']) {
173 $position->deleteWithAllDependencies();
174 ilUtil::sendSuccess($this->txt(
'msg_deleted'),
true);
175 $this->ctrl()->redirect($this, self::CMD_INDEX);
181 $this->ctrl()->redirect($this, self::CMD_INDEX);
190 $get = $this->dic()->http()->request()->getQueryParams()[self::AR_ID];
191 $post = $this->dic()->http()->request()->getParsedBody()[self::AR_ID];
193 return $post ? $post : $get;
206 public static function initAuthoritiesRenderer()
209 $lang->loadLanguageModule(
'orgu');
217 foreach ($lang_keys as $key) {
218 $t[$key] =
$lang->txt($key);
225 $ilOrgUnitAuthority = ilOrgUnitAuthority::find($id);
227 switch ($ilOrgUnitAuthority->getScope()) {
232 $in_txt = $t[
"scope_" . $ilOrgUnitAuthority->getScope()];
236 switch ($ilOrgUnitAuthority->getOver()) {
238 $over_txt = $t[
"over_" . $ilOrgUnitAuthority->getOver()];
246 return " " . $t[
"over"] .
" " . $over_txt .
" " . $t[
"in"] .
" " . $in_txt;
253 $this->ctrl()->saveParameter($this,
'arid');
254 $this->ctrl()->saveParameterByClass(ilOrgUnitDefaultPermissionGUI::class,
'arid');
255 $this->
pushSubTab(self::SUBTAB_SETTINGS, $this->ctrl()
256 ->getLinkTarget($this, self::CMD_EDIT));
257 $this->
pushSubTab(self::SUBTAB_PERMISSIONS, $this->ctrl()
258 ->getLinkTargetByClass(ilOrgUnitDefaultPermissionGUI::class, self::CMD_INDEX));
static findOrCreateAssignment($user_id, $position_id, $orgu_id)
const CORE_POSITION_EMPLOYEE
static getCorePosition($core_identifier)
Class ilOrgUnitPositionGUI.
pushSubTab($subtab_id, $url)
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
static replaceNameRenderer(Closure $closure)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static _checkAccessPositions(int $ref_id)
Class ilOrgUnitUserQueries.
static findOrGetInstance($primary_key, array $add_constructor_args=array())
Class ilOrgUnitPositionTableGUI.
const CMD_CONFIRM_DELETION
const SCOPE_SUBSEQUENT_ORGUS
Confirmation screen class.