FuelPHP Bin
Sign in
Url:
Fork
<?php class Controller_Admin extends Controller_Base { // Initial template settings public $layout = 'adminflare'; public $template = 'layouts/dashboard'; public function before() { parent::before(); Lang::load('lang'); $session = Session::instance(); // Initial template configuration $this->theme->active($this->layout); $this->theme->set_template($this->template); // Get current segments $segments = \Uri::segments(); if (empty($segments)) $segments[0] = 'homepage'; // Set template variables $this->data['template']['title'] = 'HDS Backend'; $this->data['template']['subtitle'] = 'Default subtitle'; $this->data['template']['author'] = 'Default Author'; $this->data['template']['description'] = 'Default description'; $this->data['template']['keywords'] = 'Default keywords'; $this->data['template']['username'] = Session::get('username'); $this->data['template']['segments'] = $segments; $this->theme->get_template()->set('data', $this->data); // Set template partials $this->theme->set_partial('navigation', 'partials/navigation'); $this->theme->set_partial('messages', 'partials/messages'); // Checking authorisation to see Admin section or go back to login if (Request::active()->controller !== 'Controller_Admin' or ! in_array(Request::active()->action, array('login', 'logout', 'register','mail'))) { if (Auth::check()) { $admin_group_id = Config::get('auth.driver', 'Simpleauth') == 'Ormauth' ? 6 : 100; if ( ! Auth::member($admin_group_id)) { Session::set_flash('error', e('You don\'t have access to the admin panel')); Session::set_flash('error', __('login.no_access_panel').$current_user->username); Response::redirect('/'); } } else { Response::redirect('admin/login'); } } } public function action_mail() { // Create an instance $email = Email::forge(); // Set the from address $email->from('backend@hoteldatenservice.de', 'HDS Backend'); // Set the to address $email->to('skater26do@gmx.de', 'Skater26'); // Set a subject $email->subject('Registrierung erfolgt'); // And set the body. $email->body('Registrierung hat geklappt...'); \Debug::dump($email); #die; try { $email->send(); Session::set_flash('success',$email); } catch(\EmailValidationFailedException $e) { // The validation failed \Debug::dump($e); Session::set_flash('error',$e->getMessage()); } catch(\EmailSendingFailedException $e) { // The driver could not send the email \Debug::dump($e); Session::set_flash('error',$e->getMessage()); } // Display the login page $view = \View::forge('admin\register'); $this->theme->set_template('layouts/sign'); $this->theme->set_partial('content', $view)->set('data', $this->data); } public function after($response) { // If no response object was returned by the action, if (empty($response) or ! $response instanceof Response) { // render the defined template $response = \Response::forge(\Theme::instance()->render()); } return parent::after($response); } }