public function register() { $this->load->model("User_model", "user_model"); if (User_model::is_authorize(User_model::$TYPE_ADM) || User_model::is_authorize(User_model::$TYPE_DEV)) { redirect("dashboard"); } else { $data = ['title' => "Register"]; $this->load->view('pages/register', $data); } }
public function __construct() { parent::__construct(); $this->load->model("Setting_model", "setting_model"); $this->load->model("User_model", "user_model"); if (!User_model::is_authorize(User_model::$TYPE_ADM) && !User_model::is_authorize(User_model::$TYPE_DEV)) { redirect("login"); } if ($this->session->userdata(User_model::$SESSION_LOCK) != null) { redirect("lockscreen"); } }
public function update() { if (!User_model::is_authorize(User_model::$TYPE_ADM) && !User_model::is_authorize(User_model::$TYPE_DEV)) { redirect("login"); } if ($this->input->server('REQUEST_METHOD') == "POST") { $this->form_validation->set_rules('firstname', 'Name', 'required|max_length[50]'); $this->form_validation->set_rules('lastname', 'Name', 'required|max_length[50]'); $this->form_validation->set_rules('about', 'About', 'required|max_length[300]'); $this->form_validation->set_rules('gender', 'Gender', 'required'); $this->form_validation->set_rules('password', 'Current Password', 'required|callback_match_password'); $this->form_validation->set_rules('new_password', 'New Password', 'max_length[120]'); $this->form_validation->set_rules('confirm_password', 'Confirm Password', 'matches[new_password]'); if ($this->form_validation->run() == FALSE) { $data = ["operation" => "warning", "message" => validation_errors()]; } else { $firstname = $this->input->post("firstname"); $lastname = $this->input->post("lastname"); $administrator = array("name" => $lastname != "" ? $firstname . " " . $lastname : $firstname, "about" => $this->input->post("about"), "gender" => $this->input->post("gender"), "avatar" => $_FILES["avatar"]["name"]); if ($this->input->post("new_password") != "") { $administrator["password"] = md5($this->input->post("new_password")); } $result = $this->user_model->update($administrator, $this->session->userdata(User_model::$SESSION_ID)); if (isset($result["upload"]) && !$result["upload"]) { $data = ["operation" => "warning", "message" => $result["message"]]; } else { if ($result["query"]) { $this->session->set_flashdata("operation", "success"); $this->session->set_flashdata("message", "<strong>Setting</strong> successfully updated"); redirect("account"); return; } else { $data = ["operation" => "warning", "message" => "Something is getting wrong"]; } } } } $data['title'] = "Account"; $data['page'] = "pages/account"; $data['account'] = $this->user_model->read($this->session->userdata(User_model::$SESSION_ID)); $this->load->view('templates/template', $data); }