2014-06-30 04:22:57 +00:00
|
|
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This class extends the core Kohana class by adding some core application
|
|
|
|
* specific functions, and configuration.
|
|
|
|
*
|
2014-07-09 03:04:56 +00:00
|
|
|
* @package Membership Database
|
2014-06-30 04:22:57 +00:00
|
|
|
* @category Helpers
|
|
|
|
* @author Deon George
|
|
|
|
* @copyright (c) 2014 Deon George
|
|
|
|
* @license http://dev.leenooks.net/license.html
|
|
|
|
*/
|
|
|
|
class Config extends Kohana_Config {
|
|
|
|
/**
|
|
|
|
* Some early initialisation
|
|
|
|
*
|
|
|
|
* At this point, KH hasnt been fully initialised either, so we cant rely on
|
|
|
|
* too many KH functions yet.
|
|
|
|
*
|
|
|
|
* NOTE: Kohana doesnt provide a parent construct for the Kohana_Config class.
|
|
|
|
*/
|
|
|
|
public function __construct() {
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the singleton instance of Config.
|
|
|
|
*
|
|
|
|
* $config = Config::instance();
|
|
|
|
*
|
|
|
|
* @return Config
|
|
|
|
* @compat Restore KH 3.1 functionality
|
|
|
|
*/
|
|
|
|
public static function instance() {
|
|
|
|
if (Config::$_instance === NULL)
|
|
|
|
// Create a new instance
|
|
|
|
Config::$_instance = new Config;
|
|
|
|
|
|
|
|
return Config::$_instance;
|
|
|
|
}
|
|
|
|
|
2014-09-01 13:01:01 +00:00
|
|
|
public static function Copywrite($html=FALSE) {
|
|
|
|
return ($html ? '©' : '(c)').' 2014 Deon George';
|
2014-06-30 04:22:57 +00:00
|
|
|
}
|
|
|
|
|
2014-07-09 03:04:56 +00:00
|
|
|
public static function version() {
|
|
|
|
// @todo Work out our versioning
|
|
|
|
return 'TBA';
|
2014-06-30 04:22:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-07-09 03:04:56 +00:00
|
|
|
* Find a list of all database enabled modules
|
|
|
|
*
|
|
|
|
* Our available modules are defined in the DB (along with method
|
|
|
|
* security).
|
2014-06-30 04:22:57 +00:00
|
|
|
*/
|
2014-07-09 03:04:56 +00:00
|
|
|
public static function modules() {
|
|
|
|
static $result = array();
|
2014-06-30 04:22:57 +00:00
|
|
|
|
2014-07-09 03:04:56 +00:00
|
|
|
if (! count($result)) {
|
|
|
|
// We need to know our site here, so that we can subsequently load our enabled modules.
|
|
|
|
if (PHP_SAPI === 'cli') {
|
|
|
|
if (! ($site = Minion_CLI::options('site'))) {
|
|
|
|
echo _('Cant figure out the site, use --site= for CLI')."\n";
|
|
|
|
die();
|
2014-06-30 04:22:57 +00:00
|
|
|
|
2014-07-09 03:04:56 +00:00
|
|
|
} else
|
|
|
|
$_SERVER['SERVER_NAME'] = $site;
|
2014-06-30 04:22:57 +00:00
|
|
|
|
2014-07-09 03:04:56 +00:00
|
|
|
}
|
2014-06-30 04:22:57 +00:00
|
|
|
|
2014-07-09 03:04:56 +00:00
|
|
|
foreach (ORM::factory('Module')->list_external() as $mo)
|
|
|
|
$result[$mo->name] = MODPATH.$mo->name;
|
|
|
|
}
|
2014-06-30 04:22:57 +00:00
|
|
|
|
2014-07-09 03:04:56 +00:00
|
|
|
return $result;
|
2014-06-30 04:22:57 +00:00
|
|
|
}
|
|
|
|
|
2014-07-09 03:04:56 +00:00
|
|
|
public static function module_config($item,array $value=NULL) {
|
|
|
|
return Company::instance()->module_config($item,$value);
|
2014-06-30 04:22:57 +00:00
|
|
|
}
|
|
|
|
|
2014-07-09 03:04:56 +00:00
|
|
|
public static function module_exist($module) {
|
|
|
|
return array_key_exists(strtolower($module),self::modules()) ? TRUE : FALSE;
|
2014-06-30 04:22:57 +00:00
|
|
|
}
|
|
|
|
|
2014-07-09 03:04:56 +00:00
|
|
|
/**
|
|
|
|
* See if our emails for the template should be sent to configured admin(s)
|
|
|
|
*
|
|
|
|
* @param string template - Template to test for
|
|
|
|
* @return mixed|array - Email to send test emails to
|
|
|
|
*/
|
|
|
|
public static function testmail($template) {
|
|
|
|
$config = Kohana::$config->load('debug')->email_admin_only;
|
2014-06-30 04:22:57 +00:00
|
|
|
|
2014-07-09 03:04:56 +00:00
|
|
|
if (is_null($config) OR ! is_array($config) OR empty($config[$template]))
|
|
|
|
return FALSE;
|
|
|
|
else
|
|
|
|
return $config[$template];
|
2014-06-30 04:22:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|