[ Index ]
 

Code source de CMS made simple 1.0.5

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/classes/ -> class.user.inc.php (source)

   1  <?php
   2  #CMS - CMS Made Simple
   3  #(c)2004 by Ted Kulp (tedkulp@users.sf.net)
   4  #This project's homepage is: http://cmsmadesimple.org
   5  #
   6  #This program is free software; you can redistribute it and/or modify
   7  #it under the terms of the GNU General Public License as published by
   8  #the Free Software Foundation; either version 2 of the License, or
   9  #(at your option) any later version.
  10  #
  11  #This program is distributed in the hope that it will be useful,
  12  #BUT withOUT ANY WARRANTY; without even the implied warranty of
  13  #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14  #GNU General Public License for more details.
  15  #You should have received a copy of the GNU General Public License
  16  #along with this program; if not, write to the Free Software
  17  #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  18  #
  19  #$Id: class.user.inc.php 3345 2006-08-21 12:42:08Z wishy $
  20  
  21  /**
  22   * Generic user class.  This can be used for any logged in user or user related function.
  23   *
  24   * @since 0.6.1
  25   * @package CMS
  26   */
  27  class User
  28  {
  29      /**
  30       * User ID
  31       */
  32      var $id;
  33  
  34      /**
  35       * Username
  36       */
  37      var $username;
  38  
  39      /**
  40       * Password (md5 encoded)
  41       */
  42      var $password;
  43  
  44      /**
  45       * First Name
  46       */
  47      var $firstname;
  48  
  49      /**
  50       * Last Name
  51       */
  52      var $lastname;
  53  
  54      /**
  55       * Email
  56       */
  57      var $email;
  58  
  59      /**
  60       * Active Flag
  61       */
  62      var $active;
  63  
  64      /**
  65       * Flag to tell whether user can login to admin panel
  66       */
  67      var $adminaccess;
  68  
  69      /**
  70       * Generic constructor.  Runs the SetInitialValues fuction.
  71       */
  72  	function User()
  73      {
  74          $this->SetInitialValues();
  75      }
  76  
  77      /**
  78       * Sets object to some sane initial values
  79       *
  80       * @since 0.6.1
  81       */
  82  	function SetInitialValues()
  83      {
  84          $this->id = -1;
  85          $this->username = '';
  86          $this->password = '';
  87          $this->firstname = '';
  88          $this->lastname = '';
  89          $this->email = '';
  90          $this->active = false;
  91          $this->adminaccess = false;
  92      }
  93  
  94      /**
  95       * Encrypts and sets password for the User
  96       *
  97       * @since 0.6.1
  98       */
  99  	function SetPassword($password)
 100      {
 101          $this->password = md5($password);
 102      }
 103  
 104      /**
 105       * Saves the user to the database.  If no user_id is set, then a new record
 106       * is created.  If the uset_id is set, then the record is updated to all values
 107       * in the User object.
 108       *
 109       * @returns mixed If successful, true.  If it fails, false.
 110       * @since 0.6.1
 111       */
 112  	function Save()
 113      {
 114          $result = false;
 115          
 116          if ($this->id > -1)
 117          {
 118              global $gCms;
 119              $userops =& $gCms->GetUserOperations();
 120              $result = $userops->UpdateUser($this);
 121          }
 122          else
 123          {
 124              global $gCms;
 125              $userops =& $gCms->GetUserOperations();
 126              $newid = $userops->InsertUser($this);
 127              if ($newid > -1)
 128              {
 129                  $this->id = $newid;
 130                  $result = true;
 131              }
 132  
 133          }
 134  
 135          return $result;
 136      }
 137  
 138      /**
 139       * Delete the record for this user from the database and resets
 140       * all values to their initial values.
 141       *
 142       * @returns mixed If successful, true.  If it fails, false.
 143       * @since 0.6.1
 144       */
 145  	function Delete()
 146      {
 147          $result = false;
 148  
 149          if ($this->id > -1)
 150          {
 151              global $gCms;
 152              $userops =& $gCms->GetUserOperations();
 153              $result = $userops->DeleteUserByID($this->id);
 154              if ($result)
 155              {
 156                  $this->SetInitialValues();
 157              }
 158          }
 159  
 160          return $result;
 161      }
 162  }
 163  
 164  # vim:ts=4 sw=4 noet
 165  ?>


Généré le : Tue Apr 3 18:50:37 2007 par Balluche grâce à PHPXref 0.7