From c81e81dc8d96ffc42548fdcd2ca6887a1a847837 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 9 Aug 2021 20:33:46 +0000 Subject: [PATCH] "getUserId" is now "getLoggedInUserId" --- boot.php | 2 +- include/conversation.php | 2 +- mod/events.php | 2 +- mod/follow.php | 2 +- mod/ostatus_subscribe.php | 2 +- mod/photos.php | 6 +++--- mod/removeme.php | 4 ++-- mod/repair_ostatus.php | 2 +- mod/settings.php | 6 +++--- src/App.php | 2 +- src/BaseModule.php | 4 ++-- src/Content/Nav.php | 2 +- src/Module/Contact/Poke.php | 2 +- src/Module/Conversation/Network.php | 4 ++-- src/Module/Delegation.php | 2 +- src/Module/Item/Compose.php | 2 +- src/Module/Profile/Status.php | 2 +- src/Module/Security/TwoFactor/Recovery.php | 2 +- src/Module/Security/TwoFactor/Verify.php | 2 +- src/Module/Settings/Profile/Index.php | 4 ++-- src/Object/EMail/ItemCCEMail.php | 2 +- src/Object/Post.php | 2 +- view/theme/frio/theme.php | 2 +- 23 files changed, 31 insertions(+), 31 deletions(-) diff --git a/boot.php b/boot.php index c71c16b354..7ee023b68a 100644 --- a/boot.php +++ b/boot.php @@ -379,7 +379,7 @@ function is_site_admin() $adminlist = explode(',', str_replace(' ', '', $admin_email)); - return local_user() && $admin_email && DBA::exists('user', ['uid' => $a->getUserId(), 'email' => $adminlist]); + return local_user() && $admin_email && DBA::exists('user', ['uid' => $a->getLoggedInUserId(), 'email' => $adminlist]); } /** diff --git a/include/conversation.php b/include/conversation.php index b545445e4b..684532345f 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1071,7 +1071,7 @@ function status_editor(App $a, array $x = [], $notes_cid = 0, $popup = false) DI::profiler()->startRecording('rendering'); $o = ''; - $user = User::getById($a->getUserId(), ['uid', 'nickname', 'allow_location', 'default-location']); + $user = User::getById($a->getLoggedInUserId(), ['uid', 'nickname', 'allow_location', 'default-location']); $x['allow_location'] = $x['allow_location'] ?? $user['allow_location']; $x['default_location'] = $x['default_location'] ?? $user['default-location']; diff --git a/mod/events.php b/mod/events.php index e7c3ed36f1..ebb7d3f114 100644 --- a/mod/events.php +++ b/mod/events.php @@ -513,7 +513,7 @@ function events_content(App $a) $fminute = !empty($orig_event) ? DateTimeFormat::convert($fdt, $tz, 'UTC', 'i') : '00'; if (!$cid && in_array($mode, ['new', 'copy'])) { - $acl = ACL::getFullSelectorHTML(DI::page(), $a->getUserId(), false, ACL::getDefaultUserPermissions($orig_event)); + $acl = ACL::getFullSelectorHTML(DI::page(), $a->getLoggedInUserId(), false, ACL::getDefaultUserPermissions($orig_event)); } else { $acl = ''; } diff --git a/mod/follow.php b/mod/follow.php index d7b01e6192..075e58d091 100644 --- a/mod/follow.php +++ b/mod/follow.php @@ -175,7 +175,7 @@ function follow_process(App $a, string $url) { $return_path = 'follow?url=' . urlencode($url); - $result = Contact::createFromProbeForUser($a->getUserId(), $url); + $result = Contact::createFromProbeForUser($a->getLoggedInUserId(), $url); if ($result['success'] == false) { // Possibly it is a remote item and not an account diff --git a/mod/ostatus_subscribe.php b/mod/ostatus_subscribe.php index 9de27f52ed..57f8b9a738 100644 --- a/mod/ostatus_subscribe.php +++ b/mod/ostatus_subscribe.php @@ -111,7 +111,7 @@ function ostatus_subscribe_content(App $a) $probed = Contact::getByURL($url); if (in_array($probed['network'], Protocol::FEDERATED)) { - $result = Contact::createFromProbeForUser($a->getUserId(), $probed['url']); + $result = Contact::createFromProbeForUser($a->getLoggedInUserId(), $probed['url']); if ($result['success']) { $o .= ' - ' . DI::l10n()->t('success'); } else { diff --git a/mod/photos.php b/mod/photos.php index 1379ed12e6..4512921074 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -948,7 +948,7 @@ function photos_content(App $a) $tpl = Renderer::getMarkupTemplate('photos_upload.tpl'); - $aclselect_e = ($visitor ? '' : ACL::getFullSelectorHTML(DI::page(), $a->getUserId())); + $aclselect_e = ($visitor ? '' : ACL::getFullSelectorHTML(DI::page(), $a->getLoggedInUserId())); $o .= Renderer::replaceMacros($tpl,[ '$pagename' => DI::l10n()->t('Upload Photos'), @@ -961,7 +961,7 @@ function photos_content(App $a) '$albumselect' => $albumselect, '$permissions' => DI::l10n()->t('Permissions'), '$aclselect' => $aclselect_e, - '$lockstate' => ACL::getLockstateForUserId($a->getUserId()) ? 'lock' : 'unlock', + '$lockstate' => ACL::getLockstateForUserId($a->getLoggedInUserId()) ? 'lock' : 'unlock', '$alt_uploader' => $ret['addon_text'], '$default_upload_box' => ($ret['default_upload'] ? $default_upload_box : ''), '$default_upload_submit' => ($ret['default_upload'] ? $default_upload_submit : ''), @@ -1307,7 +1307,7 @@ function photos_content(App $a) $album_e = $ph[0]['album']; $caption_e = $ph[0]['desc']; - $aclselect_e = ACL::getFullSelectorHTML(DI::page(), $a->getUserId(), false, ACL::getDefaultUserPermissions($ph[0])); + $aclselect_e = ACL::getFullSelectorHTML(DI::page(), $a->getLoggedInUserId(), false, ACL::getDefaultUserPermissions($ph[0])); $edit = Renderer::replaceMacros($edit_tpl, [ '$id' => $ph[0]['id'], diff --git a/mod/removeme.php b/mod/removeme.php index 5df3360655..bdc49ab745 100644 --- a/mod/removeme.php +++ b/mod/removeme.php @@ -69,8 +69,8 @@ function removeme_post(App $a) DI::emailer()->send($email); } - if (User::getIdFromPasswordAuthentication($a->getUserId(), trim($_POST['qxz_password']))) { - User::remove($a->getUserId()); + if (User::getIdFromPasswordAuthentication($a->getLoggedInUserId(), trim($_POST['qxz_password']))) { + User::remove($a->getLoggedInUserId()); unset($_SESSION['authenticated']); unset($_SESSION['uid']); diff --git a/mod/repair_ostatus.php b/mod/repair_ostatus.php index e201e60a4a..bc6b177f95 100644 --- a/mod/repair_ostatus.php +++ b/mod/repair_ostatus.php @@ -70,7 +70,7 @@ function repair_ostatus_content(App $a) { $o .= "

".DI::l10n()->t("Keep this window open until done.")."

"; - Contact::createFromProbeForUser($a->getUserId(), $r[0]["url"]); + Contact::createFromProbeForUser($a->getLoggedInUserId(), $r[0]["url"]); DI::page()['htmlhead'] = ''; diff --git a/mod/settings.php b/mod/settings.php index 378e25ed9f..ce556b8bf1 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -69,7 +69,7 @@ function settings_post(App $a) return; } - $user = User::getById($a->getUserId()); + $user = User::getById($a->getLoggedInUserId()); if ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] == 'connectors')) { BaseModule::checkFormSecurityTokenRedirectOnError('/settings/connectors', 'settings_connectors'); @@ -590,7 +590,7 @@ function settings_content(App $a) return; } - $user = User::getById($a->getUserId()); + $user = User::getById($a->getLoggedInUserId()); $username = $user['username']; $email = $user['email']; @@ -748,7 +748,7 @@ function settings_content(App $a) '$cntunkmail' => ['cntunkmail', DI::l10n()->t('Maximum private messages per day from unknown people:'), $cntunkmail , DI::l10n()->t("\x28to prevent spam abuse\x29")], '$group_select' => Group::displayGroupSelection(local_user(), $user['def_gid']), '$permissions' => DI::l10n()->t('Default Post Permissions'), - '$aclselect' => ACL::getFullSelectorHTML(DI::page(), $a->getUserId()), + '$aclselect' => ACL::getFullSelectorHTML(DI::page(), $a->getLoggedInUserId()), '$expire' => [ 'label' => DI::l10n()->t('Expiration settings'), diff --git a/src/App.php b/src/App.php index 3a952c7a33..69167e98f1 100644 --- a/src/App.php +++ b/src/App.php @@ -157,7 +157,7 @@ class App * Fetch the user id * @return int */ - public function getUserId() + public function getLoggedInUserId() { return $this->user_id; } diff --git a/src/BaseModule.php b/src/BaseModule.php index b812370fdf..d7ca5798de 100644 --- a/src/BaseModule.php +++ b/src/BaseModule.php @@ -136,7 +136,7 @@ abstract class BaseModule */ public static function getFormSecurityToken($typename = '') { - $user = User::getById(DI::app()->getUserId(), ['guid', 'prvkey']); + $user = User::getById(DI::app()->getLoggedInUserId(), ['guid', 'prvkey']); $timestamp = time(); $sec_hash = hash('whirlpool', ($user['guid'] ?? '') . ($user['prvkey'] ?? '') . session_id() . $timestamp . $typename); @@ -163,7 +163,7 @@ abstract class BaseModule $max_livetime = 10800; // 3 hours - $user = User::getById(DI::app()->getUserId(), ['guid', 'prvkey']); + $user = User::getById(DI::app()->getLoggedInUserId(), ['guid', 'prvkey']); $x = explode('.', $hash); if (time() > (intval($x[0]) + $max_livetime)) { diff --git a/src/Content/Nav.php b/src/Content/Nav.php index 56049fa16e..b9f61dacb2 100644 --- a/src/Content/Nav.php +++ b/src/Content/Nav.php @@ -195,7 +195,7 @@ class Nav $nav['usermenu'][] = ['notes/', DI::l10n()->t('Personal notes'), '', DI::l10n()->t('Your personal notes')]; // user info - $contact = DBA::selectFirst('contact', ['id', 'url', 'avatar', 'micro', 'name', 'nick', 'baseurl', 'updated'], ['uid' => $a->getUserId(), 'self' => true]); + $contact = DBA::selectFirst('contact', ['id', 'url', 'avatar', 'micro', 'name', 'nick', 'baseurl', 'updated'], ['uid' => $a->getLoggedInUserId(), 'self' => true]); $userinfo = [ 'icon' => Contact::getMicro($contact), 'name' => $contact['name'], diff --git a/src/Module/Contact/Poke.php b/src/Module/Contact/Poke.php index 01d3ec1385..d9dd7e27aa 100644 --- a/src/Module/Contact/Poke.php +++ b/src/Module/Contact/Poke.php @@ -55,7 +55,7 @@ class Poke extends BaseModule $private = !empty($_POST['private']) ? Model\Item::PRIVATE : Model\Item::PUBLIC; - $user = Model\User::getById($a->getUserId()); + $user = Model\User::getById($a->getLoggedInUserId()); $allow_cid = ($private ? '<' . $contact['id']. '>' : $user['allow_cid']); $allow_gid = ($private ? '' : $user['allow_gid']); $deny_cid = ($private ? '' : $user['deny_cid']); diff --git a/src/Module/Conversation/Network.php b/src/Module/Conversation/Network.php index 1e97894cb8..d9f34e3e83 100644 --- a/src/Module/Conversation/Network.php +++ b/src/Module/Conversation/Network.php @@ -139,8 +139,8 @@ class Network extends BaseModule } $x = [ - 'lockstate' => self::$groupId || self::$forumContactId || self::$network || ACL::getLockstateForUserId($a->getUserId()) ? 'lock' : 'unlock', - 'acl' => ACL::getFullSelectorHTML(DI::page(), $a->getUserId(), true, $default_permissions), + 'lockstate' => self::$groupId || self::$forumContactId || self::$network || ACL::getLockstateForUserId($a->getLoggedInUserId()) ? 'lock' : 'unlock', + 'acl' => ACL::getFullSelectorHTML(DI::page(), $a->getLoggedInUserId(), true, $default_permissions), 'bang' => ((self::$groupId || self::$forumContactId || self::$network) ? '!' : ''), 'content' => $content, ]; diff --git a/src/Module/Delegation.php b/src/Module/Delegation.php index cd3f50f59f..45f7fc57d2 100644 --- a/src/Module/Delegation.php +++ b/src/Module/Delegation.php @@ -45,7 +45,7 @@ class Delegation extends BaseModule } $uid = local_user(); - $orig_record = User::getById(DI::app()->getUserId()); + $orig_record = User::getById(DI::app()->getLoggedInUserId()); if (Session::get('submanage')) { $user = User::getById(Session::get('submanage')); diff --git a/src/Module/Item/Compose.php b/src/Module/Item/Compose.php index b7e6bce7de..29fdbea746 100644 --- a/src/Module/Item/Compose.php +++ b/src/Module/Item/Compose.php @@ -186,7 +186,7 @@ class Compose extends BaseModule '$jotplugins' => $jotplugins, '$rand_num' => Crypto::randomDigits(12), - '$acl_selector' => ACL::getFullSelectorHTML(DI::page(), $a->getUserId(), $doesFederate, [ + '$acl_selector' => ACL::getFullSelectorHTML(DI::page(), $a->getLoggedInUserId(), $doesFederate, [ 'allow_cid' => $contact_allow_list, 'allow_gid' => $group_allow_list, 'deny_cid' => $contact_deny_list, diff --git a/src/Module/Profile/Status.php b/src/Module/Profile/Status.php index b60fb2cdb6..c6a9e272a9 100644 --- a/src/Module/Profile/Status.php +++ b/src/Module/Profile/Status.php @@ -127,7 +127,7 @@ class Status extends BaseProfile 'allow_location' => ($is_owner || $commvisitor) && $profile['allow_location'], 'default_location' => $is_owner ? $profile['default-location'] : '', 'nickname' => $profile['nickname'], - 'acl' => $is_owner ? ACL::getFullSelectorHTML(DI::page(), $a->getUserId(), true) : '', + 'acl' => $is_owner ? ACL::getFullSelectorHTML(DI::page(), $a->getLoggedInUserId(), true) : '', 'visitor' => $is_owner || $commvisitor ? 'block' : 'none', 'profile_uid' => $profile['uid'], ]; diff --git a/src/Module/Security/TwoFactor/Recovery.php b/src/Module/Security/TwoFactor/Recovery.php index 9faab40705..d93146cb6c 100644 --- a/src/Module/Security/TwoFactor/Recovery.php +++ b/src/Module/Security/TwoFactor/Recovery.php @@ -60,7 +60,7 @@ class Recovery extends BaseModule Session::set('2fa', true); info(DI::l10n()->t('Remaining recovery codes: %d', RecoveryCode::countValidForUser(local_user()))); - DI::auth()->setForUser($a, User::getById($a->getUserId()), true, true); + DI::auth()->setForUser($a, User::getById($a->getLoggedInUserId()), true, true); } else { notice(DI::l10n()->t('Invalid code, please retry.')); } diff --git a/src/Module/Security/TwoFactor/Verify.php b/src/Module/Security/TwoFactor/Verify.php index bb3e444a93..22c757b82d 100644 --- a/src/Module/Security/TwoFactor/Verify.php +++ b/src/Module/Security/TwoFactor/Verify.php @@ -71,7 +71,7 @@ class Verify extends BaseModule } // Resume normal login workflow - DI::auth()->setForUser($a, User::getById($a->getUserId()), true, true); + DI::auth()->setForUser($a, User::getById($a->getLoggedInUserId()), true, true); } else { self::$errors[] = DI::l10n()->t('Invalid code, please retry.'); } diff --git a/src/Module/Settings/Profile/Index.php b/src/Module/Settings/Profile/Index.php index adf6fff974..b5f7ef3500 100644 --- a/src/Module/Settings/Profile/Index.php +++ b/src/Module/Settings/Profile/Index.php @@ -171,7 +171,7 @@ class Index extends BaseSettings 'value' => ['profile_field[' . $profileField->id . '][value]', DI::l10n()->t('Value:'), $profileField->value], 'acl' => ACL::getFullSelectorHTML( DI::page(), - $a->getUserId(), + $a->getLoggedInUserId(), false, $defaultPermissions, ['network' => Protocol::DFRN], @@ -191,7 +191,7 @@ class Index extends BaseSettings 'value' => ['profile_field[new][value]', DI::l10n()->t('Value:')], 'acl' => ACL::getFullSelectorHTML( DI::page(), - $a->getUserId(), + $a->getLoggedInUserId(), false, ['allow_cid' => []], ['network' => Protocol::DFRN], diff --git a/src/Object/EMail/ItemCCEMail.php b/src/Object/EMail/ItemCCEMail.php index 1fa2e94d77..199a6bad1a 100644 --- a/src/Object/EMail/ItemCCEMail.php +++ b/src/Object/EMail/ItemCCEMail.php @@ -37,7 +37,7 @@ class ItemCCEMail extends Email { public function __construct(App $a, L10n $l10n, BaseURL $baseUrl, array $item, string $toAddress, string $authorThumb) { - $user = User::getById($a->getUserId()); + $user = User::getById($a->getLoggedInUserId()); $disclaimer = '
' . $l10n->t('This message was sent to you by %s, a member of the Friendica social network.', $user['username']) . '
'; diff --git a/src/Object/Post.php b/src/Object/Post.php index 8ffe4bbafd..dcb7ad208b 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -870,7 +870,7 @@ class Post return ''; } - $owner = User::getOwnerDataById($a->getUserId()); + $owner = User::getOwnerDataById($a->getLoggedInUserId()); if (!Feature::isEnabled(local_user(), 'explicit_mentions')) { return ''; diff --git a/view/theme/frio/theme.php b/view/theme/frio/theme.php index 446aa6acdc..5304d3fd46 100644 --- a/view/theme/frio/theme.php +++ b/view/theme/frio/theme.php @@ -202,7 +202,7 @@ function frio_remote_nav(App $a, array &$nav_info) // this isn't optimal because the contact query will be done now twice $fields = ['id', 'url', 'avatar', 'micro', 'name', 'nick', 'baseurl', 'updated']; if ($a->isLoggedIn()) { - $remoteUser = Contact::selectFirst($fields, ['uid' => $a->getUserId(), 'self' => true]); + $remoteUser = Contact::selectFirst($fields, ['uid' => $a->getLoggedInUserId(), 'self' => true]); } elseif (!local_user() && remote_user()) { $remoteUser = Contact::getById(remote_user(), $fields); $nav_info['nav']['remote'] = DI::l10n()->t('Guest');