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

classes/class.ilObjRoleFolder.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 
00035 require_once "class.ilObject.php";
00036 
00037 class ilObjRoleFolder extends ilObject
00038 {
00045         function ilObjRoleFolder($a_id = 0,$a_call_by_reference = true)
00046         {
00047                 $this->type = "rolf";
00048                 $this->ilObject($a_id,$a_call_by_reference);
00049         }
00050         
00051         function read($a_force_db = false)
00052         {
00053                 parent::read();
00054                 
00055                 if ($this->getId() != ROLE_FOLDER_ID)
00056                 {
00057                         $this->setDescription($this->lng->txt("obj_".$this->getType()."_local_desc").$this->getTitle().$this->getDescription());
00058                         $this->setTitle($this->lng->txt("obj_".$this->getType()."_local"));
00059 
00060                 }
00061         }
00062 
00069         function ilClone($a_parent_ref)
00070         {               
00071                 // DISABLED
00072                 // DO NOTHING ROLE FOLDERS AREN'T COPIED
00073                 //      $new_ref_id = parent::ilClone($a_parent_ref);
00074                 return false;
00075 
00076                 global $rbacadmin;
00077 
00078                 // always call parent ilClone function first!!
00079                 $new_ref_id = parent::ilClone($a_parent_ref);
00080                 
00081                 // put here rolefolder specific stuff
00082 
00083                 // ... and finally always return new reference ID!!
00084                 return $new_ref_id;
00085         }
00086 
00093         function delete()
00094         {               
00095                 // always call parent delete function first!!
00096                 if (!parent::delete())
00097                 {
00098                         return false;
00099                 }
00100 
00101                 // put here rolefolder specific stuff
00102                 global $rbacreview;
00103                 
00104                 $roles = $rbacreview->getRolesOfRoleFolder($this->getRefId());
00105                 
00106                 // FIRST DELETE ALL LOCAL/BASE ROLES OF FOLDER
00107                 foreach ($roles as $role_id)
00108                 {
00109                         $roleObj =& $this->ilias->obj_factory->getInstanceByObjId($role_id);
00110                         $roleObj->setParent($this->getRefId());
00111                         $roleObj->delete();
00112                         unset($roleObj);
00113                 }
00114                 
00115                 // always call parent delete function at the end!!
00116                 return true;
00117         }
00118 
00127         function createRole($a_title,$a_desc)
00128         {
00129                 global $rbacadmin, $rbacreview;
00130                 
00131                 // check if role title is unique
00132                 if ($rbacreview->roleExists($a_title))
00133                 {
00134                         $this->ilias->raiseError($this->lng->txt("msg_role_exists1")." '".ilUtil::stripSlashes($a_title)."' ".
00135                                                                          $this->lng->txt("msg_role_exists2"),$this->ilias->error_obj->MESSAGE);
00136                 }               
00137 
00138                 include_once ("classes/class.ilObjRole.php");
00139                 $roleObj = new ilObjRole();
00140                 $roleObj->setTitle($a_title);
00141                 $roleObj->setDescription($a_desc);
00142                 $roleObj->create();
00143                         
00144                 // ...and put the role into local role folder...
00145                 $rbacadmin->assignRoleToFolder($roleObj->getId(),$this->getRefId(),"y");
00146 
00147                 return $roleObj;
00148         }
00149         
00155         function purge()
00156         {
00157                 global $rbacreview, $rbacadmin, $tree;
00158 
00159                 $local_roles = $rbacreview->getRolesOfRoleFolder($this->getRefId());
00160                         
00161                 if (count($local_roles) == 0)
00162                 {
00163                         $rbacadmin->revokePermission($this->getRefId());
00164                         
00165                         if ($tree_id = $this->isDeleted())
00166                         {
00167                                 $deleted_tree = new ilTree ($tree_id,- (int) $tree_id);
00168                                 $deleted_tree->deleteTree($deleted_tree->getNodeData($this->getRefId()));                               
00169                         }
00170                         else
00171                         {
00172                                 $tree->deleteTree($tree->getNodeData($this->getRefId()));
00173                         }
00174 
00175                         $this->delete();
00176                         
00177                         return true;
00178                 }
00179                 
00180                 return false;
00181         }
00182         
00188         function isDeleted()
00189         {
00190                 $q = "SELECT tree FROM tree WHERE child='".$this->getRefId()."'";
00191                 $row = $this->ilias->db->getRow($q);
00192                 
00193                 if ($row->tree < 0)
00194                 {
00195                         return $row->tree;
00196                 }
00197                 
00198                 return false;
00199         }
00200 } // END class.ilObjRoleFolder
00201 ?>

Generated on Fri Dec 13 2013 09:06:34 for ILIAS Release_3_4_x_branch .rev 46804 by  doxygen 1.7.1