19 declare(strict_types=1);
46 public function __construct($a_data,
int $a_id,
bool $a_call_by_reference)
50 $this->rbac_admin = $DIC->rbac()->admin();
54 $this->
lng->loadLanguageModule(
'rbac');
56 $this->
ctrl->saveParameter($this,
"obj_id");
57 $this->
http = $DIC->http();
65 $next_class = $this->
ctrl->getNextClass($this);
66 $cmd = $this->
ctrl->getCmd();
68 switch ($next_class) {
82 if ($this->creation_mode) {
83 $this->
ctrl->setParameter($this,
'new_type',
'rolt');
86 $ff = $this->ui_factory->input()->field();
88 $title_validation_constraint = $this->
refinery->custom()->constraint(
89 fn(
string $v):
bool => preg_match(
'/^il_.*$/', $v) ?
false :
true,
90 $this->
lng->txt(
'msg_role_reserved_prefix')
94 self::FORM_KEY_TITLE => $ff->text($this->
lng->txt(
'title'))
97 ->withAdditionalTransformation($title_validation_constraint)
99 $is_role_creation_form ?
'' 101 )->withDisabled($is_role_creation_form ?
false : $this->
object->isInternalTemplate()),
102 self::FORM_KEY_DESCRIPTION => $ff->textarea($this->lng->txt(
'description'))
104 ->withValue($is_role_creation_form ?
'' : $this->
object->getDescription())
107 if (!$is_role_creation_form) {
108 $inputs[self::FORM_KEY_ILIAS_ID] = $ff->text($this->
lng->txt(
'ilias_id'))
111 . $this->
object->getType() .
'_' . $this->
object->getId());
114 $inputs[self::FORM_KEY_PROTECT] = $ff->checkbox($this->
lng->txt(
'role_protect_permissions'))
116 $is_role_creation_form
118 : $this->rbac_review->isProtected($this->rolf_ref_id, $this->object->getId())
121 return $this->ui_factory->input()->container()->form()->standard(
122 $this->
ctrl->getFormActionByClass(
124 $is_role_creation_form ?
'save' :
'update' 128 $is_role_creation_form ? $this->
lng->txt(
'rolt_new') : $this->
lng->txt(
'save')
134 if (!$this->rbac_system->checkAccess(
'create_rolt', $this->rolf_ref_id)) {
135 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
138 $this->tabs_gui->setBackTarget(
139 $this->
lng->txt(
'cancel'),
140 $this->
ctrl->getParentReturnByClass(self::class)
143 $this->tpl->setContent(
144 $this->ui_renderer->render(
145 $this->ui_factory->panel()->standard(
146 $this->
lng->txt(
'rolt_new'),
158 $this->tabs_gui->activateTab(
'settings');
160 if (!$this->rbac_system->checkAccess(
"write", $this->rolf_ref_id)) {
161 $this->error->raiseError($this->
lng->txt(
"msg_no_perm_write"), $this->error->MESSAGE);
164 $this->tpl->setContent(
165 $this->ui_renderer->render(
166 $this->ui_factory->panel()->standard(
167 $this->
lng->txt(
'rolt_edit'),
176 if (!$this->rbac_system->checkAccess(
"create_rolt", $this->rolf_ref_id)) {
177 $this->
ilias->raiseError($this->
lng->txt(
"msg_no_perm_create_rolt"), $this->
ilias->error_obj->WARNING);
181 $data = $form->getData();
183 $this->tabs_gui->setBackTarget(
184 $this->
lng->txt(
'cancel'),
185 $this->
ctrl->getParentReturnByClass(self::class)
188 $this->tpl->setContent(
189 $this->ui_renderer->render(
190 $this->ui_factory->panel()->standard(
191 $this->
lng->txt(
'rolt_new'),
200 $role_template->setTitle(
$data[self::FORM_KEY_TITLE]);
201 $role_template->setDescription(
$data[self::FORM_KEY_DESCRIPTION]);
202 $role_template->create();
203 $this->rbac_admin->assignRoleToFolder($role_template->getId(),
$this->rolf_ref_id,
'n');
204 $this->rbac_admin->setProtected(
206 $role_template->getId(),
207 $data[self::FORM_KEY_PROTECT] ?
'y' :
'n' 209 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"rolt_added"),
true);
210 $this->
ctrl->setParameter($this,
'obj_id', $role_template->getId());
211 $this->
ctrl->redirect($this,
'perm');
216 if (!$this->rbac_system->checkAccess(
'write', $this->rolf_ref_id)) {
217 $this->error->raiseError($this->
lng->txt(
'msg_no_perm_modify_rolt'), $this->error->WARNING);
221 $data = $form->getData();
223 $this->tpl->setContent(
224 $this->ui_renderer->render(
225 $this->ui_factory->panel()->standard(
226 $this->
lng->txt(
'rolt_edit'),
234 if (!$this->
object->isInternalTemplate()) {
235 $this->
object->setTitle(
$data[self::FORM_KEY_TITLE]);
238 $this->
object->setDescription(
$data[self::FORM_KEY_DESCRIPTION]);
239 $this->
object->update();
240 $this->rbac_admin->setProtected(
243 $data[self::FORM_KEY_PROTECT] ?
'y' :
'n' 245 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"saved_successfully"),
true);
246 $this->
ctrl->returnToParent($this);
251 if (!$this->rbac_system->checkAccess(
'edit_permission', $this->ref_id)) {
252 $this->error->raiseError($this->
lng->txt(
'msg_no_perm_perm'), $this->error->MESSAGE);
255 $this->tabs_gui->activateTab(
'perm');
257 $this->tpl->addBlockFile(
260 'tpl.rbac_template_permissions.html',
261 'components/ILIAS/AccessControl' 264 $this->tpl->setVariable(
'PERM_ACTION', $this->
ctrl->getFormAction($this));
268 $acc->setId(
'template_perm_' . $this->ref_id);
270 $subs = ilObjRole::getSubObjects(
'root',
false);
272 foreach ($subs as $subtype => $def) {
281 $tbl->setShowChangeExistingObjects(
false);
284 $acc->addItem($def[
'translation'], $tbl->getHTML());
287 $this->tpl->setVariable(
'ACCORDION', $acc->getHTML());
297 $options->setShowOptions(
false);
298 $options->addMultiCommand(
300 $this->
lng->txt(
'save')
304 $this->tpl->setVariable(
'OPTIONS_TABLE', $options->getHTML());
312 if (!$this->rbac_system->checkAccess(
'write', $this->rolf_ref_id)) {
313 $this->error->raiseError($this->
lng->txt(
'msg_no_perm_perm'), $this->error->MESSAGE);
317 $template_permissions = [];
318 if ($this->
http->wrapper()->post()->has(
'template_perm')) {
319 $custom_transformer = $this->
refinery->custom()->transformation(
324 $template_permissions = $this->
http->wrapper()->post()->retrieve(
330 $subs = ilObjRole::getSubObjects(
'root',
false);
331 foreach (array_keys($subs) as $subtype) {
336 foreach ($template_permissions as $key => $ops_array) {
341 $this->
object->update();
343 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"saved_successfully"),
true);
344 $this->
ctrl->redirect($this,
"perm");
350 if ($this->
http->wrapper()->post()->has(
'adopt')) {
351 $source = $this->
http->wrapper()->post()->retrieve(
357 if (!$this->rbac_system->checkAccess(
'write', $this->rolf_ref_id)) {
358 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'msg_no_perm_perm'),
true);
359 } elseif ($this->obj_id == $source) {
360 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"msg_perm_adopted_from_itself"),
true);
362 $this->rbac_admin->deleteRolePermission($this->obj_id, $this->rolf_ref_id);
363 $parentRoles = $this->rbac_review->getParentRoleIds($this->rolf_ref_id,
true);
364 $this->rbac_admin->copyRoleTemplatePermissions(
366 $parentRoles[$source][
"parent"],
371 $this->
object->update();
375 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"msg_perm_adopted_from1") .
" '" . $title .
"'.<br/>" . $this->
lng->txt(
"msg_perm_adopted_from2"),
true);
377 $this->
ctrl->redirect($this,
"perm");
390 $this->tabs_gui->setBackTarget($this->
lng->txt(
'btn_back'), (string) $this->
ctrl->getParentReturn($this));
392 if ($this->rbac_system->checkAccess(
'write', $this->ref_id)) {
393 $this->tabs_gui->addTab(
395 $this->
lng->txt(
'settings'),
396 $this->
ctrl->getLinkTarget($this,
'edit')
399 if ($this->rbac_system->checkAccess(
'edit_permission', $this->ref_id)) {
400 $this->tabs_gui->addTab(
402 $this->
lng->txt(
'default_perm_settings'),
403 $this->
ctrl->getLinkTarget($this,
'perm')
413 parent::addAdminLocatorItems(
true);
415 $query = $this->
http->wrapper()->query();
417 if ($query->has(
'ref_id')) {
418 $ref_id = $query->retrieve(
'ref_id', $this->
refinery->kindlyTo()->int());
423 $this->
ctrl->getLinkTargetByClass(
"ilobjrolefoldergui",
"view")
427 if ($query->has(
'obj_id')) {
430 $this->
ctrl->getLinkTarget($this,
'perm')
editObject(?ilPropertyFormGUI $form=null)
Create new object.
addAdminLocatorItems(bool $do_not_add_object=false)
Table for object role permissions.
prepareOutput(bool $show_sub_objects=true)
const FORM_KEY_DESCRIPTION
Table for object role permissions.
static _lookupObjId(int $ref_id)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static http()
Fetches the global http state from ILIAS.
static _lookupTitle(int $obj_id)
static _getTranslation(string $a_role_title)
Class ilObjectGUI Basic methods of all Output classes.
Class ilObjForumAdministration.
getRoleTemplateForm(bool $is_role_creation_form=false)
__construct($a_data, int $a_id, bool $a_call_by_reference)
__construct(Container $dic, ilPlugin $plugin)
Class ilObjRoleTemplateGUI.
Class ilRbacAdmin Core functions for role based access control.
static _lookupType(int $id, bool $reference=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...