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
|
|
|
|
*/
|
2013-10-28 23:41:14 +00:00
|
|
|
abstract class Controller_TemplateDefault extends lnApp_Controller_TemplateDefault {
|
2013-10-10 02:44:53 +00:00
|
|
|
protected $auth_required = TRUE;
|
|
|
|
|
2013-11-22 04:36:50 +00:00
|
|
|
protected function save(Model $o) {
|
|
|
|
try {
|
2013-11-27 00:22:20 +00:00
|
|
|
return $o->save();
|
2013-11-22 04:36:50 +00:00
|
|
|
|
|
|
|
} catch (ORM_Validation_Exception $e) {
|
|
|
|
SystemMessage::factory()
|
|
|
|
->title('Record NOT updated')
|
|
|
|
->type('error')
|
|
|
|
->body(join('<br/>',array_values($e->errors('models'))));
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-10 02:44:53 +00:00
|
|
|
protected function setup(array $config_items=array()) {
|
2013-10-09 05:43:41 +00:00
|
|
|
$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
|
|
|
|
2016-08-03 06:20:25 +00:00
|
|
|
if ($this->request->post() AND array_key_exists($mo->id,$this->request->post('module_config')))
|
|
|
|
Config::instance()->module_config($mo->name,$this->request->post('module_config.'.$mo->id))->save();
|
2013-10-10 02:44:53 +00:00
|
|
|
|
|
|
|
if ($config_items) {
|
2013-10-09 05:43:41 +00:00
|
|
|
Block::factory()
|
|
|
|
->title('Update Module Configuration')
|
2016-08-15 11:23:18 +00:00
|
|
|
->title_icon('fa fa-wrench')
|
2013-10-09 05:43:41 +00:00
|
|
|
->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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|