public function is_admin() { list(list(, $group_id)) = Auth::get_groups(); if ($group_id != 100) { Response::redirect('/admin/signin'); } }
public function before() { parent::before(); // Check Auth if (!\Auth\Auth::check()) { \Fuel\Core\Response::redirect('auth'); } /* * Theme Set */ $this->theme = \Theme::instance(); $this->theme->set_template('index'); /* * Breadcrumb */ // $this->_breadcrumb = Breadcrumb::create_links(); if (Session::get('lang')) { $this->_lang = Session::get('lang'); } if (Input::method() == 'GET') { $this->_get = Input::get(); } if (Input::method() == 'POST') { $this->_post = Input::post(); } $this->initialized(); }
public function action_index() { try { $helper = new FacebookRedirectLoginHelper(Config::get('login_url')); $session = $helper->getSessionFromRedirect(); } catch (FacebookRequestException $ex) { // When Facebook returns an error } catch (\Exception $ex) { // When validation fails or other local issues } if (isset($session)) { //login succes $long_lived_session = $session->getLongLivedSession(); $access_token = $long_lived_session->getToken(); //*** Call api to get user info $user_info = $this->facebook->get_user_information($access_token); //*** Check if user has existed $user = Model_Users::find('first', array('where' => array('fb_id' => $user_info->getId()))); if (empty($user)) { // Register user if (Model_Users::register_user($user_info, $access_token)) { //Success } } //*** Set session for user Fuel\Core\Session::set('user_token', $long_lived_session->getToken()); Fuel\Core\Session::set('user_id', $user_info->getId()); //*** Redirect to home \Fuel\Core\Response::redirect('fanpage/index'); } else { // login fail $this->template->login_url = $helper->getLoginUrl(); } }
public function action_addtask($project_id) { if (!($project = Model_Project::find($project_id))) { \Fuel\Core\Session::set_flash('error', "Cannot find the selected project # {$project_id}"); \Fuel\Core\Response::redirect_back('user/projects'); } $val = Model_Projecttask::validate('create'); if (\Fuel\Core\Input::method() == 'POST') { if ($val->run()) { $projecttask = Model_Projecttask::forge(array('project_id' => Input::post('project_id'), 'user_id' => Input::post('user_id'), 'project_task_name_id' => Input::post('project_task_name_id'), 'hourly_rate' => Input::post('hourly_rate'), 'task_status' => 0, 'task_due' => Input::post('task_due'), 'project_task_description' => Input::post('project_task_description'), 'comment' => Input::post('comment'), 'priority' => Input::post('priority'))); if ($projecttask and $projecttask->save()) { Session::set_flash('success', e('Added task #' . $projecttask->id . '.')); Response::redirect('user/projects/view/' . $project_id); } else { Session::set_flash('error', e('Could not save task.')); } } else { \Fuel\Core\Session::set_flash('error', $val->error()); } } $this->load_presenter($project, Model_Projecttask::forge(array('id' => 0, 'project_id' => $project->id, 'user_id' => $this->current_user->id, 'task_status' => 0, 'hourly_rate' => 456, 'task_due' => date('Y-m-d')))); $this->template->set_global('project_task_names', Model_Projecttaskname::find('all', array('order_by' => array(array('name', 'asc'))))); $this->template->set_global('users', array(Model_User::find($this->current_user->id))); $this->template->set_global('priorities', THelper::get_priorities()); $this->template->title = 'My Projects'; $this->template->content = Fuel\Core\View::forge('user/projects/addtask'); }
public function action_edit($id = null) { if ($inventory = Model_Inventory::find($id)) { $val = Model_Inventory::validate('edit'); if ($val->run()) { $inventory->description = Input::post('description'); $inventory->barcode = Input::post('barcode'); $inventory->short_code = Input::post('short_code'); $inventory->inventory_units_id = Input::post('inventory_units_id'); $inventory->warning_level = Input::post('warning_level'); if ($inventory->save()) { Session::set_flash('success', e('Updated inventory #' . $id)); Response::redirect('admin/inventory/view/' . $inventory->id); } else { Session::set_flash('error', e('Could not update inventory #' . $id)); } } else { if (Input::method() == 'POST') { $inventory->description = $val->validated('description'); $inventory->barcode = $val->validated('barcode'); $inventory->short_code = $val->validated('short_code'); $inventory->inventory_units_id = $val->validated('inventory_units_id'); $inventory->warning_level = $val->validated('warning_level'); Session::set_flash('error', $val->error()); } $this->template->set_global('inventory', $inventory, false); } $this->template->set_global('inventory_units', Model_Inventory_Unit::find('all', array('order_by' => array(array('name', 'asc'))))); $this->template->title = "Inventory » " . $inventory->description . " » Edit"; $this->template->content = View::forge('admin/inventory/edit'); } else { Fuel\Core\Session::set_flash('error', 'Cannot find the selected item'); \Fuel\Core\Response::redirect_back('admin/inventory'); } }
public function action_index() { if (Auth::check()) { return Response::redirect('admin/home'); } else { return Response::redirect('admin/login'); } }
public function post_add() { $model = Model_Blog::forge(); $model->set(Input::post()); $model->set(BLOG_CREATED_DATE, DB::expr('now()')); $model->set(DELETE_FLG, '0'); $model->save(); Response::redirect(Config::get('base_url')); }
/** * */ public function before() { View::set_global('BASE_URL', Config::get('base_url')); // Check if is in maintenance mode if (Config::get('global.MAINTENANCE_MODE')) { // Open maintenance page return Response::redirect('page/maintenance'); } return parent::before(); }
protected function has_access($page) { $user = Session::get('user'); $access = Model_Access_Right::find('first', array('where' => array('page' => $page))); $ac = $user->access_level; if ($access->{$ac} == 0) { Session::set_flash('error', 'Sorry! You do not have access to this page.'); Response::redirect('welcome'); } }
/** * @author Thuanth6589 <*****@*****.**> * list media */ public function action_get_partner() { $m_group_id = Input::post('m_group_id'); if (!isset($m_group_id) || $m_group_id == '') { exit(json_encode($this->_partners)); } $m_partner = new \Model_Mpartner(); $partners = $this->_partners + array_column($m_partner->get_partner_group($m_group_id, $this->_partner_type), 'branch_name', 'partner_code'); return Response::forge(json_encode($partners)); }
/** * @author Bui Dang <*****@*****.**> * action detail contact */ public function action_index($id = null) { $data = array(); if (!isset($id) or !\Model_Contact::find_by_pk($id)) { Response::redirect(Uri::base() . 'support/contacts'); } $data['contact'] = \Model_Contact::find_by_pk($id); $this->template->title = 'UOS求人システム'; $this->template->content = \View::forge('contact/index', $data); }
public function action_view($id = null) { is_null($id) and Response::redirect('post'); if (!($data['post'] = Model_Post::find($id))) { Session::set_flash('error', 'お求めの記事はありません [# ' . $id . ' ]'); Response::redirect('post'); } $this->template->title = "ブログ"; $this->template->content = View::forge('post/view', $data); }
function performItemDeletion(Orm\Model $item, $successUrl) { $id = $item->get('id'); $item->delete(); $this->deleteImageFolder($id); $session = Session::instance(); $session->set($this->deletedKey, true); // Re-loads the page on success Response::redirect($successUrl); }
public function action_edit($id = null) { if (empty($id) || !Model_Base_Product::valid_field('id', $id)) { Response::redirect('/admin/product'); } $this->data['category'] = Model_Base_Category::get_all(); $this->data['product'] = Model_Base_Product::get_one($id); $this->data['product']['category'] = Model_Base_ProductCategory::get_by('category_id', 'product_id', $id); $this->data['product']['sub_photo'] = Model_Base_Product::get_sub_photo($id); $this->template->content = View::forge($this->layout . '/product/edit', $this->data); }
public function check_maintenance() { $config = Model_Config::find('first'); View::set_global('config', $config); if ($this->action === 'maintenance' && (int) $config->maintenance !== 1) { Response::redirect('/'); } if (!in_array($this->action, ['maintenance']) && (int) $config->maintenance === 1) { Response::redirect('/maintenance'); } }
/** * @author Bui Dang <*****@*****.**> * action Show model group edit */ public function action_edit() { $group = new \Model_Mgroups(); $groupid = \Input::post('groupid'); $data = $group->get_one($groupid); if (!$groupid or !\Model_Mgroups::find_by_pk($groupid)) { $data = \Constants::$_status_save['id_not_exist']; Session::set_flash('error', '取引先グループは存在しません'); } return Response::forge(json_encode($data)); }
/** * Social * * @access public * @author Dao Anh Minh */ public function action_index() { $view = View::forge('admin/social/index'); $view->social = Config::load('social.php'); if (Input::method() == 'POST') { Config::save('social.php', Input::post('social')); Session::set_flash('success', 'Chỉnh sửa thành công'); \Fuel\Core\Response::redirect('admin/social'); } $this->template->title = 'Quản lý liên kết'; $this->template->content = $view; }
public function before() { parent::before(); // Without this line, templating won't work! $this->template->head = View::forge('_partial/head'); $this->template->header = View::forge('_partial/header'); $this->template->footer = View::forge('_partial/footer'); if (!Auth::check()) { Response::redirect('/auth/login'); } // do stuff }
public static function load() { try { $dbResult = DB::SELECT('ID', 'Title', 'Description')->from('Story')->where('Type', 2)->order_by('DateCreate', 'dsc')->limit(6)->execute(); $dbData = $dbResult->as_array(); return $dbData; } catch (\Exception $e) { Log::error($e); // Redirect to 500 server error; return Response::redirect(500); } }
public function action_index($code = null) { if (empty($code) || !Model_Base_Category::valid_by(array(array('code' => $code), array('status' => 1)))) { Response::redirect('/'); } $category_id = Model_Base_Category::get_id_by_code($code); $total_page = ceil(Model_Base_Product::count_by_category($category_id) / _DEFAULT_LIMIT_); View::set_global('total_page', $total_page); $this->data['products'] = Model_Base_Product::get_by_category($category_id); $this->template->title = 'Category Page'; $this->template->content = View::forge($this->layout . '/category/list', $this->data); }
/** * Get the content/body to return to browser. * * If the request is a pjax one, only the body is returned. * * @param string $value * @return string */ public function body($value = false) { $value and $this->body = $value; // Deal with pjax request $turbo = new Turbo(); if ($turbo->isPjax()) { $this->body = $turbo->extract((string) $this->body); } // Fire event, then remove so that not called multiple times Event::trigger('turbo.pjax'); Event::unregister('turbo.pjax'); return parent::body($this->body); }
/** * @author NamNT * action index */ public function action_index() { $model = new \Model_Employment(); $person = new \Model_Person(); $person_id = \Input::get('person_id'); $data = array(); if (!$person_id) { Response::redirect('job/persons'); } if (!($data_person = $person::find($person_id))) { Response::redirect('job/persons'); } $data = $model->get_data_detail($person_id); $data['person_id'] = $person_id; $application_date = $data_person['application_date']; $get_date = getdate(strtotime($application_date)); if ($get_date['mday'] == '29' and $get_date['mon'] == '2') { $registration_expiration = date('Y-m-d', strtotime(date('Y-m-d', strtotime($application_date)) . ' + 1 year' . '-1 day')); } else { $registration_expiration = date('Y-m-d', strtotime(date('Y-m-d', strtotime($application_date)) . ' + 1 year')); } $data['reg_expiration'] = $registration_expiration; if (\Input::method() == 'POST') { $datas = \Input::post(); foreach ($datas as $key => $value) { if (\Input::post($key) == '') { $datas[$key] = null; } } if ($model->find($person_id)) { $model = $model->find($person_id); $datas['obic7_flag'] = isset($datas['obic7_flag']) ? 1 : 0; if ($datas['obic7_flag'] == 1 && $model->obic7_flag != 1) { $datas['obic7_date'] = date('Y-m-d', time()); } } else { $datas['person_id'] = $person_id; $datas['created_at'] = date('Y-m-d H:i:s'); if (isset($datas['obic7_flag'])) { $datas['obic7_date'] = date('Y-m-d', time()); } } $model->set($datas); if ($model->save()) { Session::set_flash('success', \Constants::$message_create_success); Response::redirect(\Fuel\Core\Uri::base() . 'job/employment?person_id=' . $person_id); } } $this->template->title = 'UOS求人システム'; $this->template->content = \View::forge('employment/index', $data); }
public function action_edit($id = null) { if (\Fuel\Core\Input::method() == 'POST') { $id = \Fuel\Core\Input::post('id'); } if (!($user = Model_User::find($id))) { \Fuel\Core\Session::set_flash('error', 'Could not find user # ' . $id); \Fuel\Core\Response::redirect('admin/users'); } $val = Model_User::validate('edit'); if (\Fuel\Core\Input::method() == 'POST') { if ($val->run()) { $user->username = \Fuel\Core\Input::post('username'); $user->email = \Fuel\Core\Input::post('email'); $user->group = \Fuel\Core\Input::post('group'); $user->first_name = \Fuel\Core\Input::post('first_name'); $user->last_name = \Fuel\Core\Input::post('last_name'); $user->target_billable = \Fuel\Core\Input::post('target_billable'); $user->target_unbillable = \Fuel\Core\Input::post('target_unbillable'); try { if ($user->save()) { Session::set_flash('success', e('Updated user #' . $id)); Response::redirect('admin/users'); } else { Session::set_flash('error', e('Could not update user #' . $id)); } } catch (\SimpleUserUpdateException $ex) { // duplicate email address if ($ex->getCode() == 2) { Fuel\Core\Session::set_flash('error', 'Email already exists.'); } elseif ($ex->getCode() == 3) { Fuel\Core\Session::set_flash('error', 'Username already exists.'); } else { Fuel\Core\Session::set_flash('error', $ex->getMessage()); } } } else { if (Input::method() == 'POST') { Session::set_flash('error', $val->error()); } } } $this->template->set_global('user', $user, false); $this->template->set_global('val', $val, false); $this->template->set_global('groups', $this->get_groups_list()); $this->template->title = "Users"; $this->template->content = View::forge('admin/users/edit'); }
public function action_change_status() { if ($contact_id = Input::post('contact_id')) { $user_login = Session::get('login_info'); $contact = \Model_Contact::find_by_pk($contact_id); if (Input::post('status') == 0) { $contact->set(array('status' => 1, 'user_id' => $user_login['user_id'], 'update_at' => date('Y-m-d H:i:s'))); } if (Input::post('status') == 1) { $contact->set(array('status' => 0, 'user_id' => null, 'update_at' => null)); } $contact->save(); Response::redirect(Uri::base() . 'support/contacts?' . Session::get('url_filter_contacts')); } Response::redirect(Uri::base() . 'support/contacts?' . Session::get('url_filter_contacts')); }
/** * @author Thuanth6589 <*****@*****.**> * delete sssale */ public function action_delete() { if (Input::method() == 'POST') { $sssale_id = Input::post('sssale_id'); $result = 'error-' . Input::post('panel_index'); $message = \Constants::$message_delete_error; if (isset($sssale_id) && ($sssale = \Model_Sssale::find_by_pk($sssale_id))) { if ($sssale->delete_data()) { $result = 'success'; $message = \Constants::$message_delete_success; } } Session::set_flash($result, $message); } $url = Session::get('sssale_url') ? Session::get('sssale_url') : Uri::base() . 'master/sslist'; return Response::redirect($url); }
public function before() { parent::before(); if ($login_info = \Fuel\Core\Session::get('login_info') and $login_info['expired'] < time()) { \Fuel\Core\Session::delete('login_info'); } if ($login_info = \Fuel\Core\Session::get('login_info')) { $login_info['expired'] = time() + 30 * 60; \Fuel\Core\Session::set('login_info', $login_info); } if (!\Fuel\Core\Session::get('login_info')) { \Fuel\Core\Response::redirect('login'); } if (!$this->_check_permission()) { \Fuel\Core\Response::redirect('access_denied'); } }
/** * @author Thuanth6589 <*****@*****.**> * action delete user */ public function action_delete() { if (Input::method() == 'POST') { $user_id = Input::post('user_id', null); $result = 'error'; if (!\Model_Muser::find_by_pk($user_id)) { $message = 'ユーザーは存在しません'; } else { $message = \Constants::$message_delete_error; $user = new \Model_Muser(); if ($user->delete_data($user_id)) { $result = 'success'; $message = \Constants::$message_delete_success; } } Session::set_flash($result, $message); } $url = Session::get('users_url') ? Session::get('users_url') : Uri::base() . 'master/users'; return Response::redirect($url); }
/** * @author Thuanth6589 * action index */ public function action_index() { $data['person_id'] = Input::get('person_id', ''); $inteview_usami = new \Model_Interviewusami(); if ($data['person_id'] == '' || !\Model_Person::find($data['person_id'])) { return Response::redirect(Uri::base() . 'job/persons'); } $data['inteview_usami'] = \Model_Interviewusami::find_one_by('person_id', $data['person_id']); if (Input::method() == 'POST') { $fields = Input::post('data'); $inteview_usami->set_data($fields); if ($inteview_usami->save_data()) { Session::set_flash('success', \Constants::$message_create_success); return Response::redirect(Uri::base() . 'job/interviewusami?person_id=' . $data['person_id']); } Session::set_flash('error', \Constants::$message_create_error); } $this->template->title = 'UOS求人システム'; $this->template->content = View::forge('interviewusami/index', $data); }
public function action_confirm() { $confirmView = View::forge('login/confirm'); // Lay du lieu tu DB $userData = $this->connectDB(); //var_dump($userData); // So sanh username va password voi du lieu trong DB if (!empty($_POST['username'] && !empty($_POST['password']))) { for ($i = 0; $i < 3; $i++) { if ($_POST['username'] === $userData[$i]['username']) { $confirmView->set('username', $_POST['username']); } if ($_POST['password'] === $userData[$i]['password']) { $confirmView->set('password', $_POST['password']); } } } else { echo "<br>ERROR++++++++++++++++++++++++++++++++++ERROR<br>"; } return Response::forge($confirmView); }
public function post_add_image_with_url() { $data = Libs\Helper\Input::get_new_data_photo_by_url(); if (!empty(Input::post('push_facebook_on'))) { //*** Call api if (!Libs\Helper\Features::post_photo_to_fb_by_url($data['content'])) { //Unset push_facebook_on $data['push_facebook_on'] = 0; Session::set_flash('warning', 'Cannot post to facebook. Please try again later'); } } //*** Add to DB if (!Model_Posts::add_new_post($data)) { Session::set_flash('error', 'Cannot add new post'); \Fuel\Core\Response::redirect('fanpage/index'); } Session::set_flash('success', 'Added new post'); Response::redirect('fanpage/dashboard/' . Input::post('page_id')); }