diff --git a/advancedcontentfilter/advancedcontentfilter.php b/advancedcontentfilter/advancedcontentfilter.php index c33d1248..8f5585c6 100644 --- a/advancedcontentfilter/advancedcontentfilter.php +++ b/advancedcontentfilter/advancedcontentfilter.php @@ -39,7 +39,6 @@ use Friendica\Content\Text\Markdown; use Friendica\Core\Hook; use Friendica\Core\Logger; use Friendica\Core\Renderer; -use Friendica\Core\Session; use Friendica\Database\DBA; use Friendica\Database\DBStructure; use Friendica\DI; @@ -124,21 +123,21 @@ function advancedcontentfilter_prepare_body_content_filter(App $a, &$hook_data) $expressionLanguage = new ExpressionLanguage\ExpressionLanguage(); } - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } $vars = advancedcontentfilter_get_filter_fields($hook_data['item']); - $rules = DI::cache()->get('rules_' . Session::getLocalUser()); + $rules = DI::cache()->get('rules_' . DI::userSession()->getLocalUserId()); if (!isset($rules)) { $rules = DBA::toArray(DBA::select( 'advancedcontentfilter_rules', ['name', 'expression', 'serialized'], - ['uid' => Session::getLocalUser(), 'active' => true] + ['uid' => DI::userSession()->getLocalUserId(), 'active' => true] )); - DI::cache()->set('rules_' . Session::getLocalUser(), $rules); + DI::cache()->set('rules_' . DI::userSession()->getLocalUserId(), $rules); } if ($rules) { @@ -166,7 +165,7 @@ function advancedcontentfilter_prepare_body_content_filter(App $a, &$hook_data) function advancedcontentfilter_addon_settings(App $a, array &$data) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } @@ -204,12 +203,12 @@ function advancedcontentfilter_init(App $a) function advancedcontentfilter_content(App $a) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return Login::form('/' . implode('/', DI::args()->getArgv())); } if (DI::args()->getArgc() > 1 && DI::args()->getArgv()[1] == 'help') { - $user = User::getById(Session::getLocalUser()); + $user = User::getById(DI::userSession()->getLocalUserId()); $lang = $user['language']; @@ -273,9 +272,9 @@ function advancedcontentfilter_build_fields($data) if (!empty($data['expression'])) { // Using a dummy item to validate the field existence - $condition = ["(`uid` = ? OR `uid` = 0)", Session::getLocalUser()]; + $condition = ["(`uid` = ? OR `uid` = 0)", DI::userSession()->getLocalUserId()]; $params = ['order' => ['uid' => true]]; - $item_row = Post::selectFirstForUser(Session::getLocalUser(), [], $condition, $params); + $item_row = Post::selectFirstForUser(DI::userSession()->getLocalUserId(), [], $condition, $params); if (!DBA::isResult($item_row)) { throw new HTTPException\NotFoundException(DI::l10n()->t('This addon requires this node having at least one post')); @@ -308,29 +307,29 @@ function advancedcontentfilter_build_fields($data) function advancedcontentfilter_get_rules() { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { throw new HTTPException\UnauthorizedException(DI::l10n()->t('You must be logged in to use this method')); } - $rules = DBA::toArray(DBA::select('advancedcontentfilter_rules', [], ['uid' => Session::getLocalUser()])); + $rules = DBA::toArray(DBA::select('advancedcontentfilter_rules', [], ['uid' => DI::userSession()->getLocalUserId()])); return json_encode($rules); } function advancedcontentfilter_get_rules_id(ServerRequestInterface $request, ResponseInterface $response, $args) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { throw new HTTPException\UnauthorizedException(DI::l10n()->t('You must be logged in to use this method')); } - $rule = DBA::selectFirst('advancedcontentfilter_rules', [], ['id' => $args['id'], 'uid' => Session::getLocalUser()]); + $rule = DBA::selectFirst('advancedcontentfilter_rules', [], ['id' => $args['id'], 'uid' => DI::userSession()->getLocalUserId()]); return json_encode($rule); } function advancedcontentfilter_post_rules(ServerRequestInterface $request) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { throw new HTTPException\UnauthorizedException(DI::l10n()->t('You must be logged in to use this method')); } @@ -350,7 +349,7 @@ function advancedcontentfilter_post_rules(ServerRequestInterface $request) throw new HTTPException\BadRequestException(DI::l10n()->t('The rule name and expression are required.')); } - $fields['uid'] = Session::getLocalUser(); + $fields['uid'] = DI::userSession()->getLocalUserId(); $fields['created'] = DateTimeFormat::utcNow(); if (!DBA::insert('advancedcontentfilter_rules', $fields)) { @@ -359,14 +358,14 @@ function advancedcontentfilter_post_rules(ServerRequestInterface $request) $rule = DBA::selectFirst('advancedcontentfilter_rules', [], ['id' => DBA::lastInsertId()]); - DI::cache()->delete('rules_' . Session::getLocalUser()); + DI::cache()->delete('rules_' . DI::userSession()->getLocalUserId()); return json_encode(['message' => DI::l10n()->t('Rule successfully added'), 'rule' => $rule]); } function advancedcontentfilter_put_rules_id(ServerRequestInterface $request, ResponseInterface $response, $args) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { throw new HTTPException\UnauthorizedException(DI::l10n()->t('You must be logged in to use this method')); } @@ -374,7 +373,7 @@ function advancedcontentfilter_put_rules_id(ServerRequestInterface $request, Res throw new HTTPException\BadRequestException(DI::l10n()->t('Invalid form security token, please refresh the page.')); } - if (!DBA::exists('advancedcontentfilter_rules', ['id' => $args['id'], 'uid' => Session::getLocalUser()])) { + if (!DBA::exists('advancedcontentfilter_rules', ['id' => $args['id'], 'uid' => DI::userSession()->getLocalUserId()])) { throw new HTTPException\NotFoundException(DI::l10n()->t('Rule doesn\'t exist or doesn\'t belong to you.')); } @@ -390,14 +389,14 @@ function advancedcontentfilter_put_rules_id(ServerRequestInterface $request, Res throw new HTTPException\ServiceUnavailableException(DBA::errorMessage()); } - DI::cache()->delete('rules_' . Session::getLocalUser()); + DI::cache()->delete('rules_' . DI::userSession()->getLocalUserId()); return json_encode(['message' => DI::l10n()->t('Rule successfully updated')]); } function advancedcontentfilter_delete_rules_id(ServerRequestInterface $request, ResponseInterface $response, $args) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { throw new HTTPException\UnauthorizedException(DI::l10n()->t('You must be logged in to use this method')); } @@ -405,7 +404,7 @@ function advancedcontentfilter_delete_rules_id(ServerRequestInterface $request, throw new HTTPException\BadRequestException(DI::l10n()->t('Invalid form security token, please refresh the page.')); } - if (!DBA::exists('advancedcontentfilter_rules', ['id' => $args['id'], 'uid' => Session::getLocalUser()])) { + if (!DBA::exists('advancedcontentfilter_rules', ['id' => $args['id'], 'uid' => DI::userSession()->getLocalUserId()])) { throw new HTTPException\NotFoundException(DI::l10n()->t('Rule doesn\'t exist or doesn\'t belong to you.')); } @@ -413,14 +412,14 @@ function advancedcontentfilter_delete_rules_id(ServerRequestInterface $request, throw new HTTPException\ServiceUnavailableException(DBA::errorMessage()); } - DI::cache()->delete('rules_' . Session::getLocalUser()); + DI::cache()->delete('rules_' . DI::userSession()->getLocalUserId()); return json_encode(['message' => DI::l10n()->t('Rule successfully deleted')]); } function advancedcontentfilter_get_variables_guid(ServerRequestInterface $request, ResponseInterface $response, $args) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { throw new HTTPException\UnauthorizedException(DI::l10n()->t('You must be logged in to use this method')); } @@ -428,9 +427,9 @@ function advancedcontentfilter_get_variables_guid(ServerRequestInterface $reques throw new HTTPException\BadRequestException(DI::l10n()->t('Missing argument: guid.')); } - $condition = ["`guid` = ? AND (`uid` = ? OR `uid` = 0)", $args['guid'], Session::getLocalUser()]; + $condition = ["`guid` = ? AND (`uid` = ? OR `uid` = 0)", $args['guid'], DI::userSession()->getLocalUserId()]; $params = ['order' => ['uid' => true]]; - $item_row = Post::selectFirstForUser(Session::getLocalUser(), [], $condition, $params); + $item_row = Post::selectFirstForUser(DI::userSession()->getLocalUserId(), [], $condition, $params); if (!DBA::isResult($item_row)) { throw new HTTPException\NotFoundException(DI::l10n()->t('Unknown post with guid: %s', $args['guid'])); diff --git a/birdavatar/birdavatar.php b/birdavatar/birdavatar.php index 12d150a4..44247dae 100644 --- a/birdavatar/birdavatar.php +++ b/birdavatar/birdavatar.php @@ -10,7 +10,6 @@ use Friendica\App; use Friendica\Core\Hook; use Friendica\Core\Logger; use Friendica\Core\Renderer; -use Friendica\Core\Session; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Contact; @@ -37,14 +36,14 @@ function birdavatar_install() */ function birdavatar_addon_settings(App $a, array &$data) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/birdavatar/'); $html = Renderer::replaceMacros($t, [ '$uncache' => time(), - '$uid' => Session::getLocalUser(), + '$uid' => DI::userSession()->getLocalUserId(), '$setrandomize' => DI::l10n()->t('Set default profile avatar or randomize the bird.'), ]); @@ -55,7 +54,7 @@ function birdavatar_addon_settings(App $a, array &$data) 'submit' => [ 'birdavatar-usebird' => DI::l10n()->t('Use Bird as Avatar'), 'birdavatar-morebird' => DI::l10n()->t('More Random Bird!'), - 'birdavatar-emailbird' => DI::pConfig()->get(Session::getLocalUser(), 'birdavatar', 'seed', false) ? DI::l10n()->t('Reset to email Bird') : null, + 'birdavatar-emailbird' => DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'birdavatar', 'seed', false) ? DI::l10n()->t('Reset to email Bird') : null, ], ]; } @@ -65,50 +64,50 @@ function birdavatar_addon_settings(App $a, array &$data) */ function birdavatar_addon_settings_post(App $a, &$s) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } if (!empty($_POST['birdavatar-usebird'])) { - $url = DI::baseUrl()->get() . '/birdavatar/' . Session::getLocalUser() . '?ts=' . time(); + $url = DI::baseUrl()->get() . '/birdavatar/' . DI::userSession()->getLocalUserId() . '?ts=' . time(); - $self = DBA::selectFirst('contact', ['id'], ['uid' => Session::getLocalUser(), 'self' => true]); + $self = DBA::selectFirst('contact', ['id'], ['uid' => DI::userSession()->getLocalUserId(), 'self' => true]); if (!DBA::isResult($self)) { DI::sysmsg()->addNotice(DI::l10n()->t("The bird has not found itself.")); return; } - Photo::importProfilePhoto($url, Session::getLocalUser(), $self['id']); + Photo::importProfilePhoto($url, DI::userSession()->getLocalUserId(), $self['id']); - $condition = ['uid' => Session::getLocalUser(), 'contact-id' => $self['id']]; + $condition = ['uid' => DI::userSession()->getLocalUserId(), 'contact-id' => $self['id']]; $photo = DBA::selectFirst('photo', ['resource-id'], $condition); if (!DBA::isResult($photo)) { DI::sysmsg()->addNotice(DI::l10n()->t('There was an error, the bird flew away.')); return; } - DBA::update('photo', ['profile' => false], ['profile' => true, 'uid' => Session::getLocalUser()]); + DBA::update('photo', ['profile' => false], ['profile' => true, 'uid' => DI::userSession()->getLocalUserId()]); $fields = ['profile' => true, 'album' => DI::l10n()->t('Profile Photos'), 'contact-id' => 0]; - DBA::update('photo', $fields, ['uid' => Session::getLocalUser(), 'resource-id' => $photo['resource-id']]); + DBA::update('photo', $fields, ['uid' => DI::userSession()->getLocalUserId(), 'resource-id' => $photo['resource-id']]); - Photo::importProfilePhoto($url, Session::getLocalUser(), $self['id']); + Photo::importProfilePhoto($url, DI::userSession()->getLocalUserId(), $self['id']); - Contact::updateSelfFromUserID(Session::getLocalUser(), true); + Contact::updateSelfFromUserID(DI::userSession()->getLocalUserId(), true); // Update global directory in background - Profile::publishUpdate(Session::getLocalUser()); + Profile::publishUpdate(DI::userSession()->getLocalUserId()); DI::sysmsg()->addInfo(DI::l10n()->t('Meow!')); return; } if (!empty($_POST['birdavatar-morebird'])) { - DI::pConfig()->set(Session::getLocalUser(), 'birdavatar', 'seed', time()); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'birdavatar', 'seed', time()); } if (!empty($_POST['birdavatar-emailbird'])) { - DI::pConfig()->delete(Session::getLocalUser(), 'birdavatar', 'seed'); + DI::pConfig()->delete(DI::userSession()->getLocalUserId(), 'birdavatar', 'seed'); } } diff --git a/blackout/blackout.php b/blackout/blackout.php index f291413f..c211c914 100644 --- a/blackout/blackout.php +++ b/blackout/blackout.php @@ -48,7 +48,6 @@ use Friendica\App; use Friendica\Core\Hook; use Friendica\Core\Logger; use Friendica\Core\Renderer; -use Friendica\Core\Session; use Friendica\Core\System; use Friendica\DI; @@ -59,7 +58,7 @@ function blackout_install() { function blackout_redirect (App $a, $b) { // if we have a logged in user, don't throw her out - if (Session::getLocalUser()) { + if (DI::userSession()->getLocalUserId()) { return true; } diff --git a/blockem/blockem.php b/blockem/blockem.php index 618f21a5..dfd802dd 100644 --- a/blockem/blockem.php +++ b/blockem/blockem.php @@ -10,7 +10,6 @@ use Friendica\App; use Friendica\Core\Hook; use Friendica\Core\Renderer; -use Friendica\Core\Session; use Friendica\DI; use Friendica\Util\Strings; @@ -29,11 +28,11 @@ function blockem_install() function blockem_addon_settings(App $a, array &$data) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } - $words = DI::pConfig()->get(Session::getLocalUser(), 'blockem', 'words', ''); + $words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'blockem', 'words', ''); $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/blockem/'); $html = Renderer::replaceMacros($t, [ @@ -50,12 +49,12 @@ function blockem_addon_settings(App $a, array &$data) function blockem_addon_settings_post(App $a, array &$b) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } if (!empty($_POST['blockem-submit'])) { - DI::pConfig()->set(Session::getLocalUser(), 'blockem', 'words', trim($_POST['blockem-words'])); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'blockem', 'words', trim($_POST['blockem-words'])); } } @@ -92,14 +91,14 @@ function blockem_enotify_store(App $a, array &$b) function blockem_prepare_body_content_filter(App $a, array &$hook_data) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } $profiles_string = null; - if (Session::getLocalUser()) { - $profiles_string = DI::pConfig()->get(Session::getLocalUser(), 'blockem', 'words'); + if (DI::userSession()->getLocalUserId()) { + $profiles_string = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'blockem', 'words'); } if ($profiles_string) { @@ -133,11 +132,11 @@ function blockem_conversation_start(App $a, array &$b) { global $blockem_words; - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } - $words = DI::pConfig()->get(Session::getLocalUser(), 'blockem', 'words'); + $words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'blockem', 'words'); if ($words) { $blockem_words = explode(',', $words); @@ -165,7 +164,7 @@ function blockem_item_photo_menu(App $a, array &$b) { global $blockem_words; - if (!Session::getLocalUser() || $b['item']['self']) { + if (!DI::userSession()->getLocalUserId() || $b['item']['self']) { return; } @@ -196,11 +195,11 @@ function blockem_module() {} function blockem_init(App $a) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } - $words = DI::pConfig()->get(Session::getLocalUser(), 'blockem', 'words'); + $words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'blockem', 'words'); if (array_key_exists('block', $_GET) && $_GET['block']) { if (strlen($words)) { @@ -225,6 +224,6 @@ function blockem_init(App $a) $words = implode(',', $newarr); } - DI::pConfig()->set(Session::getLocalUser(), 'blockem', 'words', $words); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'blockem', 'words', $words); exit(); } diff --git a/catavatar/catavatar.php b/catavatar/catavatar.php index 5b0b8bd6..bdca4b42 100644 --- a/catavatar/catavatar.php +++ b/catavatar/catavatar.php @@ -10,7 +10,6 @@ use Friendica\App; use Friendica\Core\Hook; use Friendica\Core\Logger; use Friendica\Core\Renderer; -use Friendica\Core\Session; use Friendica\Core\Worker; use Friendica\Database\DBA; use Friendica\DI; @@ -38,14 +37,14 @@ function catavatar_install() */ function catavatar_addon_settings(App $a, array &$data) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/catavatar/'); $html = Renderer::replaceMacros($t, [ '$uncache' => time(), - '$uid' => Session::getLocalUser(), + '$uid' => DI::userSession()->getLocalUserId(), '$setrandomize' => DI::l10n()->t('Set default profile avatar or randomize the cat.'), ]); @@ -56,7 +55,7 @@ function catavatar_addon_settings(App $a, array &$data) 'submit' => [ 'catavatar-usecat' => DI::l10n()->t('Use Cat as Avatar'), 'catavatar-morecat' => DI::l10n()->t('Another random Cat!'), - 'catavatar-emailcat' => DI::pConfig()->get(Session::getLocalUser(), 'catavatar', 'seed', false) ? DI::l10n()->t('Reset to email Cat') : null, + 'catavatar-emailcat' => DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'catavatar', 'seed', false) ? DI::l10n()->t('Reset to email Cat') : null, ], ]; } @@ -66,50 +65,50 @@ function catavatar_addon_settings(App $a, array &$data) */ function catavatar_addon_settings_post(App $a, &$s) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } if (!empty($_POST['catavatar-usecat'])) { - $url = DI::baseUrl()->get() . '/catavatar/' . Session::getLocalUser() . '?ts=' . time(); + $url = DI::baseUrl()->get() . '/catavatar/' . DI::userSession()->getLocalUserId() . '?ts=' . time(); - $self = DBA::selectFirst('contact', ['id'], ['uid' => Session::getLocalUser(), 'self' => true]); + $self = DBA::selectFirst('contact', ['id'], ['uid' => DI::userSession()->getLocalUserId(), 'self' => true]); if (!DBA::isResult($self)) { DI::sysmsg()->addNotice(DI::l10n()->t("The cat hadn't found itself.")); return; } - Photo::importProfilePhoto($url, Session::getLocalUser(), $self['id']); + Photo::importProfilePhoto($url, DI::userSession()->getLocalUserId(), $self['id']); - $condition = ['uid' => Session::getLocalUser(), 'contact-id' => $self['id']]; + $condition = ['uid' => DI::userSession()->getLocalUserId(), 'contact-id' => $self['id']]; $photo = DBA::selectFirst('photo', ['resource-id'], $condition); if (!DBA::isResult($photo)) { DI::sysmsg()->addNotice(DI::l10n()->t('There was an error, the cat ran away.')); return; } - DBA::update('photo', ['profile' => false], ['profile' => true, 'uid' => Session::getLocalUser()]); + DBA::update('photo', ['profile' => false], ['profile' => true, 'uid' => DI::userSession()->getLocalUserId()]); $fields = ['profile' => true, 'album' => DI::l10n()->t('Profile Photos'), 'contact-id' => 0]; - DBA::update('photo', $fields, ['uid' => Session::getLocalUser(), 'resource-id' => $photo['resource-id']]); + DBA::update('photo', $fields, ['uid' => DI::userSession()->getLocalUserId(), 'resource-id' => $photo['resource-id']]); - Photo::importProfilePhoto($url, Session::getLocalUser(), $self['id']); + Photo::importProfilePhoto($url, DI::userSession()->getLocalUserId(), $self['id']); - Contact::updateSelfFromUserID(Session::getLocalUser(), true); + Contact::updateSelfFromUserID(DI::userSession()->getLocalUserId(), true); // Update global directory in background - Profile::publishUpdate(Session::getLocalUser()); + Profile::publishUpdate(DI::userSession()->getLocalUserId()); DI::sysmsg()->addInfo(DI::l10n()->t('Meow!')); return; } if (!empty($_POST['catavatar-morecat'])) { - DI::pConfig()->set(Session::getLocalUser(), 'catavatar', 'seed', time()); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'catavatar', 'seed', time()); } if (!empty($_POST['catavatar-emailcat'])) { - DI::pConfig()->delete(Session::getLocalUser(), 'catavatar', 'seed'); + DI::pConfig()->delete(DI::userSession()->getLocalUserId(), 'catavatar', 'seed'); } } diff --git a/curweather/curweather.php b/curweather/curweather.php index 88e3b18c..79aa752e 100644 --- a/curweather/curweather.php +++ b/curweather/curweather.php @@ -13,7 +13,6 @@ use Friendica\App; use Friendica\Core\Cache\Enum\Duration; use Friendica\Core\Hook; use Friendica\Core\Renderer; -use Friendica\Core\Session; use Friendica\DI; use Friendica\Util\Proxy as ProxyUtils; @@ -32,7 +31,7 @@ function getWeather($loc, $units = 'metric', $lang = 'en', $appid = '', $cacheti $now = new DateTime(); if (!is_null($cached)) { - $cdate = DI::pConfig()->get(Session::getLocalUser(), 'curweather', 'last'); + $cdate = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'curweather', 'last'); $cached = unserialize($cached); if ($cdate + $cachetime > $now->getTimestamp()) { @@ -81,7 +80,7 @@ function getWeather($loc, $units = 'metric', $lang = 'en', $appid = '', $cacheti 'icon' => (string) $res->weather['icon'], ]; - DI::pConfig()->set(Session::getLocalUser(), 'curweather', 'last', $now->getTimestamp()); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'curweather', 'last', $now->getTimestamp()); DI::cache()->set('curweather'.md5($url), serialize($r), Duration::HOUR); return $r; @@ -89,7 +88,7 @@ function getWeather($loc, $units = 'metric', $lang = 'en', $appid = '', $cacheti function curweather_network_mod_init(App $a, string &$body) { - if (!intval(DI::pConfig()->get(Session::getLocalUser(), 'curweather', 'curweather_enable'))) { + if (!intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'curweather', 'curweather_enable'))) { return; } @@ -104,11 +103,11 @@ function curweather_network_mod_init(App $a, string &$body) // those parameters will be used to get: cloud status, temperature, preassure // and relative humidity for display, also the relevent area of the map is // linked from lat/log of the reply of OWMp - $rpt = DI::pConfig()->get(Session::getLocalUser(), 'curweather', 'curweather_loc'); + $rpt = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'curweather', 'curweather_loc'); // Set the language to the browsers language or default and use metric units $lang = DI::session()->get('language', DI::config()->get('system', 'language')); - $units = DI::pConfig()->get(Session::getLocalUser(), 'curweather', 'curweather_units'); + $units = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'curweather', 'curweather_units'); $appid = DI::config()->get('curweather', 'appid'); $cachetime = intval(DI::config()->get('curweather', 'cachetime')); @@ -155,23 +154,23 @@ function curweather_network_mod_init(App $a, string &$body) function curweather_addon_settings_post(App $a, $post) { - if (!Session::getLocalUser() || empty($_POST['curweather-settings-submit'])) { + if (!DI::userSession()->getLocalUserId() || empty($_POST['curweather-settings-submit'])) { return; } - DI::pConfig()->set(Session::getLocalUser(), 'curweather', 'curweather_loc' , trim($_POST['curweather_loc'])); - DI::pConfig()->set(Session::getLocalUser(), 'curweather', 'curweather_enable', intval($_POST['curweather_enable'])); - DI::pConfig()->set(Session::getLocalUser(), 'curweather', 'curweather_units' , trim($_POST['curweather_units'])); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'curweather', 'curweather_loc' , trim($_POST['curweather_loc'])); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'curweather', 'curweather_enable', intval($_POST['curweather_enable'])); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'curweather', 'curweather_units' , trim($_POST['curweather_units'])); } function curweather_addon_settings(App $a, array &$data) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } - $curweather_loc = DI::pConfig()->get(Session::getLocalUser(), 'curweather', 'curweather_loc'); - $curweather_units = DI::pConfig()->get(Session::getLocalUser(), 'curweather', 'curweather_units'); + $curweather_loc = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'curweather', 'curweather_loc'); + $curweather_units = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'curweather', 'curweather_units'); $appid = DI::config()->get('curweather', 'appid'); if ($appid == '') { @@ -180,7 +179,7 @@ function curweather_addon_settings(App $a, array &$data) $noappidtext = ''; } - $enabled = intval(DI::pConfig()->get(Session::getLocalUser(), 'curweather', 'curweather_enable')); + $enabled = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'curweather', 'curweather_enable')); $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/curweather/'); $html = Renderer::replaceMacros($t, [ diff --git a/diaspora/diaspora.php b/diaspora/diaspora.php index d548fef3..8b304181 100644 --- a/diaspora/diaspora.php +++ b/diaspora/diaspora.php @@ -14,7 +14,6 @@ use Friendica\Content\Text\BBCode; use Friendica\Core\Hook; use Friendica\Core\Logger; use Friendica\Core\Renderer; -use Friendica\Core\Session; use Friendica\Database\DBA; use Friendica\Core\Worker; use Friendica\DI; @@ -32,17 +31,17 @@ function diaspora_install() function diaspora_jot_nets(App $a, array &$jotnets_fields) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } - if (DI::pConfig()->get(Session::getLocalUser(), 'diaspora', 'post')) { + if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'diaspora', 'post')) { $jotnets_fields[] = [ 'type' => 'checkbox', 'field' => [ 'diaspora_enable', DI::l10n()->t('Post to Diaspora'), - DI::pConfig()->get(Session::getLocalUser(), 'diaspora', 'post_by_default') + DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'diaspora', 'post_by_default') ] ]; } @@ -50,16 +49,16 @@ function diaspora_jot_nets(App $a, array &$jotnets_fields) function diaspora_settings(App $a, array &$data) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } - $enabled = DI::pConfig()->get(Session::getLocalUser(), 'diaspora', 'post', false); - $def_enabled = DI::pConfig()->get(Session::getLocalUser(), 'diaspora', 'post_by_default'); + $enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'diaspora', 'post', false); + $def_enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'diaspora', 'post_by_default'); - $handle = DI::pConfig()->get(Session::getLocalUser(), 'diaspora', 'handle'); - $password = DI::pConfig()->get(Session::getLocalUser(), 'diaspora', 'password'); - $aspect = DI::pConfig()->get(Session::getLocalUser(), 'diaspora', 'aspect'); + $handle = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'diaspora', 'handle'); + $password = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'diaspora', 'password'); + $aspect = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'diaspora', 'aspect'); $info = ''; $error = ''; @@ -121,18 +120,18 @@ function diaspora_settings(App $a, array &$data) function diaspora_settings_post(App $a, array &$b) { if (!empty($_POST['diaspora-submit'])) { - DI::pConfig()->set(Session::getLocalUser(),'diaspora', 'post' , intval($_POST['enabled'])); + DI::pConfig()->set(DI::userSession()->getLocalUserId(),'diaspora', 'post' , intval($_POST['enabled'])); if (intval($_POST['enabled'])) { if (isset($_POST['handle'])) { - DI::pConfig()->set(Session::getLocalUser(),'diaspora', 'handle' , trim($_POST['handle'])); - DI::pConfig()->set(Session::getLocalUser(),'diaspora', 'password' , trim($_POST['password'])); + DI::pConfig()->set(DI::userSession()->getLocalUserId(),'diaspora', 'handle' , trim($_POST['handle'])); + DI::pConfig()->set(DI::userSession()->getLocalUserId(),'diaspora', 'password' , trim($_POST['password'])); } if (!empty($_POST['aspect'])) { - DI::pConfig()->set(Session::getLocalUser(),'diaspora', 'aspect' , trim($_POST['aspect'])); - DI::pConfig()->set(Session::getLocalUser(),'diaspora', 'post_by_default', intval($_POST['post_by_default'])); + DI::pConfig()->set(DI::userSession()->getLocalUserId(),'diaspora', 'aspect' , trim($_POST['aspect'])); + DI::pConfig()->set(DI::userSession()->getLocalUserId(),'diaspora', 'post_by_default', intval($_POST['post_by_default'])); } } else { - DI::pConfig()->delete(Session::getLocalUser(), 'diaspora', 'password'); + DI::pConfig()->delete(DI::userSession()->getLocalUserId(), 'diaspora', 'password'); } } } @@ -158,7 +157,7 @@ function diaspora_post_local(App $a, array &$b) return; } - if (!Session::getLocalUser() || (Session::getLocalUser() != $b['uid'])) { + if (!DI::userSession()->getLocalUserId() || (DI::userSession()->getLocalUserId() != $b['uid'])) { return; } @@ -166,11 +165,11 @@ function diaspora_post_local(App $a, array &$b) return; } - $diaspora_post = intval(DI::pConfig()->get(Session::getLocalUser(),'diaspora','post')); + $diaspora_post = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(),'diaspora','post')); $diaspora_enable = (($diaspora_post && !empty($_REQUEST['diaspora_enable'])) ? intval($_REQUEST['diaspora_enable']) : 0); - if ($b['api_source'] && intval(DI::pConfig()->get(Session::getLocalUser(),'diaspora','post_by_default'))) { + if ($b['api_source'] && intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(),'diaspora','post_by_default'))) { $diaspora_enable = 1; } diff --git a/discourse/discourse.php b/discourse/discourse.php index 2069ce7d..13f73690 100644 --- a/discourse/discourse.php +++ b/discourse/discourse.php @@ -14,7 +14,6 @@ use Friendica\Core\Hook; use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Core\Renderer; -use Friendica\Core\Session; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Contact; @@ -39,11 +38,11 @@ function discourse_install() function discourse_settings(App $a, array &$data) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } - $enabled = intval(DI::pConfig()->get(Session::getLocalUser(), 'discourse', 'enabled')); + $enabled = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'discourse', 'enabled')); $t = Renderer::getMarkupTemplate('connector_settings.tpl', 'addon/discourse/'); $html = Renderer::replaceMacros($t, [ @@ -61,11 +60,11 @@ function discourse_settings(App $a, array &$data) function discourse_settings_post(App $a) { - if (!Session::getLocalUser() || empty($_POST['discourse-submit'])) { + if (!DI::userSession()->getLocalUserId() || empty($_POST['discourse-submit'])) { return; } - DI::pConfig()->set(Session::getLocalUser(), 'discourse', 'enabled', intval($_POST['enabled'])); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'discourse', 'enabled', intval($_POST['enabled'])); } function discourse_email_getmessage(App $a, &$message) diff --git a/dwpost/dwpost.php b/dwpost/dwpost.php index ed7ac492..a8e82854 100644 --- a/dwpost/dwpost.php +++ b/dwpost/dwpost.php @@ -13,7 +13,6 @@ use Friendica\Content\Text\BBCode; use Friendica\Core\Hook; use Friendica\Core\Logger; use Friendica\Core\Renderer; -use Friendica\Core\Session; use Friendica\DI; use Friendica\Model\Post; use Friendica\Model\Tag; @@ -32,17 +31,17 @@ function dwpost_install() function dwpost_jot_nets(App $a, array &$jotnets_fields) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } - if (DI::pConfig()->get(Session::getLocalUser(), 'dwpost', 'post')) { + if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'dwpost', 'post')) { $jotnets_fields[] = [ 'type' => 'checkbox', 'field' => [ 'dwpost_enable', DI::l10n()->t('Post to Dreamwidth'), - DI::pConfig()->get(Session::getLocalUser(), 'dwpost', 'post_by_default') + DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'dwpost', 'post_by_default') ] ]; } @@ -51,13 +50,13 @@ function dwpost_jot_nets(App $a, array &$jotnets_fields) function dwpost_settings(App $a, array &$data) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } - $enabled = DI::pConfig()->get(Session::getLocalUser(), 'dwpost', 'post', false); - $dw_username = DI::pConfig()->get(Session::getLocalUser(), 'dwpost', 'dw_username'); - $def_enabled = DI::pConfig()->get(Session::getLocalUser(), 'dwpost', 'post_by_default'); + $enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'dwpost', 'post', false); + $dw_username = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'dwpost', 'dw_username'); + $def_enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'dwpost', 'post_by_default'); $t = Renderer::getMarkupTemplate('connector_settings.tpl', 'addon/dwpost/'); $html = Renderer::replaceMacros($t, [ @@ -80,10 +79,10 @@ function dwpost_settings(App $a, array &$data) function dwpost_settings_post(App $a, array &$b) { if (!empty($_POST['dwpost-submit'])) { - DI::pConfig()->set(Session::getLocalUser(), 'dwpost', 'post', intval($_POST['dwpost'])); - DI::pConfig()->set(Session::getLocalUser(), 'dwpost', 'post_by_default', intval($_POST['dw_bydefault'])); - DI::pConfig()->set(Session::getLocalUser(), 'dwpost', 'dw_username', trim($_POST['dw_username'])); - DI::pConfig()->set(Session::getLocalUser(), 'dwpost', 'dw_password', trim($_POST['dw_password'])); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'dwpost', 'post', intval($_POST['dwpost'])); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'dwpost', 'post_by_default', intval($_POST['dw_bydefault'])); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'dwpost', 'dw_username', trim($_POST['dw_username'])); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'dwpost', 'dw_password', trim($_POST['dw_password'])); } } @@ -94,7 +93,7 @@ function dwpost_post_local(App $a, array &$b) return; } - if ((!Session::getLocalUser()) || (Session::getLocalUser() != $b['uid'])) { + if ((!DI::userSession()->getLocalUserId()) || (DI::userSession()->getLocalUserId() != $b['uid'])) { return; } @@ -102,11 +101,11 @@ function dwpost_post_local(App $a, array &$b) return; } - $dw_post = intval(DI::pConfig()->get(Session::getLocalUser(),'dwpost','post')); + $dw_post = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(),'dwpost','post')); $dw_enable = (($dw_post && !empty($_REQUEST['dwpost_enable'])) ? intval($_REQUEST['dwpost_enable']) : 0); - if ($b['api_source'] && intval(DI::pConfig()->get(Session::getLocalUser(),'dwpost','post_by_default'))) { + if ($b['api_source'] && intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(),'dwpost','post_by_default'))) { $dw_enable = 1; } diff --git a/forumdirectory/forumdirectory.php b/forumdirectory/forumdirectory.php index da6e059c..c3b2cff5 100644 --- a/forumdirectory/forumdirectory.php +++ b/forumdirectory/forumdirectory.php @@ -12,7 +12,6 @@ use Friendica\Content\Pager; use Friendica\Content\Widget; use Friendica\Core\Hook; use Friendica\Core\Renderer; -use Friendica\Core\Session; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Profile; @@ -44,7 +43,7 @@ function forumdirectory_app_menu(App $a, array &$b) function forumdirectory_init(App $a) { - if (Session::getLocalUser()) { + if (DI::userSession()->getLocalUserId()) { DI::page()['aside'] .= Widget::findPeople(); } } @@ -62,7 +61,7 @@ function forumdirectory_content(App $a) { global $forumdirectory_search; - if (DI::config()->get('system', 'block_public') && !Session::getLocalUser() && !Session::getRemoteUser()) { + if (DI::config()->get('system', 'block_public') && !DI::userSession()->getLocalUserId() && !DI::userSession()->getRemoteUserId()) { DI::sysmsg()->addNotice(DI::l10n()->t('Public access denied.')); return; } diff --git a/fromapp/fromapp.php b/fromapp/fromapp.php index b5ad9c39..94aac63b 100644 --- a/fromapp/fromapp.php +++ b/fromapp/fromapp.php @@ -11,7 +11,6 @@ use Friendica\App; use Friendica\Core\Hook; use Friendica\Core\Logger; use Friendica\Core\Renderer; -use Friendica\Core\Session; use Friendica\DI; function fromapp_install() @@ -24,22 +23,22 @@ function fromapp_install() function fromapp_settings_post(App $a, $post) { - if (!Session::getLocalUser() || empty($_POST['fromapp-submit'])) { + if (!DI::userSession()->getLocalUserId() || empty($_POST['fromapp-submit'])) { return; } - DI::pConfig()->set(Session::getLocalUser(), 'fromapp', 'app', $_POST['fromapp-input']); - DI::pConfig()->set(Session::getLocalUser(), 'fromapp', 'force', intval($_POST['fromapp-force'])); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'fromapp', 'app', $_POST['fromapp-input']); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'fromapp', 'force', intval($_POST['fromapp-force'])); } function fromapp_settings(App &$a, array &$data) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } - $fromapp = DI::pConfig()->get(Session::getLocalUser(), 'fromapp', 'app', ''); - $force = intval(DI::pConfig()->get(Session::getLocalUser(), 'fromapp', 'force')); + $fromapp = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'fromapp', 'app', ''); + $force = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'fromapp', 'force')); $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/fromapp/'); $html = Renderer::replaceMacros($t, [ @@ -56,16 +55,16 @@ function fromapp_settings(App &$a, array &$data) function fromapp_post_hook(App $a, &$item) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } - if (Session::getLocalUser() != $item['uid']) { + if (DI::userSession()->getLocalUserId() != $item['uid']) { return; } - $app = DI::pConfig()->get(Session::getLocalUser(), 'fromapp', 'app'); - $force = intval(DI::pConfig()->get(Session::getLocalUser(), 'fromapp', 'force')); + $app = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'fromapp', 'app'); + $force = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'fromapp', 'force')); if (is_null($app) || (! strlen($app))) { return; diff --git a/geonames/geonames.php b/geonames/geonames.php index 819d9eca..2ae845e5 100644 --- a/geonames/geonames.php +++ b/geonames/geonames.php @@ -12,7 +12,6 @@ use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\DI; use Friendica\Core\Config\Util\ConfigFileLoader; -use Friendica\Core\Session; use Friendica\Util\XML; function geonames_install() @@ -49,11 +48,11 @@ function geonames_post_hook(App $a, array &$item) 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; } @@ -64,7 +63,7 @@ function geonames_post_hook(App $a, array &$item) /* 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; @@ -103,11 +102,11 @@ function geonames_post_hook(App $a, array &$item) */ function geonames_addon_settings_post(App $a, 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'])); } /** @@ -120,7 +119,7 @@ function geonames_addon_settings_post(App $a, array $post) */ function geonames_addon_settings(App $a, array &$data) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } @@ -129,7 +128,7 @@ function geonames_addon_settings(App $a, array &$data) 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, [ diff --git a/gnot/gnot.php b/gnot/gnot.php index fa311ded..e3594b14 100644 --- a/gnot/gnot.php +++ b/gnot/gnot.php @@ -12,7 +12,6 @@ use Friendica\App; use Friendica\Core\Hook; use Friendica\Core\Logger; use Friendica\Core\Renderer; -use Friendica\Core\Session; use Friendica\DI; use Friendica\Model\Notification; @@ -32,10 +31,10 @@ function gnot_install() * and if so set our configuration setting for this person. */ function gnot_settings_post(App $a, $post) { - if(! Session::getLocalUser() || empty($_POST['gnot-submit'])) + if(! DI::userSession()->getLocalUserId() || empty($_POST['gnot-submit'])) return; - DI::pConfig()->set(Session::getLocalUser(),'gnot','enable',intval($_POST['gnot'])); + DI::pConfig()->set(DI::userSession()->getLocalUserId(),'gnot','enable',intval($_POST['gnot'])); } /** @@ -44,11 +43,11 @@ function gnot_settings_post(App $a, $post) { */ function gnot_settings(App &$a, array &$data) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } - $gnot = intval(DI::pConfig()->get(Session::getLocalUser(), 'gnot', 'enable')); + $gnot = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'gnot', 'enable')); $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/gnot/'); $html = Renderer::replaceMacros($t, [ diff --git a/group_text/group_text.php b/group_text/group_text.php index 6c60b8e3..b89cd275 100644 --- a/group_text/group_text.php +++ b/group_text/group_text.php @@ -10,7 +10,6 @@ use Friendica\App; use Friendica\Core\Hook; use Friendica\Core\Logger; use Friendica\Core\Renderer; -use Friendica\Core\Session; use Friendica\DI; function group_text_install() @@ -30,11 +29,11 @@ function group_text_install() function group_text_settings_post(App $a, array $post) { - if (!Session::getLocalUser() || empty($post['group_text-submit'])) { + if (!DI::userSession()->getLocalUserId() || empty($post['group_text-submit'])) { return; } - DI::pConfig()->set(Session::getLocalUser(), 'system', 'groupedit_image_limit', intval($post['group_text'])); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'groupedit_image_limit', intval($post['group_text'])); } @@ -47,11 +46,11 @@ function group_text_settings_post(App $a, array $post) function group_text_settings(App &$a, array &$data) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } - $enabled = DI::pConfig()->get(Session::getLocalUser(), 'system', 'groupedit_image_limit'); + $enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'groupedit_image_limit'); $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/group_text/'); $html = Renderer::replaceMacros($t, [ diff --git a/ifttt/ifttt.php b/ifttt/ifttt.php index a5db28bd..582b6b26 100644 --- a/ifttt/ifttt.php +++ b/ifttt/ifttt.php @@ -12,7 +12,6 @@ use Friendica\Core\Hook; use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Core\Renderer; -use Friendica\Core\Session; use Friendica\Core\Worker; use Friendica\Database\DBA; use Friendica\DI; @@ -37,14 +36,14 @@ function ifttt_content() {} function ifttt_settings(App $a, array &$data) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } - $key = DI::pConfig()->get(Session::getLocalUser(), 'ifttt', 'key'); + $key = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'ifttt', 'key'); if (!$key) { $key = Strings::getRandomHex(20); - DI::pConfig()->set(Session::getLocalUser(), 'ifttt', 'key', $key); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'ifttt', 'key', $key); } $t = Renderer::getMarkupTemplate('connector_settings.tpl', 'addon/ifttt/'); @@ -76,7 +75,7 @@ function ifttt_settings(App $a, array &$data) function ifttt_settings_post() { if (!empty($_POST['ifttt-submit'])) { - DI::pConfig()->delete(Session::getLocalUser(), 'ifttt', 'key'); + DI::pConfig()->delete(DI::userSession()->getLocalUserId(), 'ifttt', 'key'); } } diff --git a/ijpost/ijpost.php b/ijpost/ijpost.php index 1c9a899a..613b4133 100644 --- a/ijpost/ijpost.php +++ b/ijpost/ijpost.php @@ -13,7 +13,6 @@ use Friendica\Content\Text\BBCode; use Friendica\Core\Hook; use Friendica\Core\Logger; use Friendica\Core\Renderer; -use Friendica\Core\Session; use Friendica\DI; use Friendica\Model\Tag; use Friendica\Model\User; @@ -31,17 +30,17 @@ function ijpost_install() function ijpost_jot_nets(App &$a, array &$jotnets_fields) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } - if (DI::pConfig()->get(Session::getLocalUser(), 'ijpost', 'post')) { + if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'ijpost', 'post')) { $jotnets_fields[] = [ 'type' => 'checkbox', 'field' => [ 'ijpost_enable', DI::l10n()->t('Post to Insanejournal'), - DI::pConfig()->get(Session::getLocalUser(), 'ijpost', 'post_by_default') + DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'ijpost', 'post_by_default') ] ]; } @@ -49,13 +48,13 @@ function ijpost_jot_nets(App &$a, array &$jotnets_fields) function ijpost_settings(App &$a, array &$data) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } - $enabled = DI::pConfig()->get(Session::getLocalUser(), 'ijpost', 'post', false); - $ij_username = DI::pConfig()->get(Session::getLocalUser(), 'ijpost', 'ij_username'); - $def_enabled = DI::pConfig()->get(Session::getLocalUser(), 'ijpost', 'post_by_default'); + $enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'ijpost', 'post', false); + $ij_username = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'ijpost', 'ij_username'); + $def_enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'ijpost', 'post_by_default'); $t = Renderer::getMarkupTemplate('connector_settings.tpl', 'addon/ijpost/'); $html = Renderer::replaceMacros($t, [ @@ -77,10 +76,10 @@ function ijpost_settings(App &$a, array &$data) function ijpost_settings_post(App $a, array &$b) { if (!empty($_POST['ijpost-submit'])) { - DI::pConfig()->set(Session::getLocalUser(), 'ijpost', 'post', intval($_POST['ijpost'])); - DI::pConfig()->set(Session::getLocalUser(), 'ijpost', 'post_by_default', intval($_POST['ij_bydefault'])); - DI::pConfig()->set(Session::getLocalUser(), 'ijpost', 'ij_username', trim($_POST['ij_username'])); - DI::pConfig()->set(Session::getLocalUser(), 'ijpost', 'ij_password', trim($_POST['ij_password'])); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'ijpost', 'post', intval($_POST['ijpost'])); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'ijpost', 'post_by_default', intval($_POST['ij_bydefault'])); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'ijpost', 'ij_username', trim($_POST['ij_username'])); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'ijpost', 'ij_password', trim($_POST['ij_password'])); } } @@ -92,7 +91,7 @@ function ijpost_post_local(App $a, array &$b) return; } - if (!Session::getLocalUser() || (Session::getLocalUser() != $b['uid'])) { + if (!DI::userSession()->getLocalUserId() || (DI::userSession()->getLocalUserId() != $b['uid'])) { return; } @@ -100,11 +99,11 @@ function ijpost_post_local(App $a, array &$b) return; } - $ij_post = intval(DI::pConfig()->get(Session::getLocalUser(), 'ijpost', 'post')); + $ij_post = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'ijpost', 'post')); $ij_enable = (($ij_post && !empty($_REQUEST['ijpost_enable'])) ? intval($_REQUEST['ijpost_enable']) : 0); - if ($b['api_source'] && intval(DI::pConfig()->get(Session::getLocalUser(), 'ijpost', 'post_by_default'))) { + if ($b['api_source'] && intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'ijpost', 'post_by_default'))) { $ij_enable = 1; } diff --git a/irc/irc.php b/irc/irc.php index 656c85c8..0cec5622 100644 --- a/irc/irc.php +++ b/irc/irc.php @@ -10,7 +10,6 @@ use Friendica\App; use Friendica\Core\Hook; use Friendica\Core\Renderer; -use Friendica\Core\Session; use Friendica\DI; function irc_install() @@ -22,12 +21,12 @@ function irc_install() function irc_addon_settings(App &$a, array &$data) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } - $sitechats = DI::pConfig()->get(Session::getLocalUser(), 'irc', 'sitechats'); /* popular channels */ - $autochans = DI::pConfig()->get(Session::getLocalUser(), 'irc', 'autochans'); /* auto connect chans */ + $sitechats = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'irc', 'sitechats'); /* popular channels */ + $autochans = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'irc', 'autochans'); /* auto connect chans */ $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/irc/'); $html = Renderer::replaceMacros($t, [ @@ -45,16 +44,16 @@ function irc_addon_settings(App &$a, array &$data) function irc_addon_settings_post(App $a, array &$b) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } if (!empty($_POST['irc-submit'])) { if (isset($_POST['autochans'])) { - DI::pConfig()->set(Session::getLocalUser(), 'irc', 'autochans', trim(($_POST['autochans']))); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'irc', 'autochans', trim(($_POST['autochans']))); } if (isset($_POST['sitechats'])) { - DI::pConfig()->set(Session::getLocalUser(), 'irc', 'sitechats', trim($_POST['sitechats'])); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'irc', 'sitechats', trim($_POST['sitechats'])); } /* upid pop-up thing */ } @@ -78,8 +77,8 @@ function irc_content(App $a) $o = ''; /* set the list of popular channels */ - if (Session::getLocalUser()) { - $sitechats = DI::pConfig()->get( Session::getLocalUser(), 'irc', 'sitechats'); + if (DI::userSession()->getLocalUserId()) { + $sitechats = DI::pConfig()->get( DI::userSession()->getLocalUserId(), 'irc', 'sitechats'); if (!$sitechats) { $sitechats = DI::config()->get('irc', 'sitechats'); } @@ -101,8 +100,8 @@ function irc_content(App $a) DI::page()['aside'] .= ''; /* setting the channel(s) to auto connect */ - if (Session::getLocalUser()) { - $autochans = DI::pConfig()->get(Session::getLocalUser(), 'irc', 'autochans'); + if (DI::userSession()->getLocalUserId()) { + $autochans = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'irc', 'autochans'); if (!$autochans) $autochans = DI::config()->get('irc','autochans'); } else { diff --git a/keycloakpassword/keycloakpassword.php b/keycloakpassword/keycloakpassword.php index 69720f14..7a417805 100644 --- a/keycloakpassword/keycloakpassword.php +++ b/keycloakpassword/keycloakpassword.php @@ -10,7 +10,6 @@ use Friendica\App; use Friendica\Core\Hook; use Friendica\Core\Logger; use Friendica\Core\Renderer; -use Friendica\Core\Session; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\User; @@ -143,7 +142,7 @@ function keycloakpassword_addon_admin(App $a, string &$o) function keycloakpassword_addon_admin_post(App $a) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } diff --git a/krynn/krynn.php b/krynn/krynn.php index 6c179002..48a65fdd 100644 --- a/krynn/krynn.php +++ b/krynn/krynn.php @@ -14,7 +14,6 @@ use Friendica\App; use Friendica\Core\Hook; use Friendica\Core\Logger; use Friendica\Core\Renderer; -use Friendica\Core\Session; use Friendica\DI; function krynn_install() @@ -44,12 +43,12 @@ function krynn_post_hook(App $a, &$item) * - A status post by a profile owner * - The profile owner must have allowed our addon */ - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { /* non-zero if this is a logged in user of this system */ return; } - if (Session::getLocalUser() != $item['uid']) { + if (DI::userSession()->getLocalUserId() != $item['uid']) { /* Does this person own the post? */ return; } @@ -60,7 +59,7 @@ function krynn_post_hook(App $a, &$item) } /* Retrieve our personal config setting */ - $active = DI::pConfig()->get(Session::getLocalUser(), 'krynn', 'enable'); + $active = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'krynn', 'enable'); if (!$active) { return; @@ -91,12 +90,12 @@ function krynn_post_hook(App $a, &$item) */ function krynn_settings_post(App $a, $post) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } if ($_POST['krynn-submit']) { - DI::pConfig()->set(Session::getLocalUser(),'krynn','enable',intval($_POST['krynn'])); + DI::pConfig()->set(DI::userSession()->getLocalUserId(),'krynn','enable',intval($_POST['krynn'])); } } @@ -106,11 +105,11 @@ function krynn_settings_post(App $a, $post) */ function krynn_settings(App &$a, array &$data) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } - $enabled = DI::pConfig()->get(Session::getLocalUser(),'krynn','enable'); + $enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(),'krynn','enable'); $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/krynn/'); $html = Renderer::replaceMacros($t, [ diff --git a/langfilter/langfilter.php b/langfilter/langfilter.php index eee7faf0..31efad3b 100644 --- a/langfilter/langfilter.php +++ b/langfilter/langfilter.php @@ -11,7 +11,6 @@ use Friendica\App; use Friendica\Content\Text\BBCode; use Friendica\Core\Hook; use Friendica\Core\Renderer; -use Friendica\Core\Session; use Friendica\DI; /* Define the hooks we want to use @@ -34,16 +33,16 @@ function langfilter_install() function langfilter_addon_settings(App $a, array &$data) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } - $enabled = DI::pConfig()->get(Session::getLocalUser(), 'langfilter', 'enable', - !DI::pConfig()->get(Session::getLocalUser(), 'langfilter', 'disable')); + $enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'langfilter', 'enable', + !DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'langfilter', 'disable')); - $languages = DI::pConfig()->get(Session::getLocalUser(), 'langfilter', 'languages'); - $minconfidence = DI::pConfig()->get(Session::getLocalUser(), 'langfilter', 'minconfidence', 0) * 100; - $minlength = DI::pConfig()->get(Session::getLocalUser(), 'langfilter', 'minlength', 32); + $languages = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'langfilter', 'languages'); + $minconfidence = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'langfilter', 'minconfidence', 0) * 100; + $minlength = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'langfilter', 'minlength', 32); $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/langfilter/'); $html = Renderer::replaceMacros($t, [ @@ -70,7 +69,7 @@ function langfilter_addon_settings(App $a, array &$data) function langfilter_addon_settings_post(App $a, array &$b) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } @@ -83,10 +82,10 @@ function langfilter_addon_settings_post(App $a, array &$b) $minlength = 32; } - DI::pConfig()->set(Session::getLocalUser(), 'langfilter', 'enable' , $enable); - DI::pConfig()->set(Session::getLocalUser(), 'langfilter', 'languages' , $languages); - DI::pConfig()->set(Session::getLocalUser(), 'langfilter', 'minconfidence', $minconfidence); - DI::pConfig()->set(Session::getLocalUser(), 'langfilter', 'minlength' , $minlength); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'langfilter', 'enable' , $enable); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'langfilter', 'languages' , $languages); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'langfilter', 'minconfidence', $minconfidence); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'langfilter', 'minlength' , $minlength); } } @@ -101,7 +100,7 @@ function langfilter_addon_settings_post(App $a, array &$b) function langfilter_prepare_body_content_filter(App $a, &$hook_data) { - $logged_user = Session::getLocalUser(); + $logged_user = DI::userSession()->getLocalUserId(); if (!$logged_user) { return; } @@ -129,7 +128,7 @@ function langfilter_prepare_body_content_filter(App $a, &$hook_data) $naked_body = preg_replace('#\s+#', ' ', trim($naked_body)); // Don't filter if body lenght is below minimum - $minlen = DI::pConfig()->get(Session::getLocalUser(), 'langfilter', 'minlength', 32); + $minlen = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'langfilter', 'minlength', 32); if (!$minlen) { $minlen = 32; } @@ -138,8 +137,8 @@ function langfilter_prepare_body_content_filter(App $a, &$hook_data) return; } - $read_languages_string = DI::pConfig()->get(Session::getLocalUser(), 'langfilter', 'languages'); - $minconfidence = DI::pConfig()->get(Session::getLocalUser(), 'langfilter', 'minconfidence'); + $read_languages_string = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'langfilter', 'languages'); + $minconfidence = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'langfilter', 'minconfidence'); // Don't filter if no spoken languages are configured if (!$read_languages_string) { diff --git a/libertree/libertree.php b/libertree/libertree.php index 4085fe0a..999c4972 100644 --- a/libertree/libertree.php +++ b/libertree/libertree.php @@ -11,7 +11,6 @@ use Friendica\Content\Text\BBCode; use Friendica\Core\Hook; use Friendica\Core\Logger; use Friendica\Core\Renderer; -use Friendica\Core\Session; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Post; @@ -28,17 +27,17 @@ function libertree_install() function libertree_jot_nets(App &$a, array &$jotnets_fields) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } - if (DI::pConfig()->get(Session::getLocalUser(), 'libertree', 'post')) { + if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'libertree', 'post')) { $jotnets_fields[] = [ 'type' => 'checkbox', 'field' => [ 'libertree_enable', DI::l10n()->t('Post to libertree'), - DI::pConfig()->get(Session::getLocalUser(), 'libertree', 'post_by_default'), + DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'libertree', 'post_by_default'), ], ]; } @@ -46,14 +45,14 @@ function libertree_jot_nets(App &$a, array &$jotnets_fields) function libertree_settings(App $a, array &$data) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } - $enabled = DI::pConfig()->get(Session::getLocalUser(), 'libertree', 'post', false); - $ltree_api_token = DI::pConfig()->get(Session::getLocalUser(), 'libertree', 'libertree_api_token'); - $ltree_url = DI::pConfig()->get(Session::getLocalUser(), 'libertree', 'libertree_url'); - $def_enabled = DI::pConfig()->get(Session::getLocalUser(), 'libertree', 'post_by_default'); + $enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'libertree', 'post', false); + $ltree_api_token = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'libertree', 'libertree_api_token'); + $ltree_url = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'libertree', 'libertree_url'); + $def_enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'libertree', 'post_by_default'); $t = Renderer::getMarkupTemplate('connector_settings.tpl', 'addon/libertree/'); $html = Renderer::replaceMacros($t, [ @@ -75,10 +74,10 @@ function libertree_settings(App $a, array &$data) function libertree_settings_post(App $a, array &$b) { if (!empty($_POST['libertree-submit'])) { - DI::pConfig()->set(Session::getLocalUser(),'libertree','post',intval($_POST['libertree'])); - DI::pConfig()->set(Session::getLocalUser(),'libertree','post_by_default',intval($_POST['libertree_bydefault'])); - DI::pConfig()->set(Session::getLocalUser(),'libertree','libertree_api_token',trim($_POST['libertree_api_token'])); - DI::pConfig()->set(Session::getLocalUser(),'libertree','libertree_url',trim($_POST['libertree_url'])); + DI::pConfig()->set(DI::userSession()->getLocalUserId(),'libertree','post',intval($_POST['libertree'])); + DI::pConfig()->set(DI::userSession()->getLocalUserId(),'libertree','post_by_default',intval($_POST['libertree_bydefault'])); + DI::pConfig()->set(DI::userSession()->getLocalUserId(),'libertree','libertree_api_token',trim($_POST['libertree_api_token'])); + DI::pConfig()->set(DI::userSession()->getLocalUserId(),'libertree','libertree_url',trim($_POST['libertree_url'])); } @@ -108,7 +107,7 @@ function libertree_post_local(App $a, array &$b) return; } - if (!Session::getLocalUser() || (Session::getLocalUser() != $b['uid'])) { + if (!DI::userSession()->getLocalUserId() || (DI::userSession()->getLocalUserId() != $b['uid'])) { return; } @@ -116,11 +115,11 @@ function libertree_post_local(App $a, array &$b) return; } - $ltree_post = intval(DI::pConfig()->get(Session::getLocalUser(),'libertree','post')); + $ltree_post = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(),'libertree','post')); $ltree_enable = (($ltree_post && !empty($_REQUEST['libertree_enable'])) ? intval($_REQUEST['libertree_enable']) : 0); - if ($b['api_source'] && intval(DI::pConfig()->get(Session::getLocalUser(),'libertree','post_by_default'))) { + if ($b['api_source'] && intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(),'libertree','post_by_default'))) { $ltree_enable = 1; } diff --git a/ljpost/ljpost.php b/ljpost/ljpost.php index ba2263a9..42b0c020 100644 --- a/ljpost/ljpost.php +++ b/ljpost/ljpost.php @@ -13,7 +13,6 @@ use Friendica\Content\Text\BBCode; use Friendica\Core\Hook; use Friendica\Core\Logger; use Friendica\Core\Renderer; -use Friendica\Core\Session; use Friendica\DI; use Friendica\Model\Post; use Friendica\Model\Tag; @@ -32,17 +31,17 @@ function ljpost_install() function ljpost_jot_nets(App &$a, array &$jotnets_fields) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } - if (DI::pConfig()->get(Session::getLocalUser(),'ljpost','post')) { + if (DI::pConfig()->get(DI::userSession()->getLocalUserId(),'ljpost','post')) { $jotnets_fields[] = [ 'type' => 'checkbox', 'field' => [ 'ljpost_enable', DI::l10n()->t('Post to LiveJournal'), - DI::pConfig()->get(Session::getLocalUser(), 'ljpost', 'post_by_default'), + DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'ljpost', 'post_by_default'), ], ]; } @@ -50,13 +49,13 @@ function ljpost_jot_nets(App &$a, array &$jotnets_fields) function ljpost_settings(App &$a, array &$data) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } - $enabled = DI::pConfig()->get(Session::getLocalUser(), 'ljpost', 'post', false); - $ij_username = DI::pConfig()->get(Session::getLocalUser(), 'ljpost', 'ij_username'); - $def_enabled = DI::pConfig()->get(Session::getLocalUser(), 'ljpost', 'post_by_default'); + $enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'ljpost', 'post', false); + $ij_username = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'ljpost', 'ij_username'); + $def_enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'ljpost', 'post_by_default'); $t= Renderer::getMarkupTemplate('connector_settings.tpl', 'addon/ljpost/'); $html = Renderer::replaceMacros($t, [ @@ -78,10 +77,10 @@ function ljpost_settings(App &$a, array &$data) function ljpost_settings_post(App $a, array &$b) { if (!empty($_POST['ljpost-submit'])) { - DI::pConfig()->set(Session::getLocalUser(), 'ljpost', 'post', intval($_POST['ljpost'])); - DI::pConfig()->set(Session::getLocalUser(), 'ljpost', 'post_by_default', intval($_POST['lj_bydefault'])); - DI::pConfig()->set(Session::getLocalUser(), 'ljpost', 'lj_username', trim($_POST['lj_username'])); - DI::pConfig()->set(Session::getLocalUser(), 'ljpost', 'lj_password', trim($_POST['lj_password'])); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'ljpost', 'post', intval($_POST['ljpost'])); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'ljpost', 'post_by_default', intval($_POST['lj_bydefault'])); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'ljpost', 'lj_username', trim($_POST['lj_username'])); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'ljpost', 'lj_password', trim($_POST['lj_password'])); } } @@ -92,7 +91,7 @@ function ljpost_post_local(App $a, array &$b) return; } - if (!Session::getLocalUser() || (Session::getLocalUser() != $b['uid'])) { + if (!DI::userSession()->getLocalUserId() || (DI::userSession()->getLocalUserId() != $b['uid'])) { return; } @@ -100,10 +99,10 @@ function ljpost_post_local(App $a, array &$b) return; } - $lj_post = intval(DI::pConfig()->get(Session::getLocalUser(),'ljpost','post')); + $lj_post = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(),'ljpost','post')); $lj_enable = (($lj_post && !empty($_REQUEST['ljpost_enable'])) ? intval($_REQUEST['ljpost_enable']) : 0); - if ($b['api_source'] && intval(DI::pConfig()->get(Session::getLocalUser(), 'ljpost', 'post_by_default'))) { + if ($b['api_source'] && intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'ljpost', 'post_by_default'))) { $lj_enable = 1; } diff --git a/mailstream/mailstream.php b/mailstream/mailstream.php index 7b5090fd..35c6aab0 100644 --- a/mailstream/mailstream.php +++ b/mailstream/mailstream.php @@ -11,7 +11,6 @@ use Friendica\Content\Text\BBCode; use Friendica\Core\Hook; use Friendica\Core\Logger; use Friendica\Core\Renderer; -use Friendica\Core\Session; use Friendica\Core\System; use Friendica\Core\Worker; use Friendica\Database\DBA; @@ -482,10 +481,10 @@ function mailstream_convert_table_entries() */ function mailstream_addon_settings(App &$a, array &$data) { - $enabled = DI::pConfig()->get(Session::getLocalUser(), 'mailstream', 'enabled'); - $address = DI::pConfig()->get(Session::getLocalUser(), 'mailstream', 'address'); - $nolikes = DI::pConfig()->get(Session::getLocalUser(), 'mailstream', 'nolikes'); - $attachimg = DI::pConfig()->get(Session::getLocalUser(), 'mailstream', 'attachimg'); + $enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'mailstream', 'enabled'); + $address = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'mailstream', 'address'); + $nolikes = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'mailstream', 'nolikes'); + $attachimg = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'mailstream', 'attachimg'); $template = Renderer::getMarkupTemplate('settings.tpl', 'addon/mailstream/'); $html = Renderer::replaceMacros($template, [ @@ -530,28 +529,28 @@ function mailstream_addon_settings(App &$a, array &$data) */ function mailstream_addon_settings_post(App $a, array $post) { - if (!Session::getLocalUser() || empty($post['mailstream-submit'])) { + if (!DI::userSession()->getLocalUserId() || empty($post['mailstream-submit'])) { return; } if ($post['mailstream_address'] != "") { - DI::pConfig()->set(Session::getLocalUser(), 'mailstream', 'address', $post['mailstream_address']); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'mailstream', 'address', $post['mailstream_address']); } else { - DI::pConfig()->delete(Session::getLocalUser(), 'mailstream', 'address'); + DI::pConfig()->delete(DI::userSession()->getLocalUserId(), 'mailstream', 'address'); } if ($post['mailstream_nolikes']) { - DI::pConfig()->set(Session::getLocalUser(), 'mailstream', 'nolikes', $post['mailstream_enabled']); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'mailstream', 'nolikes', $post['mailstream_enabled']); } else { - DI::pConfig()->delete(Session::getLocalUser(), 'mailstream', 'nolikes'); + DI::pConfig()->delete(DI::userSession()->getLocalUserId(), 'mailstream', 'nolikes'); } if ($post['mailstream_enabled']) { - DI::pConfig()->set(Session::getLocalUser(), 'mailstream', 'enabled', $post['mailstream_enabled']); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'mailstream', 'enabled', $post['mailstream_enabled']); } else { - DI::pConfig()->delete(Session::getLocalUser(), 'mailstream', 'enabled'); + DI::pConfig()->delete(DI::userSession()->getLocalUserId(), 'mailstream', 'enabled'); } if ($post['mailstream_attachimg']) { - DI::pConfig()->set(Session::getLocalUser(), 'mailstream', 'attachimg', $post['mailstream_attachimg']); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'mailstream', 'attachimg', $post['mailstream_attachimg']); } else { - DI::pConfig()->delete(Session::getLocalUser(), 'mailstream', 'attachimg'); + DI::pConfig()->delete(DI::userSession()->getLocalUserId(), 'mailstream', 'attachimg'); } } diff --git a/markdown/markdown.php b/markdown/markdown.php index faa1b356..ffc46ac5 100644 --- a/markdown/markdown.php +++ b/markdown/markdown.php @@ -9,7 +9,6 @@ use Friendica\App; use Friendica\Core\Hook; use Friendica\Content\Text\Markdown; use Friendica\Core\Renderer; -use Friendica\Core\Session; use Friendica\DI; function markdown_install() { @@ -20,11 +19,11 @@ function markdown_install() { function markdown_addon_settings(App $a, array &$data) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } - $enabled = intval(DI::pConfig()->get(Session::getLocalUser(), 'markdown', 'enabled')); + $enabled = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'markdown', 'enabled')); $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/markdown/'); $html = Renderer::replaceMacros($t, [ @@ -40,15 +39,15 @@ function markdown_addon_settings(App $a, array &$data) function markdown_addon_settings_post(App $a, array &$b) { - if (!Session::getLocalUser() || empty($_POST['markdown-submit'])) { + if (!DI::userSession()->getLocalUserId() || empty($_POST['markdown-submit'])) { return; } - DI::pConfig()->set(Session::getLocalUser(), 'markdown', 'enabled', intval($_POST['enabled'])); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'markdown', 'enabled', intval($_POST['enabled'])); } function markdown_post_local_start(App $a, &$request) { - if (empty($request['body']) || !DI::pConfig()->get(Session::getLocalUser(), 'markdown', 'enabled')) { + if (empty($request['body']) || !DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'markdown', 'enabled')) { return; } diff --git a/mathjax/mathjax.php b/mathjax/mathjax.php index 92ece931..b60254bd 100644 --- a/mathjax/mathjax.php +++ b/mathjax/mathjax.php @@ -11,7 +11,6 @@ use Friendica\App; use Friendica\Core\Hook; use Friendica\Core\Renderer; -use Friendica\Core\Session; use Friendica\DI; function mathjax_install() @@ -23,20 +22,20 @@ function mathjax_install() function mathjax_settings_post(App $a) { - if (!Session::getLocalUser() || empty($_POST['mathjax-submit'])) { + if (!DI::userSession()->getLocalUserId() || empty($_POST['mathjax-submit'])) { return; } - DI::pConfig()->set(Session::getLocalUser(), 'mathjax', 'use', intval($_POST['mathjax_use'])); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'mathjax', 'use', intval($_POST['mathjax_use'])); } function mathjax_settings(App $a, array &$data) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } - $use = DI::pConfig()->get(Session::getLocalUser(), 'mathjax', 'use', false); + $use = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'mathjax', 'use', false); $tpl = Renderer::getMarkupTemplate('settings.tpl', 'addon/mathjax'); $html = Renderer::replaceMacros($tpl, [ @@ -55,7 +54,7 @@ function mathjax_footer(App $a, string &$body) { // if the visitor of the page is not a local_user, use MathJax // otherwise check the users settings. - if (!Session::getLocalUser() || DI::pConfig()->get(Session::getLocalUser(), 'mathjax', 'use', false)) { + if (!DI::userSession()->getLocalUserId() || DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'mathjax', 'use', false)) { DI::page()->registerFooterScript(__DIR__ . '/asset/MathJax.js?config=TeX-MML-AM_CHTML'); DI::page()->registerFooterScript(__DIR__ . '/mathjax.js'); } diff --git a/nsfw/nsfw.php b/nsfw/nsfw.php index da45df3e..f252ffc3 100644 --- a/nsfw/nsfw.php +++ b/nsfw/nsfw.php @@ -11,7 +11,6 @@ use Friendica\App; use Friendica\Core\Hook; use Friendica\Core\Renderer; -use Friendica\Core\Session; use Friendica\DI; function nsfw_install() @@ -54,12 +53,12 @@ function nsfw_extract_photos($body) function nsfw_addon_settings(App &$a, array &$data) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } - $enabled = !DI::pConfig()->get(Session::getLocalUser(), 'nsfw', 'disable'); - $words = DI::pConfig()->get(Session::getLocalUser(), 'nsfw', 'words', 'nsfw,'); + $enabled = !DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'nsfw', 'disable'); + $words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'nsfw', 'words', 'nsfw,'); $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/nsfw/'); $html = Renderer::replaceMacros($t, [ @@ -77,27 +76,27 @@ function nsfw_addon_settings(App &$a, array &$data) function nsfw_addon_settings_post(App $a, array &$b) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } if (!empty($_POST['nsfw-submit'])) { - DI::pConfig()->set(Session::getLocalUser(), 'nsfw', 'words', trim($_POST['nsfw-words'])); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'nsfw', 'words', trim($_POST['nsfw-words'])); $enable = (!empty($_POST['nsfw-enable']) ? intval($_POST['nsfw-enable']) : 0); $disable = 1 - $enable; - DI::pConfig()->set(Session::getLocalUser(), 'nsfw', 'disable', $disable); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'nsfw', 'disable', $disable); } } function nsfw_prepare_body_content_filter(App $a, &$hook_data) { $words = null; - if (DI::pConfig()->get(Session::getLocalUser(), 'nsfw', 'disable')) { + if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'nsfw', 'disable')) { return; } - if (Session::getLocalUser()) { - $words = DI::pConfig()->get(Session::getLocalUser(), 'nsfw', 'words'); + if (DI::userSession()->getLocalUserId()) { + $words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'nsfw', 'words'); } if ($words) { diff --git a/numfriends/numfriends.php b/numfriends/numfriends.php index beba8bfd..8532e36d 100644 --- a/numfriends/numfriends.php +++ b/numfriends/numfriends.php @@ -10,7 +10,6 @@ use Friendica\App; use Friendica\Core\Hook; use Friendica\Core\Logger; use Friendica\Core\Renderer; -use Friendica\Core\Session; use Friendica\DI; function numfriends_install() { @@ -30,11 +29,11 @@ function numfriends_install() { * */ function numfriends_settings_post(App $a, $post) { - if (! Session::getLocalUser() || empty($_POST['numfriends-submit'])) { + if (! DI::userSession()->getLocalUserId() || empty($_POST['numfriends-submit'])) { return; } - DI::pConfig()->set(Session::getLocalUser(), 'system', 'display_friend_count', intval($_POST['numfriends'])); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'display_friend_count', intval($_POST['numfriends'])); } @@ -46,11 +45,11 @@ function numfriends_settings_post(App $a, $post) { */ function numfriends_settings(App &$a, array &$data) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } - $numfriends = DI::pConfig()->get(Session::getLocalUser(), 'system', 'display_friend_count', 24); + $numfriends = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'display_friend_count', 24); $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/numfriends/'); $html = Renderer::replaceMacros($t, [ diff --git a/opmlexport/opmlexport.php b/opmlexport/opmlexport.php index d32d4c77..e8d7157d 100644 --- a/opmlexport/opmlexport.php +++ b/opmlexport/opmlexport.php @@ -15,7 +15,6 @@ use Friendica\Network\HTTPException; use Friendica\Database\DBA; use Friendica\Core\Renderer; use Friendica\Core\Protocol; -use Friendica\Core\Session; use Friendica\Model\Contact; use Friendica\Model\User; @@ -30,7 +29,7 @@ function opmlexport_install() function opmlexport(App $a) { $condition = [ - 'uid' => Session::getLocalUser(), + 'uid' => DI::userSession()->getLocalUserId(), 'self' => false, 'deleted' => false, 'archive' => false, @@ -39,7 +38,7 @@ function opmlexport(App $a) 'network' => Protocol::FEED ]; $data = Contact::selectToArray([], $condition, ['order' => ['name']]); - $user = User::getById(Session::getLocalUser()); + $user = User::getById(DI::userSession()->getLocalUserId()); $xml = new \DOMDocument( '1.0', 'utf-8' ); $opml = $xml->createElement('opml'); @@ -71,7 +70,7 @@ function opmlexport(App $a) function opmlexport_addon_settings(App $a, array &$data) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } @@ -85,7 +84,7 @@ function opmlexport_addon_settings(App $a, array &$data) function opmlexport_addon_settings_post(App $a, array &$b) { - if (!Session::getLocalUser() || empty($_POST['opmlexport-submit'])) { + if (!DI::userSession()->getLocalUserId() || empty($_POST['opmlexport-submit'])) { return; } diff --git a/planets/planets.php b/planets/planets.php index 8cee996d..35a677ae 100644 --- a/planets/planets.php +++ b/planets/planets.php @@ -11,7 +11,6 @@ use Friendica\App; use Friendica\Core\Hook; use Friendica\Core\Logger; use Friendica\Core\Renderer; -use Friendica\Core\Session; use Friendica\DI; function planets_install() @@ -43,12 +42,12 @@ function planets_post_hook(App $a, &$item) { Logger::notice('planets invoked'); - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { /* non-zero if this is a logged in user of this system */ return; } - if (Session::getLocalUser() != $item['uid']) { + if (DI::userSession()->getLocalUserId() != $item['uid']) { /* Does this person own the post? */ return; } @@ -59,7 +58,7 @@ function planets_post_hook(App $a, &$item) } /* Retrieve our personal config setting */ - $active = DI::pConfig()->get(Session::getLocalUser(), 'planets', 'enable'); + $active = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'planets', 'enable'); if (!$active) { return; @@ -96,11 +95,11 @@ function planets_post_hook(App $a, &$item) function planets_settings_post(App $a, $post) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } if ($_POST['planets-submit']) { - DI::pConfig()->set(Session::getLocalUser(), 'planets', 'enable' ,intval($_POST['planets'])); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'planets', 'enable' ,intval($_POST['planets'])); } } @@ -116,11 +115,11 @@ function planets_settings_post(App $a, $post) function planets_settings(App &$a, array &$data) { - if(!Session::getLocalUser()) { + if(!DI::userSession()->getLocalUserId()) { return; } - $enabled = DI::pConfig()->get(Session::getLocalUser(),'planets','enable'); + $enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(),'planets','enable'); $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/planets/'); $html = Renderer::replaceMacros($t, [ diff --git a/public_server/public_server.php b/public_server/public_server.php index 6c0a746b..cc85ba60 100644 --- a/public_server/public_server.php +++ b/public_server/public_server.php @@ -16,7 +16,6 @@ use Friendica\DI; use Friendica\Model\Notification; use Friendica\Model\User; use Friendica\Core\Config\Util\ConfigFileLoader; -use Friendica\Core\Session; use Friendica\Util\DateTimeFormat; function public_server_install() @@ -119,7 +118,7 @@ function public_server_login(App $a, $b) } $fields = ['account_expires_on' => DateTimeFormat::utc('now +' . $days . ' days')]; - $condition = ["`uid` = ? AND `account_expires_on` > ?", Session::getLocalUser(), DBA::NULL_DATETIME]; + $condition = ["`uid` = ? AND `account_expires_on` > ?", DI::userSession()->getLocalUserId(), DBA::NULL_DATETIME]; DBA::update('user', $fields, $condition); } diff --git a/pumpio/pumpio.php b/pumpio/pumpio.php index 456342e6..cb890277 100644 --- a/pumpio/pumpio.php +++ b/pumpio/pumpio.php @@ -27,7 +27,6 @@ use Friendica\Network\HTTPClient\Client\HttpClientOptions; use Friendica\Protocol\Activity; use Friendica\Protocol\ActivityNamespace; use Friendica\Core\Config\Util\ConfigFileLoader; -use Friendica\Core\Session; use Friendica\Util\DateTimeFormat; use Friendica\Util\Strings; use Friendica\Util\XML; @@ -60,7 +59,7 @@ function pumpio_module() {} function pumpio_content(App $a) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); return ''; } @@ -139,18 +138,18 @@ function pumpio_registerclient(App $a, $host) function pumpio_connect(App $a) { // Define the needed keys - $consumer_key = DI::pConfig()->get(Session::getLocalUser(), 'pumpio', 'consumer_key'); - $consumer_secret = DI::pConfig()->get(Session::getLocalUser(), 'pumpio', 'consumer_secret'); - $hostname = DI::pConfig()->get(Session::getLocalUser(), 'pumpio', 'host'); + $consumer_key = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pumpio', 'consumer_key'); + $consumer_secret = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pumpio', 'consumer_secret'); + $hostname = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pumpio', 'host'); if ((($consumer_key == '') || ($consumer_secret == '')) && ($hostname != '')) { Logger::notice('pumpio_connect: register client'); $clientdata = pumpio_registerclient($a, $hostname); - DI::pConfig()->set(Session::getLocalUser(), 'pumpio', 'consumer_key', $clientdata->client_id); - DI::pConfig()->set(Session::getLocalUser(), 'pumpio', 'consumer_secret', $clientdata->client_secret); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pumpio', 'consumer_key', $clientdata->client_id); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pumpio', 'consumer_secret', $clientdata->client_secret); - $consumer_key = DI::pConfig()->get(Session::getLocalUser(), 'pumpio', 'consumer_key'); - $consumer_secret = DI::pConfig()->get(Session::getLocalUser(), 'pumpio', 'consumer_secret'); + $consumer_key = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pumpio', 'consumer_key'); + $consumer_secret = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pumpio', 'consumer_secret'); Logger::info('pumpio_connect: ckey: ' . $consumer_key . ' csecrect: ' . $consumer_secret); } @@ -186,8 +185,8 @@ function pumpio_connect(App $a) if (($success = $client->Process())) { if (strlen($client->access_token)) { Logger::info('pumpio_connect: otoken: ' . $client->access_token . ', osecrect: ' . $client->access_token_secret); - DI::pConfig()->set(Session::getLocalUser(), 'pumpio', 'oauth_token', $client->access_token); - DI::pConfig()->set(Session::getLocalUser(), 'pumpio', 'oauth_token_secret', $client->access_token_secret); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pumpio', 'oauth_token', $client->access_token); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pumpio', 'oauth_token_secret', $client->access_token_secret); } } $success = $client->Finalize($success); @@ -210,17 +209,17 @@ function pumpio_connect(App $a) function pumpio_jot_nets(App $a, array &$jotnets_fields) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } - if (DI::pConfig()->get(Session::getLocalUser(), 'pumpio', 'post')) { + if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pumpio', 'post')) { $jotnets_fields[] = [ 'type' => 'checkbox', 'field' => [ 'pumpio_enable', DI::l10n()->t('Post to pumpio'), - DI::pConfig()->get(Session::getLocalUser(), 'pumpio', 'post_by_default') + DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pumpio', 'post_by_default') ] ]; } @@ -228,20 +227,20 @@ function pumpio_jot_nets(App $a, array &$jotnets_fields) function pumpio_settings(App $a, array &$data) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } - $pumpio_host = DI::pConfig()->get(Session::getLocalUser(), 'pumpio', 'host'); - $pumpio_user = DI::pConfig()->get(Session::getLocalUser(), 'pumpio', 'user'); - $oauth_token = DI::pConfig()->get(Session::getLocalUser(), 'pumpio', 'oauth_token'); - $oauth_token_secret = DI::pConfig()->get(Session::getLocalUser(), 'pumpio', 'oauth_token_secret'); + $pumpio_host = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pumpio', 'host'); + $pumpio_user = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pumpio', 'user'); + $oauth_token = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pumpio', 'oauth_token'); + $oauth_token_secret = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pumpio', 'oauth_token_secret'); - $import_enabled = DI::pConfig()->get(Session::getLocalUser(), 'pumpio', 'import', false); - $enabled = DI::pConfig()->get(Session::getLocalUser(), 'pumpio', 'post', false); - $def_enabled = DI::pConfig()->get(Session::getLocalUser(), 'pumpio', 'post_by_default', false); - $public_enabled = DI::pConfig()->get(Session::getLocalUser(), 'pumpio', 'public', false); - $mirror_enabled = DI::pConfig()->get(Session::getLocalUser(), 'pumpio', 'mirror', false); + $import_enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pumpio', 'import', false); + $enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pumpio', 'post', false); + $def_enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pumpio', 'post_by_default', false); + $public_enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pumpio', 'public', false); + $mirror_enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pumpio', 'mirror', false); $submit = ['pumpio-submit' => DI::l10n()->t('Save Settings')]; if ($oauth_token && $oauth_token_secret) { @@ -280,19 +279,19 @@ function pumpio_settings(App $a, array &$data) function pumpio_settings_post(App $a, array &$b) { if (!empty($_POST['pumpio_delete'])) { - DI::pConfig()->set(Session::getLocalUser(), 'pumpio', 'consumer_key' , ''); - DI::pConfig()->set(Session::getLocalUser(), 'pumpio', 'consumer_secret' , ''); - DI::pConfig()->set(Session::getLocalUser(), 'pumpio', 'oauth_token' , ''); - DI::pConfig()->set(Session::getLocalUser(), 'pumpio', 'oauth_token_secret', ''); - DI::pConfig()->set(Session::getLocalUser(), 'pumpio', 'post' , false); - DI::pConfig()->set(Session::getLocalUser(), 'pumpio', 'import' , false); - DI::pConfig()->set(Session::getLocalUser(), 'pumpio', 'host' , ''); - DI::pConfig()->set(Session::getLocalUser(), 'pumpio', 'user' , ''); - DI::pConfig()->set(Session::getLocalUser(), 'pumpio', 'public' , false); - DI::pConfig()->set(Session::getLocalUser(), 'pumpio', 'mirror' , false); - DI::pConfig()->set(Session::getLocalUser(), 'pumpio', 'post_by_default' , false); - DI::pConfig()->set(Session::getLocalUser(), 'pumpio', 'lastdate' , 0); - DI::pConfig()->set(Session::getLocalUser(), 'pumpio', 'last_id' , ''); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pumpio', 'consumer_key' , ''); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pumpio', 'consumer_secret' , ''); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pumpio', 'oauth_token' , ''); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pumpio', 'oauth_token_secret', ''); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pumpio', 'post' , false); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pumpio', 'import' , false); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pumpio', 'host' , ''); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pumpio', 'user' , ''); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pumpio', 'public' , false); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pumpio', 'mirror' , false); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pumpio', 'post_by_default' , false); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pumpio', 'lastdate' , 0); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pumpio', 'last_id' , ''); } elseif (!empty($_POST['pumpio-submit'])) { // filtering the username if it is filled wrong $user = $_POST['pumpio_user']; @@ -309,16 +308,16 @@ function pumpio_settings_post(App $a, array &$b) $host = trim($host); $host = str_replace(['https://', 'http://'], ['', ''], $host); - DI::pConfig()->set(Session::getLocalUser(), 'pumpio', 'post' , $_POST['pumpio'] ?? false); - DI::pConfig()->set(Session::getLocalUser(), 'pumpio', 'import' , $_POST['pumpio_import'] ?? false); - DI::pConfig()->set(Session::getLocalUser(), 'pumpio', 'host' , $host); - DI::pConfig()->set(Session::getLocalUser(), 'pumpio', 'user' , $user); - DI::pConfig()->set(Session::getLocalUser(), 'pumpio', 'public' , $_POST['pumpio_public'] ?? false); - DI::pConfig()->set(Session::getLocalUser(), 'pumpio', 'mirror' , $_POST['pumpio_mirror'] ?? false); - DI::pConfig()->set(Session::getLocalUser(), 'pumpio', 'post_by_default', $_POST['pumpio_bydefault'] ?? false); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pumpio', 'post' , $_POST['pumpio'] ?? false); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pumpio', 'import' , $_POST['pumpio_import'] ?? false); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pumpio', 'host' , $host); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pumpio', 'user' , $user); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pumpio', 'public' , $_POST['pumpio_public'] ?? false); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pumpio', 'mirror' , $_POST['pumpio_mirror'] ?? false); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pumpio', 'post_by_default', $_POST['pumpio_bydefault'] ?? false); if (!empty($_POST['pumpio_mirror'])) { - DI::pConfig()->delete(Session::getLocalUser(), 'pumpio', 'lastdate'); + DI::pConfig()->delete(DI::userSession()->getLocalUserId(), 'pumpio', 'lastdate'); } } } @@ -366,15 +365,15 @@ function pumpio_hook_fork(App $a, array &$b) function pumpio_post_local(App $a, array &$b) { - if (!Session::getLocalUser() || (Session::getLocalUser() != $b['uid'])) { + if (!DI::userSession()->getLocalUserId() || (DI::userSession()->getLocalUserId() != $b['uid'])) { return; } - $pumpio_post = intval(DI::pConfig()->get(Session::getLocalUser(), 'pumpio', 'post')); + $pumpio_post = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pumpio', 'post')); $pumpio_enable = (($pumpio_post && !empty($_REQUEST['pumpio_enable'])) ? intval($_REQUEST['pumpio_enable']) : 0); - if ($b['api_source'] && intval(DI::pConfig()->get(Session::getLocalUser(), 'pumpio', 'post_by_default'))) { + if ($b['api_source'] && intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pumpio', 'post_by_default'))) { $pumpio_enable = 1; } diff --git a/qcomment/qcomment.php b/qcomment/qcomment.php index 496b0a06..d4d88e8e 100644 --- a/qcomment/qcomment.php +++ b/qcomment/qcomment.php @@ -21,7 +21,6 @@ use Friendica\App; use Friendica\Core\Hook; use Friendica\Core\Renderer; -use Friendica\Core\Session; use Friendica\DI; use Friendica\Util\XML; @@ -39,11 +38,11 @@ function qcomment_footer(App $a, string &$body) function qcomment_addon_settings(App &$a, array &$data) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } - $words = DI::pConfig()->get(Session::getLocalUser(), 'qcomment', 'words', DI::l10n()->t(':-)') . "\n" . DI::l10n()->t(':-(') . "\n" . DI::l10n()->t('lol')); + $words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'qcomment', 'words', DI::l10n()->t(':-)') . "\n" . DI::l10n()->t(':-(') . "\n" . DI::l10n()->t('lol')); $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/qcomment/'); $html = Renderer::replaceMacros($t, [ @@ -60,11 +59,11 @@ function qcomment_addon_settings(App &$a, array &$data) function qcomment_addon_settings_post(App $a, array &$b) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } if (isset($_POST['qcomment-words'])) { - DI::pConfig()->set(Session::getLocalUser(), 'qcomment', 'words', XML::escape($_POST['qcomment-words'])); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'qcomment', 'words', XML::escape($_POST['qcomment-words'])); } } diff --git a/randplace/randplace.php b/randplace/randplace.php index 439068db..badc1c9e 100644 --- a/randplace/randplace.php +++ b/randplace/randplace.php @@ -23,7 +23,6 @@ use Friendica\App; use Friendica\Core\Hook; use Friendica\Core\Logger; use Friendica\Core\Renderer; -use Friendica\Core\Session; use Friendica\DI; function randplace_install() @@ -65,12 +64,12 @@ function randplace_post_hook(App $a, &$item) */ Logger::notice('randplace invoked'); - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { /* non-zero if this is a logged in user of this system */ return; } - if (Session::getLocalUser() != $item['uid']) { + if (DI::userSession()->getLocalUserId() != $item['uid']) { /* Does this person own the post? */ return; } @@ -82,7 +81,7 @@ function randplace_post_hook(App $a, &$item) /* Retrieve our personal config setting */ - $active = DI::pConfig()->get(Session::getLocalUser(), 'randplace', 'enable'); + $active = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'randplace', 'enable'); if (!$active) { return; @@ -123,12 +122,12 @@ function randplace_post_hook(App $a, &$item) */ function randplace_settings_post(App $a, $post) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } if ($_POST['randplace-submit']) { - DI::pConfig()->set(Session::getLocalUser(), 'randplace', 'enable', intval($_POST['randplace'])); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'randplace', 'enable', intval($_POST['randplace'])); } } @@ -139,11 +138,11 @@ function randplace_settings_post(App $a, $post) */ function randplace_settings(App &$a, array &$data) { - if(!Session::getLocalUser()) { + if(!DI::userSession()->getLocalUserId()) { return; } - $enabled = DI::pConfig()->get(Session::getLocalUser(),'randplace','enable'); + $enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(),'randplace','enable'); $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/randplace/'); $html = Renderer::replaceMacros($t, [ diff --git a/saml/saml.php b/saml/saml.php index d511d90e..52d36d99 100755 --- a/saml/saml.php +++ b/saml/saml.php @@ -11,7 +11,6 @@ use Friendica\Content\Text\BBCode; use Friendica\Core\Hook; use Friendica\Core\Logger; use Friendica\Core\Renderer; -use Friendica\Core\Session; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\User; @@ -118,7 +117,7 @@ function saml_sso_initiate(App $a, array &$b) $auth = new \OneLogin\Saml2\Auth(saml_settings()); $ssoBuiltUrl = $auth->login(null, [], false, false, true); - $_SESSION['AuthNRequestID'] = $auth->getLastRequestID(); + DI::session()->set('AuthNRequestID', $auth->getLastRequestID()); header('Pragma: no-cache'); header('Cache-Control: no-cache, must-revalidate'); header('Location: ' . $ssoBuiltUrl); @@ -130,12 +129,12 @@ function saml_sso_reply(App $a) $auth = new \OneLogin\Saml2\Auth(saml_settings()); $requestID = null; - if (isset($_SESSION) && isset($_SESSION['AuthNRequestID'])) { - $requestID = $_SESSION['AuthNRequestID']; + if (DI::session()->exists('AuthNRequestID')) { + $requestID = DI::session()->get('AuthNRequestID'); } $auth->processResponse($requestID); - unset($_SESSION['AuthNRequestID']); + DI::session()->remove('AuthNRequestID'); $errors = $auth->getErrors(); @@ -184,7 +183,7 @@ function saml_slo_initiate(App $a, array &$b) $auth = new \OneLogin\Saml2\Auth(saml_settings()); $sloBuiltUrl = $auth->logout(); - $_SESSION['LogoutRequestID'] = $auth->getLastRequestID(); + DI::session()->set('LogoutRequestID', $auth->getLastRequestID()); header('Pragma: no-cache'); header('Cache-Control: no-cache, must-revalidate'); header('Location: ' . $sloBuiltUrl); @@ -195,8 +194,8 @@ function saml_slo_reply() { $auth = new \OneLogin\Saml2\Auth(saml_settings()); - if (isset($_SESSION) && isset($_SESSION['LogoutRequestID'])) { - $requestID = $_SESSION['LogoutRequestID']; + if (DI::session()->exists('LogoutRequestID')) { + $requestID = DI::session()->get('LogoutRequestID'); } else { $requestID = null; } diff --git a/securemail/SecureTestEmail.php b/securemail/SecureTestEmail.php index 632336e7..b51bdde1 100644 --- a/securemail/SecureTestEmail.php +++ b/securemail/SecureTestEmail.php @@ -25,7 +25,6 @@ use Friendica\App; use Friendica\App\BaseURL; use Friendica\Core\Config\Capability\IManageConfigValues; use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues; -use Friendica\Core\Session; use Friendica\Model\User; use Friendica\Object\Email; @@ -48,16 +47,16 @@ class SecureTestEmail extends Email $sender_email = 'noreply@' . $hostname; } - $user = User::getById(Session::getLocalUser()); + $user = User::getById(DI::userSession()->getLocalUserId()); $subject = 'Friendica - Secure Mail - Test'; $message = 'This is a test message from your Friendica Secure Mail addon.'; // enable addon for test - $pConfig->set(Session::getLocalUser(), 'securemail', 'enable', 1); + $pConfig->set(DI::userSession()->getLocalUserId(), 'securemail', 'enable', 1); parent::__construct($sitename, $sender_email, $sender_email, $user['email'], $subject, "
{$message}
", $message, - [], Session::getLocalUser()); + [], DI::userSession()->getLocalUserId()); } } diff --git a/securemail/securemail.php b/securemail/securemail.php index 777e0343..470db0e4 100644 --- a/securemail/securemail.php +++ b/securemail/securemail.php @@ -11,7 +11,6 @@ use Friendica\App; use Friendica\Core\Hook; use Friendica\Core\Logger; use Friendica\Core\Renderer; -use Friendica\Core\Session; use Friendica\DI; use Friendica\Object\EMail\IEmail; @@ -39,12 +38,12 @@ function securemail_install() */ function securemail_settings(App &$a, array &$data) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } - $enabled = intval(DI::pConfig()->get(Session::getLocalUser(), 'securemail', 'enable')); - $publickey = DI::pConfig()->get(Session::getLocalUser(), 'securemail', 'pkey'); + $enabled = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'securemail', 'enable')); + $publickey = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'securemail', 'pkey'); $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/securemail/'); $html = Renderer::replaceMacros($t, [ @@ -75,20 +74,20 @@ function securemail_settings(App &$a, array &$data) */ function securemail_settings_post(App &$a, array &$b) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } if (!empty($_POST['securemail-submit']) || !empty($_POST['securemail-test'])) { - DI::pConfig()->set(Session::getLocalUser(), 'securemail', 'pkey', trim($_POST['securemail-pkey'])); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'securemail', 'pkey', trim($_POST['securemail-pkey'])); $enable = (!empty($_POST['securemail-enable']) ? 1 : 0); - DI::pConfig()->set(Session::getLocalUser(), 'securemail', 'enable', $enable); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'securemail', 'enable', $enable); if (!empty($_POST['securemail-test'])) { $res = DI::emailer()->send(new SecureTestEmail(DI::app(), DI::config(), DI::pConfig(), DI::baseUrl())); // revert to saved value - DI::pConfig()->set(Session::getLocalUser(), 'securemail', 'enable', $enable); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'securemail', 'enable', $enable); if ($res) { DI::sysmsg()->addInfo(DI::l10n()->t('Test email sent')); diff --git a/showmore/showmore.php b/showmore/showmore.php index 52e9771b..aed11520 100644 --- a/showmore/showmore.php +++ b/showmore/showmore.php @@ -11,7 +11,6 @@ use Friendica\App; use Friendica\Core\Hook; use Friendica\Core\Renderer; -use Friendica\Core\Session; use Friendica\DI; use Friendica\Util\Strings; @@ -24,14 +23,14 @@ function showmore_install() function showmore_addon_settings(App &$a, array &$data) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } DI::page()->registerStylesheet(__DIR__ . '/showmore.css', 'all'); - $enabled = !DI::pConfig()->get(Session::getLocalUser(), 'showmore', 'disable'); - $chars = DI::pConfig()->get(Session::getLocalUser(), 'showmore', 'chars', 1100); + $enabled = !DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'showmore', 'disable'); + $chars = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'showmore', 'chars', 1100); $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/showmore/'); $html = Renderer::replaceMacros($t, [ @@ -48,15 +47,15 @@ function showmore_addon_settings(App &$a, array &$data) function showmore_addon_settings_post(App $a, array &$b) { - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { return; } if (!empty($_POST['showmore-submit'])) { - DI::pConfig()->set(Session::getLocalUser(), 'showmore', 'chars', trim($_POST['showmore-chars'])); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'showmore', 'chars', trim($_POST['showmore-chars'])); $enable = (!empty($_POST['showmore-enable']) ? intval($_POST['showmore-enable']) : 0); $disable = 1-$enable; - DI::pConfig()->set(Session::getLocalUser(), 'showmore', 'disable', $disable); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'showmore', 'disable', $disable); } } @@ -101,11 +100,11 @@ function showmore_prepare_body(App $a, &$hook_data) return; } - if (DI::pConfig()->get(Session::getLocalUser(), 'showmore', 'disable')) { + if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'showmore', 'disable')) { return; } - $chars = (int) DI::pConfig()->get(Session::getLocalUser(), 'showmore', 'chars', 1100); + $chars = (int) DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'showmore', 'chars', 1100); if (get_body_length($hook_data['html']) > $chars) { $found = true; diff --git a/showmore_dyn/showmore_dyn.php b/showmore_dyn/showmore_dyn.php index b5dda5d0..5fc07722 100644 --- a/showmore_dyn/showmore_dyn.php +++ b/showmore_dyn/showmore_dyn.php @@ -12,7 +12,6 @@ use Friendica\Core\Hook; use Friendica\Core\L10n; use Friendica\Core\Logger; use Friendica\Core\Renderer; -use Friendica\Core\Session; use Friendica\Database\DBA; use Friendica\DI; @@ -37,23 +36,23 @@ function showmore_dyn_footer(App $a, string &$body) function showmore_dyn_settings_post() { - if(!Session::getLocalUser()) { + if(!DI::userSession()->getLocalUserId()) { return; } if (isset($_POST['showmore_dyn-submit'])) { - DI::pConfig()->set(Session::getLocalUser(), 'showmore_dyn', 'limitHeight', $_POST['limitHeight'] ?? 0); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'showmore_dyn', 'limitHeight', $_POST['limitHeight'] ?? 0); } } function showmore_dyn_settings(App &$a, array &$data) { - if(!Session::getLocalUser()) { + if(!DI::userSession()->getLocalUserId()) { return; } - $limitHeight = DI::pConfig()->get(Session::getLocalUser(), 'showmore_dyn', 'limitHeight', 250); - DI::pConfig()->set(Session::getLocalUser(), 'showmore_dyn', 'limitHeight', $limitHeight); + $limitHeight = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'showmore_dyn', 'limitHeight', 250); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'showmore_dyn', 'limitHeight', $limitHeight); $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/showmore_dyn/'); $html = Renderer::replaceMacros($t, [ @@ -69,7 +68,7 @@ function showmore_dyn_settings(App &$a, array &$data) function showmore_dyn_script() { - $limitHeight = intval(DI::pConfig()->get(Session::getLocalUser(), 'showmore_dyn', 'limitHeight', 250)); + $limitHeight = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'showmore_dyn', 'limitHeight', 250)); $showmore_dyn_showmore_linktext = DI::l10n()->t('Show more...'); DI::page()['htmlhead'] .= <<