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

Generated on Fri Dec 13 2013 11:57:55 for ILIAS Release_3_6_x_branch .rev 46809 by  doxygen 1.7.1