/** * 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'); } }
/** * Update User Account or Profile * * @return Redirect */ public function update() { $post = $this->input->post(); if (!count($post)) { AZ::redirectError('account', __('Unauthorized Access', true)); } if (isset($post['old_password']) && $this->user->match_password($post['id'], $post['old_password'])) { if ($this->_validateUpdate() == FALSE) { AZ::redirectError('account', validation_errors()); return false; } $this->db->where('id', $post['id']); if ($this->db->update('users', array('password' => $this->user->hash_password($post['password'])))) { AZ::redirectSuccess('account', __('Password Changed', true)); return TRUE; } else { AZ::redirectError('account', __('Error occured', true)); return FALSE; } } if (isset($_FILES['avatar']['error']) && $_FILES['avatar']['error'] == 0) { $avatarData = $this->user->uploadUserAvatar(); if (isset($avatarData['error']) && (int) $avatarData['error']) { AZ::redirectError('admin/users/edit/' . $id, $avatarData['error_string']); } if (isset($avatarData['avatar']) && !empty($avatarData['avatar'])) { $post['avatar'] = $avatarData['avatar']; } } if (!$this->user->updateUserProfile($post)) { AZ::redirectError('account', __('Error occured', true)); } else { AZ::redirectSuccess('account', __('Saved', true)); } }
/** * Update Message Label * * @param integer $id * @param integer $label * @return redirect */ public function message_label($id, $label) { $this->db->where('id', (int) $id); if ($this->db->update('messages', array('label' => $label))) { AZ::redirectSuccess('admin/dashboard/messages', lang('Saved')); } else { AZ::redirectError('admin/dashboard/messages', lang('Error occured')); } }
/** * Remove Menu Item * * @param integer $item_id * @return redirect */ public function remove_item($item_id) { if ($this->db->delete('menu_items', array('id' => (int) $item_id))) { AZ::redirectSuccess('admin/menus', lang('Removed')); } else { AZ::redirectError('admin/menus', lang('Error occured')); } }
public static function redirectUnauthorizedAccess($uri = 'administrator', $flashValue = 'Unauthorized Access', $loggedout = false) { if (!self::access()) { if ($loggedout) { self::flush(); } AZ::redirectError($uri, $flashValue); } }
/** * Remove Setting * * @param integer $setting_id * @return redirect */ public function remove_setting($setting_id) { if ($this->db->delete('settings', array('id' => (int) $setting_id))) { AZ::redirectSuccess('admin/settings', lang('Removed')); } else { AZ::redirectError('admin/settings', lang('Error occured')); } }
/** * Remove Field and Redirect Back to Fields * * @param integer $id * @param integer $fieldset * @return redirect */ public function remove_field($id, $fieldset = 1) { if ($this->db->delete('content_fields', array('id' => (int) $id))) { AZ::redirectSuccess('admin/contents/fields/' . $fieldset, lang('Removed')); } else { AZ::redirectError('admin/contents/fields/' . $fieldset, lang('Error occured')); } }
/** * Update Permissions * * @return Redirect */ public function permissions_reset() { if (user::access_id() != 1) { AZ::redirectError('admin/dashboard', lang('Unauthorized Access')); } $post = $this->input->post(); if (empty($post)) { AZ::redirectError('admin/users/permissions', lang('no_option')); return FALSE; } if (!$this->user->resetPermissions($post)) { AZ::redirectError('admin/users/permissions', lang('Error occured')); } else { AZ::redirectSuccess('admin/users/permissions', lang('Saved')); } }