Exemplo n.º 1
0
 function authenticate_user()
 {
     $user_model = new User_model();
     $user_service = new User_service();
     $user_model->set_user_name($this->input->post('login_username', TRUE));
     $user_model->set_password(md5($this->input->post('login_password', TRUE)));
     $result_user = $user_service->authenticate_user_with_password($user_model);
     if (count($result_user) == 0) {
         $logged_user_result = false;
     } else {
         $logged_user_result = true;
     }
     if ($logged_user_result) {
         $this->session->set_userdata('USER_ID', $result_user->id);
         $this->session->set_userdata('USER_FULLNAME', $result_user->name);
         $this->session->set_userdata('USER_NAME', $result_user->user_name);
         $this->session->set_userdata('USER_TYPE', $result_user->user_type);
         $this->session->set_userdata('USER_EMAIL', $result_user->email);
         $this->session->set_userdata('USER_PHONE', $result_user->contact_no_1);
         $this->session->set_userdata('USER_ADDRESS', $result_user->address);
         $this->session->set_userdata('USER_PROFILE_PIC', $result_user->profile_pic);
         $this->session->set_userdata('USER_ONLINE', 'Y');
         $this->session->set_userdata('USER_LOGGED_IN', 'TRUE');
         $user_model->set_id($this->session->userdata('USER_ID'));
         $user_model->set_is_online('1');
         $user_service->update_user_online_status($user_model);
         echo 1;
     } else {
         echo 0;
     }
 }
Exemplo n.º 2
0
 function add_admin()
 {
     $user_model = new User_model();
     $user_service = new User_service();
     $avatar = $this->input->post('profile_pic', TRUE);
     $user_model->set_title($this->input->post('title', TRUE));
     $user_model->set_name($this->input->post('name', TRUE));
     if ($avatar == '') {
         $user_model->set_profile_pic('avatar.png');
     } else {
         $user_model->set_profile_pic($avatar);
     }
     $user_model->set_user_name($this->input->post('user_name', TRUE));
     $user_model->set_user_type($this->input->post('user_type', TRUE));
     $user_model->set_email($this->input->post('email', TRUE));
     $user_model->set_address($this->input->post('address', TRUE));
     $user_model->set_contact_no_1($this->input->post('contact_no_1', TRUE));
     $user_model->set_contact_no_2($this->input->post('contact_no_2', TRUE));
     $user_model->set_password(md5($this->input->post('password', TRUE)));
     $user_model->set_added_by($this->session->userdata('USER_ID'));
     $user_model->set_added_date(date("Y-m-d H:i:s"));
     $user_model->set_account_activation_code('code');
     $user_model->set_is_online('0');
     //        $body_type_model->set_updated_date(date("Y-m-d H:i:s"));
     //        $body_type_model->set_updated_by(1);
     $user_model->set_is_published('1');
     $user_model->set_is_deleted('0');
     echo $user_service->add_user($user_model);
 }
Exemplo n.º 3
0
 function reset_password()
 {
     $user_model = new User_model();
     $user_service = new User_service();
     $user_model->set_user_name($this->input->post('txtusername', TRUE));
     $user_model->set_password(md5($this->input->post('txtpassword', TRUE)));
     echo $user_service->update_password($user_model);
 }
Exemplo n.º 4
0
 function authenticate_user()
 {
     $user_model = new User_model();
     $user_service = new User_service();
     $user_model->set_Email($this->input->post('login_username', TRUE));
     $user_model->set_password(md5($this->input->post('login_password', TRUE)));
     $result_user = $user_service->authenticate_user_with_password($user_model);
     if (count($result_user) == 0) {
         $logged_user_result = false;
     } else {
         $logged_user_result = true;
     }
     if ($logged_user_result) {
         $this->session->set_userdata('USER_ID', $result_user->UserID);
         $this->session->set_userdata('USER_FULLNAME', $result_user->FirstName);
         $this->session->set_userdata('USER_NAME', $result_user->FirstName);
         $this->session->set_userdata('USER_TYPE', 'admin');
         $this->session->set_userdata('USER_EMAIL', $result_user->Email);
         $this->session->set_userdata('USER_LOGGED_IN', 'TRUE');
         echo 1;
     } else {
         echo 0;
     }
 }
Exemplo n.º 5
0
 function update_password()
 {
     $user_service = new User_service();
     $reg_user_list = $user_service->get_admin_details();
     $input_username = trim($this->input->post('username', TRUE));
     foreach ($reg_user_list as $user) {
         if (strcmp($user->user_name, $input_username) == 0) {
             $user_model = new User_model();
             $user_model->set_id($user->id);
             $user_model->set_password(md5($this->input->post('password', TRUE)));
             $result = $user_service->update_password($user_model);
             if ($result == '1') {
                 echo "1";
                 die;
             } else {
                 echo "2";
                 die;
             }
         }
     }
     echo '0';
 }
Exemplo n.º 6
0
 function reset_password_and_avatar()
 {
     $user_model = new User_model();
     $user_service = new User_service();
     $user_model->set_password($this->input->post('profile_pic', TRUE));
     $user_model->set_profile_pic($this->input->post('pasword', TRUE));
     $user_model->set_updated_by($this->session->userdata('USER_ID'));
     $user_model->set_updated_date(date("Y-m-d H:i:s"));
     echo $user_service->update_user($user_model);
 }