home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / dotproject / modules / system / roles / roles.class.php < prev   
Encoding:
PHP Script  |  2003-02-26  |  1.2 KB  |  57 lines

  1. <?php /* ROLES $Id: roles.class.php,v 1.1 2003/02/26 01:24:30 eddieajau Exp $ */
  2.  
  3. class CRole {
  4.     var $role_id = NULL;
  5.     var $role_name = NULL;
  6.     var $role_description = NULL;
  7.     var $role_type = NULL;
  8.     var $role_module = NULL;
  9.  
  10.     function CRole( $name='', $description='', $type='0', $module='0' ) {
  11.         $this->role_name = $name;
  12.         $this->role_description = $description;
  13.         $this->role_type = $type;
  14.         $this->role_module = $module;
  15.     }
  16.  
  17.     function bind( $hash ) {
  18.         if (!is_array( $hash )) {
  19.             return get_class( $this )."::bind failed";
  20.         } else {
  21.             bindHashToObject( $hash, $this );
  22.             return NULL;
  23.         }
  24.     }
  25.  
  26.     function check() {
  27.         // TODO MORE
  28.         return NULL; // object is ok
  29.     }
  30.  
  31.     function store() {
  32.         $msg = $this->check();
  33.         if( $msg ) {
  34.             return get_class( $this )."::store-check failed<br />$msg";
  35.         }
  36.         if( $this->role_id ) {
  37.             $ret = db_updateObject( 'roles', $this, 'role_id', false );
  38.         } else {
  39.             $ret = db_insertObject( 'roles', $this, 'role_id' );
  40.         }
  41.         if( !$ret ) {
  42.             return get_class( $this )."::store failed <br />" . db_error();
  43.         } else {
  44.             return NULL;
  45.         }
  46.     }
  47.  
  48.     function delete() {
  49.         $sql = "DELETE FROM roles WHERE role_id = '$this->role_id'";
  50.         if (!db_exec( $sql )) {
  51.             return db_error();
  52.         } else {
  53.             return NULL;
  54.         }
  55.     }
  56. }
  57. ?>