Location: PHPKode > projects > Mac's MVC Framework > Application/plugins/CMS/models/Users_Model.php
<?php
/**
 * Roles Table Model
 *
 * @author Macdonald Robinson
 */

class Users_Model extends CMS_Model
{
    public function __construct()
    {
      parent::__construct();
    }

    public function getCMSTableNameUsers()
    {
      return $this->getCMSTableName('Users');
    }
    
    public function getAllUsers()
    {
      return $this->select( $this->getCMSTableNameUsers());
    }

    public function getUserByID($userId)
    {
      return $this->selectSingle(  $this->getCMSTableNameUsers(), array('ID'=>$userId));
    }

    public function getUsersByRoleID($roleId)
    {
      return $this->select( $this->getCMSTableNameUsers(), array('RoleID'=>$roleId));
    }

    public function getUserByUsername($username)
    {
       return $this->selectSingle( $this->getCMSTableNameUsers(), array('Username'=>$username));
    }

    public function getUserByEmailAddress($emailAddress)
    {
       return $this->selectSingle( $this->getCMSTableNameUsers(), array('EmailAddress'=>$emailAddress));
    }

    public function getUserByTempPassword($emailAddress, $tempPassword)
    {
       return $this->selectSingle( $this->getCMSTableNameUsers(), array('EmailAddress'=>$emailAddress, 'TempPassword'=>$tempPassword));
    }

    public function insertUser($username, $password, $emailAddress, $roleId)
    {
      return $this->insert( $this->getCMSTableNameUsers(), array('Username'=>$username, 'Password'=>$password, 'EmailAddress'=>$emailAddress, 'RoleID'=>$roleId, 'CreatedOn'=>time(), 'LastModifiedOn'=>time() ));
    }

    public function updateUser($user, $username, $password, $emailAddress, $roleId)
    {
      return $this->update( $this->getCMSTableNameUsers(), array('Username'=>$username, 'Password'=>$password, 'EmailAddress'=>$emailAddress, 'RoleID'=>$roleId, 'LastModifiedOn'=>time() ),  array('ID'=>$user->ID));
    }

    public function updateUserObject($userObject)
    {
      return $this->update( $this->getCMSTableNameUsers(), array('Username'=>$userObject->Username, 'Password'=>$userObject->Password, 'EmailAddress'=>$userObject->EmailAddress, 'RoleID'=>$userObject->RoleID, 'TempPassword'=>$userObject->TempPassword, 'LastModifiedOn'=>time() ),  array('ID'=>$userObject->ID));
    }

    public function deleteUserByID($userId)
    {
      return $this->delete( $this->getCMSTableNameUsers(), array('ID'=>$userId));
    }
}
?>
Return current item: Mac's MVC Framework