コード例 #1
0
 function authenticate_user()
 {
     $setting_login_type_id = '1';
     //setting id 1 = User Login Options , in main_settings table
     $user_model = new User_model();
     $user_service = new User_service();
     //assigning the value in login_username to $email if login_type=1
     $email = $this->input->post('login_username', TRUE);
     $login_option = $this->config->item('LOGIN_OPTION');
     // 1 = Username & Password
     //taking the un and pswd in sign in
     if ($login_option == 1) {
         //  $logged_user_result = '';
         $user_model->set_user_email($email);
         $user_model->set_user_password(md5($this->input->post('login_password', TRUE)));
         // password md 5 change
         if (count($user_service->authenticate_user_with_password($user_model)) == 0) {
             $logged_user_result = false;
         } else {
             $logged_user_result = true;
         }
     }
     if ($login_option == 2) {
         $logged_user_result = true;
         $user_model->set_user_email($email);
     }
     //if logged_in_user=true take user details frm authenticate_user and put it to logged_user_dateils var
     if ($logged_user_result) {
         // change
         $logged_user_details = $user_service->authenticate_user($user_model);
         if (count($logged_user_details) == 0) {
             echo 0;
         } else {
             $user_login_status_model = new User_model();
             $user_login_status_model->set_is_online('Y');
             $user_login_status_model->set_user_id($logged_user_details->user_id);
             $user_service->update_online_status($user_login_status_model);
             //setting data to session variables and user_model setters using logged_user_details
             $this->session->set_userdata('USER_ID', $logged_user_details->user_id);
             //                                print_r(die);
             //                                echo'user_id';
             $this->session->set_userdata('USER_FIRST', '1');
             //check first time log in and redirect to welcome page
             $this->session->set_userdata('USER_FNAME', $logged_user_details->user_fname);
             $this->session->set_userdata('USER_LNAME', $logged_user_details->user_lname);
             $this->session->set_userdata('USER_EMAIL', $logged_user_details->user_email);
             $this->session->set_userdata('USER_ONLINE', 'Y');
             $this->session->set_userdata('USER_LOGGED_IN', 'TRUE');
             //get system date & save it in variable then update the updated_by colun of user table for relevant user
             echo 1;
         }
     } else {
         echo 0;
     }
 }
コード例 #2
0
 function add_new_user()
 {
     $user_model = new User_model();
     $user_service = new User_service();
     $user_model->set_user_id($this->input->post('user_id', TRUE));
     $user_model->set_user_fname($this->input->post('user_fname', TRUE));
     $user_model->set_user_lname($this->input->post('user_lname', TRUE));
     $user_model->set_user_password(md5($this->input->post('user_password', TRUE)));
     $user_model->set_user_email($this->input->post('user_email', TRUE));
     $user_model->set_user_type($this->input->post('user_type', TRUE));
     $user_model->set_user_job($this->input->post('user_job', TRUE));
     $user_model->set_user_bday($this->input->post('user_bday', TRUE));
     $user_model->set_user_contact($this->input->post('user_contact', TRUE));
     $user_model->set_user_avatar('default_cover_pic.png');
     $user_model->set_del_ind('1');
     $user_model->set_added_by($this->session->userdata('USER_CODE'));
     $user_model->set_added_date(date("Y-m-d H:i:s"));
     echo $user_service->add_new_user($user_model);
 }