Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function GetUsers($options=array())
- {
- if(isset($options['userId']))
- $this->db->where('userId',$options['userId']);
- if(isset($options['userEmail']))
- $this->db->where('userEmail',$options['userEmail']);
- //echo "salt=".$this->config->item('SALT');
- //echo "password=".$options['userPassword'];
- if(isset($options['userPassword']))
- $this->db->where('userPassword',dohash($this->config->item('SALT').$options['userPassword'].$this->config->item('SALT')));
- if(isset($options['userStatus']))
- $this->db->where('userStatus',$options['userStatus']);
- if(isset($options['userType']))
- $this->db->where('userType',$options['userType']);
- //Limit / offset
- if(isset($options['limit']) && isset($options['offset']))
- $this->db->limit($options['limit'],$options['offset']);
- else if(isset($options['limit']))
- $this->db->limit($options['limit']);
- if(isset($options['sortBy']) && isset($options['sortDirection']))
- $this->db->order_by($options['sortBy'],$options['sortDirection']);
- if(!isset($options['userStatus'])) $this->db->where('userStatus !=','deleted');
- $query = $this->db->get('users');//query
- echo $this->db->last_query();
- if(isset($options['userId']) || isset($options['userEmail']))
- {
- //echo "<br />";
- //print_r($query->row(0));exit;
- return $query->row(0);
- }
- echo "not here";
- return $query->result();
- }//end func
- function _default($defaults,$options)
- {
- return array_merge($defaults,$options);
- }
- /*Authentication methods*/
- function Login($options=array())
- {
- if(!$this->_required(array('userEmail','userPassword'),$options))//check the required options of email and pass aggainst provided $options.
- {
- return false;
- }
- $user = $this->GetUsers(array('userEmail' => $options['userEmail'],
- 'userPassword' => dohash( $this->config->item('SALT').
- $options['userPassword'].
- $this->config->item('SALT')),
- 'userStatus' => 'active'));
- print_r($user);exit;
- //Returns empty array() which == false
- if(!$user)
- return false;
- //Set session vars
- $this->session->set_userdata('userEmail',$user->userEmail);
- $this->session->set_userdata('userId',$user->userId);
- $this->session->set_userdata('userType',$user->userType);
- $this->session->set_userdata('userStatus',$user->userStatus);
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement