• 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,$a_import_id = 0)
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 //echo "aaa-1-";
00143                 if ($a_import_id != "")
00144                 {
00145 //echo "aaa-2-".$a_import_id."-";
00146                         $roleObj->setImportId($a_import_id);
00147                 }
00148                 $roleObj->create();
00149                         
00150                 // ...and put the role into local role folder...
00151                 $rbacadmin->assignRoleToFolder($roleObj->getId(),$this->getRefId(),"y");
00152 
00153                 return $roleObj;
00154         }
00155         
00161         function purge()
00162         {
00163                 global $rbacreview, $rbacadmin, $tree;
00164 
00165                 $local_roles = $rbacreview->getRolesOfRoleFolder($this->getRefId());
00166                         
00167                 if (count($local_roles) == 0)
00168                 {
00169                         $rbacadmin->revokePermission($this->getRefId());
00170                         
00171                         if ($tree_id = $this->isDeleted())
00172                         {
00173                                 $deleted_tree = new ilTree ($tree_id,- (int) $tree_id);
00174                                 $deleted_tree->deleteTree($deleted_tree->getNodeData($this->getRefId()));                               
00175                         }
00176                         else
00177                         {
00178                                 $tree->deleteTree($tree->getNodeData($this->getRefId()));
00179                         }
00180 
00181                         $this->delete();
00182                         
00183                         return true;
00184                 }
00185                 
00186                 return false;
00187         }
00188         
00194         function isDeleted()
00195         {
00196                 $q = "SELECT tree FROM tree WHERE child='".$this->getRefId()."'";
00197                 $row = $this->ilias->db->getRow($q);
00198                 
00199                 if ($row->tree < 0)
00200                 {
00201                         return $row->tree;
00202                 }
00203                 
00204                 return false;
00205         }
00206 } // END class.ilObjRoleFolder
00207 ?>

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