101 lines
4.0 KiB
PHP
Executable File
101 lines
4.0 KiB
PHP
Executable File
<?php
|
|
|
|
if (!defined('BASEPATH'))
|
|
exit('No direct script access allowed');
|
|
|
|
class Profile extends MX_Controller {
|
|
|
|
function __construct() {
|
|
parent::__construct();
|
|
$this->load->model('profile_model');
|
|
if (!$this->ion_auth->logged_in()) {
|
|
redirect('auth/login', 'refresh');
|
|
}
|
|
}
|
|
|
|
public function index() {
|
|
$data = array();
|
|
$id = $this->ion_auth->get_user_id();
|
|
$data['profile'] = $this->profile_model->getProfileById($id);
|
|
$this->load->view('home/dashboard'); // just the header file
|
|
$this->load->view('profile', $data);
|
|
$this->load->view('home/footer'); // just the footer file
|
|
}
|
|
|
|
public function addNew() {
|
|
//$this->load->helper('fileupload');
|
|
// $id=123;
|
|
// $folder_name='uploads/PatientDocuments/PATIENT_'.str_pad($id, 6, "0", STR_PAD_LEFT).'/';
|
|
// $uploadData['folder_name']=$folder_name;
|
|
// $uploadData['NAME']='documents';
|
|
// $uploadData['NEW_FILENAME_START']='DOC';
|
|
// $uploadData['CONFIG']['allowed_types']='gif|jpg|png|jpeg|pdf';
|
|
// $uploadData['CONFIG']['max_size']='20480000';
|
|
// $output=fileStore($_FILES,$uploadData);
|
|
// print_r($output);
|
|
// //echo 'test';
|
|
// die;
|
|
|
|
$id = $this->input->post('id');
|
|
$name = $this->input->post('name');
|
|
$password = $this->input->post('password');
|
|
$email = $this->input->post('email');
|
|
|
|
$data['profile'] = $this->profile_model->getProfileById($id);
|
|
if ($data['profile']->email != $email) {
|
|
if ($this->ion_auth->email_check($email)) {
|
|
$this->session->set_flashdata('feedback', 'This Email Address Is Already Registered');
|
|
redirect('profile');
|
|
}
|
|
}
|
|
|
|
$this->load->library('form_validation');
|
|
$this->form_validation->set_error_delimiters('<div class="error">', '</div>');
|
|
// Validating Name Field
|
|
$this->form_validation->set_rules('name', 'Name', 'trim|required|min_length[5]|max_length[100]|xss_clean');
|
|
// Validating Password Field
|
|
if (!empty($password)) {
|
|
$this->form_validation->set_rules('password', 'Password', 'trim|required|min_length[5]|max_length[100]|xss_clean');
|
|
}
|
|
// Validating Email Field
|
|
$this->form_validation->set_rules('email', 'Email', 'trim|required|min_length[5]|max_length[100]|xss_clean');
|
|
if ($this->form_validation->run() == FALSE) {
|
|
$data = array();
|
|
$id = $this->ion_auth->get_user_id();
|
|
$data['profile'] = $this->profile_model->getProfileById($id);
|
|
$this->load->view('home/dashboard'); // just the header file
|
|
$this->load->view('profile', $data);
|
|
$this->load->view('home/footer'); // just the footer file
|
|
} else {
|
|
$data = array();
|
|
$data = array(
|
|
'name' => $name,
|
|
'email' => $email,
|
|
);
|
|
|
|
$username = $this->input->post('name');
|
|
$ion_user_id = $this->ion_auth->get_user_id();
|
|
$group_id = $this->profile_model->getUsersGroups($ion_user_id)->row()->group_id;
|
|
$group_name = $this->profile_model->getGroups($group_id)->row()->name;
|
|
$group_name = strtolower($group_name);
|
|
if (empty($password)) {
|
|
$password = $this->db->get_where('users', array('id' => $ion_user_id))->row()->password;
|
|
} else {
|
|
$password = $this->ion_auth_model->hash_password($password);
|
|
}
|
|
$this->profile_model->updateIonUser($username, $email, $password, $ion_user_id);
|
|
if (!$this->ion_auth->in_group('admin')) {
|
|
$this->profile_model->updateProfile($ion_user_id, $data, $group_name);
|
|
}
|
|
$this->session->set_flashdata('feedback', 'Updated');
|
|
|
|
// Loading View
|
|
redirect('profile');
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
/* End of file profile.php */
|
|
/* Location: ./application/modules/profile/controllers/profile.php */
|