function initialize() { $ci =& get_instance(); $uri =& load_class('URI', 'core'); $admin = $uri->segment(1); $is_admin = $admin == 'administrator' || $admin == 'admin' ? true : false; $language = $is_admin ? admin_language() : site_language(); $side = $is_admin ? 'app' : 'site'; $user_lang_request = trim($ci->input->get('lang')); $user_lang = $ci->session->userdata('user_lang'); if (!empty($user_lang_request)) { $ci->session->set_userdata('user_lang', $user_lang_request); AZ::redirect(current_url()); } if (isset($user_lang) && !empty($user_lang) && !$is_admin) { $ci->lang->load($side, $user_lang); } else { $ci->lang->load($side, $language); } }
/** * Match User details and Logged in Application * * @return Redirect */ public function login() { if (user::id()) { AZ::redirect('admin/dashboard'); } $post = $this->input->post(); if ($this->_validate() == FALSE) { $this->index(); return false; } $user_id = $this->user->authenicate($post['username'], $post['password']); if ($user_id) { if (have_permission('dashboard/index')) { AZ::redirect('admin/dashboard'); } else { user::flush(); AZ::redirectError('administrator', __('Unauthorized Access', true)); } } else { AZ::redirectError('administrator', 'Invalid'); } }
/** * Match User details and Logged in Application if verify * * @return Redirect */ public function authenicate() { if (user::id()) { AZ::redirect('account'); } $post = $this->input->post(); if ($this->_validateLogin() == FALSE) { $this->index(); return false; } if ($this->user->authenicate($post['username'], $post['password'])) { AZ::redirect('account'); } else { AZ::redirectError('account', 'Invalid'); } }
/** * Save Content Field * * @return Redirect */ public function save_field() { $post = $this->input->post(); if (!count($post)) { return FALSE; } if (!isset($post['id'])) { AZ::redirect('admin/contents/fields'); } $this->load->library('form_validation'); $this->form_validation->set_rules('label', lang('Label'), 'trim|required'); if ($post['id'] > 0) { $this->form_validation->set_rules('name', lang('Name'), 'trim|required'); } else { $this->form_validation->set_rules('name', lang('Name'), 'trim|required|is_unique[content_fields.name]'); } if (!$this->form_validation->run()) { AZ::redirectError('admin/contents/edit_field/' . $post['id'] . '/' . $post['group_id'], validation_errors()); return false; } $field = $this->content->saveField($post); if (!$field) { AZ::redirectError('admin/contents/edit_field/' . $field . '/' . $post['group_id'], lang('Error occured')); } else { AZ::redirectSuccess('admin/contents/fields/' . $post['group_id'], lang('Saved')); } }