19 declare(strict_types=1);
41 public function __construct($a_data,
int $a_id,
bool $a_call_by_reference)
47 $this->
lng->loadLanguageModule(
'rbac');
49 $this->
ctrl->saveParameter($this,
"obj_id");
56 $next_class = $this->
ctrl->getNextClass($this);
57 $cmd = $this->
ctrl->getCmd();
59 switch ($next_class) {
73 if ($this->creation_mode) {
74 $this->
ctrl->setParameter($this,
'new_type',
'rolt');
77 $ff = $this->ui_factory->input()->field();
79 $title_validation_constraint = $this->
refinery->custom()->constraint(
80 fn(
string $v):
bool => preg_match(
'/^il_.*$/', $v) ?
false :
true,
81 $this->
lng->txt(
'msg_role_reserved_prefix')
85 self::FORM_KEY_TITLE => $ff->text($this->
lng->txt(
'title'))
88 ->withAdditionalTransformation($title_validation_constraint)
90 $is_role_creation_form ?
'' 92 )->withDisabled($is_role_creation_form ?
false : $this->
object->isInternalTemplate()),
93 self::FORM_KEY_DESCRIPTION => $ff->textarea($this->lng->txt(
'description'))
95 ->withValue($is_role_creation_form ?
'' : $this->
object->getDescription())
98 if (!$is_role_creation_form) {
99 $inputs[self::FORM_KEY_ILIAS_ID] = $ff->text($this->
lng->txt(
'ilias_id'))
102 . $this->
object->getType() .
'_' . $this->
object->getId());
105 $inputs[self::FORM_KEY_PROTECT] = $ff->checkbox($this->
lng->txt(
'role_protect_permissions'))
107 $is_role_creation_form
109 : $this->rbac_review->isProtected($this->rolf_ref_id, $this->object->getId())
112 return $this->ui_factory->input()->container()->form()->standard(
113 $this->
ctrl->getFormActionByClass(
115 $is_role_creation_form ?
'save' :
'update' 119 $is_role_creation_form ? $this->
lng->txt(
'rolt_new') : $this->
lng->txt(
'save')
125 if (!$this->rbac_system->checkAccess(
'create_rolt', $this->rolf_ref_id)) {
126 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
129 $this->tabs_gui->setBackTarget(
130 $this->
lng->txt(
'cancel'),
131 $this->
ctrl->getParentReturnByClass(self::class)
134 $this->tpl->setContent(
135 $this->ui_renderer->render(
136 $this->ui_factory->panel()->standard(
137 $this->
lng->txt(
'rolt_new'),
149 $this->tabs_gui->activateTab(
'settings');
151 if (!$this->rbac_system->checkAccess(
"write", $this->rolf_ref_id)) {
152 $this->error->raiseError($this->
lng->txt(
"msg_no_perm_write"), $this->error->MESSAGE);
155 $this->tpl->setContent(
156 $this->ui_renderer->render(
157 $this->ui_factory->panel()->standard(
158 $this->
lng->txt(
'rolt_edit'),
167 if (!$this->rbac_system->checkAccess(
"create_rolt", $this->rolf_ref_id)) {
168 $this->
ilias->raiseError($this->
lng->txt(
"msg_no_perm_create_rolt"), $this->
ilias->error_obj->WARNING);
172 $data = $form->getData();
174 $this->tabs_gui->setBackTarget(
175 $this->
lng->txt(
'cancel'),
176 $this->
ctrl->getParentReturnByClass(self::class)
179 $this->tpl->setContent(
180 $this->ui_renderer->render(
181 $this->ui_factory->panel()->standard(
182 $this->
lng->txt(
'rolt_new'),
191 $role_template->setTitle(
$data[self::FORM_KEY_TITLE]);
192 $role_template->setDescription(
$data[self::FORM_KEY_DESCRIPTION]);
193 $role_template->create();
194 $this->rbac_admin->assignRoleToFolder($role_template->getId(),
$this->rolf_ref_id,
'n');
195 $this->rbac_admin->setProtected(
197 $role_template->getId(),
198 $data[self::FORM_KEY_PROTECT] ?
'y' :
'n' 200 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"rolt_added"),
true);
201 $this->
ctrl->setParameter($this,
'obj_id', $role_template->getId());
202 $this->
ctrl->redirect($this,
'perm');
207 if (!$this->rbac_system->checkAccess(
'write', $this->rolf_ref_id)) {
208 $this->error->raiseError($this->
lng->txt(
'msg_no_perm_modify_rolt'), $this->error->WARNING);
212 $data = $form->getData();
214 $this->tpl->setContent(
215 $this->ui_renderer->render(
216 $this->ui_factory->panel()->standard(
217 $this->
lng->txt(
'rolt_edit'),
225 if (!$this->
object->isInternalTemplate()) {
226 $this->
object->setTitle(
$data[self::FORM_KEY_TITLE]);
229 $this->
object->setDescription(
$data[self::FORM_KEY_DESCRIPTION]);
230 $this->
object->update();
231 $this->rbac_admin->setProtected(
234 $data[self::FORM_KEY_PROTECT] ?
'y' :
'n' 236 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"saved_successfully"),
true);
237 $this->
ctrl->returnToParent($this);
242 if (!$this->rbac_system->checkAccess(
'edit_permission', $this->ref_id)) {
243 $this->error->raiseError($this->
lng->txt(
'msg_no_perm_perm'), $this->error->MESSAGE);
246 $this->tabs_gui->activateTab(
'perm');
248 $this->tpl->addBlockFile(
251 'tpl.rbac_template_permissions.html',
252 'components/ILIAS/AccessControl' 255 $this->tpl->setVariable(
'PERM_ACTION', $this->
ctrl->getFormAction($this));
259 $acc->setId(
'template_perm_' . $this->ref_id);
261 $subs = ilObjRole::getSubObjects(
'root',
false);
263 foreach ($subs as $subtype => $def) {
272 $tbl->setShowChangeExistingObjects(
false);
275 $acc->addItem($def[
'translation'], $tbl->getHTML());
278 $this->tpl->setVariable(
'ACCORDION', $acc->getHTML());
288 $options->setShowOptions(
false);
289 $options->addMultiCommand(
291 $this->
lng->txt(
'save')
295 $this->tpl->setVariable(
'OPTIONS_TABLE', $options->getHTML());
303 if (!$this->rbac_system->checkAccess(
'write', $this->rolf_ref_id)) {
304 $this->error->raiseError($this->
lng->txt(
'msg_no_perm_perm'), $this->error->MESSAGE);
308 $template_permissions = [];
309 if ($this->
http->wrapper()->post()->has(
'template_perm')) {
310 $custom_transformer = $this->
refinery->custom()->transformation(
315 $template_permissions = $this->
http->wrapper()->post()->retrieve(
321 $subs = ilObjRole::getSubObjects(
'root',
false);
322 foreach (array_keys($subs) as $subtype) {
327 foreach ($template_permissions as $key => $ops_array) {
332 $this->
object->update();
334 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"saved_successfully"),
true);
335 $this->
ctrl->redirect($this,
"perm");
341 if ($this->
http->wrapper()->post()->has(
'adopt')) {
342 $source = $this->
http->wrapper()->post()->retrieve(
348 if (!$this->rbac_system->checkAccess(
'write', $this->rolf_ref_id)) {
349 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'msg_no_perm_perm'),
true);
350 } elseif ($this->obj_id == $source) {
351 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"msg_perm_adopted_from_itself"),
true);
353 $this->rbac_admin->deleteRolePermission($this->obj_id, $this->rolf_ref_id);
354 $parentRoles = $this->rbac_review->getParentRoleIds($this->rolf_ref_id,
true);
355 $this->rbac_admin->copyRoleTemplatePermissions(
357 $parentRoles[$source][
"parent"],
362 $this->
object->update();
366 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"msg_perm_adopted_from1") .
" '" . $title .
"'.<br/>" . $this->
lng->txt(
"msg_perm_adopted_from2"),
true);
368 $this->
ctrl->redirect($this,
"perm");
381 $this->tabs_gui->setBackTarget($this->
lng->txt(
'btn_back'), (string) $this->
ctrl->getParentReturn($this));
383 if ($this->rbac_system->checkAccess(
'write', $this->ref_id)) {
384 $this->tabs_gui->addTab(
386 $this->
lng->txt(
'settings'),
387 $this->
ctrl->getLinkTarget($this,
'edit')
390 if ($this->rbac_system->checkAccess(
'edit_permission', $this->ref_id)) {
391 $this->tabs_gui->addTab(
393 $this->
lng->txt(
'default_perm_settings'),
394 $this->
ctrl->getLinkTarget($this,
'perm')
404 parent::addAdminLocatorItems(
true);
406 $query = $this->
http->wrapper()->query();
408 if ($query->has(
'ref_id')) {
409 $ref_id = $query->retrieve(
'ref_id', $this->
refinery->kindlyTo()->int());
414 $this->
ctrl->getLinkTargetByClass(
"ilobjrolefoldergui",
"view")
418 if ($query->has(
'obj_id')) {
421 $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.
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...