Beispiel #1
0
 function index()
 {
     $main_view = new View('main');
     $main_view->set_global('username', $this->username);
     $main_view->set_global('role_id', $this->role_id);
     $main_view->render(TRUE);
 }
Beispiel #2
0
 protected function _setLayoutVars()
 {
     $this->layout->set('months', $this->_getMonths());
     $this->layout->set('days', $this->_getDays());
     $this->layout->set_global('active_month', "{$this->_year}/{$this->_month}");
     $this->layout->set_global('active_day', $this->_day);
     $this->layout->set_global('active_report', "{$this->_day}.php");
     $this->layout->set_global('log_level', $this->_level);
 }
Beispiel #3
0
 public function action_register()
 {
     $employee = \Model_Employee::query()->where(['user_id' => \Auth::get_user()->id, 'seller_id' => \Session::get('seller')->id])->get_one();
     $store = false;
     if ($employee) {
         $store = \Model_Store::query()->where(['seller_id' => \Session::get('seller')->id, 'manager_id' => $employee->id])->get_one();
     }
     $create_flag = false;
     if (\Input::method() == 'POST') {
         $data = \Input::post();
         if (!$employee) {
             $employee = \Model_Employee::forge();
         }
         $employee->set(['user_id' => \Auth::get_user()->id, 'seller_id' => \Session::get('seller')->id, 'no' => time(), 'work_tel' => $data['work_tel'], 'work_phone' => $data['work_phone']]);
         if ($employee->save()) {
             if (!$store) {
                 $create_flag = true;
                 $store = \Model_Store::forge();
             }
             $store->set(['manager_id' => $employee->id, 'seller_id' => \Session::get('seller')->id, 'no' => time(), 'name' => $data['name'], 'tel' => $data['tel'], 'phone' => $data['phone']]);
             if ($store->save()) {
                 if ($create_flag) {
                     //发送发货模板消息
                     $params = ['first' => ['value' => '您推荐的一个会员已成功申请店铺!', 'color' => '#D02090'], 'keyword1' => ['value' => \Auth::get_user()->username, 'color' => '#D02090'], 'keyword2' => ['value' => $data['work_phone'], 'color' => '#D02090'], 'keyword3' => ['value' => date('Y年m月d日 H时i分s秒'), 'color' => '#D02090'], 'remark' => ['value' => '', 'color' => '#D02090']];
                     $this->sendMsgTemplate('x8ykw2fHARq6QYKFWUJZjU3M6beYxoimtKJNWQWF4XQ', $params, 'http://ticket.wangxiaolei.cn');
                 }
             }
         }
     }
     $params = ['employee' => $employee, 'store' => $store, 'people' => \Model_People::query()->where('parent_id', \Auth::get_user()->id)->get_one()];
     \View::set_global($params);
     $this->template->content = \View::forge("{$this->theme}/register");
 }
Beispiel #4
0
 public function __construct($request, $response)
 {
     $this->info = new AdminInfo();
     $this->translator = FrontHelper::getTranslation();
     View::set_global('translator', $this->translator);
     parent::__construct($request, $response);
 }
Beispiel #5
0
 public function before()
 {
     if (!User::current()) {
         $this->redirect('/login');
     }
     $url = str_replace('.', '_', URL::base() . $this->request->uri());
     if (isset($_GET[$url])) {
         unset($_GET[$url]);
     }
     if (isset($_GET[$url . '/'])) {
         unset($_GET[$url . '/']);
     }
     if (Group::current('is_admin') || Group::current('show_all_jobs') && Group::current('allow_finance')) {
         Pager::$counts[] = 2500;
     }
     if (Arr::get($_GET, 'limit') && in_array($_GET['limit'], Pager::$counts)) {
         DB::update('users')->set(array('list_items' => intval($_GET['limit'])))->where('id', '=', User::current('id'))->execute();
         die(json_encode(array('success' => 'true')));
     }
     if (Arr::get($_GET, 'dismiss')) {
         DB::delete('notifications')->where('user_id', '=', User::current('id'))->and_where('id', '=', intval($_GET['dismiss']))->execute();
         die(json_encode(array('success' => 'true')));
     }
     if (!Group::current('allow_assign')) {
         Enums::$statuses[Enums::STATUS_UNALLOC] = 'Not active';
     }
     View::set_global('notifications', DB::select()->from('notifications')->where('user_id', '=', User::current('id'))->order_by('id', 'desc')->execute());
 }
Beispiel #6
0
 public function before()
 {
     parent::before();
     //Visits
     $visited = \Cookie::get('visited', false);
     if (!$visited) {
         \Dashboard::log_visitor();
         \Cookie::set("visited", true, time() + 86400);
     }
     // Cart
     \Config::load('cart', true);
     $cartManager = new \Cart\Manager(\Config::get('cart'));
     \CartManager::init($cartManager);
     \CartManager::context('Cart');
     // Set Visitors group default
     \Product\Model_Attribute::set_user_group(3);
     \Theme::instance()->active('frontend');
     \Theme::instance()->set_template($this->template);
     // Set a global variable so views can use it
     $seo = array('meta_title' => '', 'meta_description' => '', 'meta_keywords' => '', 'canonical_links' => '', 'meta_robots_index' => 1, 'meta_robots_follow' => 1);
     \View::set_global('seo', $seo, false);
     \View::set_global('theme', \Theme::instance(), false);
     \View::set_global('logged', $this->check_logged(), false);
     \View::set_global('guest', $this->check_guest(), false);
     \View::set_global('logged_type', $this->check_logged_type(), false);
 }
Beispiel #7
0
 public function getFeatureForm()
 {
     $feature = Input::instance()->post('Feature');
     if ($feature['ftr_package_id'] != 0) {
         $packageobj = Doctrine::getTable('package')->find($feature['ftr_package_id']);
         if ($packageobj) {
             try {
                 if (!($package = Package_Catalog::getInstalledPackage($packageobj->name))) {
                     echo 'Package not ' . $packageobj->name . ' found.';
                     exit;
                 }
                 $formfile = $package['directory'] . '/views/' . $packageobj->name . '/' . $feature['ftr_name'] . '.php';
                 if (!file_exists($formfile)) {
                     exit;
                 } else {
                     $featureFormView = new View($packageobj->name . '/' . $feature['ftr_name']);
                     $featureFormView->set_global('Feature', (object) $feature);
                     echo $featureFormView->render(TRUE);
                 }
             } catch (Package_Catalog_Exception $e) {
                 echo 'Package not ' . $packageobj->name . ' found.';
             }
         }
     }
     exit;
 }
Beispiel #8
0
 public function before()
 {
     parent::before();
     // if user not connected and not on the login, 404 or session_up pages then redirect to login page
     if (Request::active()->action != 'login' && !Sentry::check() && Request::active()->action != '404' && Request::active()->action != 'session_up') {
         Session::set(array('redirect' => Request::active()->route->translation));
         Response::redirect('login');
     }
     $this->current_user = self::current_user();
     View::set_global('current_user', self::current_user());
     if (Sentry::check()) {
         // logout if banned
         if (Sentry::attempts($this->current_user->username)->get() == Sentry::attempts()->get_limit()) {
             Session::set_flash('Your account has been blocked');
             Sentry::logout();
             Response::redirect('login');
         }
     }
     View::set_global('site_title', 'IKON Backend');
     View::set_global('separator', '/');
     foreach (Model_Forms::find('all') as $k => $form) {
         $this->tables[$k]['cleanName'] = $form->cleanName;
         $this->tables[$k]['url'] = $form->url;
         $this->tables[$k]['table'] = $form->table;
     }
     View::set_global('tables', $this->tables);
 }
Beispiel #9
0
 protected function template_set_global_vars()
 {
     parent::template_set_global_vars();
     if ($this->request->current()->is_initial()) {
         View::set_global('MAIN_SITE', $this->site_main());
     }
 }
Beispiel #10
0
 /**
  * The index action
  * 
  * @access public
  * @return void
  */
 public function action_index()
 {
     $settings = \Config::load('autoresponder.db');
     // $autoResponder = Model_Setting::find(array('where' => array(array('meta_key', '=', 'auto-responders'))));
     if (\Input::post()) {
         $input = \Input::post();
         if (!\Input::is_ajax()) {
             $val = Model_Setting::validate('create');
             if (!$val->run()) {
                 if ($val->error() != array()) {
                     // show validation errors
                     \Messages::error('<strong>There was an error while trying to create settings</strong>');
                     foreach ($val->error() as $e) {
                         \Messages::error($e->get_message());
                     }
                 }
             } else {
                 try {
                     \Config::save('autoresponder.db', array('logo_url' => $input['logo_url'], 'company_name' => $input['company_name'], 'address' => $input['address'], 'website' => $input['website'], 'phone' => $input['phone'], 'email_address' => $input['email_address'], 'sender_email_address' => $input['sender_email_address'], 'contact_us_email_address' => $input['contact_us_email_address'], 'instagram_account_name' => $input['instagram_account_name'], 'facebook_account_name' => $input['facebook_account_name']));
                     // $setting->save();
                     \Messages::success('Settings successfully created.');
                     \Response::redirect('admin/settings');
                 } catch (\Database_Exception $e) {
                     // show validation errors
                     \Messages::error('<strong>There was an error while trying to create settings.</strong>');
                     // Uncomment lines below to show database errors
                     $errors = $e->getMessage();
                     \Messages::error($errors);
                 }
             }
         }
     }
     \View::set_global('title', 'Settings');
     \Theme::instance()->set_partial('content', $this->view_dir . 'index')->set('settings', $settings, false);
 }
Beispiel #11
0
 public function getDispositionForm()
 {
     $faxprof = Input::instance()->post('faxprofile');
     $faxdisp = Doctrine::getTable('FaxDisposition')->find($faxprof['fxp_fxd_id']);
     if ($faxdisp) {
         $packageobj = Doctrine::getTable('package')->find($faxdisp['fxd_package_id']);
         if ($packageobj) {
             try {
                 if (!($package = Package_Catalog::getInstalledPackage($packageobj->name))) {
                     echo 'Package not ' . $packageobj->name . ' found.';
                     exit;
                 }
                 $formfile = $package['directory'] . '/views/' . $packageobj->name . '/' . $faxdisp['fxd_name'] . '.php';
                 kohana::Log('debug', 'Looking for view ' . $formfile);
                 if (file_exists($formfile)) {
                     $featureFormView = new View($packageobj->name . '/' . $faxdisp['fxd_name']);
                     kohana::Log('debug', 'View file found.');
                     if (isset($faxprof['fxp_id']) && !empty($faxprof['fxp_id']) && $faxprof['fxp_id'] != '') {
                         $faxprofobj = Doctrine::getTable('FaxProfile')->find($faxprof['fxp_id']);
                     } else {
                         $faxprofobj = new FaxProfile();
                     }
                     $featureFormView->set_global('faxprofile', $faxprofobj);
                     echo $featureFormView->render(TRUE);
                 } else {
                     kohana::Log('debug', 'View file not found.');
                 }
             } catch (Package_Catalog_Exception $e) {
                 echo 'Package not ' . $packageobj->name . ' found.';
             }
         }
     }
     exit;
 }
Beispiel #12
0
 public function action_profile($id = 0)
 {
     $params = ['title' => '用户信息面板——用户管理', 'action_name' => '用户信息面板'];
     $params['people'] = \Model_People::find($id);
     \View::set_global($params);
     $this->template->content = \View::forge("{$this->theme}/user/profile");
 }
 public function before()
 {
     parent::before();
     View::set_global('base', URL::base(TRUE, FALSE));
     $this->__JS__ = 'public/static/template/admin/';
     $this->__CSS__ = 'public/static/template/admin/';
 }
Beispiel #14
0
 public function action_tags()
 {
     $widgets = array();
     $tagName = urldecode($this->request->param('id'));
     $materials = new Model_Material('groups');
     $materialList = $materials->getMidFromTags($tagName);
     if (!$materialList) {
         throw new HTTP_Exception_404();
     }
     //Описание ингридиента
     $tagUrl = $materials->str2url($tagName);
     $ingridientId = $materials->getMaterialIdByUrl($tagUrl);
     if ($ingridientId) {
         $widgets[] = Request::factory('widgets/material/index/' . $ingridientId)->execute();
     }
     $this->styles = array('/css/search.css');
     $old_styles = $this->template->styles;
     array_unique($this->styles);
     $new_styles = array_merge($this->styles, $old_styles);
     $this->template->styles = $new_styles;
     $this->template->title = $tagName . '';
     $this->template->page_title = $tagName;
     $this->template->keywords = $tagName . '' . $tagName;
     $this->template->description = '' . $tagName;
     $materialsString = implode('/', $materialList);
     View::set_global('categoryName', '');
     $widgets[] = Request::factory('widgets/catalog/index/' . $materialsString . '/tags')->execute();
     $this->template->styles[] = 'css/catalog.css';
     $this->template->block_center = $widgets;
 }
Beispiel #15
0
 /**
  * 拍品详情
  *
  * @param int $id 拍品ID
  */
 public function action_view($id = 0)
 {
     $params = ['title' => '精选拍品'];
     $params['item'] = \Model_Lot::find($id);
     \View::set_global($params);
     $this->template->content = \View::forge("{$this->theme}/lot/view");
 }
Beispiel #16
0
 function before()
 {
     parent::before();
     $this->session = Session::instance();
     $this->auth = Auth::instance();
     $this->user = $this->auth->get_user();
     $this->cache = Cache::instance();
     if ($this->auto_render) {
         // Initialize empty values
         $this->template->user = $this->user;
         $this->template->styles = array();
         $this->template->scripts = array();
         $this->template->title = '';
         $this->template->meta_keywords = '';
         $this->template->meta_description = '';
         $this->template->meta_copywrite = '';
         // Breadcrubms
         $this->template->bc = array();
         $this->template->content = '';
         $this->template->user = $this->user;
         $this->template->debug = array();
     }
     //View::set_global('user', $this->user);
     View::set_global('title', $this->template->title);
 }
Beispiel #17
0
 public function action_create()
 {
     if (\Input::method() == 'POST') {
         $msg = ['msg' => '', 'errcode' => 0, 'status' => 'succ'];
         //检测必要的订单信息
         $data = \Input::post();
         //生成订单明细
         $details = [];
         foreach ($data['goods'] as $id) {
             $item = \Model_Trolley::find_one_by('goods_id', $id);
             array_push($details, $item->to_array());
         }
         $this->load_details($details);
         //生成优惠信息
         $this->load_preferential($data['coupons']);
         if (!$this->save($data)) {
             $msg = ['msg' => $this->result_message, 'errcode' => 20, 'status' => 'err'];
         }
         if (\Input::is_ajax()) {
             die(json_encode($msg));
         }
     }
     $params = ['title' => ''];
     $params['trolley_ids'] = [1, 2, 3];
     \View::set_global($params);
     $this->template->title = '创建订单';
     $this->template->content = \View::forge("{$this->theme}/create");
 }
Beispiel #18
0
 protected function _set_view_globals()
 {
     View::bind_global('site_title', $this->_config->site_title);
     View::bind_global('oUser', $this->_oUser);
     View::set_global('action', $this->request->action());
     View::set_global('welcome', Session::instance()->get('title'));
 }
 public function before()
 {
     parent::before();
     View::set_global('title', 'Kohana Site');
     $this->template->content = '';
     $this->template->styles = array('style');
     $this->template->scripts = '';
 }
Beispiel #20
0
 public function after()
 {
     View::set_global('title', __($this->title));
     if ($this->auto_render === TRUE && !Request::$is_ajax) {
         // Assign the template as the request response and render it
         $this->request->response = $this->template;
     }
 }
Beispiel #21
0
 public function action_index()
 {
     $this->template->title = 'Chat';
     $this->template->description = 'Asynchronous chat';
     View::set_global('_token', Security::token(true));
     $this->template->messages = View::factory('messages');
     $this->template->send_message_form = View::factory('send_message_form');
 }
Beispiel #22
0
 public function before()
 {
     parent::before();
     // Assign current_user to the instance so controllers can use it
     $this->current_user = Auth::check() ? Model_User::find_by_username(Auth::get_screen_name()) : null;
     // Set a global variable so views can use it
     View::set_global('current_user', $this->current_user);
 }
Beispiel #23
0
 public function action_index()
 {
     if (!\Input::get('id', false)) {
         die('');
     }
     $params['bank'] = \Model_QuestionBank::find(\Input::get('id'));
     \View::set_global($params);
     $this->template->content = \View::forge("questionnaire/{$this->theme}/index");
 }
Beispiel #24
0
 public function after()
 {
     $this->template->styles = array_merge($this->template->styles, $this->theme_config['styles']);
     $this->template->scripts = array_merge($this->template->scripts, $this->theme_config['jscripts']);
     View::set_global(array('title' => !isset($this->template->title) ? $this->config->get('title_admin') : $this->template->title, 'theme_dir' => '/themes/' . $this->config->get('admin_theme') . '', 'user' => $this->user, 'error' => Session::instance()->get('error'), 'message' => Session::instance()->get('message'), 'admin_url' => $this->config->get('admin_url')));
     Session::instance()->set('message', '');
     Session::instance()->set('error', '');
     parent::after();
 }
Beispiel #25
0
 public function action_cashback_records()
 {
     $params = ['title' => '提现记录'];
     $store = \Session::get('store');
     $items = \Model_Order::query()->where(['store_id' => $store->id, 'cashback_status' => 0])->where('order_status', 'IN', ['FINISH', 'SELLER_SHIPPED', 'SECTION_FINISH'])->get();
     $params['items'] = $items;
     \View::set_global($params);
     $this->template->content = \View::forge("{$this->theme}/finance/cashback_records");
 }
Beispiel #26
0
 public function before()
 {
     parent::before();
     View::set_global('title', 'Мой сайт');
     View::set_global('description', 'Самый лучший сайт');
     $this->template->content = '';
     $this->template->styles = '';
     $this->template->scripts = '';
 }
Beispiel #27
0
 public function before()
 {
     parent::before();
     \Theme::instance()->active('admin');
     \Theme::instance()->set_template($this->template);
     // Assign current_user to the instance so controllers can use it
     $this->current_user = \Sentry::check() ? \Sentry::user() : null;
     // Set a global variable so views can use it
     \View::set_global('current_user', $this->current_user);
 }
Beispiel #28
0
 public function before()
 {
     parent::before();
     View::set_global('title', 'ITS');
     View::set_global('description', 'Internet test system');
     //View::bind_global('styles', '');
     $this->template->content = '';
     $this->template->styles = array();
     $this->template->scripts = array();
 }
Beispiel #29
0
 protected function set_login_validation()
 {
     Fieldset::reset();
     $this->login_val = Validation::forge('site_login');
     $options = array('1' => '次回から自動的にログイン');
     $this->login_val->add('rememberme', '', array('type' => 'checkbox', 'options' => $options))->add_rule('checkbox_val', $options);
     $this->login_val->add_model(Model_MemberAuth::forge());
     $this->login_val->fieldset()->field('email')->delete_rule('unique');
     View::set_global('login_val', $this->login_val);
 }
Beispiel #30
0
 public function after()
 {
     View::set_global('current_user', $this->get_current_user());
     if (!$this->response->body()) {
         $layout = View::factory($this->layout, $this->template_data);
         $body = View::factory($this->view, $this->template_data);
         $layout->bind('body', $body);
         $this->response->body($layout);
     }
     parent::after();
 }