use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
-use Friendica\Core\Config\Util\ConfigFileLoader;
-use Friendica\Core\Session;
+use Friendica\Core\Config\Util\ConfigFileManager;
use Friendica\Util\XML;
function geonames_install()
Hook::register('addon_settings_post', __FILE__, 'geonames_addon_settings_post');
}
-function geonames_load_config(App $a, ConfigFileLoader $loader)
+function geonames_load_config(ConfigFileManager $loader)
{
- $a->getConfigCache()->load($loader->loadAddonConfig('geonames'));
+ DI::app()->getConfigCache()->load($loader->loadAddonConfig('geonames'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
}
-function geonames_post_hook(App $a, array &$item)
+function geonames_post_hook(array &$item)
{
/* An item was posted on the local system.
* We are going to look for specific items:
Logger::notice('geonames invoked');
- if (!Session::getLocalUser()) { /* non-zero if this is a logged in user of this system */
+ if (!DI::userSession()->getLocalUserId()) { /* non-zero if this is a logged in user of this system */
return;
}
- if (Session::getLocalUser() != $item['uid']) { /* Does this person own the post? */
+ if (DI::userSession()->getLocalUserId() != $item['uid']) { /* Does this person own the post? */
return;
}
/* Retrieve our personal config setting */
$geo_account = DI::config()->get('geonames', 'username');
- $active = DI::pConfig()->get(Session::getLocalUser(), 'geonames', 'enable');
+ $active = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'geonames', 'enable');
if (!$geo_account || !$active) {
return;
* We will make sure we've got a valid user account
* and if so set our configuration setting for this person.
*
- * @param App $a
* @param array $post The $_POST array
*/
-function geonames_addon_settings_post(App $a, array $post)
+function geonames_addon_settings_post(array $post)
{
- if (!Session::getLocalUser() || empty($_POST['geonames-submit'])) {
+ if (!DI::userSession()->getLocalUserId() || empty($_POST['geonames-submit'])) {
return;
}
- DI::pConfig()->set(Session::getLocalUser(), 'geonames', 'enable', intval($_POST['geonames-enable']));
+ DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'geonames', 'enable', intval($_POST['geonames-enable']));
}
/**
* Called from the Addon Setting form.
* Add our own settings info to the page.
*
- * @param App $a
* @param array $data
* @throws Exception
*/
-function geonames_addon_settings(App $a, array &$data)
+function geonames_addon_settings(array &$data)
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
return;
}
return;
}
- $enabled = intval(DI::pConfig()->get(Session::getLocalUser(), 'geonames', 'enable'));
+ $enabled = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'geonames', 'enable'));
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/geonames/');
$html = Renderer::replaceMacros($t, [