[ Index ] |
|
Code source de LifeType 1.2.4 |
1 <?php 2 3 lt_include( PLOG_CLASS_PATH."class/dao/model.class.php" ); 4 lt_include( PLOG_CLASS_PATH."class/dao/permission.class.php" ); 5 lt_include( PLOG_CLASS_PATH."class/dao/daocacheconstants.properties.php" ); 6 7 /** 8 * \ingroup DAO 9 * 10 * Model class that manages the 'permissions' table 11 */ 12 class Permissions extends Model 13 { 14 15 function Permissions() 16 { 17 $this->Model(); 18 $this->table = $this->getPrefix()."permissions"; 19 } 20 21 /** 22 * Add a new permission 23 * 24 * @param perm A Permission object 25 * @return True if successful or false otherwise 26 */ 27 function addPermission( &$perm ) 28 { 29 if( ($result = $this->add( $perm, Array( CACHE_PERMISSIONS => "getId" )))) { 30 $this->_cache->removeData( "_all_", CACHE_PERMISSIONS_ALL ); 31 } 32 33 return( $result ); 34 } 35 36 /** 37 * Update a permission 38 * 39 * @param perm 40 * @return True if successful or false otherwise 41 */ 42 function updatePermission( &$perm ) 43 { 44 if( ($result = $this->update( $perm ))) { 45 $this->_cache->removeData( $perm->getId(), CACHE_PERMISSIONS ); 46 $this->_cache->removeData( "_all_", CACHE_PERMISSIONS_ALL ); 47 } 48 49 return( $result ); 50 } 51 52 /** 53 * Retrieve a permission given its id 54 * 55 * @param id The id of the permission 56 * @return A Permission object if successful or false otherwise 57 */ 58 function getPermission( $id ) 59 { 60 return( $this->get( "id", $id, CACHE_PERMISSIONS )); 61 } 62 63 /** 64 * Retrieve a permission given its name 65 * 66 * @param name The name of the permission 67 * @return A Permission object if successful or false otherwise 68 */ 69 function getPermissionByName( $name ) 70 { 71 $perms = $this->getAllPermissions(); 72 foreach( $perms as $perm ) { 73 if( $perm->getName() == $name ) { 74 return( $perm ); 75 } 76 } 77 78 return( false ); 79 } 80 81 /** 82 * Deletes a permission given its id 83 * 84 * @param id The id of the permission 85 * @return True if successful or false otherwise 86 */ 87 function deletePermission( $id ) 88 { 89 if( ($result = $this->delete( "id", $id ))) { 90 $this->_cache->removeData( $id, CACHE_PERMISSIONS ); 91 $this->_cache->removeData( "_all_", CACHE_PERMISSIONS_ALL ); 92 } 93 94 return( $result ); 95 } 96 97 /** 98 * Loads all permissions from the database 99 * 100 * @return An array of Permission objects, or an empty array if no 101 * permissions were found 102 */ 103 function getAllPermissions() 104 { 105 $permissions = $this->getAll( "all", 106 CACHE_PERMISSIONS_ALL, 107 Array( CACHE_PERMISSIONS => "getId" ), 108 Array( "permission" => "ASC" )); 109 if( !$permissions ) 110 return( Array()); 111 112 return( $permissions ); 113 } 114 115 /** 116 * @private 117 */ 118 function mapRow( $row ) 119 { 120 $perm = new Permission( $row["permission"], $row["description"], $row["id"] ); 121 $perm->setAdminOnlyPermission( $row["admin_only"] ); 122 $perm->setCorePermission( $row["core_perm"] ); 123 return( $perm ); 124 } 125 } 126 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 21:04:15 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |