Source for file User.class.php

Documentation is available at User.class.php

  1. <?php
  2. /**
  3.  * Gumbo Library Framework
  4.  *
  5.  * LICENSE
  6.  * This library is being released under the terms of the New BSD License.  A
  7.  * copy of the license is packaged with the software (LICENSE.txt).  If no
  8.  * copy is found, a copy of the license template can be found at:
  9.  * http://www.opensource.org/licenses/bsd-license.php
  10.  * 
  11.  * @category Gumbo
  12.  * @package Valid
  13.  * @copyright Copyright (c) 2007, iBayou, Michael Luster
  14.  * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
  15.  * @author Michael Luster <mluster79@yahoo.com>
  16.  * @link http://sourceforge.net/projects/phpgumbo
  17.  * @version 0.0.1
  18.  */
  19.  
  20. /**
  21.  * User Validation Class
  22.  *
  23.  * @category Gumbo
  24.  * @package Valid
  25.  * @copyright Copyright (c) 2007, iBayou, Michael Luster
  26.  * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
  27.  * @author Michael Luster <mluster79@yahoo.com>
  28.  * @link http://sourceforge.net/projects/phpgumbo
  29.  * @desc User Validation Class
  30.  * @version 0.0.1
  31.  */
  32.  
  33. gumbo_load ("Valid");
  34.  
  35. class Gumbo_Valid_User extends Gumbo_Valid {
  36.     
  37.     /**
  38.      * Constructor
  39.      * @param bool $throw throw Exceptions
  40.      * @param int $level Error Level thrown
  41.      */
  42.     public function __construct ($throw=false$level=null{
  43.         parent::__construct ($throw$level);
  44.     }
  45.     
  46.     
  47.     
  48.     /**
  49.      * Returns if the value is a Social Security Number
  50.      * @param string $val 
  51.      * @return bool 
  52.      * @todo implement this method
  53.      */
  54.     public function isSSN ($val{
  55.         return false;
  56.     }
  57.     
  58.     /**
  59.      * Returns if the value is a Drivers Liscence Number
  60.      * @param mixed $val 
  61.      * @return bool 
  62.      * @todo implement this method
  63.      */
  64.     public function isDriversLisense ($val{
  65.         return false;
  66.     }
  67.     
  68.     
  69.     
  70.     /**
  71.      * Returns if the value is a valid Login/Username
  72.      * @param string $val 
  73.      * @return bool 
  74.      * @throws Gumbo_Exception
  75.      */
  76.     public function isLogin ($val{
  77.         $passed false;
  78.         
  79.         $this->turnOn ();
  80.         try {
  81.             // verify precondition
  82.             $this->precondition ($val"str");
  83.             $this->isLessThanEqualTo ($val25);
  84.             $this->isMatch ($val"^([a-zA-Z0-9_-]){0,}$");
  85.             $passed true;
  86.         catch (Exception $e{
  87.             $e null;
  88.         }
  89.         $this->turnOff ();
  90.         
  91.         if (!$passed && $this->isThrowing ()) {
  92.             throw new Gumbo_Exception ("Validation Failed: Login"$this->getLevel ());
  93.         }
  94.         return $passed;
  95.     }
  96.     
  97.     /**
  98.      * Returns if the value is a valid Password
  99.      * @param string $val 
  100.      * @return bool 
  101.      * @throws Gumbo_Exception
  102.      */
  103.     public function isPassword ($val{
  104.         $passed false;
  105.         
  106.         $this->turnOn ();
  107.         try {
  108.             // verify precondition
  109.             $this->precondition ($val"str");
  110.             $this->isLessThanEqualTo ($val20);
  111.             $this->isMatch ($val"^([a-zA-Z0-9!@_-]){0,}$");
  112.             $passed true;
  113.         catch (Exception $e{
  114.             $e null;
  115.         }
  116.         $this->turnOff ();
  117.         
  118.         if (!$passed && $this->isThrowing ()) {
  119.             throw new Gumbo_Exception ("Validation Failed: Password"$this->getLevel ());
  120.         }
  121.         return $passed;
  122.     }
  123.     
  124.     /**
  125.      * Returns if the value is a valid Alias
  126.      * @param string $val 
  127.      * @return bool 
  128.      * @throws Gumbo_Exception
  129.      */
  130.     public function isAlias ($val{
  131.         $passed false;
  132.         
  133.         $this->turnOn ();
  134.         try {
  135.             // verify precondition
  136.             $this->precondition ($val"str");
  137.             $this->isLessThanEqualTo ($val50);
  138.             $this->isMatch ($val"^([a-z0-9[:space:]\.\)\(,_-]){0,}$");
  139.             $passed true;
  140.         catch (Exception $e{
  141.             $e null;
  142.         }
  143.         $this->turnOff ();
  144.         
  145.         if (!$passed && $this->isThrowing ()) {
  146.             throw new Gumbo_Exception ("Validation Failed: Alias"$this->getLevel ());
  147.         }
  148.         return $passed;
  149.     }
  150.     
  151.     /**
  152.      * Returns if the value is a valid Name
  153.      * @param string $val 
  154.      * @return bool 
  155.      * @throws Gumbo_Exception
  156.      */
  157.     public function isName ($val{
  158.         $passed false;
  159.         
  160.         $this->turnOn ();
  161.         try {
  162.             // verify precondition
  163.             $this->precondition ($val"str");
  164.             $this->isLessThanEqualTo ($val50);
  165.             $this->isMatch ($val"^([a-z[:space:]\.,']){0,}$");
  166.             $passed true;
  167.         catch (Exception $e{
  168.             $e null;
  169.         }
  170.         $this->turnOff ();
  171.         
  172.         if (!$passed && $this->isThrowing ()) {
  173.             throw new Gumbo_Exception ("Validation Failed: Name"$this->getLevel ());
  174.         }
  175.         return $passed;
  176.     }
  177.     
  178. }
  179.  
  180. ?>