From 3dd8db9cc5eae2db4e8207aaf29f01173d18950a Mon Sep 17 00:00:00 2001 From: Eike Foken Date: Fri, 22 Apr 2011 19:52:15 +0200 Subject: [PATCH] Fix saving the settings to database --- application/controllers/auth.php | 21 ++++++++++++++++++--- application/libraries/Access.php | 2 +- application/models/user.php | 2 +- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/application/controllers/auth.php b/application/controllers/auth.php index 4f201d5..1ba4d35 100755 --- a/application/controllers/auth.php +++ b/application/controllers/auth.php @@ -123,7 +123,7 @@ class Auth extends CI_Controller { } // validate form - $this->form_validation->set_rules('new_password', 'New Password', 'min_length[' . $this->config->item('min_password_length', 'auth') . ']|max_length[' . $this->config->item('max_password_length', 'auth') . ']|matches[new_password_confirm]'); + $this->form_validation->set_rules('new_password', 'New Password', 'min_length[' . $this->config->item('min_password_length', 'auth') . ']|max_length[' . $this->config->item('max_password_length', 'access') . ']|matches[new_password_confirm]'); if ($this->form_validation->run() == true) { // change password if needed @@ -135,10 +135,25 @@ class Auth extends CI_Controller { $this->logout(); } } + + // update user + $updateData = array( + 'firstname' => $this->input->post('firstname'), + 'lastname' => $this->input->post('lastname'), + 'institution' => $this->input->post('institution'), + 'phone' => $this->input->post('phone'), + 'email' => $this->input->post('email'), + ); + $this->access->updateUser($this->session->userdata('user_id'), $updateData); + echo "{success: true}"; } else { - echo validation_errors(); - $user = $this->access->getCurrentUser(); + $this->data['success'] = true; + $this->data['data'] = $this->access->getCurrentUser(); + + // output json data + $this->output->set_content_type('application/json') + ->set_output(json_encode($this->data)); } } diff --git a/application/libraries/Access.php b/application/libraries/Access.php index bdb3b62..dba18fd 100644 --- a/application/libraries/Access.php +++ b/application/libraries/Access.php @@ -238,7 +238,7 @@ class Access { * @return object */ public function getCurrentUser() { - return $this->ci->user->getUserByID($this->ci->session->userdata('user_id'))->row(); + return $this->ci->user->getUserByID($this->ci->session->userdata('user_id'))->row_array(); } /** diff --git a/application/models/user.php b/application/models/user.php index 209a617..ca1fe0c 100644 --- a/application/models/user.php +++ b/application/models/user.php @@ -397,7 +397,7 @@ class User extends CI_Model { * @return boolean */ public function update($id, $data) { - $user = $this->get_user($id)->row(); + $user = $this->getUserByID($id)->row(); $this->db->trans_begin();