80 lines
2.1 KiB
PHP
80 lines
2.1 KiB
PHP
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
/**
|
|
* OSB Setup Model
|
|
*
|
|
* This module must remain in applications/ as it is used very early in the
|
|
* OSB initialisation.
|
|
*
|
|
* @package OSB
|
|
* @subpackage Modules
|
|
* @category Models
|
|
* @author Deon George
|
|
* @copyright (c) 2010 Deon George
|
|
* @license http://dev.leenooks.net/license.html
|
|
*/
|
|
class Model_Setup extends ORMOSB {
|
|
// Setup doesnt use the update column
|
|
protected $_updated_column = FALSE;
|
|
|
|
protected $_has_one = array(
|
|
'country'=>array('foreign_key'=>'id','far_key'=>'country_id'),
|
|
);
|
|
|
|
public function rules() {
|
|
$r = parent::rules();
|
|
|
|
// This module doesnt use site_id.
|
|
unset($r['site_id']);
|
|
|
|
return $r;
|
|
}
|
|
|
|
/**
|
|
* Get/Set Module Configuration
|
|
*
|
|
* @param $key Module name.
|
|
* @param $value Values to store. If NULL, retrieves the value stored, otherwise stores value.
|
|
*/
|
|
public function module_config($key,array $value=NULL) {
|
|
// If we are not loaded, we dont have any config.
|
|
if (! $this->loaded() OR (is_null($value) AND ! $this->module_config))
|
|
return array();
|
|
|
|
$mo = ORM::factory('module')->where('name','=',$key)->find();
|
|
|
|
if (! $mo->loaded())
|
|
throw new Kohana_Exception('Unknown module :name',array(':name'=>$key));
|
|
|
|
// If $value is NULL, we are a getter
|
|
if ($value === NULL)
|
|
return empty($this->module_config[$mo->id]) ? array() : $this->module_config[$mo->id];
|
|
|
|
// Store new value
|
|
$this->module_config[$mo->id] = $value;
|
|
|
|
return $value;
|
|
}
|
|
|
|
/**
|
|
* Get/Set our Site Configuration from the DB
|
|
*
|
|
* @param $key Key
|
|
* @param $value Values to store. If NULL, retrieves the value stored, otherwise stores value.
|
|
*/
|
|
public function site_details($key,array $value=NULL) {
|
|
if (! in_array($key,array('name','address1','address2','city','state','pcode','phone','fax','email')))
|
|
throw new Kohana_Exception('Unknown Site Configuration Key :key',array(':key'=>$key));
|
|
|
|
// If $value is NULL, we are a getter
|
|
if ($value === NULL)
|
|
return empty($this->site_details[$key]) ? '' : $this->site_details[$key];
|
|
|
|
// Store new value
|
|
$sc[$key] = $value;
|
|
|
|
return $value;
|
|
}
|
|
}
|
|
?>
|