5 require_once
"./classes/class.ilObjectGUI.php";
41 $lng->loadLanguageModule(
'rbac');
44 $this->
ilObjectGUI($a_data,$a_id,$a_call_by_reference,
false);
46 $this->ctrl->saveParameter($this,
"obj_id");
53 if($this->ctrl->getTargetScript() ==
'role.php')
55 $this->__prepareOutput();
62 $next_class = $this->ctrl->getNextClass($this);
63 $cmd = $this->ctrl->getCmd();
91 if (!$rbacsystem->checkAccess(
"create_rolt", $this->rolf_ref_id))
93 $this->ilias->raiseError($this->lng->txt(
"permission_denied"),$this->ilias->error_obj->MESSAGE);
99 $data[
"fields"] = array();
105 foreach (
$data[
"fields"] as
$key => $val)
107 $this->tpl->setVariable(
"TXT_".strtoupper(
$key), $this->lng->txt(
$key));
108 $this->tpl->setVariable(strtoupper(
$key), $val);
110 if ($this->prepare_output)
112 $this->tpl->parseCurrentBlock();
116 $this->tpl->setCurrentBlock(
"protect_permissions");
117 $protect_permissions =
$_SESSION[
"error_post_vars"][
"Fobject"][
"protect_permissions"] ?
"checked=\"checked\"" :
"";
118 $this->tpl->setVariable(
"TXT_PROTECT_PERMISSIONS",$this->lng->txt(
"role_protect_permissions"));
119 $this->tpl->setVariable(
"PROTECT_PERMISSIONS",$protect_permissions);
120 $this->tpl->parseCurrentBlock();
122 $this->ctrl->setParameter($this,
"new_type", $this->type);
123 $this->tpl->setVariable(
"FORMACTION",
124 $this->ctrl->getFormAction($this));
125 $this->tpl->setVariable(
"TXT_HEADER", $this->lng->txt($this->type.
"_new"));
126 $this->tpl->setVariable(
"TXT_CANCEL", $this->lng->txt(
"cancel"));
127 $this->tpl->setVariable(
"TXT_SUBMIT", $this->lng->txt($this->type.
"_add"));
128 $this->tpl->setVariable(
"CMD_SUBMIT",
"save");
130 $this->tpl->setVariable(
"TXT_REQUIRED_FLD", $this->lng->txt(
"required_field"));
142 global $rbacsystem,$rbacadmin, $rbacreview;
146 if (!$rbacsystem->checkAccess(
"create_rolt",$this->rolf_ref_id))
148 $this->ilias->raiseError($this->lng->txt(
"msg_no_perm_create_rolt"),$this->ilias->error_obj->WARNING);
152 if (empty(
$_POST[
"Fobject"][
"title"]))
154 $this->ilias->raiseError($this->lng->txt(
"fill_out_all_required_fields"),$this->ilias->error_obj->MESSAGE);
158 if (substr(
$_POST[
"Fobject"][
"title"],0,3) ==
"il_")
160 $this->ilias->raiseError($this->lng->txt(
"msg_role_reserved_prefix"),$this->ilias->error_obj->MESSAGE);
164 include_once(
"./Services/AccessControl/classes/class.ilObjRoleTemplate.php");
170 $rbacadmin->setProtected($this->rolf_ref_id,$roltObj->getId(),
ilUtil::tf2yn(
$_POST[
"Fobject"][
"protect_permissions"]));
173 $this->ctrl->returnToParent($this);
185 if (!$rbacsystem->checkAccess(
'write',$this->rolf_ref_id))
187 $this->ilias->raiseError($this->lng->txt(
"msg_no_perm_perm"),$this->ilias->error_obj->WARNING);
191 $to_filter = $objDefinition->getSubobjectsToFilter();
193 $tpl_filter = array();
194 $internal_tpl =
false;
196 if (($internal_tpl = $this->object->isInternalTemplate()))
198 $tpl_filter = $this->
object->getFilterOfInternalTemplate();
201 $operation_info = $rbacreview->getOperationAssignment();
203 foreach($operation_info as $info)
205 if($objDefinition->getDevMode($info[
'type']))
210 if(in_array($info[
'type'],$to_filter))
214 if ($internal_tpl and !in_array($info[
'type'],$tpl_filter))
218 $rbac_objects[$info[
'typ_id']] = array(
"obj_id" => $info[
'typ_id'],
219 "type" => $info[
'type']);
221 $txt = $objDefinition->isPlugin($info[
'type'])
223 : $this->lng->txt($info[
'type'].
"_".$info[
'operation']);
224 if (substr($info[
'operation'], 0, 7) ==
"create_" &&
225 $objDefinition->isPlugin(substr($info[
'operation'], 7)))
227 $txt =
ilPlugin::lookupTxt(
"rep_robj", substr($info[
'operation'], 7), $info[
'type'].
"_".$info[
'operation']);
230 $rbac_operations[$info[
'typ_id']][$info[
'ops_id']] = array(
231 "ops_id" => $info[
'ops_id'],
232 "title" => $info[
'operation'],
237 foreach ($rbac_objects as
$key => $obj_data)
239 if ($objDefinition->isPlugin($obj_data[
"type"]))
242 "obj_".$obj_data[
"type"]);
246 $rbac_objects[
$key][
"name"] = $this->lng->txt(
"obj_".$obj_data[
"type"]);
249 $rbac_objects[
$key][
"ops"] = $rbac_operations[
$key];
254 foreach ($rbac_objects as
$key => $obj_data)
256 sort($rbac_objects[
$key][
"ops"]);
263 foreach ($rbac_objects as
$key => $obj_data)
265 $arr_selected = $rbacreview->getOperationsOfRole($this->object->getId(), $obj_data[
"type"],
$this->rolf_ref_id);
266 $arr_checked = array_intersect($arr_selected,array_keys($rbac_operations[$obj_data[
"obj_id"]]));
268 foreach ($rbac_operations[$obj_data[
"obj_id"]] as $operation)
270 $checked = in_array($operation[
"ops_id"],$arr_checked);
274 $box = ilUtil::formCheckBox($checked,
"template_perm[".$obj_data[
"type"].
"][]",$operation[
"ops_id"],$disabled);
275 $output[
"perm"][$obj_data[
"obj_id"]][$operation[
"ops_id"]] = $box;
280 $output[
"col_anz"] = count($rbac_objects);
281 $output[
"txt_save"] = $this->lng->txt(
"save");
282 $output[
"check_protected"] = ilUtil::formCheckBox($rbacreview->isProtected($this->rolf_ref_id,$this->object->getId()),
"protected",1);
283 $output[
"text_protected"] = $this->lng->txt(
"role_protect_permissions");
289 $output[
"message_middle"] = $this->lng->txt(
"adopt_perm_from_template");
292 if ($this->object->getId() == SYSTEM_ROLE_ID)
294 $output[
"adopt"] = array();
300 $parent_role_ids = $rbacreview->getParentRoleIds($this->rolf_ref_id,
true);
303 ksort($parent_role_ids);
305 foreach ($parent_role_ids as
$key => $par)
307 if ($par[
"obj_id"] != SYSTEM_ROLE_ID)
311 $output[
"adopt"][
$key][
"check_adopt"] = $radio;
312 $output[
"adopt"][
$key][
"type"] = ($par[
"type"] ==
'role' ?
'Role' :
'Template');
313 $output[
"adopt"][
$key][
"role_name"] = $par[
"title"];
317 $output[
"formaction_adopt"] = $this->ctrl->getFormAction($this);
321 $output[
"formaction"] =
322 $this->ctrl->getFormAction($this);
324 $this->data = $output;
331 $this->tpl->addBlockFile(
"CONTENT",
"content",
"tpl.adm_content.html");
332 $this->tpl->addBlockFile(
"LOCATOR",
"locator",
"tpl.locator.html",
"Services/Locator");
333 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.adm_perm_role.html");
335 foreach ($rbac_objects as $obj_data)
338 $this->tpl->setCurrentBlock(
"object_operations");
340 foreach ($obj_data[
"ops"] as $operation)
342 $ops_ids[] = $operation[
"ops_id"];
345 $this->tpl->setVariable(
"CSS_ROW",$css_row);
346 $this->tpl->setVariable(
"PERMISSION",$operation[
"name"]);
347 $this->tpl->setVariable(
"CHECK_PERMISSION",$this->data[
"perm"][$obj_data[
"obj_id"]][$operation[
"ops_id"]]);
348 $this->tpl->parseCurrentBlock();
352 $this->tpl->setCurrentBlock(
"object_type");
353 $this->tpl->setVariable(
"TXT_OBJ_TYPE",$obj_data[
"name"]);
356 if ($this->objDefinition->getDevMode($obj_data[
"type"]))
358 $this->tpl->setVariable(
"TXT_NOT_IMPL",
"(".$this->lng->txt(
"not_implemented_yet").
")");
360 else if ($obj_data[
"type"] ==
"icrs" and !$this->ilias->getSetting(
"ilinc_active"))
362 $this->tpl->setVariable(
"TXT_NOT_IMPL",
"(".$this->lng->txt(
"not_enabled_or_configured").
")");
366 $this->tpl->setVariable(
"JS_VARNAME",
"template_perm_".$obj_data[
"type"]);
368 $this->tpl->setVariable(
"TXT_CHECKALL", $this->lng->txt(
"check_all"));
369 $this->tpl->setVariable(
"TXT_UNCHECKALL", $this->lng->txt(
"uncheck_all"));
372 $this->tpl->parseCurrentBlock();
377 foreach ($this->data[
"adopt"] as
$key => $value)
379 $this->tpl->setCurrentBlock(
"ADOPT_PERM_ROW");
380 $this->tpl->setVariable(
"CSS_ROW_ADOPT",$value[
"css_row_adopt"]);
381 $this->tpl->setVariable(
"CHECK_ADOPT",$value[
"check_adopt"]);
382 $this->tpl->setVariable(
"TYPE",$value[
"type"]);
383 $this->tpl->setVariable(
"ROLE_NAME",$value[
"role_name"]);
384 $this->tpl->parseCurrentBlock();
387 $this->tpl->setCurrentBlock(
"ADOPT_PERM_FORM");
388 $this->tpl->setVariable(
"MESSAGE_MIDDLE",$this->data[
"message_middle"]);
389 $this->tpl->setVariable(
"FORMACTION_ADOPT",$this->data[
"formaction_adopt"]);
390 $this->tpl->setVariable(
"ADOPT",$this->lng->txt(
'copy'));
391 $this->tpl->parseCurrentBlock();
394 $this->tpl->setCurrentBlock(
"tblfooter_protected");
395 $this->tpl->setVariable(
"COL_ANZ",3);
396 $this->tpl->setVariable(
"CHECK_BOTTOM",$this->data[
"check_protected"]);
397 $this->tpl->setVariable(
"MESSAGE_TABLE",$this->data[
"text_protected"]);
398 $this->tpl->parseCurrentBlock();
400 $this->tpl->setCurrentBlock(
"tblfooter_standard");
401 $this->tpl->setVariable(
"COL_ANZ_PLUS",4);
402 $this->tpl->setVariable(
"TXT_SAVE",$this->data[
"txt_save"]);
403 $this->tpl->parseCurrentBlock();
406 $this->tpl->setCurrentBlock(
"adm_content");
407 $this->tpl->setVariable(
"TBL_TITLE_IMG",
ilUtil::getImagePath(
"icon_".$this->object->getType().
".gif"));
408 $this->tpl->setVariable(
"TBL_TITLE_IMG_ALT",$this->lng->txt($this->object->getType()));
410 $this->tpl->setVariable(
"TBL_HELP_LINK",
"tbl_help.php");
411 $this->tpl->setVariable(
"TBL_HELP_IMG_ALT",$this->lng->txt(
"help"));
414 if (substr($this->object->getTitle(),0,3) ==
"il_")
416 $desc = $this->lng->txt(
"predefined_template");
419 $description =
"<br/> <span class=\"small\">".$desc.
"</span>";
422 if (substr($this->object->getTitle(),0,3) ==
"il_")
424 include_once(
'./Services/AccessControl/classes/class.ilObjRole.php');
430 $title = $this->
object->getTitle();
433 $this->tpl->setVariable(
"TBL_TITLE",
$title.$description);
435 $this->tpl->setVariable(
"TXT_PERMISSION",$this->data[
"txt_permission"]);
436 $this->tpl->setVariable(
"FORMACTION",$this->data[
"formaction"]);
437 $this->tpl->parseCurrentBlock();
450 if (!$rbacsystem->checkAccess(
'write',$this->rolf_ref_id))
452 $this->ilias->raiseError($this->lng->txt(
"msg_no_perm_perm"),$this->ilias->error_obj->WARNING);
459 foreach (
$_POST[
"template_perm"] as
$key => $ops_array)
467 $this->
object->update();
470 $rbacadmin->setProtected($this->rolf_ref_id,$this->object->getId(),
ilUtil::tf2yn(
$_POST[
'protected']));
474 $this->ctrl->redirect($this,
"perm");
484 global $rbacadmin, $rbacsystem, $rbacreview;
486 if (!$rbacsystem->checkAccess(
'write',$this->rolf_ref_id))
488 $this->ilias->raiseError($this->lng->txt(
"msg_no_perm_perm"),$this->ilias->error_obj->WARNING);
496 $rbacadmin->deleteRolePermission($this->obj_id, $this->rolf_ref_id);
497 $parentRoles = $rbacreview->getParentRoleIds($this->rolf_ref_id,
true);
498 $rbacadmin->copyRoleTemplatePermissions(
$_POST[
"adopt"],$parentRoles[
$_POST[
"adopt"]][
"parent"],
499 $this->rolf_ref_id,$this->obj_id);
501 $this->
object->update();
504 $obj_data =& $this->ilias->obj_factory->getInstanceByObjId($_POST[
"adopt"]);
505 ilUtil::sendSuccess($this->lng->txt(
"msg_perm_adopted_from1").
" '".$obj_data->getTitle().
"'.<br/>".$this->lng->txt(
"msg_perm_adopted_from2"),
true);
508 $this->ctrl->redirect($this,
"perm");
518 global $rbacsystem, $rbacreview;
520 if (!$rbacsystem->checkAccess(
"write", $this->rolf_ref_id))
522 $this->ilias->raiseError($this->lng->txt(
"msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
530 if (substr($this->object->getTitle(),0,3) !=
"il_")
536 $protect_permissions = (
$_SESSION[
"error_post_vars"][
"Fobject"][
"protect_permissions"]) ?
"checked=\"checked\"" :
"";
540 if (substr($this->object->getTitle(),0,3) !=
"il_")
546 $protect_permissions = $rbacreview->isProtected($this->rolf_ref_id,$this->object->getId()) ?
"checked=\"checked\"" :
"";
549 $obj_str =
"&obj_id=".$this->obj_id;
551 $this->tpl->setVariable(
"TXT_TITLE",$this->lng->txt(
"title"));
552 $this->tpl->setVariable(
"TXT_DESC",$this->lng->txt(
"desc"));
554 $this->tpl->setCurrentBlock(
"protect_permissions");
555 $this->tpl->setVariable(
"TXT_PROTECT_PERMISSIONS",$this->lng->txt(
'role_protect_permissions'));
556 $this->tpl->setVariable(
"PROTECT_PERMISSIONS",$protect_permissions);
557 $this->tpl->parseCurrentBlock();
559 $this->tpl->setVariable(
"FORMACTION",
560 $this->ctrl->getFormAction($this));
561 $this->tpl->setVariable(
"TXT_HEADER", $this->lng->txt($this->object->getType().
"_edit"));
562 $this->tpl->setVariable(
"TARGET", $this->
getTargetFrame(
"update"));
563 $this->tpl->setVariable(
"TXT_CANCEL", $this->lng->txt(
"cancel"));
564 $this->tpl->setVariable(
"TXT_SUBMIT", $this->lng->txt(
"save"));
565 $this->tpl->setVariable(
"CMD_SUBMIT",
"update");
566 $this->tpl->setVariable(
"TXT_REQUIRED_FLD", $this->lng->txt(
"required_field"));
568 if (substr($this->object->getTitle(),0,3) ==
"il_")
570 $this->tpl->setVariable(
"SHOW_TITLE",$this->object->getTitle());
584 global $rbacsystem,$rbacreview;
586 if ($rbacsystem->checkAccess(
'write',$this->rolf_ref_id))
588 $tabs_gui->addTarget(
"edit_properties",
589 $this->ctrl->getLinkTarget($this,
"edit"),
590 array(
"edit",
"update"), get_class($this));
592 $tabs_gui->addTarget(
"default_perm_settings",
593 $this->ctrl->getLinkTarget($this,
"perm"),
594 array(
"perm"), get_class($this));
605 $this->ctrl->redirectByClass(
"ilobjrolefoldergui",
"view");
617 global $rbacsystem, $rbacadmin, $rbacreview;
620 if (!$rbacsystem->checkAccess(
"write", $this->rolf_ref_id))
622 $this->ilias->raiseError($this->lng->txt(
"msg_no_perm_modify_rolt"),$this->ilias->error_obj->WARNING);
625 if (substr($this->object->getTitle(),0,3) !=
"il_")
628 if (empty(
$_POST[
"Fobject"][
"title"]))
630 $this->ilias->raiseError($this->lng->txt(
"fill_out_all_required_fields"),$this->ilias->error_obj->MESSAGE);
634 if (substr(
$_POST[
"Fobject"][
"title"],0,3) ==
"il_")
636 $this->ilias->raiseError($this->lng->txt(
"msg_role_reserved_prefix"),$this->ilias->error_obj->MESSAGE);
644 $rbacadmin->setProtected($this->rolf_ref_id,$this->object->getId(),
ilUtil::tf2yn(
$_POST[
"Fobject"][
"protect_permissions"]));
645 $this->
object->update();
649 $this->ctrl->returnToParent($this);
660 if (
$_GET[
"admin_mode"] ==
"settings")
662 $ilLocator->addItem($this->lng->txt(
"administration"),
663 $this->ctrl->getLinkTargetByClass(
"iladministrationgui",
"frameset"),
668 $this->ctrl->getLinkTargetByClass(
"ilobjrolefoldergui",
"view"));
670 $ilLocator->addItem($this->object->getTitle(),
671 $this->ctrl->getLinkTarget($this,
"perm"));
684 if (strtolower(
$_GET[
"baseClass"]) ==
"iladministrationgui")
687 $this->ctrl->getLinkTargetByClass(
"ilobjrolefoldergui",
"view"));
691 if ($this->object->getRefId() != ROOT_FOLDER_ID &&
692 $this->
object->getRefId() != SYSTEM_FOLDER_ID)
694 $par_id = $tree->getParentId($this->object->getRefId());
695 $tpl->setUpperIcon(
"repository.php?ref_id=".$par_id);