2010-11-29 22:41:08 +00:00
|
|
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
|
2011-09-28 06:46:22 +00:00
|
|
|
/**
|
|
|
|
* This class is for access system configuration.
|
|
|
|
*
|
|
|
|
* @package OSB
|
|
|
|
* @subpackage Config
|
|
|
|
* @category Helpers
|
|
|
|
* @author Deon George
|
|
|
|
* @copyright (c) 2010 Open Source Billing
|
|
|
|
* @license http://dev.osbill.net/license.html
|
|
|
|
*/
|
2011-05-02 12:28:17 +00:00
|
|
|
class Config extends lnApp_Config {
|
2011-09-29 07:13:32 +00:00
|
|
|
// Our setup object
|
|
|
|
public $so;
|
2011-12-30 07:10:02 +00:00
|
|
|
public static $no_site_id_tables = array('setup','country','currency','tax');
|
2011-09-29 07:13:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Load our site configuration from the DB
|
|
|
|
*
|
|
|
|
* We cant do this in __construct(), since Kohana hasn't been fully initialised yet.
|
|
|
|
*/
|
|
|
|
public function loadsite() {
|
|
|
|
// Anti-loop, if we have loaded our record, just return;
|
|
|
|
if ($this->so AND $this->so->loaded())
|
|
|
|
return $this;
|
|
|
|
|
|
|
|
$this->so = ORM::factory('setup',array('nonssl_url'=>URL::base('http')));
|
|
|
|
|
|
|
|
if (! $this->so->loaded())
|
|
|
|
throw new Kohana_Exception(_('Site [:site] not defined in DB?'),array(':site'=>URL::base('http')));
|
|
|
|
|
2011-10-14 05:44:12 +00:00
|
|
|
Kohana::$environment = (int)static::sitemode();
|
|
|
|
|
2011-09-29 07:13:32 +00:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2011-05-02 12:28:17 +00:00
|
|
|
/**
|
|
|
|
* Find a list of all database enabled modules
|
|
|
|
*
|
2011-09-17 10:45:08 +00:00
|
|
|
* Our available modules are defined in the DB (along with method
|
|
|
|
* security).
|
2011-05-02 12:28:17 +00:00
|
|
|
*/
|
2011-09-28 06:46:22 +00:00
|
|
|
public static function modules() {
|
|
|
|
static $return = array();
|
2011-05-02 12:28:17 +00:00
|
|
|
|
2011-09-28 06:46:22 +00:00
|
|
|
if (! count($return))
|
|
|
|
foreach (ORM::factory('module')->where('status','=',1)->find_all() as $mo)
|
|
|
|
$return[$mo->name] = MODPATH.$mo->name;
|
2011-05-02 12:28:17 +00:00
|
|
|
|
2011-09-28 06:46:22 +00:00
|
|
|
return $return;
|
|
|
|
}
|
2011-05-02 12:28:17 +00:00
|
|
|
|
2011-09-28 06:46:22 +00:00
|
|
|
public static function moduleexist($module) {
|
|
|
|
return array_key_exists($module,static::modules()) ? TRUE : FALSE;
|
2011-05-02 12:28:17 +00:00
|
|
|
}
|
2011-12-30 07:10:02 +00:00
|
|
|
|
|
|
|
public static function sitename() {
|
|
|
|
return Company::name();
|
|
|
|
}
|
|
|
|
|
2012-01-11 08:59:20 +00:00
|
|
|
public static function siteid($format=FALSE) {
|
|
|
|
return $format ? sprintf('%02s',Config::instance()->loadsite()->so->id) : Config::instance()->loadsite()->so->id;
|
2011-12-30 07:10:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function sitemode() {
|
|
|
|
return Config::instance()->loadsite()->so->status;
|
|
|
|
}
|
2012-01-29 06:23:24 +00:00
|
|
|
|
|
|
|
public static function copywrite() {
|
|
|
|
return '(c) Open Source Billing Development Team';
|
|
|
|
}
|
2011-05-02 12:28:17 +00:00
|
|
|
}
|
2010-11-29 22:41:08 +00:00
|
|
|
?>
|