+
+ $this->load->view('user/login_view', array(
+ 'redirect'=> $redirect
+ ));
+
+ $this->load->view('footer');
+ $this->load->view('html_end');
+ }
+ else
+ {
+ if ($this->user_id !== NULL)
+ {
+ $this->session->set_userdata(array(
+ 'user_id'=> $this->user_id,
+ 'username'=> $this->username
+ ));
+
+ // Redirect to last page before login.
+ header('Location: '. site_url(urldecode_segments($redirect)));
+ }
+ else
+ {
+ $this->session->set_userdata(array(
+ 'username'=> $this->username
+ ));
+
+ // Redirect to register page because an user authenticates here
+ // for the first time with LDAP.
+ // TODO
+ header('Location: '. site_url(urldecode_segments($redirect)));
+ }
+ }
+ }
+
+ /**
+ * Logout user and then redirect it to the last page which must be encoded
+ * in $redirect.
+ *
+ * @param string $redirect contains the last page URI segments encoded
+ * with helper url_encode_segments.
+ */
+ public function logout($redirect = '')
+ {
+ $this->session->unset_userdata('user_id');
+ $this->session->unset_userdata('username');
+
+ header('Location: '. site_url(urldecode_segments($redirect)));
+ }
+
+ public function register($redirect = '')
+ {
+ $this->load->library('form_validation');
+ $this->load->model('users_model');
+ $this->load->helper('localization');
+ $this->load->helper('date');