Fix saving the settings to database

This commit is contained in:
Eike Foken
2011-04-22 19:52:15 +02:00
parent b70dc810b9
commit 3dd8db9cc5
3 changed files with 20 additions and 5 deletions

View File

@@ -123,7 +123,7 @@ class Auth extends CI_Controller {
} }
// validate form // 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) { if ($this->form_validation->run() == true) {
// change password if needed // change password if needed
@@ -135,10 +135,25 @@ class Auth extends CI_Controller {
$this->logout(); $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}"; echo "{success: true}";
} else { } else {
echo validation_errors(); $this->data['success'] = true;
$user = $this->access->getCurrentUser(); $this->data['data'] = $this->access->getCurrentUser();
// output json data
$this->output->set_content_type('application/json')
->set_output(json_encode($this->data));
} }
} }

View File

@@ -238,7 +238,7 @@ class Access {
* @return object * @return object
*/ */
public function getCurrentUser() { 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();
} }
/** /**

View File

@@ -397,7 +397,7 @@ class User extends CI_Model {
* @return boolean * @return boolean
*/ */
public function update($id, $data) { public function update($id, $data) {
$user = $this->get_user($id)->row(); $user = $this->getUserByID($id)->row();
$this->db->trans_begin(); $this->db->trans_begin();