5 require_once
"./Services/Object/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");
55 $next_class = $this->ctrl->getNextClass($this);
56 $cmd = $this->ctrl->getCmd();
84 if (!$rbacsystem->checkAccess(
"create_rolt", $this->rolf_ref_id))
86 $this->ilias->raiseError($this->lng->txt(
"permission_denied"),$this->ilias->error_obj->MESSAGE);
92 $data[
"fields"] = array();
96 $this->tpl->addBlockfile(
'ADM_CONTENT',
'adm_content',
'tpl.role_edit.html',
'Services/AccessControl');
98 foreach (
$data[
"fields"] as $key => $val)
100 $this->tpl->setVariable(
"TXT_".strtoupper($key), $this->lng->txt($key));
101 $this->tpl->setVariable(strtoupper($key), $val);
103 if ($this->prepare_output)
105 $this->tpl->parseCurrentBlock();
109 $this->tpl->setCurrentBlock(
"protect_permissions");
110 $protect_permissions =
$_SESSION[
"error_post_vars"][
"Fobject"][
"protect_permissions"] ?
"checked=\"checked\"" :
"";
111 $this->tpl->setVariable(
"TXT_PROTECT_PERMISSIONS",$this->lng->txt(
"role_protect_permissions"));
112 $this->tpl->setVariable(
"PROTECT_PERMISSIONS",$protect_permissions);
113 $this->tpl->parseCurrentBlock();
115 $this->ctrl->setParameter($this,
"new_type", $this->type);
116 $this->tpl->setVariable(
"FORMACTION",
117 $this->ctrl->getFormAction($this));
118 $this->tpl->setVariable(
"TXT_HEADER", $this->lng->txt($this->type.
"_new"));
119 $this->tpl->setVariable(
"TXT_CANCEL", $this->lng->txt(
"cancel"));
120 $this->tpl->setVariable(
"TXT_SUBMIT", $this->lng->txt($this->type.
"_add"));
121 $this->tpl->setVariable(
"CMD_SUBMIT",
"save");
123 $this->tpl->setVariable(
"TXT_REQUIRED_FLD", $this->lng->txt(
"required_field"));
135 global $rbacsystem,$rbacadmin, $rbacreview;
139 if (!$rbacsystem->checkAccess(
"create_rolt",$this->rolf_ref_id))
141 $this->ilias->raiseError($this->lng->txt(
"msg_no_perm_create_rolt"),$this->ilias->error_obj->WARNING);
145 if (empty(
$_POST[
"Fobject"][
"title"]))
147 $this->ilias->raiseError($this->lng->txt(
"fill_out_all_required_fields"),$this->ilias->error_obj->MESSAGE);
151 if (substr(
$_POST[
"Fobject"][
"title"],0,3) ==
"il_")
153 $this->ilias->raiseError($this->lng->txt(
"msg_role_reserved_prefix"),$this->ilias->error_obj->MESSAGE);
157 include_once(
"./Services/AccessControl/classes/class.ilObjRoleTemplate.php");
163 $rbacadmin->setProtected($this->rolf_ref_id,$roltObj->getId(),
ilUtil::tf2yn(
$_POST[
"Fobject"][
"protect_permissions"]));
166 $this->ctrl->returnToParent($this);
178 if (!$rbacsystem->checkAccess(
'write',$this->rolf_ref_id))
180 $this->ilias->raiseError($this->lng->txt(
"msg_no_perm_perm"),$this->ilias->error_obj->WARNING);
184 $to_filter = $objDefinition->getSubobjectsToFilter();
186 $tpl_filter = array();
187 $internal_tpl =
false;
189 if (($internal_tpl = $this->object->isInternalTemplate()))
191 $tpl_filter = $this->
object->getFilterOfInternalTemplate();
194 $operation_info = $rbacreview->getOperationAssignment();
196 foreach($operation_info as $info)
198 if($objDefinition->getDevMode($info[
'type']))
203 if(in_array($info[
'type'],$to_filter))
207 if ($internal_tpl and $tpl_filter and !in_array($info[
'type'],$tpl_filter))
211 $rbac_objects[$info[
'typ_id']] = array(
"obj_id" => $info[
'typ_id'],
212 "type" => $info[
'type']);
214 $txt = $objDefinition->isPlugin($info[
'type'])
216 : $this->lng->txt($info[
'type'].
"_".$info[
'operation']);
217 if (substr($info[
'operation'], 0, 7) ==
"create_" &&
218 $objDefinition->isPlugin(substr($info[
'operation'], 7)))
220 $txt =
ilPlugin::lookupTxt(
"rep_robj", substr($info[
'operation'], 7), $info[
'type'].
"_".$info[
'operation']);
222 elseif(substr($info[
'operation'],0,6) ==
'create')
224 $txt = $this->lng->txt(
'rbac_'.$info[
'operation']);
227 $rbac_operations[$info[
'typ_id']][$info[
'ops_id']] = array(
228 "ops_id" => $info[
'ops_id'],
229 "title" => $info[
'operation'],
233 foreach ($rbac_objects as $key => $obj_data)
235 if ($objDefinition->isPlugin($obj_data[
"type"]))
238 "obj_".$obj_data[
"type"]);
242 $rbac_objects[$key][
"name"] = $this->lng->txt(
"obj_".$obj_data[
"type"]);
245 $rbac_objects[$key][
"ops"] = $rbac_operations[$key];
250 foreach ($rbac_objects as $key => $obj_data)
252 sort($rbac_objects[$key][
"ops"]);
259 foreach ($rbac_objects as $key => $obj_data)
261 $arr_selected = $rbacreview->getOperationsOfRole($this->object->getId(), $obj_data[
"type"],
$this->rolf_ref_id);
262 $arr_checked = array_intersect($arr_selected,array_keys($rbac_operations[$obj_data[
"obj_id"]]));
264 foreach ($rbac_operations[$obj_data[
"obj_id"]] as $operation)
266 $checked = in_array($operation[
"ops_id"],$arr_checked);
270 $box = ilUtil::formCheckBox($checked,
"template_perm[".$obj_data[
"type"].
"][]",$operation[
"ops_id"],$disabled);
271 $output[
"perm"][$obj_data[
"obj_id"]][$operation[
"ops_id"]] = $box;
276 $output[
"col_anz"] = count($rbac_objects);
277 $output[
"txt_save"] = $this->lng->txt(
"save");
278 $output[
"check_protected"] = ilUtil::formCheckBox($rbacreview->isProtected($this->rolf_ref_id,$this->object->getId()),
"protected",1);
279 $output[
"text_protected"] = $this->lng->txt(
"role_protect_permissions");
285 $output[
"message_middle"] = $this->lng->txt(
"adopt_perm_from_template");
288 if ($this->object->getId() == SYSTEM_ROLE_ID)
290 $output[
"adopt"] = array();
296 $parent_role_ids = $rbacreview->getParentRoleIds($this->rolf_ref_id,
true);
299 ksort($parent_role_ids);
301 foreach ($parent_role_ids as $key => $par)
303 if ($par[
"obj_id"] != SYSTEM_ROLE_ID)
307 $output[
"adopt"][$key][
"check_adopt"] = $radio;
308 $output[
"adopt"][$key][
"type"] = ($par[
"type"] ==
'role' ?
'Role' :
'Template');
309 $output[
"adopt"][$key][
"role_name"] = $par[
"title"];
313 $output[
"formaction_adopt"] = $this->ctrl->getFormAction($this);
317 $output[
"formaction"] =
318 $this->ctrl->getFormAction($this);
320 $this->data = $output;
327 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.adm_perm_role.html",
328 "Services/AccessControl");
330 foreach ($rbac_objects as $obj_data)
333 $this->tpl->setCurrentBlock(
"object_operations");
335 foreach ($obj_data[
"ops"] as $operation)
337 $ops_ids[] = $operation[
"ops_id"];
340 $this->tpl->setVariable(
"CSS_ROW",$css_row);
341 $this->tpl->setVariable(
"PERMISSION",$operation[
"name"]);
342 $this->tpl->setVariable(
"CHECK_PERMISSION",$this->data[
"perm"][$obj_data[
"obj_id"]][$operation[
"ops_id"]]);
343 $this->tpl->parseCurrentBlock();
347 $this->tpl->setCurrentBlock(
"object_type");
348 $this->tpl->setVariable(
"TXT_OBJ_TYPE",$obj_data[
"name"]);
351 if ($this->objDefinition->getDevMode($obj_data[
"type"]))
353 $this->tpl->setVariable(
"TXT_NOT_IMPL",
"(".$this->lng->txt(
"not_implemented_yet").
")");
355 else if ($obj_data[
"type"] ==
"icrs" and !$this->ilias->getSetting(
"ilinc_active"))
357 $this->tpl->setVariable(
"TXT_NOT_IMPL",
"(".$this->lng->txt(
"not_enabled_or_configured").
")");
361 $this->tpl->setVariable(
"JS_VARNAME",
"template_perm_".$obj_data[
"type"]);
363 $this->tpl->setVariable(
"TXT_CHECKALL", $this->lng->txt(
"check_all"));
364 $this->tpl->setVariable(
"TXT_UNCHECKALL", $this->lng->txt(
"uncheck_all"));
367 $this->tpl->parseCurrentBlock();
391 $this->tpl->setCurrentBlock(
"tblfooter_protected");
392 $this->tpl->setVariable(
"COL_ANZ",3);
393 $this->tpl->setVariable(
"CHECK_BOTTOM",$this->data[
"check_protected"]);
394 $this->tpl->setVariable(
"MESSAGE_TABLE",$this->data[
"text_protected"]);
395 $this->tpl->parseCurrentBlock();
397 $this->tpl->setVariable(
"COL_ANZ_PLUS",4);
398 $this->tpl->setVariable(
"TXT_SAVE",$this->data[
"txt_save"]);
400 $this->tpl->setCurrentBlock(
"adm_content");
401 $this->tpl->setVariable(
"TBL_TITLE_IMG",
ilUtil::getImagePath(
"icon_".$this->object->getType().
".png"));
402 $this->tpl->setVariable(
"TBL_TITLE_IMG_ALT",$this->lng->txt($this->object->getType()));
404 $this->tpl->setVariable(
"TBL_HELP_LINK",
"tbl_help.php");
405 $this->tpl->setVariable(
"TBL_HELP_IMG_ALT",$this->lng->txt(
"help"));
408 if (substr($this->object->getTitle(),0,3) ==
"il_")
410 $desc = $this->lng->txt(
"predefined_template");
413 $description =
"<br/> <span class=\"small\">".$desc.
"</span>";
416 if (substr($this->object->getTitle(),0,3) ==
"il_")
418 include_once(
'./Services/AccessControl/classes/class.ilObjRole.php');
424 $title = $this->
object->getTitle();
427 $this->tpl->setVariable(
"TBL_TITLE",
$title.$description);
429 $this->tpl->setVariable(
"TXT_PERMISSION",$this->data[
"txt_permission"]);
430 $this->tpl->setVariable(
"FORMACTION",$this->data[
"formaction"]);
431 $this->tpl->parseCurrentBlock();
444 if (!$rbacsystem->checkAccess(
'write',$this->rolf_ref_id))
446 $this->ilias->raiseError($this->lng->txt(
"msg_no_perm_perm"),$this->ilias->error_obj->WARNING);
453 foreach (
$_POST[
"template_perm"] as $key => $ops_array)
456 $rbacadmin->setRolePermission($this->object->getId(), $key,$ops_array,
$this->rolf_ref_id);
461 $this->
object->update();
465 #$rbacadmin->setProtected($this->rolf_ref_id,$this->object->getId(),ilUtil::tf2yn($_POST['protected']));
469 $this->ctrl->redirect($this,
"perm");
479 global $rbacadmin, $rbacsystem, $rbacreview;
481 if (!$rbacsystem->checkAccess(
'write',$this->rolf_ref_id))
483 $this->ilias->raiseError($this->lng->txt(
"msg_no_perm_perm"),$this->ilias->error_obj->WARNING);
485 elseif ($this->obj_id ==
$_POST[
"adopt"])
491 $rbacadmin->deleteRolePermission($this->obj_id, $this->rolf_ref_id);
492 $parentRoles = $rbacreview->getParentRoleIds($this->rolf_ref_id,
true);
493 $rbacadmin->copyRoleTemplatePermissions(
$_POST[
"adopt"],$parentRoles[
$_POST[
"adopt"]][
"parent"],
494 $this->rolf_ref_id,$this->obj_id);
496 $this->
object->update();
499 $obj_data =& $this->ilias->obj_factory->getInstanceByObjId($_POST[
"adopt"]);
500 ilUtil::sendSuccess($this->lng->txt(
"msg_perm_adopted_from1").
" '".$obj_data->getTitle().
"'.<br/>".$this->lng->txt(
"msg_perm_adopted_from2"),
true);
503 $this->ctrl->redirect($this,
"perm");
513 global $rbacsystem, $rbacreview;
515 if (!$rbacsystem->checkAccess(
"write", $this->rolf_ref_id))
517 $this->ilias->raiseError($this->lng->txt(
"msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
520 $this->tpl->addBlockfile(
'ADM_CONTENT',
'adm_content',
'tpl.role_edit.html',
'Services/AccessControl');
525 if (substr($this->object->getTitle(),0,3) !=
"il_")
531 $protect_permissions = (
$_SESSION[
"error_post_vars"][
"Fobject"][
"protect_permissions"]) ?
"checked=\"checked\"" :
"";
535 if (substr($this->object->getTitle(),0,3) !=
"il_")
541 $protect_permissions = $rbacreview->isProtected($this->rolf_ref_id,$this->object->getId()) ?
"checked=\"checked\"" :
"";
544 $obj_str =
"&obj_id=".$this->obj_id;
546 $this->tpl->setVariable(
"TXT_TITLE",$this->lng->txt(
"title"));
547 $this->tpl->setVariable(
"TXT_DESC",$this->lng->txt(
"desc"));
549 $this->tpl->setCurrentBlock(
"protect_permissions");
550 $this->tpl->setVariable(
"TXT_PROTECT_PERMISSIONS",$this->lng->txt(
'role_protect_permissions'));
551 $this->tpl->setVariable(
"PROTECT_PERMISSIONS",$protect_permissions);
552 $this->tpl->parseCurrentBlock();
554 $this->tpl->setVariable(
"FORMACTION",
555 $this->ctrl->getFormAction($this));
556 $this->tpl->setVariable(
"TXT_HEADER", $this->lng->txt($this->object->getType().
"_edit"));
557 $this->tpl->setVariable(
"TARGET", $this->
getTargetFrame(
"update"));
558 $this->tpl->setVariable(
"TXT_CANCEL", $this->lng->txt(
"cancel"));
559 $this->tpl->setVariable(
"TXT_SUBMIT", $this->lng->txt(
"save"));
560 $this->tpl->setVariable(
"CMD_SUBMIT",
"update");
561 $this->tpl->setVariable(
"TXT_REQUIRED_FLD", $this->lng->txt(
"required_field"));
563 if (substr($this->object->getTitle(),0,3) ==
"il_")
565 $this->tpl->setVariable(
"SHOW_TITLE",$this->object->getTitle());
579 global $rbacsystem,$rbacreview;
581 if ($rbacsystem->checkAccess(
'write',$this->rolf_ref_id))
583 $tabs_gui->addTarget(
"edit_properties",
584 $this->ctrl->getLinkTarget($this,
"edit"),
585 array(
"edit",
"update"), get_class($this));
587 $tabs_gui->addTarget(
"default_perm_settings",
588 $this->ctrl->getLinkTarget($this,
"perm"),
589 array(
"perm"), get_class($this));
600 $this->ctrl->redirectByClass(
"ilobjrolefoldergui",
"view");
612 global $rbacsystem, $rbacadmin, $rbacreview;
615 if (!$rbacsystem->checkAccess(
"write", $this->rolf_ref_id))
617 $this->ilias->raiseError($this->lng->txt(
"msg_no_perm_modify_rolt"),$this->ilias->error_obj->WARNING);
620 if (substr($this->object->getTitle(),0,3) !=
"il_")
623 if (empty(
$_POST[
"Fobject"][
"title"]))
625 $this->ilias->raiseError($this->lng->txt(
"fill_out_all_required_fields"),$this->ilias->error_obj->MESSAGE);
629 if (substr(
$_POST[
"Fobject"][
"title"],0,3) ==
"il_")
631 $this->ilias->raiseError($this->lng->txt(
"msg_role_reserved_prefix"),$this->ilias->error_obj->MESSAGE);
639 $rbacadmin->setProtected($this->rolf_ref_id,$this->object->getId(),
ilUtil::tf2yn(
$_POST[
"Fobject"][
"protect_permissions"]));
640 $this->
object->update();
644 $this->ctrl->returnToParent($this);
655 $ilLocator->addItem($this->lng->txt(
"administration"),
656 $this->ctrl->getLinkTargetByClass(
"iladministrationgui",
"frameset"),
661 $this->ctrl->getLinkTargetByClass(
"ilobjrolefoldergui",
"view"));