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 $pro =
new ilCheckboxInputGUI($this->lng->txt(
'role_protect_permissions'),
'protected');
135 $this->object->getId()
138 $form->addItem($pro);
153 if (!$rbacsystem->checkAccess(
"create_rolt", $this->rolf_ref_id))
155 $this->ilias->raiseError($this->lng->txt(
"permission_denied"),$this->ilias->error_obj->MESSAGE);
161 $this->tpl->setContent($form->getHTML());
172 if (!$rbacsystem->checkAccess(
"write", $this->rolf_ref_id))
174 $this->ilias->raiseError($this->lng->txt(
"msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
181 $GLOBALS[
'tpl']->setContent($form->getHTML());
191 global $rbacsystem, $rbacadmin, $rbacreview;
194 if (!$rbacsystem->checkAccess(
"write", $this->rolf_ref_id))
196 $this->ilias->raiseError($this->lng->txt(
"msg_no_perm_modify_rolt"),$this->ilias->error_obj->WARNING);
200 if($form->checkInput())
202 $this->
object->setTitle($form->getInput(
'title'));
203 $this->
object->setDescription($form->getInput(
'desc'));
204 $rbacadmin->setProtected(
206 $this->object->getId(),
207 $form->getInput(
'protected') ?
'y' :
'n'
209 $this->
object->update();
211 $this->ctrl->returnToParent($this);
214 $form->setValuesByPost();
227 global $rbacsystem,$rbacadmin, $rbacreview;
229 if (!$rbacsystem->checkAccess(
"create_rolt",$this->rolf_ref_id))
231 $this->ilias->raiseError($this->lng->txt(
"msg_no_perm_create_rolt"),$this->ilias->error_obj->WARNING);
234 if($form->checkInput())
236 include_once(
"./Services/AccessControl/classes/class.ilObjRoleTemplate.php");
238 $roltObj->setTitle($form->getInput(
'title'));
239 $roltObj->setDescription($form->getInput(
'desc'));
242 $rbacadmin->setProtected(
245 $form->getInput(
'protected') ?
'y' :
'n'
250 $this->ctrl->setParameter($this,
'obj_id',$roltObj->getId());
251 $this->ctrl->redirect($this,
'perm');
253 $form->setValuesByPost();
266 if (!$rbacsystem->checkAccess(
'write',$this->rolf_ref_id))
268 $this->ilias->raiseError($this->lng->txt(
"msg_no_perm_perm"),$this->ilias->error_obj->WARNING);
272 $to_filter = $objDefinition->getSubobjectsToFilter();
274 $tpl_filter = array();
275 $internal_tpl =
false;
277 if (($internal_tpl = $this->object->isInternalTemplate()))
279 $tpl_filter = $this->
object->getFilterOfInternalTemplate();
282 $operation_info = $rbacreview->getOperationAssignment();
284 foreach($operation_info as $info)
286 if($objDefinition->getDevMode($info[
'type']))
291 if(in_array($info[
'type'],$to_filter))
295 if ($internal_tpl and $tpl_filter and !in_array($info[
'type'],$tpl_filter))
299 $rbac_objects[$info[
'typ_id']] = array(
"obj_id" => $info[
'typ_id'],
300 "type" => $info[
'type']);
302 $txt = $objDefinition->isPlugin($info[
'type'])
304 : $this->lng->txt($info[
'type'].
"_".$info[
'operation']);
305 if (substr($info[
'operation'], 0, 7) ==
"create_" &&
306 $objDefinition->isPlugin(substr($info[
'operation'], 7)))
308 $txt =
ilPlugin::lookupTxt(
"rep_robj", substr($info[
'operation'], 7), $info[
'type'].
"_".$info[
'operation']);
310 elseif(substr($info[
'operation'],0,6) ==
'create')
312 $txt = $this->lng->txt(
'rbac_'.$info[
'operation']);
315 $rbac_operations[$info[
'typ_id']][$info[
'ops_id']] = array(
316 "ops_id" => $info[
'ops_id'],
317 "title" => $info[
'operation'],
321 foreach ($rbac_objects as $key => $obj_data)
323 if ($objDefinition->isPlugin($obj_data[
"type"]))
326 "obj_".$obj_data[
"type"]);
330 $rbac_objects[$key][
"name"] = $this->lng->txt(
"obj_".$obj_data[
"type"]);
333 $rbac_objects[$key][
"ops"] = $rbac_operations[$key];
338 foreach ($rbac_objects as $key => $obj_data)
340 sort($rbac_objects[$key][
"ops"]);
347 foreach ($rbac_objects as $key => $obj_data)
349 $arr_selected = $rbacreview->getOperationsOfRole($this->object->getId(), $obj_data[
"type"],
$this->rolf_ref_id);
350 $arr_checked = array_intersect($arr_selected,array_keys($rbac_operations[$obj_data[
"obj_id"]]));
352 foreach ($rbac_operations[$obj_data[
"obj_id"]] as $operation)
354 $checked = in_array($operation[
"ops_id"],$arr_checked);
358 $box = ilUtil::formCheckBox($checked,
"template_perm[".$obj_data[
"type"].
"][]",$operation[
"ops_id"],$disabled);
359 $output[
"perm"][$obj_data[
"obj_id"]][$operation[
"ops_id"]] = $box;
364 $output[
"col_anz"] = count($rbac_objects);
365 $output[
"txt_save"] = $this->lng->txt(
"save");
366 $output[
"check_protected"] = ilUtil::formCheckBox($rbacreview->isProtected($this->rolf_ref_id,$this->object->getId()),
"protected",1);
367 $output[
"text_protected"] = $this->lng->txt(
"role_protect_permissions");
373 $output[
"message_middle"] = $this->lng->txt(
"adopt_perm_from_template");
376 if ($this->object->getId() == SYSTEM_ROLE_ID)
378 $output[
"adopt"] = array();
384 $parent_role_ids = $rbacreview->getParentRoleIds($this->rolf_ref_id,
true);
387 ksort($parent_role_ids);
389 foreach ($parent_role_ids as $key => $par)
391 if ($par[
"obj_id"] != SYSTEM_ROLE_ID)
395 $output[
"adopt"][$key][
"check_adopt"] = $radio;
396 $output[
"adopt"][$key][
"type"] = ($par[
"type"] ==
'role' ?
'Role' :
'Template');
397 $output[
"adopt"][$key][
"role_name"] = $par[
"title"];
401 $output[
"formaction_adopt"] = $this->ctrl->getFormAction($this);
405 $output[
"formaction"] =
406 $this->ctrl->getFormAction($this);
408 $this->data = $output;
415 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.adm_perm_role.html",
416 "Services/AccessControl");
418 foreach ($rbac_objects as $obj_data)
421 $this->tpl->setCurrentBlock(
"object_operations");
423 foreach ($obj_data[
"ops"] as $operation)
425 $ops_ids[] = $operation[
"ops_id"];
428 $this->tpl->setVariable(
"CSS_ROW",$css_row);
429 $this->tpl->setVariable(
"PERMISSION",$operation[
"name"]);
430 $this->tpl->setVariable(
"CHECK_PERMISSION",$this->data[
"perm"][$obj_data[
"obj_id"]][$operation[
"ops_id"]]);
431 $this->tpl->parseCurrentBlock();
435 $this->tpl->setCurrentBlock(
"object_type");
436 $this->tpl->setVariable(
"TXT_OBJ_TYPE",$obj_data[
"name"]);
439 if ($this->objDefinition->getDevMode($obj_data[
"type"]))
441 $this->tpl->setVariable(
"TXT_NOT_IMPL",
"(".$this->lng->txt(
"not_implemented_yet").
")");
443 else if ($obj_data[
"type"] ==
"icrs" and !$this->ilias->getSetting(
"ilinc_active"))
445 $this->tpl->setVariable(
"TXT_NOT_IMPL",
"(".$this->lng->txt(
"not_enabled_or_configured").
")");
449 $this->tpl->setVariable(
"JS_VARNAME",
"template_perm_".$obj_data[
"type"]);
451 $this->tpl->setVariable(
"TXT_CHECKALL", $this->lng->txt(
"check_all"));
452 $this->tpl->setVariable(
"TXT_UNCHECKALL", $this->lng->txt(
"uncheck_all"));
455 $this->tpl->parseCurrentBlock();
479 $this->tpl->setCurrentBlock(
"tblfooter_protected");
480 $this->tpl->setVariable(
"COL_ANZ",3);
481 $this->tpl->setVariable(
"CHECK_BOTTOM",$this->data[
"check_protected"]);
482 $this->tpl->setVariable(
"MESSAGE_TABLE",$this->data[
"text_protected"]);
483 $this->tpl->parseCurrentBlock();
485 $this->tpl->setVariable(
"COL_ANZ_PLUS",4);
486 $this->tpl->setVariable(
"TXT_SAVE",$this->data[
"txt_save"]);
488 $this->tpl->setCurrentBlock(
"adm_content");
489 $this->tpl->setVariable(
"TBL_TITLE_IMG",
ilUtil::getImagePath(
"icon_".$this->object->getType().
".png"));
490 $this->tpl->setVariable(
"TBL_TITLE_IMG_ALT",$this->lng->txt($this->object->getType()));
492 $this->tpl->setVariable(
"TBL_HELP_LINK",
"tbl_help.php");
493 $this->tpl->setVariable(
"TBL_HELP_IMG_ALT",$this->lng->txt(
"help"));
496 if (substr($this->object->getTitle(),0,3) ==
"il_")
498 $desc = $this->lng->txt(
"predefined_template");
501 $description =
"<br/> <span class=\"small\">".$desc.
"</span>";
504 if (substr($this->object->getTitle(),0,3) ==
"il_")
506 include_once(
'./Services/AccessControl/classes/class.ilObjRole.php');
512 $title = $this->
object->getTitle();
515 $this->tpl->setVariable(
"TBL_TITLE",$title.$description);
517 $this->tpl->setVariable(
"TXT_PERMISSION",$this->data[
"txt_permission"]);
518 $this->tpl->setVariable(
"FORMACTION",$this->data[
"formaction"]);
519 $this->tpl->parseCurrentBlock();
532 if (!$rbacsystem->checkAccess(
'write',$this->rolf_ref_id))
534 $this->ilias->raiseError($this->lng->txt(
"msg_no_perm_perm"),$this->ilias->error_obj->WARNING);
541 foreach (
$_POST[
"template_perm"] as $key => $ops_array)
544 $rbacadmin->setRolePermission($this->object->getId(), $key,$ops_array,
$this->rolf_ref_id);
549 $this->
object->update();
553 #$rbacadmin->setProtected($this->rolf_ref_id,$this->object->getId(),ilUtil::tf2yn($_POST['protected']));
557 $this->ctrl->redirect($this,
"perm");
567 global $rbacadmin, $rbacsystem, $rbacreview;
569 if (!$rbacsystem->checkAccess(
'write',$this->rolf_ref_id))
571 $this->ilias->raiseError($this->lng->txt(
"msg_no_perm_perm"),$this->ilias->error_obj->WARNING);
573 elseif ($this->obj_id ==
$_POST[
"adopt"])
579 $rbacadmin->deleteRolePermission($this->obj_id, $this->rolf_ref_id);
580 $parentRoles = $rbacreview->getParentRoleIds($this->rolf_ref_id,
true);
581 $rbacadmin->copyRoleTemplatePermissions(
$_POST[
"adopt"],$parentRoles[
$_POST[
"adopt"]][
"parent"],
582 $this->rolf_ref_id,$this->obj_id);
584 $this->
object->update();
587 $obj_data =& $this->ilias->obj_factory->getInstanceByObjId($_POST[
"adopt"]);
588 ilUtil::sendSuccess($this->lng->txt(
"msg_perm_adopted_from1").
" '".$obj_data->getTitle().
"'.<br/>".$this->lng->txt(
"msg_perm_adopted_from2"),
true);
591 $this->ctrl->redirect($this,
"perm");
604 global $rbacsystem,$rbacreview;
606 if ($rbacsystem->checkAccess(
'write',$this->rolf_ref_id))
608 $tabs_gui->addTarget(
"settings",
609 $this->ctrl->getLinkTarget($this,
"edit"),
610 array(
"edit",
"update"), get_class($this));
612 $tabs_gui->addTarget(
"default_perm_settings",
613 $this->ctrl->getLinkTarget($this,
"perm"),
614 array(
"perm"), get_class($this));
625 $this->ctrl->redirectByClass(
"ilobjrolefoldergui",
"view");
643 $this->ctrl->getLinkTargetByClass(
"ilobjrolefoldergui",
"view"));