Add addon config hook
This commit is contained in:
parent
b10ae510c0
commit
2e2930d770
|
@ -36,10 +36,6 @@ $a->backend = false;
|
||||||
require_once "include/dba.php";
|
require_once "include/dba.php";
|
||||||
|
|
||||||
if (!$a->mode == App::MODE_INSTALL) {
|
if (!$a->mode == App::MODE_INSTALL) {
|
||||||
if (!dba::connected()) {
|
|
||||||
System::unavailable();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load configs from db. Overwrite configs from config/local.ini.php
|
* Load configs from db. Overwrite configs from config/local.ini.php
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -845,6 +845,12 @@ function admin_page_summary(App $a)
|
||||||
$warningtext[] = L10n::t('The last worker execution was on %s UTC. This is older than one hour. Please check your crontab settings.', $last_worker_call);
|
$warningtext[] = L10n::t('The last worker execution was on %s UTC. This is older than one hour. Please check your crontab settings.', $last_worker_call);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Legacy config file warning
|
||||||
|
if (file_exists('.htconfig.php')) {
|
||||||
|
$showwarning = true;
|
||||||
|
$warningtext[] = L10n::t('Friencia\'s configuration now is stored in config/local.ini.php, please copy config/local-sample.ini.php and move your config from <code>.htconfig.php</code>.');
|
||||||
|
}
|
||||||
|
|
||||||
$r = q("SELECT `page-flags`, COUNT(`uid`) AS `count` FROM `user` GROUP BY `page-flags`");
|
$r = q("SELECT `page-flags`, COUNT(`uid`) AS `count` FROM `user` GROUP BY `page-flags`");
|
||||||
$accounts = [
|
$accounts = [
|
||||||
[L10n::t('Normal Account'), 0],
|
[L10n::t('Normal Account'), 0],
|
||||||
|
|
66
src/App.php
66
src/App.php
|
@ -151,6 +151,12 @@ class App
|
||||||
|
|
||||||
$this->determineMode();
|
$this->determineMode();
|
||||||
|
|
||||||
|
if ($this->mode === self::MODE_NORMAL) {
|
||||||
|
Core\Addon::loadHooks();
|
||||||
|
|
||||||
|
$this->loadAddonConfig();
|
||||||
|
}
|
||||||
|
|
||||||
$this->loadDefaultTimezone();
|
$this->loadDefaultTimezone();
|
||||||
|
|
||||||
$this->performance['start'] = microtime(true);
|
$this->performance['start'] = microtime(true);
|
||||||
|
@ -295,6 +301,12 @@ class App
|
||||||
$this->register_template_engine('Friendica\Render\FriendicaSmartyEngine');
|
$this->register_template_engine('Friendica\Render\FriendicaSmartyEngine');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load the configuration files
|
||||||
|
*
|
||||||
|
* First loads the default value for all the configuration keys, then the legacy configuration files, then the
|
||||||
|
* expected local.ini.php
|
||||||
|
*/
|
||||||
private function loadConfigFiles()
|
private function loadConfigFiles()
|
||||||
{
|
{
|
||||||
$this->loadConfigFile($this->basepath . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'defaults.ini.php');
|
$this->loadConfigFile($this->basepath . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'defaults.ini.php');
|
||||||
|
@ -328,6 +340,23 @@ class App
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tries to load the specified configuration file into the App->config array.
|
||||||
|
* Overwrites previously set values.
|
||||||
|
*
|
||||||
|
* The config format is INI and the template for configuration files is the following:
|
||||||
|
*
|
||||||
|
* <?php return <<<INI
|
||||||
|
*
|
||||||
|
* [section]
|
||||||
|
* key = value
|
||||||
|
*
|
||||||
|
* INI;
|
||||||
|
* // Keep this line
|
||||||
|
*
|
||||||
|
* @param type $filepath
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
public function loadConfigFile($filepath)
|
public function loadConfigFile($filepath)
|
||||||
{
|
{
|
||||||
if (!file_exists($filepath)) {
|
if (!file_exists($filepath)) {
|
||||||
|
@ -349,6 +378,12 @@ class App
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads addons configuration files
|
||||||
|
*
|
||||||
|
* First loads all activated addons default configuration throught the load_config hook, then load the local.ini.php
|
||||||
|
* again to overwrite potential local addon configuration.
|
||||||
|
*/
|
||||||
private function loadAddonConfig()
|
private function loadAddonConfig()
|
||||||
{
|
{
|
||||||
// Loads addons default config
|
// Loads addons default config
|
||||||
|
@ -360,6 +395,13 @@ class App
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads the default timezone
|
||||||
|
*
|
||||||
|
* Include support for legacy $default_timezone
|
||||||
|
*
|
||||||
|
* @global string $default_timezone
|
||||||
|
*/
|
||||||
private function loadDefaultTimezone()
|
private function loadDefaultTimezone()
|
||||||
{
|
{
|
||||||
if ($this->getConfigValue('system', 'default_timezone')) {
|
if ($this->getConfigValue('system', 'default_timezone')) {
|
||||||
|
@ -375,8 +417,7 @@ class App
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Figure out if we are running at the top of a domain
|
* Figure out if we are running at the top of a domain or in a sub-directory and adjust accordingly
|
||||||
* or in a sub-directory and adjust accordingly
|
|
||||||
*/
|
*/
|
||||||
private function determineUrlPath()
|
private function determineUrlPath()
|
||||||
{
|
{
|
||||||
|
@ -396,16 +437,31 @@ class App
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the App mode
|
||||||
|
*
|
||||||
|
* - App::MODE_INSTALL : Either the database connection can't be established or the config table doesn't exist
|
||||||
|
* - App::MODE_MAINTENANCE: The maintenance mode has been set
|
||||||
|
* - App::MODE_NORMAL : Normal run with all features enabled
|
||||||
|
*
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
private function determineMode()
|
private function determineMode()
|
||||||
{
|
{
|
||||||
$this->mode = App::MODE_INSTALL;
|
$this->mode = App::MODE_INSTALL;
|
||||||
|
|
||||||
// Missing DB connection
|
// Missing local config files: MODE_INSTALL
|
||||||
if (!\dba::connected()) {
|
if (!file_exists($this->basepath . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'local.ini.php')
|
||||||
|
&& !file_exists($this->basepath . DIRECTORY_SEPARATOR . '.htconfig.php')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Working DB connection, missing tables
|
// Missing DB connection: ERROR
|
||||||
|
if (!\dba::connected()) {
|
||||||
|
System::unavailable();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Working DB connection, missing tables: MODE_INSTALL
|
||||||
if (\dba::fetch_first("SHOW TABLES LIKE 'config'") === false) {
|
if (\dba::fetch_first("SHOW TABLES LIKE 'config'") === false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue