Advertisement
Guest User

Untitled

a guest
Aug 4th, 2012
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.37 KB | None | 0 0
  1. <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
  2.  
  3. /**
  4.  * Users Model
  5.  *
  6.  * @package KOW Manager
  7.  * @author  Jeff Davidson
  8.  * @version 1.0.0
  9.  */
  10.  
  11. class Users_model extends CI_Model
  12. {  
  13.     function __construct()
  14.     {
  15.         parent::__construct();
  16.     }
  17.    
  18.     /**
  19.      * Check if username available for registering
  20.      *
  21.      * @param   string
  22.      * @return  bool
  23.      */
  24.     public function is_username_available( $username )
  25.     {
  26.         $this->db->where( 'username', $username );
  27.        
  28.         $query = $this->db->get( $this->master_model->users_table );
  29.         return $query->num_rows() == 1 ? FALSE : TRUE;
  30.     }
  31.    
  32.    
  33.     /**
  34.      * Check if email available for registering
  35.      *
  36.      * @param   string
  37.      * @return  bool
  38.      */
  39.     public function is_email_address_available( $email_address )
  40.     {
  41.         $this->db->where( 'email_address', $email_address );
  42.        
  43.         $query = $this->db->get( $this->master_model->users_table );
  44.         return $query->num_rows() == 1 ? FALSE : TRUE;
  45.     }
  46.    
  47.      /**
  48.     * Create new user
  49.     *
  50.     * @param   string
  51.     * @param   string
  52.     * @param   string
  53.     * @param   string
  54.     * @param   string
  55.     * @param   string                    
  56.     * @return  integer
  57.     */
  58.     public function create_user( $username, $password, $password_hash, $first_name, $last_name, $email_address )
  59.     {
  60.         $this->db->set( 'username', $username );
  61.         $this->db->set( 'password', $password );
  62.         $this->db->set( 'password_hash', $password_hash );
  63.         $this->db->set( 'first_name', $first_name );
  64.         $this->db->set( 'last_name', $last_name );  
  65.         $this->db->set( 'email_address', $email_address );
  66.  
  67.         $this->db->insert( $this->master_model->users_table );
  68.         if ( $this->db->affected_rows == 1)
  69.         {
  70.             $user_id = $this->db->insert_id();
  71.             return $user_id            
  72.         }
  73.         else
  74.         {
  75.             return 0;                            
  76.         }                
  77.        
  78.     }
  79.    
  80.      /**
  81.     * Create user profile
  82.     *
  83.     * @param   integer
  84.     * @return  void
  85.     */
  86.     public function create_user_profile( $user_id )
  87.     {
  88.         $this->db->set( 'user_id', $user_id );
  89.         $this->db->insert( $this->master_model->user_profiles_table );
  90.         if ( $this->db->affected_rows() == 1 )
  91.         {
  92.             return TRUE;
  93.         }
  94.         else
  95.         {
  96.             return FALSE;        
  97.         }                                            
  98.     }
  99.    
  100.      /**
  101.     * Create user registration
  102.     *
  103.     * @param   integer
  104.     * @return  void
  105.     */
  106.     public function insert_user_registration_details( $user_id, $registration_ip_address, $registration_key, $registration_date )
  107.     {
  108.         $this->db->set( 'user_id', $user_id );
  109.         $this->db->set( 'registration_ip_address', $registration_ip_address );
  110.         $this->db->set( 'registration_key', $registration_key );
  111.         $this->db->set( 'registration_date', $registration_date );
  112.         $this->db->insert( $this->master_model->user_registrations_table );    
  113.         if ( $this->db->affected_rows() == 1 )
  114.         {
  115.             return TRUE;            
  116.         }
  117.         else
  118.         {
  119.             return FALSE;
  120.         }                            
  121.     }
  122. }
  123.  
  124. /* End of file users_model.php */
  125. /* Location: ./application/modules/users/models/users_model.php */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement