• Main Page
  • Related Pages
  • Modules
  • 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 
00025 require_once "class.ilObject.php";
00026 
00035 class ilObjRoleFolder extends ilObject
00036 {
00043         function ilObjRoleFolder($a_id = 0,$a_call_by_reference = true)
00044         {
00045                 $this->type = "rolf";
00046                 $this->ilObject($a_id,$a_call_by_reference);
00047         }
00048         
00049         function read($a_force_db = false)
00050         {
00051                 parent::read();
00052                 
00053                 if ($this->getId() != ROLE_FOLDER_ID)
00054                 {
00055                         $this->setDescription($this->lng->txt("obj_".$this->getType()."_local_desc").$this->getTitle().$this->getDescription());
00056                         $this->setTitle($this->lng->txt("obj_".$this->getType()."_local"));
00057 
00058                 }
00059         }
00060 
00061 
00068         function delete()
00069         {               
00070                 // always call parent delete function first!!
00071                 if (!parent::delete())
00072                 {
00073                         return false;
00074                 }
00075 
00076                 // put here rolefolder specific stuff
00077                 global $rbacreview;
00078                 
00079                 $roles = $rbacreview->getRolesOfRoleFolder($this->getRefId());
00080                 
00081                 // FIRST DELETE ALL LOCAL/BASE ROLES OF FOLDER
00082                 foreach ($roles as $role_id)
00083                 {
00084                         $roleObj =& $this->ilias->obj_factory->getInstanceByObjId($role_id);
00085                         $roleObj->setParent($this->getRefId());
00086                         $roleObj->delete();
00087                         unset($roleObj);
00088                 }
00089                 
00090                 // always call parent delete function at the end!!
00091                 return true;
00092         }
00093 
00102         function createRole($a_title,$a_desc,$a_import_id = 0)
00103         {
00104                 global $rbacadmin, $rbacreview;
00105                 
00106                 include_once ("classes/class.ilObjRole.php");
00107                 $roleObj = new ilObjRole();
00108                 $roleObj->setTitle($a_title);
00109                 $roleObj->setDescription($a_desc);
00110 //echo "aaa-1-";
00111                 if ($a_import_id != "")
00112                 {
00113 //echo "aaa-2-".$a_import_id."-";
00114                         $roleObj->setImportId($a_import_id);
00115                 }
00116                 $roleObj->create();
00117                         
00118                 // ...and put the role into local role folder...
00119                 $rbacadmin->assignRoleToFolder($roleObj->getId(),$this->getRefId(),"y");
00120 
00121                 return $roleObj;
00122         }
00123         
00129         function purge()
00130         {
00131                 global $rbacreview, $rbacadmin, $tree;
00132 
00133                 $local_roles = $rbacreview->getRolesOfRoleFolder($this->getRefId());
00134                         
00135                 if (count($local_roles) == 0)
00136                 {
00137                         $rbacadmin->revokePermission($this->getRefId());
00138                         
00139                         if ($tree_id = $this->isDeleted())
00140                         {
00141                                 $deleted_tree = new ilTree ($tree_id,- (int) $tree_id);
00142                                 $deleted_tree->deleteTree($deleted_tree->getNodeData($this->getRefId()));                               
00143                         }
00144                         else
00145                         {
00146                                 $tree->deleteTree($tree->getNodeData($this->getRefId()));
00147                         }
00148 
00149                         $this->delete();
00150                         
00151                         return true;
00152                 }
00153                 
00154                 return false;
00155         }
00156         
00162         function isDeleted()
00163         {
00164                 $q = "SELECT tree FROM tree WHERE child= ".$this->ilias->db->quote($this->getRefId())." ";
00165                 $row = $this->ilias->db->getRow($q);
00166                 
00167                 if ($row->tree < 0)
00168                 {
00169                         return $row->tree;
00170                 }
00171                 
00172                 return false;
00173         }
00174 } // END class.ilObjRoleFolder
00175 ?>

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