[geonames] Add addon config

pull/633/head
Hypolite Petovan 2018-06-27 23:12:27 -04:00
parent 9ad60dfe4d
commit 57f6ac5bad
2 changed files with 30 additions and 10 deletions

View File

@ -0,0 +1,12 @@
<?php return <<<INI
; Warning: Don't change this file! It only holds the default config values for this addon.
; Instead overwrite these config values in config/local.ini.php in your Friendica directory
[geonames]
; username (String)
; The geonames.org API username
username =
INI;
//Keep this line

View File

@ -7,9 +7,11 @@
* *
* *
* Pre-requisite: Register a username at geonames.org * Pre-requisite: Register a username at geonames.org
* and set in .htconfig.php * and set in config/local.ini.php
*
* [geonames]
* username = your_username
* *
* $a->config['geonames']['username'] = 'your_username';
* Also visit http://geonames.org/manageaccount and enable access to the free web services * Also visit http://geonames.org/manageaccount and enable access to the free web services
* *
* When addon is installed, the system calls the addon * When addon is installed, the system calls the addon
@ -28,6 +30,8 @@ use Friendica\Util\XML;
function geonames_install() { function geonames_install() {
Addon::registerHook('load_config', 'addon/geonames/geonames.php', 'geonames_load_config');
/** /**
* *
* Our addon will attach in three places. * Our addon will attach in three places.
@ -62,6 +66,7 @@ function geonames_uninstall() {
* *
*/ */
Addon::unregisterHook('load_config', 'addon/geonames/geonames.php', 'geonames_load_config');
Addon::unregisterHook('post_local', 'addon/geonames/geonames.php', 'geonames_post_hook'); Addon::unregisterHook('post_local', 'addon/geonames/geonames.php', 'geonames_post_hook');
Addon::unregisterHook('addon_settings', 'addon/geonames/geonames.php', 'geonames_addon_admin'); Addon::unregisterHook('addon_settings', 'addon/geonames/geonames.php', 'geonames_addon_admin');
Addon::unregisterHook('addon_settings_post', 'addon/geonames/geonames.php', 'geonames_addon_admin_post'); Addon::unregisterHook('addon_settings_post', 'addon/geonames/geonames.php', 'geonames_addon_admin_post');
@ -70,7 +75,10 @@ function geonames_uninstall() {
logger("removed geonames"); logger("removed geonames");
} }
function geonames_load_config(\Friendica\App $a)
{
$a->loadConfigFile(__DIR__. '/config/geonames.ini.php');
}
function geonames_post_hook($a, &$item) { function geonames_post_hook($a, &$item) {