function add_new_user()
 {
     $register_users_model = new Register_Users_model();
     $register_users_service = new Register_Users_service();
     $register_users_model->set_name($this->input->post('form_register_full_name', TRUE));
     $register_users_model->set_user_name($this->input->post('form_register_user_name', TRUE));
     $register_users_model->set_user_type('3');
     $register_users_model->set_email(trim($this->input->post('form_register_email', TRUE)));
     $register_users_model->set_address($this->input->post('form_register_address', TRUE));
     $register_users_model->set_contact1($this->input->post('form_register_contact', TRUE));
     //$register_users_model->set_contact2($this->input->post('contact_no_2', TRUE));
     $register_users_model->set_profile_pic('avatar.png');
     $register_users_model->set_password(md5($this->input->post('form_register_password', TRUE)));
     $register_users_model->set_is_online('0');
     $register_users_model->set_title(trim($this->input->post('title', TRUE)));
     $token = $this->generate_random_string();
     //generate account activation token
     $register_users_model->set_account_activation_code($token);
     $register_users_model->set_is_published('0');
     $register_users_model->set_is_deleted('0');
     //$register_users_model->set_added_by($this->input->post('added_by', TRUE));
     //$register_users_model->set_added_date($this->input->post('added_date', TRUE));
     //$register_users_model->set_updated_date($this->input->post('updated_date', TRUE));
     //$register_users_model->set_updated_by($this->input->post('updated_by', TRUE));
     $register_users_model->set_account_activation_code($token);
     $register_users_service->add_new_user_registration($register_users_model);
     $email = trim($this->input->post('form_register_email', TRUE));
     //'*****@*****.**';
     $email_subject = "AutoVille Account Activation";
     $data['name'] = $this->input->post('form_register_full_name', TRUE);
     $data['user_name'] = $this->input->post('form_register_user_name', TRUE);
     $data['pasword'] = $this->input->post('form_register_password', TRUE);
     $data['link'] = site_url() . '/login/activate?email=' . $this->input->post('form_register_email', TRUE) . '&token=' . $token;
     $msg = $this->load->view('template/mail_template/body', $data, TRUE);
     $headers = 'MIME-Version: 1.0' . "\r\n";
     $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
     $headers .= 'From: Autoville <*****@*****.**>' . "\r\n";
     $headers .= 'Cc: info.autovillle@gmail.com' . "\r\n";
     //        echo $msg;
     //        return;
     if (mail($email, $email_subject, $msg, $headers)) {
         echo "1";
         $this->session->set_flashdata('info', 'Please go to your email account and continue the registration process');
     } else {
         echo "0";
     }
     return true;
 }
Exemple #2
0
 function google_authenticate_user()
 {
     $user_model = new User_model();
     $user_service = new User_service();
     $this->load->library('googleplus');
     $code = $this->input->post('code', TRUE);
     if (!empty($code)) {
         $this->googleplus->client->authenticate();
         $this->session->set_userdata('token', $this->googleplus->client->getAccessToken());
         $email = $this->input->post('email', TRUE);
         $name = $this->input->post('name', TRUE);
         $image_url = $this->input->post('image_url', TRUE);
         $exist_user = $user_service->check_user_email_exist($email);
         if (!empty($exist_user)) {
             $this->session->set_userdata('USER_ID', $exist_user->id);
             $this->session->set_userdata('USER_FULLNAME', $exist_user->name);
             $this->session->set_userdata('USER_NAME', $exist_user->user_name);
             $this->session->set_userdata('USER_TYPE', $exist_user->user_type);
             $this->session->set_userdata('USER_EMAIL', $exist_user->email);
             $this->session->set_userdata('USER_PHONE', $exist_user->contact_no_1);
             $this->session->set_userdata('USER_ADDRESS', $exist_user->address);
             $this->session->set_userdata('USER_PROFILE_PIC', $exist_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);
         } else {
             $register_users_model = new Register_Users_model();
             $register_users_service = new Register_Users_service();
             $register_users_model->set_name($name);
             $register_users_model->set_user_name($name);
             $register_users_model->set_user_type('3');
             $register_users_model->set_email($email);
             $register_users_model->set_profile_pic($image_url);
             $register_users_model->set_is_online('1');
             $register_users_model->set_is_published('1');
             $register_users_model->set_is_deleted('0');
             $new_user_id = $register_users_service->add_new_user_registration($register_users_model);
             $this->session->set_userdata('USER_ID', $new_user_id);
             $this->session->set_userdata('USER_NAME', $name);
             $this->session->set_userdata('USER_FULLNAME', $name);
             $this->session->set_userdata('USER_EMAIL', $email);
             $this->session->set_userdata('USER_ONLINE', 'Y');
             $this->session->set_userdata('USER_TYPE', 3);
             $this->session->set_userdata('USER_PHONE', '');
             $this->session->set_userdata('USER_ADDRESS', '');
             $this->session->set_userdata('USER_PROFILE_PIC', $image_url);
             $this->session->set_userdata('USER_LOGGED_IN', 'TRUE');
         }
     }
     echo '1';
     die;
 }