• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

classes/class.ilObjRoleTemplateGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 require_once "class.ilObjectGUI.php";
00025 
00036 class ilObjRoleTemplateGUI extends ilObjectGUI
00037 {
00043         var $type;
00044 
00050         var $rolf_ref_id;
00056         function ilObjRoleTemplateGUI($a_data,$a_id,$a_call_by_reference)
00057         {
00058                 global $lng;
00059                 
00060                 $lng->loadLanguageModule('rbac');
00061                 
00062                 $this->type = "rolt";
00063                 $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,false);
00064                 $this->rolf_ref_id =& $this->ref_id;
00065                 $this->ctrl->saveParameter($this, "obj_id");
00066         }
00067         
00068         function &executeCommand()
00069         {
00070                 global $rbacsystem;
00071 
00072                 if($this->ctrl->getTargetScript() == 'role.php')
00073                 {
00074                         $this->__prepareOutput();
00075                 }
00076                 else
00077                 {
00078                         $this->prepareOutput();
00079                 }
00080 
00081                 $next_class = $this->ctrl->getNextClass($this);
00082                 $cmd = $this->ctrl->getCmd();
00083 
00084                 switch($next_class)
00085                 {
00086                         default:
00087                                 if(!$cmd)
00088                                 {
00089                                         $cmd = "perm";
00090                                 }
00091                                 $cmd .= "Object";
00092                                 $this->$cmd();
00093                                         
00094                                 break;
00095                 }
00096 
00097                 return true;
00098         }
00099 
00100         
00106         function createObject()
00107         {
00108                 global $rbacsystem;
00109 
00110                 if (!$rbacsystem->checkAccess("create_rolt", $this->rolf_ref_id))
00111                 {
00112                         $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00113                 }
00114                 else
00115                 {
00116                         // fill in saved values in case of error
00117                         $data = array();
00118                         $data["fields"] = array();
00119                         $data["fields"]["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
00120                         $data["fields"]["desc"] = ilUtil::stripSlashes($_SESSION["error_post_vars"]["Fobject"]["desc"]);
00121 
00122                         $this->getTemplateFile("edit","role");
00123 
00124                         foreach ($data["fields"] as $key => $val)
00125                         {
00126                                 $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
00127                                 $this->tpl->setVariable(strtoupper($key), $val);
00128 
00129                                 if ($this->prepare_output)
00130                                 {
00131                                         $this->tpl->parseCurrentBlock();
00132                                 }
00133                         }
00134                         
00135                         $this->tpl->setCurrentBlock("protect_permissions");
00136                         $protect_permissions = $_SESSION["error_post_vars"]["Fobject"]["protect_permissions"] ? "checked=\"checked\"" : "";
00137                         $this->tpl->setVariable("TXT_PROTECT_PERMISSIONS",$this->lng->txt("role_protect_permissions"));
00138                         $this->tpl->setVariable("PROTECT_PERMISSIONS",$protect_permissions);
00139                         $this->tpl->parseCurrentBlock();
00140 
00141                         $this->ctrl->setParameter($this, "new_type", $this->type);
00142                         $this->tpl->setVariable("FORMACTION",
00143                                 $this->ctrl->getFormAction($this));
00144                         $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($this->type."_new"));
00145                         $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00146                         $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($this->type."_add"));
00147                         $this->tpl->setVariable("CMD_SUBMIT", "save");
00148                         $this->tpl->setVariable("TARGET", $this->getTargetFrame("save"));
00149                         $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00150                 }
00151         }
00152 
00153 
00159         function saveObject()
00160         {
00161                 global $rbacsystem,$rbacadmin, $rbacreview;
00162 
00163                 // CHECK ACCESS 'write' to role folder
00164                 // TODO: check for create role permission should be better
00165                 if (!$rbacsystem->checkAccess("create_rolt",$this->rolf_ref_id))
00166                 {
00167                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_create_rolt"),$this->ilias->error_obj->WARNING);
00168                 }
00169 
00170                 // check required fields
00171                 if (empty($_POST["Fobject"]["title"]))
00172                 {
00173                         $this->ilias->raiseError($this->lng->txt("fill_out_all_required_fields"),$this->ilias->error_obj->MESSAGE);
00174                 }
00175 
00176                 // check if role title has il_ prefix
00177                 if (substr($_POST["Fobject"]["title"],0,3) == "il_")
00178                 {
00179                         $this->ilias->raiseError($this->lng->txt("msg_role_reserved_prefix"),$this->ilias->error_obj->MESSAGE);
00180                 }
00181 
00182                 // create new rolt object
00183                 include_once("./classes/class.ilObjRoleTemplate.php");
00184                 $roltObj = new ilObjRoleTemplate();
00185                 $roltObj->setTitle(ilUtil::stripSlashes($_POST["Fobject"]["title"]));
00186                 $roltObj->setDescription(ilUtil::stripSlashes($_POST["Fobject"]["desc"]));
00187                 $roltObj->create();
00188                 $rbacadmin->assignRoleToFolder($roltObj->getId(), $this->rolf_ref_id,'n');
00189                 $rbacadmin->setProtected($this->rolf_ref_id,$roltObj->getId(),ilUtil::tf2yn($_POST["Fobject"]["protect_permissions"])); 
00190                 
00191                 ilUtil::sendInfo($this->lng->txt("rolt_added"),true);
00192                 $this->ctrl->returnToParent($this);
00193         }
00194 
00200         function permObject()
00201         {
00202                 global $rbacadmin, $rbacreview, $rbacsystem,$objDefinition;
00203 
00204                 if (!$rbacsystem->checkAccess('write',$this->rolf_ref_id))
00205                 {
00206                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_perm"),$this->ilias->error_obj->WARNING);
00207                         exit();
00208                 }
00209 
00210                 $to_filter = $objDefinition->getSubobjectsToFilter();
00211                 
00212                 $tpl_filter = array();
00213                 $internal_tpl = false;
00214 
00215                 if (($internal_tpl = $this->object->isInternalTemplate()))
00216                 {
00217                         $tpl_filter = $this->object->getFilterOfInternalTemplate();
00218                 }
00219 
00220                 // build array with all rbac object types
00221                 $q = "SELECT ta.typ_id,obj.title,ops.ops_id,ops.operation FROM rbac_ta AS ta ".
00222                          "LEFT JOIN object_data AS obj ON obj.obj_id=ta.typ_id ".
00223                          "LEFT JOIN rbac_operations AS ops ON ops.ops_id=ta.ops_id";
00224                 $r = $this->ilias->db->query($q);
00225 
00226                 while ($row = $r->fetchRow(DB_FETCHMODE_OBJECT))
00227                 {
00228                         if($objDefinition->getDevMode($row->title))
00229                         {
00230                                 continue;
00231                         }
00232                         // FILTER SUBOJECTS OF adm OBJECT
00233                         if(in_array($row->title,$to_filter))
00234                         {
00235                                 continue;
00236                         }
00237 
00238                         if ($internal_tpl and !in_array($row->title,$tpl_filter))
00239                         {
00240                                 continue;
00241                         }
00242                                 
00243                         $rbac_objects[$row->typ_id] = array("obj_id"    => $row->typ_id,
00244                                                                                             "type"              => $row->title
00245                                                                                                 );
00246 
00247                         $rbac_operations[$row->typ_id][$row->ops_id] = array(
00248                                                                                                                                 "ops_id"        => $row->ops_id,
00249                                                                                                                                 "title"         => $row->operation,
00250                                                                                                                                 "name"          => $this->lng->txt($row->title."_".$row->operation)
00251                                                                                                                            );
00252                 }
00253 
00254                 foreach ($rbac_objects as $key => $obj_data)
00255                 {
00256                         $rbac_objects[$key]["name"] = $this->lng->txt("obj_".$obj_data["type"]);
00257                         $rbac_objects[$key]["ops"] = $rbac_operations[$key];
00258                 }
00259 
00260                 sort($rbac_objects);
00261                         
00262                 foreach ($rbac_objects as $key => $obj_data)
00263                 {
00264                         sort($rbac_objects[$key]["ops"]);
00265                 }
00266                 
00267                 // sort by (translated) name of object type
00268                 $rbac_objects = ilUtil::sortArray($rbac_objects,"name","asc");
00269 
00270                 // BEGIN CHECK_PERM
00271                 foreach ($rbac_objects as $key => $obj_data)
00272                 {
00273                         $arr_selected = $rbacreview->getOperationsOfRole($this->object->getId(), $obj_data["type"], $this->rolf_ref_id);
00274                         $arr_checked = array_intersect($arr_selected,array_keys($rbac_operations[$obj_data["obj_id"]]));
00275 
00276                         foreach ($rbac_operations[$obj_data["obj_id"]] as $operation)
00277                         {
00278                                 $checked = in_array($operation["ops_id"],$arr_checked);
00279                                 $disabled = false;
00280 
00281                                 // Es wird eine 2-dim Post Variable �bergeben: perm[rol_id][ops_id]
00282                                 $box = ilUtil::formCheckBox($checked,"template_perm[".$obj_data["type"]."][]",$operation["ops_id"],$disabled);
00283                                 $output["perm"][$obj_data["obj_id"]][$operation["ops_id"]] = $box;
00284                         }
00285                 }
00286                 // END CHECK_PERM
00287 
00288                 $output["col_anz"] = count($rbac_objects);
00289                 $output["txt_save"] = $this->lng->txt("save");
00290                 $output["check_protected"] = ilUtil::formCheckBox($rbacreview->isProtected($this->rolf_ref_id,$this->object->getId()),"protected",1);
00291                 $output["text_protected"] = $this->lng->txt("role_protect_permissions");
00292 
00293 /************************************/
00294 /*              adopt permissions form          */
00295 /************************************/
00296 
00297                 $output["message_middle"] = $this->lng->txt("adopt_perm_from_template");
00298 
00299                 // send message for system role
00300                 if ($this->object->getId() == SYSTEM_ROLE_ID)
00301                 {
00302                         $output["adopt"] = array();
00303                         ilUtil::sendInfo($this->lng->txt("msg_sysrole_not_editable"));
00304                 }
00305                 else
00306                 {
00307                         // BEGIN ADOPT_PERMISSIONS
00308                         $parent_role_ids = $rbacreview->getParentRoleIds($this->rolf_ref_id,true);
00309 
00310                         // sort output for correct color changing
00311                         ksort($parent_role_ids);
00312 
00313                         foreach ($parent_role_ids as $key => $par)
00314                         {
00315                                 if ($par["obj_id"] != SYSTEM_ROLE_ID)
00316                                 {
00317                                         $radio = ilUtil::formRadioButton(0,"adopt",$par["obj_id"]);
00318                                         $output["adopt"][$key]["css_row_adopt"] = ilUtil::switchColor($key, "tblrow1", "tblrow2");
00319                                         $output["adopt"][$key]["check_adopt"] = $radio;
00320                                         $output["adopt"][$key]["type"] = ($par["type"] == 'role' ? 'Role' : 'Template');
00321                                         $output["adopt"][$key]["role_name"] = $par["title"];
00322                                 }
00323                         }
00324 
00325                         $output["formaction_adopt"] = $this->ctrl->getFormAction($this);
00326                         // END ADOPT_PERMISSIONS
00327                 }
00328 
00329                 $output["formaction"] =
00330                         $this->ctrl->getFormAction($this);
00331 
00332                 $this->data = $output;
00333 
00334 
00335 /************************************/
00336 /*                      generate output                 */
00337 /************************************/
00338 
00339                 $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
00340                 $this->tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html");
00341                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.adm_perm_role.html");
00342 
00343                 foreach ($rbac_objects as $obj_data)
00344                 {
00345                         // BEGIN object_operations
00346                         $this->tpl->setCurrentBlock("object_operations");
00347         
00348                         foreach ($obj_data["ops"] as $operation)
00349                         {
00350                                 $ops_ids[] = $operation["ops_id"];
00351                                 
00352                                 $css_row = ilUtil::switchColor($key, "tblrow1", "tblrow2");
00353                                 $this->tpl->setVariable("CSS_ROW",$css_row);
00354                                 $this->tpl->setVariable("PERMISSION",$operation["name"]);
00355                                 $this->tpl->setVariable("CHECK_PERMISSION",$this->data["perm"][$obj_data["obj_id"]][$operation["ops_id"]]);
00356                                 $this->tpl->parseCurrentBlock();
00357                         } // END object_operations
00358                         
00359                         // BEGIN object_type
00360                         $this->tpl->setCurrentBlock("object_type");
00361                         $this->tpl->setVariable("TXT_OBJ_TYPE",$obj_data["name"]);
00362                         
00363 // TODO: move this if in a function and query all objects that may be disabled or inactive
00364                         if ($this->objDefinition->getDevMode($obj_data["type"]))
00365                         {
00366                                 $this->tpl->setVariable("TXT_NOT_IMPL", "(".$this->lng->txt("not_implemented_yet").")");
00367                         }
00368                         else if ($obj_data["type"] == "icrs" and !$this->ilias->getSetting("ilinc_active"))
00369                         {
00370                                 $this->tpl->setVariable("TXT_NOT_IMPL", "(".$this->lng->txt("not_enabled_or_configured").")");
00371                         }
00372                         
00373                         // js checkbox toggles
00374                         $this->tpl->setVariable("JS_VARNAME","template_perm_".$obj_data["type"]);
00375                         $this->tpl->setVariable("JS_ONCLICK",ilUtil::array_php2js($ops_ids));
00376                         $this->tpl->setVariable("TXT_CHECKALL", $this->lng->txt("check_all"));
00377                         $this->tpl->setVariable("TXT_UNCHECKALL", $this->lng->txt("uncheck_all"));      
00378 
00379 
00380                         $this->tpl->parseCurrentBlock();
00381                         // END object_type
00382                 }
00383 
00384                 // BEGIN ADOPT PERMISSIONS
00385                 foreach ($this->data["adopt"] as $key => $value)
00386                 {
00387                         $this->tpl->setCurrentBlock("ADOPT_PERM_ROW");
00388                         $this->tpl->setVariable("CSS_ROW_ADOPT",$value["css_row_adopt"]);
00389                         $this->tpl->setVariable("CHECK_ADOPT",$value["check_adopt"]);
00390                         $this->tpl->setVariable("TYPE",$value["type"]);
00391                         $this->tpl->setVariable("ROLE_NAME",$value["role_name"]);
00392                         $this->tpl->parseCurrentBlock();
00393                 }
00394                         
00395                 $this->tpl->setCurrentBlock("ADOPT_PERM_FORM");
00396                 $this->tpl->setVariable("MESSAGE_MIDDLE",$this->data["message_middle"]);
00397                 $this->tpl->setVariable("FORMACTION_ADOPT",$this->data["formaction_adopt"]);
00398                 $this->tpl->setVariable("ADOPT",$this->lng->txt('copy'));
00399                 $this->tpl->parseCurrentBlock();
00400                 // END ADOPT PERMISSIONS
00401                 
00402                 $this->tpl->setCurrentBlock("tblfooter_protected");
00403                 $this->tpl->setVariable("COL_ANZ",3);
00404                 $this->tpl->setVariable("CHECK_BOTTOM",$this->data["check_protected"]);
00405                 $this->tpl->setVariable("MESSAGE_TABLE",$this->data["text_protected"]);
00406                 $this->tpl->parseCurrentBlock();
00407         
00408                 $this->tpl->setCurrentBlock("tblfooter_standard");
00409                 $this->tpl->setVariable("COL_ANZ_PLUS",4);
00410                 $this->tpl->setVariable("TXT_SAVE",$this->data["txt_save"]);
00411                 $this->tpl->parseCurrentBlock();
00412 
00413                 
00414                 $this->tpl->setCurrentBlock("adm_content");
00415                 $this->tpl->setVariable("TBL_TITLE_IMG",ilUtil::getImagePath("icon_".$this->object->getType().".gif"));
00416                 $this->tpl->setVariable("TBL_TITLE_IMG_ALT",$this->lng->txt($this->object->getType()));
00417                 $this->tpl->setVariable("TBL_HELP_IMG",ilUtil::getImagePath("icon_help.gif"));
00418                 $this->tpl->setVariable("TBL_HELP_LINK","tbl_help.php");
00419                 $this->tpl->setVariable("TBL_HELP_IMG_ALT",$this->lng->txt("help"));
00420 
00421                 // compute additional information in title
00422                 if (substr($this->object->getTitle(),0,3) == "il_")
00423                 {
00424                         $desc = $this->lng->txt("predefined_template");//$this->lng->txt("obj_".$parent_node['type'])." (".$parent_node['obj_id'].") : ".$parent_node['title'];
00425                 }
00426                 
00427                 $description = "<br/>&nbsp;<span class=\"small\">".$desc."</span>";
00428 
00429                 // translation for autogenerated roles
00430                 if (substr($this->object->getTitle(),0,3) == "il_")
00431                 {
00432                         include_once('class.ilObjRole.php');
00433 
00434                         $title = ilObjRole::_getTranslation($this->object->getTitle())." (".$this->object->getTitle().")";
00435                 }
00436                 else
00437                 {
00438                         $title = $this->object->getTitle();
00439                 }
00440 
00441                 $this->tpl->setVariable("TBL_TITLE",$title.$description);
00442                         
00443                 $this->tpl->setVariable("TXT_PERMISSION",$this->data["txt_permission"]);
00444                 $this->tpl->setVariable("FORMACTION",$this->data["formaction"]);
00445                 $this->tpl->parseCurrentBlock();
00446         }
00447 
00448 
00454         function permSaveObject()
00455         {
00456                 global $rbacadmin, $rbacsystem, $rbacreview,$objDefinition;
00457 
00458                 if (!$rbacsystem->checkAccess('write',$this->rolf_ref_id))
00459                 {
00460                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_perm"),$this->ilias->error_obj->WARNING);
00461                 }
00462                 else
00463                 {
00464                         // Alle Template Eintraege loeschen
00465                         $rbacadmin->deleteRolePermission($this->object->getId(), $this->rolf_ref_id);
00466 
00467                         foreach ($_POST["template_perm"] as $key => $ops_array)
00468                         {
00469                                 // Setzen der neuen template permissions
00470                                 $rbacadmin->setRolePermission($this->object->getId(), $key,$ops_array,$this->rolf_ref_id);
00471                         }
00472                 }
00473                 
00474                 // update object data entry (to update last modification date)
00475                 $this->object->update();
00476                 
00477                 // set protected flag
00478                 $rbacadmin->setProtected($this->rolf_ref_id,$this->object->getId(),ilUtil::tf2yn($_POST['protected']));
00479 
00480                 ilUtil::sendInfo($this->lng->txt("saved_successfully"),true);
00481 
00482                 $this->ctrl->redirect($this, "perm");
00483         }
00484 
00490         function adoptPermSaveObject()
00491         {
00492                 global $rbacadmin, $rbacsystem, $rbacreview;
00493 
00494                 if (!$rbacsystem->checkAccess('write',$this->rolf_ref_id))
00495                 {
00496                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_perm"),$this->ilias->error_obj->WARNING);
00497                 }
00498                 elseif ($this->obj_id == $_POST["adopt"])
00499                 {
00500                         ilUtil::sendInfo($this->lng->txt("msg_perm_adopted_from_itself"),true);
00501                 }
00502                 else
00503                 {
00504                         $rbacadmin->deleteRolePermission($this->obj_id, $this->rolf_ref_id);
00505                         $parentRoles = $rbacreview->getParentRoleIds($this->rolf_ref_id,true);
00506                         $rbacadmin->copyRoleTemplatePermissions($_POST["adopt"],$parentRoles[$_POST["adopt"]]["parent"],
00507                                                                                    $this->rolf_ref_id,$this->obj_id);           
00508                         // update object data entry (to update last modification date)
00509                         $this->object->update();
00510 
00511                         // send info
00512                         $obj_data =& $this->ilias->obj_factory->getInstanceByObjId($_POST["adopt"]);
00513                         ilUtil::sendInfo($this->lng->txt("msg_perm_adopted_from1")." '".$obj_data->getTitle()."'.<br/>".$this->lng->txt("msg_perm_adopted_from2"),true);
00514                 }
00515 
00516                 $this->ctrl->redirect($this, "perm");
00517         }
00518 
00524         function editObject()
00525         {
00526                 global $rbacsystem, $rbacreview;
00527 
00528                 if (!$rbacsystem->checkAccess("write", $this->rolf_ref_id))
00529                 {
00530                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
00531                 }
00532 
00533                 $this->getTemplateFile("edit","role");
00534 
00535                 if ($_SESSION["error_post_vars"])
00536                 {
00537                         // fill in saved values in case of error
00538                         if (substr($this->object->getTitle(),0,3) != "il_")
00539                         {
00540                                 $this->tpl->setVariable("TITLE",ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"]),true);
00541                         }
00542                 
00543                         $this->tpl->setVariable("DESC",ilUtil::stripSlashes($_SESSION["error_post_vars"]["Fobject"]["desc"]));
00544                         $protect_permissions = ($_SESSION["error_post_vars"]["Fobject"]["protect_permissions"]) ? "checked=\"checked\"" : "";
00545                 }
00546                 else
00547                 {
00548                         if (substr($this->object->getTitle(),0,3) != "il_")
00549                         {
00550                                 $this->tpl->setVariable("TITLE",ilUtil::prepareFormOutput($this->object->getTitle()));
00551                         }
00552 
00553                         $this->tpl->setVariable("DESC",ilUtil::stripSlashes($this->object->getDescription()));
00554                         $protect_permissions = $rbacreview->isProtected($this->rolf_ref_id,$this->object->getId()) ? "checked=\"checked\"" : "";
00555                 }
00556 
00557                 $obj_str = "&obj_id=".$this->obj_id;
00558 
00559                 $this->tpl->setVariable("TXT_TITLE",$this->lng->txt("title"));
00560                 $this->tpl->setVariable("TXT_DESC",$this->lng->txt("desc"));
00561                 
00562                 $this->tpl->setCurrentBlock("protect_permissions");
00563                 $this->tpl->setVariable("TXT_PROTECT_PERMISSIONS",$this->lng->txt('role_protect_permissions'));
00564                 $this->tpl->setVariable("PROTECT_PERMISSIONS",$protect_permissions);
00565                 $this->tpl->parseCurrentBlock();
00566                 
00567                 $this->tpl->setVariable("FORMACTION",
00568                         $this->ctrl->getFormAction($this));
00569                 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($this->object->getType()."_edit"));
00570                 $this->tpl->setVariable("TARGET", $this->getTargetFrame("update"));
00571                 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00572                 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
00573                 $this->tpl->setVariable("CMD_SUBMIT", "update");
00574                 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00575                 
00576                 if (substr($this->object->getTitle(),0,3) == "il_")
00577                 {
00578                         $this->tpl->setVariable("SHOW_TITLE",$this->object->getTitle());
00579                 }
00580         }
00581         
00585         function getAdminTabs(&$tabs_gui)
00586         {
00587                 $this->getTabs($tabs_gui);
00588         }
00589         
00590         function getTabs(&$tabs_gui)
00591         {
00592                 global $rbacsystem,$rbacreview;
00593 
00594                 if ($rbacsystem->checkAccess('write',$this->rolf_ref_id))
00595                 {
00596                         $tabs_gui->addTarget("edit_properties",
00597                                 $this->ctrl->getLinkTarget($this, "edit"),
00598                                 array("edit","update"), get_class($this));
00599                                 
00600                         $tabs_gui->addTarget("default_perm_settings",
00601                                 $this->ctrl->getLinkTarget($this, "perm"),
00602                                 array("perm"), get_class($this));
00603                 }
00604         }
00605 
00606         
00611         function cancelObject()
00612         {
00613                 ilUtil::sendInfo($this->lng->txt("action_aborted"),true);
00614                 
00615                 $this->ctrl->redirectByClass("ilobjrolefoldergui","view");
00616         }
00617 
00618 
00619 
00625         function updateObject()
00626         {
00627                 global $rbacsystem, $rbacadmin, $rbacreview;
00628 
00629                 // check write access
00630                 if (!$rbacsystem->checkAccess("write", $this->rolf_ref_id))
00631                 {
00632                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_rolt"),$this->ilias->error_obj->WARNING);
00633                 }
00634                 
00635                 if (substr($this->object->getTitle(),0,3) != "il_")
00636                 {
00637                         // check required fields
00638                         if (empty($_POST["Fobject"]["title"]))
00639                         {
00640                                 $this->ilias->raiseError($this->lng->txt("fill_out_all_required_fields"),$this->ilias->error_obj->MESSAGE);
00641                         }
00642                         
00643                         // check if role title has il_ prefix
00644                         if (substr($_POST["Fobject"]["title"],0,3) == "il_")
00645                         {
00646                                 $this->ilias->raiseError($this->lng->txt("msg_role_reserved_prefix"),$this->ilias->error_obj->MESSAGE);
00647                         }
00648         
00649                         // update
00650                         $this->object->setTitle(ilUtil::stripSlashes($_POST["Fobject"]["title"]));
00651                 }
00652 
00653                 $this->object->setDescription(ilUtil::stripSlashes($_POST["Fobject"]["desc"]));
00654                 $rbacadmin->setProtected($this->rolf_ref_id,$this->object->getId(),ilUtil::tf2yn($_POST["Fobject"]["protect_permissions"]));    
00655                 $this->object->update();
00656                 
00657                 ilUtil::sendInfo($this->lng->txt("saved_successfully"),true);
00658 
00659                 $this->ctrl->returnToParent($this);
00660         }
00661         
00666         function addAdminLocatorItems()
00667         {
00668                 global $ilLocator;
00669 
00670                 if ($_GET["admin_mode"] == "settings")  // system settings
00671                 {               
00672                         $ilLocator->addItem($this->lng->txt("administration"),
00673                                 $this->ctrl->getLinkTargetByClass("iladministrationgui", "frameset"),
00674                                 ilFrameTargetInfo::_getFrame("MainContent"));
00675                                 
00676                         $ilLocator->addItem(ilObject::_lookupTitle(
00677                                 ilObject::_lookupObjId($_GET["ref_id"])),
00678                                 $this->ctrl->getLinkTargetByClass("ilobjrolefoldergui", "view"));
00679 
00680                         $ilLocator->addItem($this->object->getTitle(),
00681                                 $this->ctrl->getLinkTarget($this, "perm"));
00682                 }
00683                 else                                                    // repository administration
00684                 {
00685                         //?
00686                 }
00687 
00688         }
00689         
00690         function showUpperIcon()
00691         {
00692                 global $tree, $tpl, $objDefinition;
00693                 
00694                 if (strtolower($_GET["baseClass"]) == "iladministrationgui")
00695                 {
00696                                 $tpl->setUpperIcon(
00697                                         $this->ctrl->getLinkTargetByClass("ilobjrolefoldergui", "view"));
00698                 }
00699                 else
00700                 {               
00701                         if ($this->object->getRefId() != ROOT_FOLDER_ID &&
00702                                 $this->object->getRefId() != SYSTEM_FOLDER_ID)
00703                         {
00704                                 $par_id = $tree->getParentId($this->object->getRefId());
00705                                 $tpl->setUpperIcon("repository.php?ref_id=".$par_id);
00706                         }
00707                 }
00708         }
00709 
00710 
00711 } // END class.ilObjRoleTemplateGUI
00712 ?>

Generated on Fri Dec 13 2013 17:56:48 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1