24 require_once
"./classes/class.ilObjectGUI.php";
60 $lng->loadLanguageModule(
'rbac');
63 $this->
ilObjectGUI($a_data,$a_id,$a_call_by_reference,
false);
65 $this->ctrl->saveParameter($this,
"obj_id");
72 if($this->ctrl->getTargetScript() ==
'role.php')
74 $this->__prepareOutput();
81 $next_class = $this->ctrl->getNextClass($this);
82 $cmd = $this->ctrl->getCmd();
110 if (!$rbacsystem->checkAccess(
"create_rolt", $this->rolf_ref_id))
112 $this->ilias->raiseError($this->lng->txt(
"permission_denied"),$this->ilias->error_obj->MESSAGE);
118 $data[
"fields"] = array();
124 foreach (
$data[
"fields"] as $key => $val)
126 $this->tpl->setVariable(
"TXT_".strtoupper($key), $this->lng->txt($key));
127 $this->tpl->setVariable(strtoupper($key), $val);
129 if ($this->prepare_output)
131 $this->tpl->parseCurrentBlock();
135 $this->tpl->setCurrentBlock(
"protect_permissions");
136 $protect_permissions =
$_SESSION[
"error_post_vars"][
"Fobject"][
"protect_permissions"] ?
"checked=\"checked\"" :
"";
137 $this->tpl->setVariable(
"TXT_PROTECT_PERMISSIONS",$this->lng->txt(
"role_protect_permissions"));
138 $this->tpl->setVariable(
"PROTECT_PERMISSIONS",$protect_permissions);
139 $this->tpl->parseCurrentBlock();
141 $this->ctrl->setParameter($this,
"new_type", $this->type);
142 $this->tpl->setVariable(
"FORMACTION",
143 $this->ctrl->getFormAction($this));
144 $this->tpl->setVariable(
"TXT_HEADER", $this->lng->txt($this->type.
"_new"));
145 $this->tpl->setVariable(
"TXT_CANCEL", $this->lng->txt(
"cancel"));
146 $this->tpl->setVariable(
"TXT_SUBMIT", $this->lng->txt($this->type.
"_add"));
147 $this->tpl->setVariable(
"CMD_SUBMIT",
"save");
149 $this->tpl->setVariable(
"TXT_REQUIRED_FLD", $this->lng->txt(
"required_field"));
161 global $rbacsystem,$rbacadmin, $rbacreview;
165 if (!$rbacsystem->checkAccess(
"create_rolt",$this->rolf_ref_id))
167 $this->ilias->raiseError($this->lng->txt(
"msg_no_perm_create_rolt"),$this->ilias->error_obj->WARNING);
171 if (empty($_POST[
"Fobject"][
"title"]))
173 $this->ilias->raiseError($this->lng->txt(
"fill_out_all_required_fields"),$this->ilias->error_obj->MESSAGE);
177 if (substr($_POST[
"Fobject"][
"title"],0,3) ==
"il_")
179 $this->ilias->raiseError($this->lng->txt(
"msg_role_reserved_prefix"),$this->ilias->error_obj->MESSAGE);
183 include_once(
"./Services/AccessControl/classes/class.ilObjRoleTemplate.php");
189 $rbacadmin->setProtected($this->rolf_ref_id,$roltObj->getId(),
ilUtil::tf2yn($_POST[
"Fobject"][
"protect_permissions"]));
192 $this->ctrl->returnToParent($this);
204 if (!$rbacsystem->checkAccess(
'write',$this->rolf_ref_id))
206 $this->ilias->raiseError($this->lng->txt(
"msg_no_perm_perm"),$this->ilias->error_obj->WARNING);
210 $to_filter = $objDefinition->getSubobjectsToFilter();
212 $tpl_filter = array();
213 $internal_tpl =
false;
215 if (($internal_tpl = $this->object->isInternalTemplate()))
217 $tpl_filter = $this->
object->getFilterOfInternalTemplate();
221 $q =
"SELECT ta.typ_id,obj.title,ops.ops_id,ops.operation FROM rbac_ta AS ta ".
222 "JOIN object_data AS obj ON obj.obj_id=ta.typ_id ".
223 "JOIN rbac_operations AS ops ON ops.ops_id=ta.ops_id";
225 $r = $this->ilias->db->query($q);
229 if($objDefinition->getDevMode($row->title))
234 if(in_array($row->title,$to_filter))
239 if ($internal_tpl and !in_array($row->title,$tpl_filter))
244 $rbac_objects[$row->typ_id] = array(
"obj_id" => $row->typ_id,
245 "type" => $row->title
248 $rbac_operations[$row->typ_id][$row->ops_id] = array(
249 "ops_id" => $row->ops_id,
250 "title" => $row->operation,
251 "name" => $this->lng->txt($row->title.
"_".$row->operation)
255 foreach ($rbac_objects as $key => $obj_data)
257 $rbac_objects[$key][
"name"] = $this->lng->txt(
"obj_".$obj_data[
"type"]);
258 $rbac_objects[$key][
"ops"] = $rbac_operations[$key];
263 foreach ($rbac_objects as $key => $obj_data)
265 sort($rbac_objects[$key][
"ops"]);
272 foreach ($rbac_objects as $key => $obj_data)
274 $arr_selected = $rbacreview->getOperationsOfRole($this->object->getId(), $obj_data[
"type"],
$this->rolf_ref_id);
275 $arr_checked = array_intersect($arr_selected,array_keys($rbac_operations[$obj_data[
"obj_id"]]));
277 foreach ($rbac_operations[$obj_data[
"obj_id"]] as $operation)
279 $checked = in_array($operation[
"ops_id"],$arr_checked);
283 $box = ilUtil::formCheckBox($checked,
"template_perm[".$obj_data[
"type"].
"][]",$operation[
"ops_id"],$disabled);
284 $output[
"perm"][$obj_data[
"obj_id"]][$operation[
"ops_id"]] = $box;
289 $output[
"col_anz"] = count($rbac_objects);
290 $output[
"txt_save"] = $this->lng->txt(
"save");
291 $output[
"check_protected"] = ilUtil::formCheckBox($rbacreview->isProtected($this->rolf_ref_id,$this->object->getId()),
"protected",1);
292 $output[
"text_protected"] = $this->lng->txt(
"role_protect_permissions");
298 $output[
"message_middle"] = $this->lng->txt(
"adopt_perm_from_template");
301 if ($this->object->getId() == SYSTEM_ROLE_ID)
303 $output[
"adopt"] = array();
309 $parent_role_ids = $rbacreview->getParentRoleIds($this->rolf_ref_id,
true);
312 ksort($parent_role_ids);
314 foreach ($parent_role_ids as $key => $par)
316 if ($par[
"obj_id"] != SYSTEM_ROLE_ID)
320 $output[
"adopt"][$key][
"check_adopt"] = $radio;
321 $output[
"adopt"][$key][
"type"] = ($par[
"type"] ==
'role' ?
'Role' :
'Template');
322 $output[
"adopt"][$key][
"role_name"] = $par[
"title"];
326 $output[
"formaction_adopt"] = $this->ctrl->getFormAction($this);
330 $output[
"formaction"] =
331 $this->ctrl->getFormAction($this);
333 $this->data = $output;
340 $this->tpl->addBlockFile(
"CONTENT",
"content",
"tpl.adm_content.html");
341 $this->tpl->addBlockFile(
"LOCATOR",
"locator",
"tpl.locator.html");
342 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.adm_perm_role.html");
344 foreach ($rbac_objects as $obj_data)
347 $this->tpl->setCurrentBlock(
"object_operations");
349 foreach ($obj_data[
"ops"] as $operation)
351 $ops_ids[] = $operation[
"ops_id"];
354 $this->tpl->setVariable(
"CSS_ROW",$css_row);
355 $this->tpl->setVariable(
"PERMISSION",$operation[
"name"]);
356 $this->tpl->setVariable(
"CHECK_PERMISSION",$this->data[
"perm"][$obj_data[
"obj_id"]][$operation[
"ops_id"]]);
357 $this->tpl->parseCurrentBlock();
361 $this->tpl->setCurrentBlock(
"object_type");
362 $this->tpl->setVariable(
"TXT_OBJ_TYPE",$obj_data[
"name"]);
365 if ($this->objDefinition->getDevMode($obj_data[
"type"]))
367 $this->tpl->setVariable(
"TXT_NOT_IMPL",
"(".$this->lng->txt(
"not_implemented_yet").
")");
369 else if ($obj_data[
"type"] ==
"icrs" and !$this->ilias->getSetting(
"ilinc_active"))
371 $this->tpl->setVariable(
"TXT_NOT_IMPL",
"(".$this->lng->txt(
"not_enabled_or_configured").
")");
375 $this->tpl->setVariable(
"JS_VARNAME",
"template_perm_".$obj_data[
"type"]);
377 $this->tpl->setVariable(
"TXT_CHECKALL", $this->lng->txt(
"check_all"));
378 $this->tpl->setVariable(
"TXT_UNCHECKALL", $this->lng->txt(
"uncheck_all"));
381 $this->tpl->parseCurrentBlock();
386 foreach ($this->data[
"adopt"] as $key => $value)
388 $this->tpl->setCurrentBlock(
"ADOPT_PERM_ROW");
389 $this->tpl->setVariable(
"CSS_ROW_ADOPT",$value[
"css_row_adopt"]);
390 $this->tpl->setVariable(
"CHECK_ADOPT",$value[
"check_adopt"]);
391 $this->tpl->setVariable(
"TYPE",$value[
"type"]);
392 $this->tpl->setVariable(
"ROLE_NAME",$value[
"role_name"]);
393 $this->tpl->parseCurrentBlock();
396 $this->tpl->setCurrentBlock(
"ADOPT_PERM_FORM");
397 $this->tpl->setVariable(
"MESSAGE_MIDDLE",$this->data[
"message_middle"]);
398 $this->tpl->setVariable(
"FORMACTION_ADOPT",$this->data[
"formaction_adopt"]);
399 $this->tpl->setVariable(
"ADOPT",$this->lng->txt(
'copy'));
400 $this->tpl->parseCurrentBlock();
403 $this->tpl->setCurrentBlock(
"tblfooter_protected");
404 $this->tpl->setVariable(
"COL_ANZ",3);
405 $this->tpl->setVariable(
"CHECK_BOTTOM",$this->data[
"check_protected"]);
406 $this->tpl->setVariable(
"MESSAGE_TABLE",$this->data[
"text_protected"]);
407 $this->tpl->parseCurrentBlock();
409 $this->tpl->setCurrentBlock(
"tblfooter_standard");
410 $this->tpl->setVariable(
"COL_ANZ_PLUS",4);
411 $this->tpl->setVariable(
"TXT_SAVE",$this->data[
"txt_save"]);
412 $this->tpl->parseCurrentBlock();
415 $this->tpl->setCurrentBlock(
"adm_content");
416 $this->tpl->setVariable(
"TBL_TITLE_IMG",
ilUtil::getImagePath(
"icon_".$this->object->getType().
".gif"));
417 $this->tpl->setVariable(
"TBL_TITLE_IMG_ALT",$this->lng->txt($this->object->getType()));
419 $this->tpl->setVariable(
"TBL_HELP_LINK",
"tbl_help.php");
420 $this->tpl->setVariable(
"TBL_HELP_IMG_ALT",$this->lng->txt(
"help"));
423 if (substr($this->object->getTitle(),0,3) ==
"il_")
425 $desc = $this->lng->txt(
"predefined_template");
428 $description =
"<br/> <span class=\"small\">".$desc.
"</span>";
431 if (substr($this->object->getTitle(),0,3) ==
"il_")
433 include_once(
'./Services/AccessControl/classes/class.ilObjRole.php');
439 $title = $this->
object->getTitle();
442 $this->tpl->setVariable(
"TBL_TITLE",
$title.$description);
444 $this->tpl->setVariable(
"TXT_PERMISSION",$this->data[
"txt_permission"]);
445 $this->tpl->setVariable(
"FORMACTION",$this->data[
"formaction"]);
446 $this->tpl->parseCurrentBlock();
459 if (!$rbacsystem->checkAccess(
'write',$this->rolf_ref_id))
461 $this->ilias->raiseError($this->lng->txt(
"msg_no_perm_perm"),$this->ilias->error_obj->WARNING);
468 foreach ($_POST[
"template_perm"] as $key => $ops_array)
471 $rbacadmin->setRolePermission($this->object->getId(), $key,$ops_array,
$this->rolf_ref_id);
476 $this->
object->update();
479 $rbacadmin->setProtected($this->rolf_ref_id,$this->object->getId(),
ilUtil::tf2yn($_POST[
'protected']));
483 $this->ctrl->redirect($this,
"perm");
493 global $rbacadmin, $rbacsystem, $rbacreview;
495 if (!$rbacsystem->checkAccess(
'write',$this->rolf_ref_id))
497 $this->ilias->raiseError($this->lng->txt(
"msg_no_perm_perm"),$this->ilias->error_obj->WARNING);
499 elseif ($this->obj_id == $_POST[
"adopt"])
505 $rbacadmin->deleteRolePermission($this->obj_id, $this->rolf_ref_id);
506 $parentRoles = $rbacreview->getParentRoleIds($this->rolf_ref_id,
true);
507 $rbacadmin->copyRoleTemplatePermissions($_POST[
"adopt"],$parentRoles[$_POST[
"adopt"]][
"parent"],
508 $this->rolf_ref_id,$this->obj_id);
510 $this->
object->update();
513 $obj_data =& $this->ilias->obj_factory->getInstanceByObjId($_POST[
"adopt"]);
514 ilUtil::sendInfo($this->lng->txt(
"msg_perm_adopted_from1").
" '".$obj_data->getTitle().
"'.<br/>".$this->lng->txt(
"msg_perm_adopted_from2"),
true);
517 $this->ctrl->redirect($this,
"perm");
527 global $rbacsystem, $rbacreview;
529 if (!$rbacsystem->checkAccess(
"write", $this->rolf_ref_id))
531 $this->ilias->raiseError($this->lng->txt(
"msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
539 if (substr($this->object->getTitle(),0,3) !=
"il_")
545 $protect_permissions = (
$_SESSION[
"error_post_vars"][
"Fobject"][
"protect_permissions"]) ?
"checked=\"checked\"" :
"";
549 if (substr($this->object->getTitle(),0,3) !=
"il_")
555 $protect_permissions = $rbacreview->isProtected($this->rolf_ref_id,$this->object->getId()) ?
"checked=\"checked\"" :
"";
558 $obj_str =
"&obj_id=".$this->obj_id;
560 $this->tpl->setVariable(
"TXT_TITLE",$this->lng->txt(
"title"));
561 $this->tpl->setVariable(
"TXT_DESC",$this->lng->txt(
"desc"));
563 $this->tpl->setCurrentBlock(
"protect_permissions");
564 $this->tpl->setVariable(
"TXT_PROTECT_PERMISSIONS",$this->lng->txt(
'role_protect_permissions'));
565 $this->tpl->setVariable(
"PROTECT_PERMISSIONS",$protect_permissions);
566 $this->tpl->parseCurrentBlock();
568 $this->tpl->setVariable(
"FORMACTION",
569 $this->ctrl->getFormAction($this));
570 $this->tpl->setVariable(
"TXT_HEADER", $this->lng->txt($this->object->getType().
"_edit"));
571 $this->tpl->setVariable(
"TARGET", $this->
getTargetFrame(
"update"));
572 $this->tpl->setVariable(
"TXT_CANCEL", $this->lng->txt(
"cancel"));
573 $this->tpl->setVariable(
"TXT_SUBMIT", $this->lng->txt(
"save"));
574 $this->tpl->setVariable(
"CMD_SUBMIT",
"update");
575 $this->tpl->setVariable(
"TXT_REQUIRED_FLD", $this->lng->txt(
"required_field"));
577 if (substr($this->object->getTitle(),0,3) ==
"il_")
579 $this->tpl->setVariable(
"SHOW_TITLE",$this->object->getTitle());
593 global $rbacsystem,$rbacreview;
595 if ($rbacsystem->checkAccess(
'write',$this->rolf_ref_id))
597 $tabs_gui->addTarget(
"edit_properties",
598 $this->ctrl->getLinkTarget($this,
"edit"),
599 array(
"edit",
"update"), get_class($this));
601 $tabs_gui->addTarget(
"default_perm_settings",
602 $this->ctrl->getLinkTarget($this,
"perm"),
603 array(
"perm"), get_class($this));
616 $this->ctrl->redirectByClass(
"ilobjrolefoldergui",
"view");
628 global $rbacsystem, $rbacadmin, $rbacreview;
631 if (!$rbacsystem->checkAccess(
"write", $this->rolf_ref_id))
633 $this->ilias->raiseError($this->lng->txt(
"msg_no_perm_modify_rolt"),$this->ilias->error_obj->WARNING);
636 if (substr($this->object->getTitle(),0,3) !=
"il_")
639 if (empty($_POST[
"Fobject"][
"title"]))
641 $this->ilias->raiseError($this->lng->txt(
"fill_out_all_required_fields"),$this->ilias->error_obj->MESSAGE);
645 if (substr($_POST[
"Fobject"][
"title"],0,3) ==
"il_")
647 $this->ilias->raiseError($this->lng->txt(
"msg_role_reserved_prefix"),$this->ilias->error_obj->MESSAGE);
655 $rbacadmin->setProtected($this->rolf_ref_id,$this->object->getId(),
ilUtil::tf2yn($_POST[
"Fobject"][
"protect_permissions"]));
656 $this->
object->update();
660 $this->ctrl->returnToParent($this);
671 if (
$_GET[
"admin_mode"] ==
"settings")
673 $ilLocator->addItem($this->lng->txt(
"administration"),
674 $this->ctrl->getLinkTargetByClass(
"iladministrationgui",
"frameset"),
679 $this->ctrl->getLinkTargetByClass(
"ilobjrolefoldergui",
"view"));
681 $ilLocator->addItem($this->object->getTitle(),
682 $this->ctrl->getLinkTarget($this,
"perm"));
695 if (strtolower(
$_GET[
"baseClass"]) ==
"iladministrationgui")
698 $this->ctrl->getLinkTargetByClass(
"ilobjrolefoldergui",
"view"));
702 if ($this->object->getRefId() != ROOT_FOLDER_ID &&
703 $this->
object->getRefId() != SYSTEM_FOLDER_ID)
705 $par_id = $tree->getParentId($this->object->getRefId());
706 $tpl->setUpperIcon(
"repository.php?ref_id=".$par_id);