user.php

Go to the documentation of this file.
00001 <?php
00002 
00003   /*
00004   Easy PHP Framework
00005 
00006   Copyright (c) 2005 Michal Molhanec
00007 
00008   This software is provided 'as-is', without any express or implied
00009   warranty. In no event will the authors be held liable for any damages
00010   arising from the use of this software.
00011 
00012   Permission is granted to anyone to use this software for any purpose,
00013   including commercial applications, and to alter it and redistribute
00014   it freely, subject to the following restrictions:
00015 
00016       1. The origin of this software must not be misrepresented;
00017          you must not claim that you wrote the original software.
00018          If you use this software in a product, an acknowledgment
00019          in the product documentation would be appreciated but
00020          is not required.
00021 
00022       2. Altered source versions must be plainly marked as such,
00023          and must not be misrepresented as being the original software.
00024 
00025       3. This notice may not be removed or altered from any
00026          source distribution.
00027   */
00028 
00029   /**
00030    *  This class represents user.
00031    */
00032   class User implements ArrayAccess {
00033   
00034     private $id;
00035     private $properties = array();
00036 
00037     function __construct($id) {
00038       $this->id = $id;
00039     }
00040     
00041     function get_id() {
00042       return $this->id;
00043     }
00044     
00045     function isAdmin() {
00046       return FALSE;
00047     }
00048 
00049     ///////////////////////////////////////////////////////////////
00050     //// ArrayAccess API
00051     ///////////////////////////////////////////////////////////////
00052 
00053     function offsetExists($offset) {
00054       return isset($this->properties[$offset]);
00055     }
00056     
00057     function offsetGet($offset) {
00058       return $this->properties[$offset];
00059     }
00060 
00061     function offsetSet($offset, $value) {
00062       $this->properties[$offset] = $value;
00063     }
00064 
00065     function offsetUnset($offset) {
00066       unset($this->properties[$offset]);
00067     }
00068 
00069 
00070   }
00071 
00072   class AdminUser extends User {
00073   
00074     function isAdmin() {
00075       return TRUE;
00076     }
00077 
00078   }
00079 
00080 ?>

Generated on Sat Sep 24 01:26:42 2005 for Easy PHP Framework by  doxygen 1.4.2