5 require_once
"./Services/Object/classes/class.ilObjectGUI.php";
45 $lng->loadLanguageModule(
'rbac');
48 $this->
ilObjectGUI($a_data,$a_id,$a_call_by_reference,
false);
50 $this->ctrl->saveParameter($this,
"obj_id");
59 $next_class = $this->ctrl->getNextClass($this);
60 $cmd = $this->ctrl->getCmd();
85 include_once
'./Services/Form/classes/class.ilPropertyFormGUI.php';
88 if($this->creation_mode)
90 $this->ctrl->setParameter($this,
"new_type",
'rolt');
93 $form->setFormAction($this->ctrl->getFormAction($this));
95 if($a_mode == self::FORM_MODE_CREATE)
97 $form->setTitle($this->lng->txt(
'rolt_new'));
98 $form->addCommandButton(
'save', $this->lng->txt(
'rolt_new'));
102 $form->setTitle($this->lng->txt(
'rolt_edit'));
103 $form->addCommandButton(
'update', $this->lng->txt(
'save'));
106 $form->addCommandButton(
'cancel', $this->lng->txt(
'cancel'));
109 if($a_mode != self::FORM_MODE_CREATE)
111 if($this->object->isInternalTemplate())
115 $title->setValue($this->object->getTitle());
118 $title->setMaxLength(70);
119 $title->setRequired(
true);
120 $form->addItem($title);
124 if($a_mode != self::FORM_MODE_CREATE)
126 $desc->
setValue($this->object->getDescription());
130 $form->addItem($desc);
132 if($a_mode != self::FORM_MODE_CREATE)
136 $form->addItem($ilias_id);
139 $pro =
new ilCheckboxInputGUI($this->lng->txt(
'role_protect_permissions'),
'protected');
142 $this->object->getId()
145 $form->addItem($pro);
160 if (!$rbacsystem->checkAccess(
"create_rolt", $this->rolf_ref_id))
162 $this->ilias->raiseError($this->lng->txt(
"permission_denied"),$this->ilias->error_obj->MESSAGE);
168 $this->tpl->setContent($form->getHTML());
179 if (!$rbacsystem->checkAccess(
"write", $this->rolf_ref_id))
181 $this->ilias->raiseError($this->lng->txt(
"msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
188 $GLOBALS[
'tpl']->setContent($form->getHTML());
198 global $rbacsystem, $rbacadmin, $rbacreview;
201 if (!$rbacsystem->checkAccess(
"write", $this->rolf_ref_id))
203 $this->ilias->raiseError($this->lng->txt(
"msg_no_perm_modify_rolt"),$this->ilias->error_obj->WARNING);
207 if($form->checkInput())
209 $this->
object->setTitle($form->getInput(
'title'));
210 $this->
object->setDescription($form->getInput(
'desc'));
211 $rbacadmin->setProtected(
213 $this->object->getId(),
214 $form->getInput(
'protected') ?
'y' :
'n'
216 $this->
object->update();
218 $this->ctrl->returnToParent($this);
221 $form->setValuesByPost();
234 global $rbacsystem,$rbacadmin, $rbacreview;
236 if (!$rbacsystem->checkAccess(
"create_rolt",$this->rolf_ref_id))
238 $this->ilias->raiseError($this->lng->txt(
"msg_no_perm_create_rolt"),$this->ilias->error_obj->WARNING);
241 if($form->checkInput())
243 include_once(
"./Services/AccessControl/classes/class.ilObjRoleTemplate.php");
245 $roltObj->setTitle($form->getInput(
'title'));
246 $roltObj->setDescription($form->getInput(
'desc'));
249 $rbacadmin->setProtected(
252 $form->getInput(
'protected') ?
'y' :
'n'
257 $this->ctrl->setParameter($this,
'obj_id',$roltObj->getId());
258 $this->ctrl->redirect($this,
'perm');
260 $form->setValuesByPost();
273 if (!$rbacsystem->checkAccess(
'write',$this->rolf_ref_id))
275 $this->ilias->raiseError($this->lng->txt(
"msg_no_perm_perm"),$this->ilias->error_obj->WARNING);
279 $to_filter = $objDefinition->getSubobjectsToFilter();
281 $tpl_filter = array();
282 $internal_tpl =
false;
284 if (($internal_tpl = $this->object->isInternalTemplate()))
286 $tpl_filter = $this->
object->getFilterOfInternalTemplate();
292 $op_order[$op[
"ops_id"]] = $op[
"order"];
295 $operation_info = $rbacreview->getOperationAssignment();
297 foreach($operation_info as $info)
299 if($objDefinition->getDevMode($info[
'type']))
304 if(in_array($info[
'type'],$to_filter))
308 if ($internal_tpl and $tpl_filter and !in_array($info[
'type'],$tpl_filter))
312 $rbac_objects[$info[
'typ_id']] = array(
"obj_id" => $info[
'typ_id'],
313 "type" => $info[
'type']);
315 $txt = $objDefinition->isPlugin($info[
'type'])
317 : $this->lng->txt($info[
'type'].
"_".$info[
'operation']);
318 if (substr($info[
'operation'], 0, 7) ==
"create_" &&
319 $objDefinition->isPlugin(substr($info[
'operation'], 7)))
323 elseif(substr($info[
'operation'],0,6) ==
'create')
325 $txt = $this->lng->txt(
'rbac_'.$info[
'operation']);
328 $order = $op_order[$info[
'ops_id']];
329 if(substr($info[
'operation'],0,6) ==
'create')
331 $order = $objDefinition->getPositionByType($info[
'type']);
334 $rbac_operations[$info[
'typ_id']][$info[
'ops_id']] = array(
335 "ops_id" => $info[
'ops_id'],
336 "title" => $info[
'operation'],
341 foreach ($rbac_objects as $key => $obj_data)
343 if ($objDefinition->isPlugin($obj_data[
"type"]))
346 "obj_".$obj_data[
"type"]);
350 $rbac_objects[$key][
"name"] = $this->lng->txt(
"obj_".$obj_data[
"type"]);
353 $rbac_objects[$key][
"ops"] = $rbac_operations[$key];
358 foreach ($rbac_objects as $key => $obj_data)
360 sort($rbac_objects[$key][
"ops"]);
367 foreach ($rbac_objects as $key => $obj_data)
369 $arr_selected = $rbacreview->getOperationsOfRole($this->object->getId(), $obj_data[
"type"],
$this->rolf_ref_id);
370 $arr_checked = array_intersect($arr_selected,array_keys($rbac_operations[$obj_data[
"obj_id"]]));
372 foreach ($rbac_operations[$obj_data[
"obj_id"]] as $operation)
374 $checked = in_array($operation[
"ops_id"],$arr_checked);
378 $box = ilUtil::formCheckBox($checked,
"template_perm[".$obj_data[
"type"].
"][]",$operation[
"ops_id"],$disabled);
379 $output[
"perm"][$obj_data[
"obj_id"]][$operation[
"ops_id"]] = $box;
384 $output[
"col_anz"] = count($rbac_objects);
385 $output[
"txt_save"] = $this->lng->txt(
"save");
386 $output[
"check_protected"] = ilUtil::formCheckBox($rbacreview->isProtected($this->rolf_ref_id,$this->object->getId()),
"protected",1);
387 $output[
"text_protected"] = $this->lng->txt(
"role_protect_permissions");
393 $output[
"message_middle"] = $this->lng->txt(
"adopt_perm_from_template");
396 if ($this->object->getId() == SYSTEM_ROLE_ID)
398 $output[
"adopt"] = array();
404 $parent_role_ids = $rbacreview->getParentRoleIds($this->rolf_ref_id,
true);
407 ksort($parent_role_ids);
409 foreach ($parent_role_ids as $key => $par)
411 if ($par[
"obj_id"] != SYSTEM_ROLE_ID)
415 $output[
"adopt"][$key][
"check_adopt"] = $radio;
416 $output[
"adopt"][$key][
"type"] = ($par[
"type"] ==
'role' ?
'Role' :
'Template');
417 $output[
"adopt"][$key][
"role_name"] = $par[
"title"];
421 $output[
"formaction_adopt"] = $this->ctrl->getFormAction($this);
425 $output[
"formaction"] =
426 $this->ctrl->getFormAction($this);
428 $this->data = $output;
435 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.adm_perm_role.html",
436 "Services/AccessControl");
438 foreach ($rbac_objects as $obj_data)
441 $this->tpl->setCurrentBlock(
"object_operations");
445 foreach ($obj_data[
"ops"] as $operation)
447 $ops_ids[] = $operation[
"ops_id"];
450 $this->tpl->setVariable(
"CSS_ROW",$css_row);
451 $this->tpl->setVariable(
"PERMISSION",$operation[
"name"]);
452 $this->tpl->setVariable(
"CHECK_PERMISSION",$this->data[
"perm"][$obj_data[
"obj_id"]][$operation[
"ops_id"]]);
453 $this->tpl->parseCurrentBlock();
457 $this->tpl->setCurrentBlock(
"object_type");
458 $this->tpl->setVariable(
"TXT_OBJ_TYPE",$obj_data[
"name"]);
461 if ($this->objDefinition->getDevMode($obj_data[
"type"]))
463 $this->tpl->setVariable(
"TXT_NOT_IMPL",
"(".$this->lng->txt(
"not_implemented_yet").
")");
465 else if ($obj_data[
"type"] ==
"icrs" and !$this->ilias->getSetting(
"ilinc_active"))
467 $this->tpl->setVariable(
"TXT_NOT_IMPL",
"(".$this->lng->txt(
"not_enabled_or_configured").
")");
471 $this->tpl->setVariable(
"JS_VARNAME",
"template_perm_".$obj_data[
"type"]);
473 $this->tpl->setVariable(
"TXT_CHECKALL", $this->lng->txt(
"check_all"));
474 $this->tpl->setVariable(
"TXT_UNCHECKALL", $this->lng->txt(
"uncheck_all"));
477 $this->tpl->parseCurrentBlock();
501 $this->tpl->setCurrentBlock(
"tblfooter_protected");
502 $this->tpl->setVariable(
"COL_ANZ",3);
503 $this->tpl->setVariable(
"CHECK_BOTTOM",$this->data[
"check_protected"]);
504 $this->tpl->setVariable(
"MESSAGE_TABLE",$this->data[
"text_protected"]);
505 $this->tpl->parseCurrentBlock();
507 $this->tpl->setVariable(
"COL_ANZ_PLUS",4);
508 $this->tpl->setVariable(
"TXT_SAVE",$this->data[
"txt_save"]);
509 $this->tpl->setCurrentBlock(
"adm_content");
510 $this->tpl->setVariable(
"TBL_TITLE_IMG",
ilUtil::getImagePath(
"icon_".$this->object->getType().
".svg"));
511 $this->tpl->setVariable(
"TBL_TITLE_IMG_ALT",$this->lng->txt($this->object->getType()));
514 if (substr($this->object->getTitle(),0,3) ==
"il_")
516 $desc = $this->lng->txt(
"predefined_template");
519 $description =
"<br/> <span class=\"small\">".$desc.
"</span>";
522 if (substr($this->object->getTitle(),0,3) ==
"il_")
524 include_once(
'./Services/AccessControl/classes/class.ilObjRole.php');
530 $title = $this->
object->getTitle();
533 $this->tpl->setVariable(
"TBL_TITLE",$title.$description);
535 $this->tpl->setVariable(
"TXT_PERMISSION",$this->data[
"txt_permission"]);
536 $this->tpl->setVariable(
"FORMACTION",$this->data[
"formaction"]);
537 $this->tpl->parseCurrentBlock();
550 if (!$rbacsystem->checkAccess(
'write',$this->rolf_ref_id))
552 $this->ilias->raiseError($this->lng->txt(
"msg_no_perm_perm"),$this->ilias->error_obj->WARNING);
559 foreach (
$_POST[
"template_perm"] as $key => $ops_array)
562 $rbacadmin->setRolePermission($this->object->getId(), $key,$ops_array,
$this->rolf_ref_id);
567 $this->
object->update();
571 #$rbacadmin->setProtected($this->rolf_ref_id,$this->object->getId(),ilUtil::tf2yn($_POST['protected']));
575 $this->ctrl->redirect($this,
"perm");
585 global $rbacadmin, $rbacsystem, $rbacreview;
587 if (!$rbacsystem->checkAccess(
'write',$this->rolf_ref_id))
589 $this->ilias->raiseError($this->lng->txt(
"msg_no_perm_perm"),$this->ilias->error_obj->WARNING);
591 elseif ($this->obj_id ==
$_POST[
"adopt"])
597 $rbacadmin->deleteRolePermission($this->obj_id, $this->rolf_ref_id);
598 $parentRoles = $rbacreview->getParentRoleIds($this->rolf_ref_id,
true);
599 $rbacadmin->copyRoleTemplatePermissions(
$_POST[
"adopt"],$parentRoles[
$_POST[
"adopt"]][
"parent"],
600 $this->rolf_ref_id,$this->obj_id);
602 $this->
object->update();
605 $obj_data =& $this->ilias->obj_factory->getInstanceByObjId($_POST[
"adopt"]);
606 ilUtil::sendSuccess($this->lng->txt(
"msg_perm_adopted_from1").
" '".$obj_data->getTitle().
"'.<br/>".$this->lng->txt(
"msg_perm_adopted_from2"),
true);
609 $this->ctrl->redirect($this,
"perm");
622 global $rbacsystem,$rbacreview;
624 if ($rbacsystem->checkAccess(
'write',$this->rolf_ref_id))
626 $tabs_gui->addTarget(
"settings",
627 $this->ctrl->getLinkTarget($this,
"edit"),
628 array(
"edit",
"update"), get_class($this));
630 $tabs_gui->addTarget(
"default_perm_settings",
631 $this->ctrl->getLinkTarget($this,
"perm"),
632 array(
"perm"), get_class($this));
643 $this->ctrl->redirectByClass(
"ilobjrolefoldergui",
"view");
661 $this->ctrl->getLinkTargetByClass(
"ilobjrolefoldergui",
"view"));