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)
 
  462                                 $rbacadmin->setRolePermission($this->object->getId(), $key,$ops_array,
$this->rolf_ref_id);
 
  467                 $this->
object->update();
 
  471                 #$rbacadmin->setProtected($this->rolf_ref_id,$this->object->getId(),ilUtil::tf2yn($_POST['protected'])); 
  475                 $this->ctrl->redirect($this, 
"perm");
 
  485                 global $rbacadmin, $rbacsystem, $rbacreview;
 
  487                 if (!$rbacsystem->checkAccess(
'write',$this->rolf_ref_id))
 
  489                         $this->ilias->raiseError($this->lng->txt(
"msg_no_perm_perm"),$this->ilias->error_obj->WARNING);
 
  491                 elseif ($this->obj_id == 
$_POST[
"adopt"])
 
  497                         $rbacadmin->deleteRolePermission($this->obj_id, $this->rolf_ref_id);
 
  498                         $parentRoles = $rbacreview->getParentRoleIds($this->rolf_ref_id,
true);
 
  499                         $rbacadmin->copyRoleTemplatePermissions(
$_POST[
"adopt"],$parentRoles[
$_POST[
"adopt"]][
"parent"],
 
  500                                                                                    $this->rolf_ref_id,$this->obj_id);           
 
  502                         $this->
object->update();
 
  505                         $obj_data =& $this->ilias->obj_factory->getInstanceByObjId($_POST[
"adopt"]);
 
  506                         ilUtil::sendSuccess($this->lng->txt(
"msg_perm_adopted_from1").
" '".$obj_data->getTitle().
"'.<br/>".$this->lng->txt(
"msg_perm_adopted_from2"),
true);
 
  509                 $this->ctrl->redirect($this, 
"perm");
 
  519                 global $rbacsystem, $rbacreview;
 
  521                 if (!$rbacsystem->checkAccess(
"write", $this->rolf_ref_id))
 
  523                         $this->ilias->raiseError($this->lng->txt(
"msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
 
  531                         if (substr($this->object->getTitle(),0,3) != 
"il_")
 
  537                         $protect_permissions = (
$_SESSION[
"error_post_vars"][
"Fobject"][
"protect_permissions"]) ? 
"checked=\"checked\"" : 
"";
 
  541                         if (substr($this->object->getTitle(),0,3) != 
"il_")
 
  547                         $protect_permissions = $rbacreview->isProtected($this->rolf_ref_id,$this->object->getId()) ? 
"checked=\"checked\"" : 
"";
 
  550                 $obj_str = 
"&obj_id=".$this->obj_id;
 
  552                 $this->tpl->setVariable(
"TXT_TITLE",$this->lng->txt(
"title"));
 
  553                 $this->tpl->setVariable(
"TXT_DESC",$this->lng->txt(
"desc"));
 
  555                 $this->tpl->setCurrentBlock(
"protect_permissions");
 
  556                 $this->tpl->setVariable(
"TXT_PROTECT_PERMISSIONS",$this->lng->txt(
'role_protect_permissions'));
 
  557                 $this->tpl->setVariable(
"PROTECT_PERMISSIONS",$protect_permissions);
 
  558                 $this->tpl->parseCurrentBlock();
 
  560                 $this->tpl->setVariable(
"FORMACTION",
 
  561                         $this->ctrl->getFormAction($this));
 
  562                 $this->tpl->setVariable(
"TXT_HEADER", $this->lng->txt($this->object->getType().
"_edit"));
 
  563                 $this->tpl->setVariable(
"TARGET", $this->
getTargetFrame(
"update"));
 
  564                 $this->tpl->setVariable(
"TXT_CANCEL", $this->lng->txt(
"cancel"));
 
  565                 $this->tpl->setVariable(
"TXT_SUBMIT", $this->lng->txt(
"save"));
 
  566                 $this->tpl->setVariable(
"CMD_SUBMIT", 
"update");
 
  567                 $this->tpl->setVariable(
"TXT_REQUIRED_FLD", $this->lng->txt(
"required_field"));
 
  569                 if (substr($this->object->getTitle(),0,3) == 
"il_")
 
  571                         $this->tpl->setVariable(
"SHOW_TITLE",$this->object->getTitle());
 
  585                 global $rbacsystem,$rbacreview;
 
  587                 if ($rbacsystem->checkAccess(
'write',$this->rolf_ref_id))
 
  589                         $tabs_gui->addTarget(
"edit_properties",
 
  590                                 $this->ctrl->getLinkTarget($this, 
"edit"),
 
  591                                 array(
"edit",
"update"), get_class($this));
 
  593                         $tabs_gui->addTarget(
"default_perm_settings",
 
  594                                 $this->ctrl->getLinkTarget($this, 
"perm"),
 
  595                                 array(
"perm"), get_class($this));
 
  606                 $this->ctrl->redirectByClass(
"ilobjrolefoldergui",
"view");
 
  618                 global $rbacsystem, $rbacadmin, $rbacreview;
 
  621                 if (!$rbacsystem->checkAccess(
"write", $this->rolf_ref_id))
 
  623                         $this->ilias->raiseError($this->lng->txt(
"msg_no_perm_modify_rolt"),$this->ilias->error_obj->WARNING);
 
  626                 if (substr($this->object->getTitle(),0,3) != 
"il_")
 
  629                         if (empty(
$_POST[
"Fobject"][
"title"]))
 
  631                                 $this->ilias->raiseError($this->lng->txt(
"fill_out_all_required_fields"),$this->ilias->error_obj->MESSAGE);
 
  635                         if (substr(
$_POST[
"Fobject"][
"title"],0,3) == 
"il_")
 
  637                                 $this->ilias->raiseError($this->lng->txt(
"msg_role_reserved_prefix"),$this->ilias->error_obj->MESSAGE);
 
  645                 $rbacadmin->setProtected($this->rolf_ref_id,$this->object->getId(),
ilUtil::tf2yn(
$_POST[
"Fobject"][
"protect_permissions"]));    
 
  646                 $this->
object->update();
 
  650                 $this->ctrl->returnToParent($this);
 
  661                 if (
$_GET[
"admin_mode"] == 
"settings")  
 
  663                         $ilLocator->addItem($this->lng->txt(
"administration"),
 
  664                                 $this->ctrl->getLinkTargetByClass(
"iladministrationgui", 
"frameset"),
 
  669                                 $this->ctrl->getLinkTargetByClass(
"ilobjrolefoldergui", 
"view"));
 
  671                         $ilLocator->addItem($this->object->getTitle(),
 
  672                                 $this->ctrl->getLinkTarget($this, 
"perm"));
 
  685                 if (strtolower(
$_GET[
"baseClass"]) == 
"iladministrationgui")
 
  688                                         $this->ctrl->getLinkTargetByClass(
"ilobjrolefoldergui", 
"view"));
 
  692                         if ($this->object->getRefId() != ROOT_FOLDER_ID &&
 
  693                                 $this->
object->getRefId() != SYSTEM_FOLDER_ID)
 
  695                                 $par_id = $tree->getParentId($this->object->getRefId());
 
  696                                 $tpl->setUpperIcon(
"repository.php?ref_id=".$par_id);