Exemple #1
0
 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();
 }
Exemple #2
0
 public function is_admin()
 {
     list(list(, $group_id)) = Auth::get_groups();
     if ($group_id != 100) {
         Response::redirect('/admin/signin');
     }
 }
 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();
     }
 }
Exemple #4
0
 public function action_index()
 {
     if (Auth::check()) {
         return Response::redirect('admin/home');
     } else {
         return Response::redirect('admin/login');
     }
 }
Exemple #5
0
 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();
 }
 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);
 }
Exemple #8
0
 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');
     }
 }
Exemple #9
0
 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);
 }
Exemple #10
0
 /**
  * @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);
 }
Exemple #11
0
 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');
     }
 }
Exemple #12
0
 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);
 }
Exemple #13
0
 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);
 }
 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
 }
Exemple #15
0
 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);
     }
 }
Exemple #16
0
 /**
  * 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;
 }
Exemple #17
0
 /**
  * @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');
 }
Exemple #19
0
 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'));
 }
Exemple #20
0
 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');
     }
 }
Exemple #21
0
 /**
  * @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);
 }
Exemple #22
0
 /**
  * @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);
 }
Exemple #23
0
 /**
  * @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);
 }
 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'));
 }
 public function action_filter($customer_id = null)
 {
     \Fuel\Core\Response::redirect('user/projects/');
 }
Exemple #26
0
 /**
  * @author Thuanth6589 <*****@*****.**>
  * action delete media
  */
 public function action_delete()
 {
     if (Input::method() == 'POST') {
         $result = 'error';
         $m_media_id = Input::post('m_media_id', null);
         if (!\Model_Mmedia::find_by_pk($m_media_id)) {
             $message = '媒体は存在しません';
         } else {
             $umedia = new \Model_Umedia();
             $message = \Constants::$message_delete_error;
             if ($umedia->delete_media($m_media_id)) {
                 $result = 'success';
                 $message = \Constants::$message_delete_success;
             }
         }
         Session::set_flash($result, $message);
     }
     $url = Session::get('medias_url') ? Session::get('medias_url') : Uri::base() . 'master/medias';
     return Response::redirect($url);
 }
Exemple #27
0
 public function action_index()
 {
     return Response::redirect('admissions/home');
 }
Exemple #28
0
 public function action_fields($id, $type)
 {
     $pass = Model_Pass::find($id);
     if (\Fuel\Core\Input::method() == 'POST') {
         if ($type == 'primary') {
             $pass->set_primary_field(\Fuel\Core\Input::post('label', ''), \Fuel\Core\Input::post('value', ''));
             Session::set_flash('success', e('Added ' . $type . ' field.'));
         } else {
             $pass->set_field(Model_Field::string2type($type), \Fuel\Core\Input::post('key', ''), \Fuel\Core\Input::post('label', ''), \Fuel\Core\Input::post('value', ''), \Fuel\Core\Input::post('others', ''));
             Session::set_flash('success', e('Added ' . $type . ' field.'));
             \Fuel\Core\Response::redirect('admin/pass/fields/' . $pass->id . '/' . $type);
         }
     }
     if ($type == 'primary') {
         $this->template->set_global('field', $pass->primary_field(), false);
         $this->template->content = View::forge('admin/pass/primaryfields');
     } else {
         $this->template->set_global('fields', $pass->{$type . '_fields'}(), false);
         $this->template->content = View::forge('admin/pass/fields');
     }
     $this->template->set_global('type', $type, false);
     $this->template->set_global('pass', $pass, false);
     $this->template->title = "Pass " . $type . ' fields';
 }
 public function action_create($what = null)
 {
     is_null($what) and \Fuel\Core\Response::redirect('filemanager');
     try {
         if (\Fuel\Core\Input::method() == 'POST') {
             if ($what == 'dir') {
                 $dir = \Fuel\Core\File::create_dir('/var/www/html/' . $this->_dir . '/', \Fuel\Core\Input::post('dir_name'), 0777);
                 if ($dir) {
                     \Fuel\Core\Response::redirect('filemanager');
                 }
             }
         }
     } catch (Exception $e) {
         die($e->getMessage());
     }
     \Fuel\Core\Response::redirect('filemanager');
 }
Exemple #30
0
 /**
  *
  * @return boolean is true str1!=str2
  */
 public function action_index()
 {
     $data_interview = array();
     if (!($person_id = Input::get('person_id')) or !\Model_Person::find($person_id)) {
         Response::redirect(Uri::base() . 'job/persons');
     }
     if ($data = Input::post()) {
         if (isset($data['anamnesis'])) {
             $data['anamnesis'] = json_encode($this->remove_value_empty($data['anamnesis']));
         }
         if (isset($data['medical_history'])) {
             $data['medical_history'] = json_encode($this->remove_value_empty($data['medical_history'], array('name', 'year')));
         }
         if (isset($data['surgical_history'])) {
             $data['surgical_history'] = json_encode($this->remove_value_empty($data['surgical_history'], array('name', 'year')));
         }
         if (isset($data['working_arrangements'])) {
             $data['working_arrangements'] = $this->convertarraytostring($data['working_arrangements']);
         }
         if (isset($data['weekend'])) {
             $data['weekend'] = $this->convertarraytostring($data['weekend']);
         }
         if (isset($data['special_license'])) {
             $data['special_license'] = $this->convertarraytostring($data['special_license']);
         }
         if (isset($data['other'])) {
             $data['other'] = $this->convertarraytostring($data['other']);
         }
         if (isset($data['mechanic_qualification'])) {
             $data['mechanic_qualification'] = $this->convertarraytostring($data['mechanic_qualification']);
         }
         if (isset($data['PC'])) {
             $data['PC'] = $this->convertarraytostring($data['PC']);
         }
         if (isset($data['start_time_hh']) or isset($data['start_time_mm'])) {
             $data['start_time'] = $this->merge_hh_mm($data['start_time_hh'], $data['start_time_mm']);
         }
         if (isset($data['end_time_hh']) or isset($data['end_time_mm'])) {
             $data['end_time'] = $this->merge_hh_mm($data['end_time_hh'], $data['end_time_mm']);
         }
         if (isset($data['weekend_start_time_hh']) or isset($data['weekend_start_time_mm'])) {
             $data['weekend_start_time'] = $this->merge_hh_mm($data['weekend_start_time_hh'], $data['weekend_start_time_mm']);
         }
         if (isset($data['weekend_end_time_hh']) or isset($data['weekend_end_time_mm'])) {
             $data['weekend_end_time'] = $this->merge_hh_mm($data['weekend_end_time_hh'], $data['weekend_end_time_mm']);
         }
         $data['person'] = $person_id;
         $data = \Model_Interview::_set($data);
         $interview_id = null;
         if (isset($data['interview_id']) and $data['interview_id'] != '') {
             $interview_id = $data['interview_id'];
             unset($data['interview_id']);
         }
         $interview = new \Model_Interview();
         if ($interview->save_data($data, $interview_id)) {
             Session::set_flash('success', \Constants::$message_create_success);
         } else {
             Session::set_flash('error', \Constants::$message_create_error);
         }
     }
     if ($interview_data = \Model_Interview::find_one_by('person', $person_id)) {
         $data_interview['interviews'] = $interview_data;
     }
     $this->template->title = 'UOS求人システム';
     $this->template->content = \View::forge('interview/index', $data_interview);
 }