/** Possible actions for a user: edit, view participants, call, archive, delete */ function user_actions($user_id) { $CI =& get_instance(); $u = $CI->userModel->get_user_by_id($user_id); $edit_link = anchor('user/edit/' . $u->id, img_edit()); $act_link = is_activated($u) ? anchor('user/deactivate/' . $u->id, img_active(TRUE)) : anchor('user/activate/' . $u->id, img_active(FALSE)); $delete_link = is_admin($u) ? img_delete(TRUE) : anchor('user/delete/' . $u->id, img_delete(), warning(lang('sure_delete_user'))); return implode(' ', array($edit_link, $act_link, $delete_link)); }
/** Authenticates username and password. Returns true if authentication was successful. */ public function authenticate() { $username = $this->input->post('username'); $password = $this->input->post('password'); $user = $this->userModel->get_user_by_username($username); // If username found in DB... if ($user) { // Check against password and if activated if (!$this->phpass->check($password, $user->password) || !is_activated($user)) { $this->session->sess_destroy(); return FALSE; } else { // Destroy old session $this->session->sess_destroy(); // Create a fresh, brand new session $this->session->sess_create(); // Remove the password field unset($user->password); // Set session data $session_data = array('username' => $username, 'user_id' => $user->id, 'user_role' => $user->role, 'role' => $user->role, 'logged_in' => TRUE, 'language' => user_language($user)); $this->session->set_userdata($session_data); // Login was successful return TRUE; } } else { $this->session->sess_destroy(); return FALSE; } }