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 if($a_mode != self::FORM_MODE_CREATE)
136 $form->addItem($ilias_id);
139 $pro =
new ilCheckboxInputGUI($this->lng->txt(
'role_protect_permissions'),
'protected');
142 $this->object->getId()
145 $form->addItem($pro);
160 if (!$rbacsystem->checkAccess(
"create_rolt", $this->rolf_ref_id))
162 $this->
ilias->raiseError($this->lng->txt(
"permission_denied"),$this->
ilias->error_obj->MESSAGE);
168 $this->tpl->setContent($form->getHTML());
179 if (!$rbacsystem->checkAccess(
"write", $this->rolf_ref_id))
181 $this->
ilias->raiseError($this->lng->txt(
"msg_no_perm_write"),$this->
ilias->error_obj->MESSAGE);
188 $GLOBALS[
'tpl']->setContent($form->getHTML());
198 global $rbacsystem, $rbacadmin, $rbacreview;
201 if (!$rbacsystem->checkAccess(
"write", $this->rolf_ref_id))
203 $this->
ilias->raiseError($this->lng->txt(
"msg_no_perm_modify_rolt"),$this->
ilias->error_obj->WARNING);
207 if($form->checkInput())
209 $this->
object->setTitle($form->getInput(
'title'));
210 $this->
object->setDescription($form->getInput(
'desc'));
211 $rbacadmin->setProtected(
213 $this->object->getId(),
214 $form->getInput(
'protected') ?
'y' :
'n' 216 $this->
object->update();
218 $this->ctrl->returnToParent($this);
221 $form->setValuesByPost();
234 global $rbacsystem,$rbacadmin, $rbacreview;
236 if (!$rbacsystem->checkAccess(
"create_rolt",$this->rolf_ref_id))
238 $this->
ilias->raiseError($this->lng->txt(
"msg_no_perm_create_rolt"),$this->
ilias->error_obj->WARNING);
241 if($form->checkInput())
243 include_once(
"./Services/AccessControl/classes/class.ilObjRoleTemplate.php");
245 $roltObj->setTitle($form->getInput(
'title'));
246 $roltObj->setDescription($form->getInput(
'desc'));
249 $rbacadmin->setProtected(
252 $form->getInput(
'protected') ?
'y' :
'n' 257 $this->ctrl->setParameter($this,
'obj_id',$roltObj->getId());
258 $this->ctrl->redirect($this,
'perm');
260 $form->setValuesByPost();
273 if (!$rbacsystem->checkAccess(
'write',$this->rolf_ref_id))
275 $this->
ilias->raiseError($this->lng->txt(
"msg_no_perm_perm"),$this->
ilias->error_obj->WARNING);
279 $to_filter = $objDefinition->getSubobjectsToFilter();
281 $tpl_filter = array();
282 $internal_tpl =
false;
284 if (($internal_tpl = $this->object->isInternalTemplate()))
286 $tpl_filter = $this->
object->getFilterOfInternalTemplate();
292 $op_order[$op[
"ops_id"]] = $op[
"order"];
295 $operation_info = $rbacreview->getOperationAssignment();
297 foreach($operation_info as
$info)
299 if($objDefinition->getDevMode($info[
'type']))
304 if(in_array($info[
'type'],$to_filter))
308 if ($internal_tpl and $tpl_filter and !in_array($info[
'type'],$tpl_filter))
312 $rbac_objects[$info[
'typ_id']] = array(
"obj_id" => $info[
'typ_id'],
313 "type" => $info[
'type']);
315 $txt = $objDefinition->isPlugin($info[
'type'])
317 : $this->lng->txt($info[
'type'].
"_".$info[
'operation']);
318 if (substr($info[
'operation'], 0, 7) ==
"create_" &&
319 $objDefinition->isPlugin(substr($info[
'operation'], 7)))
323 elseif(substr($info[
'operation'],0,6) ==
'create')
325 $txt = $this->lng->txt(
'rbac_'.$info[
'operation']);
328 $order = $op_order[$info[
'ops_id']];
329 if(substr($info[
'operation'],0,6) ==
'create')
331 $order = $objDefinition->getPositionByType($info[
'type']);
334 $rbac_operations[$info[
'typ_id']][$info[
'ops_id']] = array(
335 "ops_id" => $info[
'ops_id'],
336 "title" => $info[
'operation'],
341 foreach ($rbac_objects as $key => $obj_data)
343 if ($objDefinition->isPlugin($obj_data[
"type"]))
346 "obj_".$obj_data[
"type"]);
350 $rbac_objects[$key][
"name"] = $this->lng->txt(
"obj_".$obj_data[
"type"]);
353 $rbac_objects[$key][
"ops"] = $rbac_operations[$key];
358 foreach ($rbac_objects as $key => $obj_data)
360 sort($rbac_objects[$key][
"ops"]);
367 foreach ($rbac_objects as $key => $obj_data)
369 $arr_selected = $rbacreview->getOperationsOfRole($this->object->getId(), $obj_data[
"type"],
$this->rolf_ref_id);
370 $arr_checked = array_intersect($arr_selected,array_keys($rbac_operations[$obj_data[
"obj_id"]]));
372 foreach ($rbac_operations[$obj_data[
"obj_id"]] as $operation)
374 $checked = in_array($operation[
"ops_id"],$arr_checked);
378 $box = ilUtil::formCheckBox($checked,
"template_perm[".$obj_data[
"type"].
"][]",$operation[
"ops_id"],$disabled);
379 $output[
"perm"][$obj_data[
"obj_id"]][$operation[
"ops_id"]] = $box;
384 $output[
"col_anz"] = count($rbac_objects);
385 $output[
"txt_save"] = $this->lng->txt(
"save");
386 $output[
"check_protected"] = ilUtil::formCheckBox($rbacreview->isProtected($this->rolf_ref_id,$this->object->getId()),
"protected",1);
387 $output[
"text_protected"] = $this->lng->txt(
"role_protect_permissions");
393 $output[
"message_middle"] = $this->lng->txt(
"adopt_perm_from_template");
396 if ($this->object->getId() == SYSTEM_ROLE_ID)
398 $output[
"adopt"] = array();
404 $parent_role_ids = $rbacreview->getParentRoleIds($this->rolf_ref_id,
true);
407 ksort($parent_role_ids);
409 foreach ($parent_role_ids as $key => $par)
411 if ($par[
"obj_id"] != SYSTEM_ROLE_ID)
415 $output[
"adopt"][$key][
"check_adopt"] = $radio;
416 $output[
"adopt"][$key][
"type"] = ($par[
"type"] ==
'role' ?
'Role' :
'Template');
417 $output[
"adopt"][$key][
"role_name"] = $par[
"title"];
421 $output[
"formaction_adopt"] = $this->ctrl->getFormAction($this);
425 $output[
"formaction"] =
426 $this->ctrl->getFormAction($this);
428 $this->data = $output;
435 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.adm_perm_role.html",
436 "Services/AccessControl");
438 foreach ($rbac_objects as $obj_data)
441 $this->tpl->setCurrentBlock(
"object_operations");
445 foreach ($obj_data[
"ops"] as $operation)
447 $ops_ids[] = $operation[
"ops_id"];
450 $this->tpl->setVariable(
"CSS_ROW",$css_row);
451 $this->tpl->setVariable(
"PERMISSION",$operation[
"name"]);
452 $this->tpl->setVariable(
"CHECK_PERMISSION",$this->data[
"perm"][$obj_data[
"obj_id"]][$operation[
"ops_id"]]);
453 $this->tpl->parseCurrentBlock();
457 $this->tpl->setCurrentBlock(
"object_type");
458 $this->tpl->setVariable(
"TXT_OBJ_TYPE",$obj_data[
"name"]);
461 if ($this->objDefinition->getDevMode($obj_data[
"type"]))
463 $this->tpl->setVariable(
"TXT_NOT_IMPL",
"(".$this->lng->txt(
"not_implemented_yet").
")");
467 $this->tpl->setVariable(
"JS_VARNAME",
"template_perm_".$obj_data[
"type"]);
469 $this->tpl->setVariable(
"TXT_CHECKALL", $this->lng->txt(
"check_all"));
470 $this->tpl->setVariable(
"TXT_UNCHECKALL", $this->lng->txt(
"uncheck_all"));
473 $this->tpl->parseCurrentBlock();
497 $this->tpl->setCurrentBlock(
"tblfooter_protected");
498 $this->tpl->setVariable(
"COL_ANZ",3);
499 $this->tpl->setVariable(
"CHECK_BOTTOM",$this->data[
"check_protected"]);
500 $this->tpl->setVariable(
"MESSAGE_TABLE",$this->data[
"text_protected"]);
501 $this->tpl->parseCurrentBlock();
503 $this->tpl->setVariable(
"COL_ANZ_PLUS",4);
504 $this->tpl->setVariable(
"TXT_SAVE",$this->data[
"txt_save"]);
505 $this->tpl->setCurrentBlock(
"adm_content");
506 $this->tpl->setVariable(
"TBL_TITLE_IMG",
ilUtil::getImagePath(
"icon_".$this->object->getType().
".svg"));
507 $this->tpl->setVariable(
"TBL_TITLE_IMG_ALT",$this->lng->txt($this->object->getType()));
510 if (substr($this->object->getTitle(),0,3) ==
"il_")
512 $desc = $this->lng->txt(
"predefined_template");
515 $description =
"<br/> <span class=\"small\">".$desc.
"</span>";
518 if (substr($this->object->getTitle(),0,3) ==
"il_")
520 include_once(
'./Services/AccessControl/classes/class.ilObjRole.php');
526 $title = $this->
object->getTitle();
529 $this->tpl->setVariable(
"TBL_TITLE",$title.$description);
531 $this->tpl->setVariable(
"TXT_PERMISSION",$this->data[
"txt_permission"]);
532 $this->tpl->setVariable(
"FORMACTION",$this->data[
"formaction"]);
533 $this->tpl->parseCurrentBlock();
546 if (!$rbacsystem->checkAccess(
'write',$this->rolf_ref_id))
548 $this->
ilias->raiseError($this->lng->txt(
"msg_no_perm_perm"),$this->
ilias->error_obj->WARNING);
555 foreach (
$_POST[
"template_perm"] as $key => $ops_array)
558 $rbacadmin->setRolePermission($this->object->getId(), $key,$ops_array,
$this->rolf_ref_id);
563 $this->
object->update();
567 #$rbacadmin->setProtected($this->rolf_ref_id,$this->object->getId(),ilUtil::tf2yn($_POST['protected'])); 571 $this->ctrl->redirect($this,
"perm");
581 global $rbacadmin, $rbacsystem, $rbacreview;
583 if (!$rbacsystem->checkAccess(
'write',$this->rolf_ref_id))
585 $this->
ilias->raiseError($this->lng->txt(
"msg_no_perm_perm"),$this->
ilias->error_obj->WARNING);
587 elseif ($this->obj_id ==
$_POST[
"adopt"])
593 $rbacadmin->deleteRolePermission($this->obj_id, $this->rolf_ref_id);
594 $parentRoles = $rbacreview->getParentRoleIds($this->rolf_ref_id,
true);
595 $rbacadmin->copyRoleTemplatePermissions(
$_POST[
"adopt"],$parentRoles[
$_POST[
"adopt"]][
"parent"],
596 $this->rolf_ref_id,$this->obj_id);
598 $this->
object->update();
601 $obj_data =& $this->
ilias->obj_factory->getInstanceByObjId($_POST[
"adopt"]);
602 ilUtil::sendSuccess($this->lng->txt(
"msg_perm_adopted_from1").
" '".$obj_data->getTitle().
"'.<br/>".$this->lng->txt(
"msg_perm_adopted_from2"),
true);
605 $this->ctrl->redirect($this,
"perm");
618 global $rbacsystem,$rbacreview;
620 if ($rbacsystem->checkAccess(
'write',$this->rolf_ref_id))
622 $tabs_gui->addTarget(
"settings",
623 $this->ctrl->getLinkTarget($this,
"edit"),
624 array(
"edit",
"update"), get_class($this));
626 $tabs_gui->addTarget(
"default_perm_settings",
627 $this->ctrl->getLinkTarget($this,
"perm"),
628 array(
"perm"), get_class($this));
639 $this->ctrl->redirectByClass(
"ilobjrolefoldergui",
"view");
653 parent::addAdminLocatorItems(
true);
657 $this->ctrl->getLinkTargetByClass(
"ilobjrolefoldergui",
"view"));
updateObject()
update role template object
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
setValue($a_value)
Set Value.
adoptPermSaveObject()
adopting permission setting from other roles/role templates
_getTranslation($a_role_title)
setValue($a_value)
Set Value.
static _getOperationList($a_type=null)
get operation list by object type public static
ilObjectGUI($a_data, $a_id=0, $a_call_by_reference=true, $a_prepare_output=true)
Constructor public.
static _lookupTitle($a_id)
lookup object title
createObject()
create new object form
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
saveObject()
save a new role template object
static lookupTxt($a_mod_prefix, $a_pl_id, $a_lang_var)
Lookup language text.
permObject()
display permissions
cancelObject()
cancelObject is called when an operation is canceled, method links back public
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
initFormRoleTemplate($a_mode=self::FORM_MODE_CREATE)
Init create form.
Class ilObjectGUI Basic methods of all Output classes.
static _lookupObjId($a_id)
This class represents a text property in a property form.
ilObjRoleTemplateGUI($a_data, $a_id, $a_call_by_reference)
Constructor.
redirection script todo: (a better solution should control the processing via a xml file) ...
getAdminTabs(&$tabs_gui)
admin and normal tabs are equal for roles
prepareOutput()
prepare output
static _lookupType($a_id, $a_reference=false)
lookup object type
static array_php2js($data)
convert php arrays to javascript arrays
static formRadioButton($checked, $varname, $value, $onclick=null, $disabled=false)
??? public
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
addAdminLocatorItems()
should be overwritten to add object specific items (repository items are preloaded) ...
This class represents a non editable value in a property form.
This class represents a text area property in a property form.
permSaveObject()
save permission templates of role
static switchColor($a_num, $a_css1, $a_css2)
switches style sheets for each even $a_num (used for changing colors of different result rows) ...
Class ilObjRoleTemplateGUI.
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
createObject(ilPropertyFormGUI $form=null)
create new role definition template
editObject(ilPropertyFormGUI $form=null)
Create new object.