This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
khosb/application/classes/Controller/TemplateDefault.php

76 lines
2.7 KiB
PHP
Raw Normal View History

2013-10-10 02:44:53 +00:00
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides the default template controller for rendering pages.
*
* @package OSB
* @category Controllers
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Controller_TemplateDefault extends lnApp_Controller_TemplateDefault {
protected $auth_required = TRUE;
// Our acccount object
protected $ao;
public function __construct(Request $request, Response $response) {
$this->template = Config::theme().'/page';
2013-10-10 02:44:53 +00:00
return parent::__construct($request,$response);
}
public function before() {
// If our action doesnt exist, no point processing any further.
if (! method_exists($this,'action_'.Request::current()->action()))
return;
if ($this->auth_required) {
if (! count($this->secure_actions) OR (! isset($this->secure_actions[Request::current()->action()])))
2013-05-10 10:48:10 +00:00
throw HTTP_Exception::factory(403,'Class has no security defined :class, or no security configured for :method',array(':class'=>get_class($this),':method'=>Request::current()->action()));
2013-10-10 02:44:53 +00:00
$this->ao = Auth::instance()->get_user();
if (! is_null($this->ao) AND (is_string($this->ao) OR ! $this->ao->loaded()))
throw HTTP_Exception::factory(501,'Account doesnt exist :account ?',array(':account'=>(is_string($this->ao) OR is_null($this->ao)) ? $this->ao : Auth::instance()->get_user()->id));
}
parent::before();
}
2013-05-10 10:48:10 +00:00
// @todo To rework
2013-10-10 02:44:53 +00:00
public function after() {
$dc = URL::link('user','welcome/index');
2013-10-10 02:44:53 +00:00
$m = sprintf('%s/%s',Request::current()->directory(),Request::current()->controller());
BreadCrumb::URL(Request::current()->directory(),sprintf('%s/%s',Request::current()->directory(),$dc),FALSE);
BreadCrumb::URL($m,method_exists($this,'action_menu') ? $m.'/menu' : sprintf('%s/%s',Request::current()->directory(),$dc),FALSE);
parent::after();
}
protected function setup(array $config_items=array()) {
$mo = ORM::factory('Module',array('name'=>Request::current()->controller()));
if (! $mo->loaded())
throw HTTP_Exception::factory(501,'Unknown module :module',array(':module'=>Request::current()->controller()));
2013-10-10 02:44:53 +00:00
if ($_POST AND isset($_POST['module_config'][$mo->id]))
if (Config::instance()->module_config($mo->name,$_POST['module_config'][$mo->id])->save())
SystemMessage::factory()
->title('Record updated')
->type('success')
->body(_('Your setup record has been updated.'));
2013-10-10 02:44:53 +00:00
if ($config_items) {
Block::factory()
->title('Update Module Configuration')
->title_icon('icon-wrench')
->type('form-horizontal')
->body(View::factory('setup/admin/module')->set('o',Company::instance()->so())->set('mid',$mo->id));
2013-10-10 02:44:53 +00:00
}
}
}
?>