From 8e6973b774efeff5dd381e8984c22171c6a14c31 Mon Sep 17 00:00:00 2001 From: nupplaPhil Date: Mon, 16 Dec 2019 00:28:31 +0100 Subject: [PATCH] Refactor deprecated App::internalRedirect() to DI::baseUrl()->redirect() --- include/items.php | 17 +++++----- mod/api.php | 3 +- mod/cal.php | 7 ++--- mod/dfrn_confirm.php | 5 +-- mod/dfrn_poll.php | 18 +++++------ mod/dfrn_request.php | 15 ++++----- mod/events.php | 11 ++++--- mod/follow.php | 15 ++++----- mod/item.php | 16 +++++----- mod/lostpass.php | 7 +++-- mod/message.php | 13 ++++---- mod/network.php | 6 ++-- mod/notifications.php | 7 ++--- mod/ostatus_subscribe.php | 3 +- mod/photos.php | 24 +++++++------- mod/profile_photo.php | 7 +++-- mod/profiles.php | 15 ++++----- mod/redir.php | 5 +-- mod/regmod.php | 5 +-- mod/removeme.php | 5 +-- mod/repair_ostatus.php | 3 +- mod/settings.php | 12 +++---- mod/suggest.php | 3 +- mod/tagrm.php | 17 +++++----- mod/uimport.php | 2 +- mod/unfollow.php | 19 ++++++------ mod/videos.php | 7 +++-- mod/wallmessage.php | 3 +- src/App.php | 31 +++++++------------ src/App/Authentication.php | 2 +- src/App/Module.php | 6 ++-- src/BaseModule.php | 2 +- src/Core/UserImport.php | 6 ++-- src/Model/Contact.php | 2 +- src/Module/Admin/Addons/Details.php | 10 +++--- src/Module/Admin/Addons/Index.php | 2 +- src/Module/Admin/Blocklist/Contact.php | 2 +- src/Module/Admin/Blocklist/Server.php | 2 +- src/Module/Admin/DBSync.php | 2 +- src/Module/Admin/Features.php | 2 +- src/Module/Admin/Item/Delete.php | 2 +- src/Module/Admin/Logs/Settings.php | 2 +- src/Module/Admin/Site.php | 10 +++--- src/Module/Admin/Themes/Details.php | 6 ++-- src/Module/Admin/Themes/Embed.php | 2 +- src/Module/Admin/Themes/Index.php | 2 +- src/Module/Admin/Tos.php | 2 +- src/Module/Admin/Users.php | 6 ++-- src/Module/Apps.php | 2 +- src/Module/BaseAdminModule.php | 2 +- src/Module/Contact.php | 27 ++++++++-------- src/Module/Debug/Feed.php | 2 +- src/Module/Delegation.php | 2 +- src/Module/Filer/RemoveTag.php | 2 +- src/Module/Filer/SaveTag.php | 2 +- src/Module/FollowConfirm.php | 4 +-- src/Module/Group.php | 16 +++++----- src/Module/Home.php | 4 +-- src/Module/Item/Ignore.php | 2 +- src/Module/Like.php | 2 +- src/Module/Notifications/Notify.php | 4 +-- src/Module/Objects.php | 2 +- src/Module/Pinned.php | 2 +- src/Module/RandomProfile.php | 2 +- src/Module/Register.php | 12 +++---- src/Module/Search/Saved.php | 2 +- src/Module/Security/Login.php | 4 +-- src/Module/Security/Logout.php | 2 +- src/Module/Security/TwoFactor/Recovery.php | 4 +-- src/Module/Security/TwoFactor/Verify.php | 4 +-- src/Module/Settings/Delegation.php | 8 ++--- src/Module/Settings/TwoFactor/AppSpecific.php | 12 +++---- src/Module/Settings/TwoFactor/Index.php | 10 +++--- src/Module/Settings/TwoFactor/Recovery.php | 6 ++-- src/Module/Settings/TwoFactor/Verify.php | 6 ++-- src/Module/Starred.php | 2 +- src/Module/Tos.php | 2 +- 77 files changed, 263 insertions(+), 259 deletions(-) diff --git a/include/items.php b/include/items.php index 5ae8558d81..e72b97c1d2 100644 --- a/include/items.php +++ b/include/items.php @@ -12,6 +12,7 @@ use Friendica\Core\Renderer; use Friendica\Core\System; use Friendica\Core\Session; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Model\Item; use Friendica\Protocol\DFRN; use Friendica\Protocol\Feed; @@ -339,7 +340,7 @@ function drop_items(array $items) function drop_item($id, $return = '') { - $a = Friendica\DI::app(); + $a = DI::app(); // locate item to be deleted @@ -348,7 +349,7 @@ function drop_item($id, $return = '') if (!DBA::isResult($item)) { notice(L10n::t('Item not found.') . EOL); - $a->internalRedirect('network'); + DI::baseUrl()->redirect('network'); } if ($item['deleted']) { @@ -389,7 +390,7 @@ function drop_item($id, $return = '') } // Now check how the user responded to the confirmation query if (!empty($_REQUEST['canceled'])) { - $a->internalRedirect('display/' . $item['guid']); + DI::baseUrl()->redirect('display/' . $item['guid']); } $is_comment = ($item['gravity'] == GRAVITY_COMMENT) ? true : false; @@ -411,28 +412,28 @@ function drop_item($id, $return = '') if ($is_comment) { // Return to parent guid if (!empty($parentitem)) { - $a->internalRedirect('display/' . $parentitem['guid']); + DI::baseUrl()->redirect('display/' . $parentitem['guid']); //NOTREACHED } // In case something goes wrong else { - $a->internalRedirect('network'); + DI::baseUrl()->redirect('network'); //NOTREACHED } } else { // if unknown location or deleting top level post called from display if (empty($return_url) || strpos($return_url, 'display') !== false) { - $a->internalRedirect('network'); + DI::baseUrl()->redirect('network'); //NOTREACHED } else { - $a->internalRedirect($return_url); + DI::baseUrl()->redirect($return_url); //NOTREACHED } } } else { notice(L10n::t('Permission denied.') . EOL); - $a->internalRedirect('display/' . $item['guid']); + DI::baseUrl()->redirect('display/' . $item['guid']); //NOTREACHED } } diff --git a/mod/api.php b/mod/api.php index 929832480a..8ef9f5ec47 100644 --- a/mod/api.php +++ b/mod/api.php @@ -8,6 +8,7 @@ use Friendica\Core\Config; use Friendica\Core\L10n; use Friendica\Core\Renderer; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Module\Security\Login; require_once __DIR__ . '/../include/api.php'; @@ -76,7 +77,7 @@ function api_content(App $a) if (strstr($consumer->callback_url, $glue)) { $glue = "?"; } - $a->internalRedirect($consumer->callback_url . $glue . 'oauth_token=' . OAuthUtil::urlencode_rfc3986($params['oauth_token']) . '&oauth_verifier=' . OAuthUtil::urlencode_rfc3986($verifier)); + DI::baseUrl()->redirect($consumer->callback_url . $glue . 'oauth_token=' . OAuthUtil::urlencode_rfc3986($params['oauth_token']) . '&oauth_verifier=' . OAuthUtil::urlencode_rfc3986($verifier)); exit(); } diff --git a/mod/cal.php b/mod/cal.php index 51d17a10a4..5a4f0a9c51 100644 --- a/mod/cal.php +++ b/mod/cal.php @@ -16,12 +16,11 @@ use Friendica\Core\Renderer; use Friendica\Core\System; use Friendica\Core\Session; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\Event; -use Friendica\Model\Group; use Friendica\Model\Item; use Friendica\Model\Profile; -use Friendica\Protocol\DFRN; use Friendica\Util\DateTimeFormat; use Friendica\Util\Temporal; @@ -289,7 +288,7 @@ function cal_content(App $a) // Respect the export feature setting for all other /cal pages if it's not the own profile if ((local_user() !== $owner_uid) && !Feature::isEnabled($owner_uid, "export_calendar")) { notice(L10n::t('Permission denied.') . EOL); - $a->internalRedirect('cal/' . $nick); + DI::baseUrl()->redirect('cal/' . $nick); } // Get the export data by uid @@ -310,7 +309,7 @@ function cal_content(App $a) $return_path = "cal/" . $nick; } - $a->internalRedirect($return_path); + DI::baseUrl()->redirect($return_path); } // If nothing went wrong we can echo the export content diff --git a/mod/dfrn_confirm.php b/mod/dfrn_confirm.php index c92e5493a1..d9ba9dfac5 100644 --- a/mod/dfrn_confirm.php +++ b/mod/dfrn_confirm.php @@ -24,6 +24,7 @@ use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Core\System; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\Group; use Friendica\Model\User; @@ -331,7 +332,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) // Let's send our user to the contact editor in case they want to // do anything special with this new friend. if ($handsfree === null) { - $a->internalRedirect('contact/' . intval($contact_id)); + DI::baseUrl()->redirect('contact/' . intval($contact_id)); } else { return; } @@ -551,6 +552,6 @@ function dfrn_confirm_post(App $a, $handsfree = null) } // somebody arrived here by mistake or they are fishing. Send them to the homepage. - $a->internalRedirect(); + DI::baseUrl()->redirect(); // NOTREACHED } diff --git a/mod/dfrn_poll.php b/mod/dfrn_poll.php index 7ebca9effa..002ddf924b 100644 --- a/mod/dfrn_poll.php +++ b/mod/dfrn_poll.php @@ -91,7 +91,7 @@ function dfrn_poll_init(App $a) $my_id = '0:' . $dfrn_id; break; default: - $a->internalRedirect(); + DI::baseUrl()->redirect(); break; // NOTREACHED } @@ -138,10 +138,10 @@ function dfrn_poll_init(App $a) if (!empty($destination_url)) { System::externalRedirect($destination_url); } else { - $a->internalRedirect('profile/' . $profile); + DI::baseUrl()->redirect('profile/' . $profile); } } - $a->internalRedirect(); + DI::baseUrl()->redirect(); } if ($type === 'profile-check' && $dfrn_version < 2.2) { @@ -325,7 +325,7 @@ function dfrn_poll_post(App $a) $sql_extra = sprintf(" AND `dfrn-id` = '%s' AND `duplex` = 1 ", DBA::escape($dfrn_id)); break; default: - $a->internalRedirect(); + DI::baseUrl()->redirect(); break; // NOTREACHED } @@ -445,7 +445,7 @@ function dfrn_poll_content(App $a) $my_id = '0:' . $dfrn_id; break; default: - $a->internalRedirect(); + DI::baseUrl()->redirect(); break; // NOTREACHED } @@ -541,18 +541,18 @@ function dfrn_poll_content(App $a) switch ($destination_url) { case 'profile': - $a->internalRedirect('profile/' . $profile . '?f=&tab=profile'); + DI::baseUrl()->redirect('profile/' . $profile . '?f=&tab=profile'); break; case 'photos': - $a->internalRedirect('photos/' . $profile); + DI::baseUrl()->redirect('photos/' . $profile); break; case 'status': case '': - $a->internalRedirect('profile/' . $profile); + DI::baseUrl()->redirect('profile/' . $profile); break; default: $appendix = (strstr($destination_url, '?') ? '&f=&redir=1' : '?f=&redir=1'); - $a->redirect($destination_url . $appendix); + DI::baseUrl()->redirect($destination_url . $appendix); break; } // NOTREACHED diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php index 28845634ad..f7c9d9aafc 100644 --- a/mod/dfrn_request.php +++ b/mod/dfrn_request.php @@ -21,6 +21,7 @@ use Friendica\Core\Renderer; use Friendica\Core\System; use Friendica\Core\Session; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\Group; use Friendica\Model\Profile; @@ -68,7 +69,7 @@ function dfrn_request_post(App $a) } if (!empty($_POST['cancel'])) { - $a->internalRedirect(); + DI::baseUrl()->redirect(); } /* @@ -194,14 +195,14 @@ function dfrn_request_post(App $a) } // (ignore reply, nothing we can do it failed) - $a->internalRedirect($forward_path); + DI::baseUrl()->redirect($forward_path); return; // NOTREACHED } } // invalid/bogus request notice(L10n::t('Unrecoverable protocol error.') . EOL); - $a->internalRedirect(); + DI::baseUrl()->redirect(); return; // NOTREACHED } @@ -334,19 +335,19 @@ function dfrn_request_post(App $a) $url = Network::isUrlValid($url); if (!$url) { notice(L10n::t('Invalid profile URL.') . EOL); - $a->internalRedirect($a->cmd); + DI::baseUrl()->redirect($a->cmd); return; // NOTREACHED } if (!Network::isUrlAllowed($url)) { notice(L10n::t('Disallowed profile URL.') . EOL); - $a->internalRedirect($a->cmd); + DI::baseUrl()->redirect($a->cmd); return; // NOTREACHED } if (Network::isUrlBlocked($url)) { notice(L10n::t('Blocked domain') . EOL); - $a->internalRedirect($a->cmd); + DI::baseUrl()->redirect($a->cmd); return; // NOTREACHED } @@ -354,7 +355,7 @@ function dfrn_request_post(App $a) if (!count($parms)) { notice(L10n::t('Profile location is not valid or does not contain profile information.') . EOL); - $a->internalRedirect($a->cmd); + DI::baseUrl()->redirect($a->cmd); } else { if (empty($parms['fn'])) { notice(L10n::t('Warning: profile location has no identifiable owner name.') . EOL); diff --git a/mod/events.php b/mod/events.php index 1a8eccde11..ddcac1bd15 100644 --- a/mod/events.php +++ b/mod/events.php @@ -15,6 +15,7 @@ use Friendica\Core\System; use Friendica\Core\Theme; use Friendica\Core\Worker; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Model\Event; use Friendica\Model\Item; use Friendica\Model\Profile; @@ -123,7 +124,7 @@ function events_post(App $a) echo L10n::t('Event can not end before it has started.'); exit(); } - $a->internalRedirect($onerror_path); + DI::baseUrl()->redirect($onerror_path); } if (!$summary || ($start === DBA::NULL_DATETIME)) { @@ -132,7 +133,7 @@ function events_post(App $a) echo L10n::t('Event title and start time are required.'); exit(); } - $a->internalRedirect($onerror_path); + DI::baseUrl()->redirect($onerror_path); } $share = intval($_POST['share'] ?? 0); @@ -150,7 +151,7 @@ function events_post(App $a) if ($share) { - $aclFormatter = \Friendica\DI::aclFormatter(); + $aclFormatter = DI::aclFormatter(); $str_group_allow = $aclFormatter->toString($_POST['group_allow'] ?? ''); $str_contact_allow = $aclFormatter->toString($_POST['contact_allow'] ?? ''); @@ -205,7 +206,7 @@ function events_post(App $a) Worker::add(PRIORITY_HIGH, "Notifier", Delivery::POST, $item_id); } - $a->internalRedirect('events'); + DI::baseUrl()->redirect('events'); } function events_content(App $a) @@ -578,6 +579,6 @@ function events_content(App $a) info(L10n::t('Event removed') . EOL); } - $a->internalRedirect('events'); + DI::baseUrl()->redirect('events'); } } diff --git a/mod/follow.php b/mod/follow.php index 31b92aa0dc..94db3ad38d 100644 --- a/mod/follow.php +++ b/mod/follow.php @@ -8,6 +8,7 @@ use Friendica\Core\L10n; use Friendica\Core\Protocol; use Friendica\Core\Renderer; use Friendica\Core\System; +use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\Profile; use Friendica\Network\Probe; @@ -21,7 +22,7 @@ function follow_post(App $a) } if (isset($_REQUEST['cancel'])) { - $a->internalRedirect('contact'); + DI::baseUrl()->redirect('contact'); } $uid = local_user(); @@ -38,14 +39,14 @@ function follow_post(App $a) if ($result['message']) { notice($result['message']); } - $a->internalRedirect($return_path); + DI::baseUrl()->redirect($return_path); } elseif ($result['cid']) { - $a->internalRedirect('contact/' . $result['cid']); + DI::baseUrl()->redirect('contact/' . $result['cid']); } info(L10n::t('The contact could not be added.')); - $a->internalRedirect($return_path); + DI::baseUrl()->redirect($return_path); // NOTREACHED } @@ -55,7 +56,7 @@ function follow_content(App $a) if (!local_user()) { notice(L10n::t('Permission denied.')); - $a->internalRedirect($return_path); + DI::baseUrl()->redirect($return_path); // NOTREACHED } @@ -70,7 +71,7 @@ function follow_content(App $a) } if (!$url) { - $a->internalRedirect($return_path); + DI::baseUrl()->redirect($return_path); } $submit = L10n::t('Submit Request'); @@ -132,7 +133,7 @@ function follow_content(App $a) if (!$r) { notice(L10n::t('Permission denied.')); - $a->internalRedirect($return_path); + DI::baseUrl()->redirect($return_path); // NOTREACHED } diff --git a/mod/item.php b/mod/item.php index e20fb99521..9326bf60d9 100644 --- a/mod/item.php +++ b/mod/item.php @@ -125,7 +125,7 @@ function item_post(App $a) { if (!DBA::isResult($toplevel_item)) { notice(L10n::t('Unable to locate original post.') . EOL); if (!empty($_REQUEST['return'])) { - $a->internalRedirect($return_path); + DI::baseUrl()->redirect($return_path); } exit(); } @@ -173,7 +173,7 @@ function item_post(App $a) { notice(L10n::t('Permission denied.') . EOL); if (!empty($_REQUEST['return'])) { - $a->internalRedirect($return_path); + DI::baseUrl()->redirect($return_path); } exit(); @@ -327,7 +327,7 @@ function item_post(App $a) { } info(L10n::t('Empty post discarded.') . EOL); if (!empty($_REQUEST['return'])) { - $a->internalRedirect($return_path); + DI::baseUrl()->redirect($return_path); } exit(); } @@ -678,7 +678,7 @@ function item_post(App $a) { if (!empty($datarray['cancel'])) { Logger::log('mod_item: post cancelled by addon.'); if ($return_path) { - $a->internalRedirect($return_path); + DI::baseUrl()->redirect($return_path); } $json = ['cancel' => 1]; @@ -713,7 +713,7 @@ function item_post(App $a) { if (!empty($_REQUEST['return']) && strlen($return_path)) { Logger::log('return: ' . $return_path); - $a->internalRedirect($return_path); + DI::baseUrl()->redirect($return_path); } exit(); } @@ -733,14 +733,14 @@ function item_post(App $a) { if (!$post_id) { Logger::log("Item wasn't stored."); - $a->internalRedirect($return_path); + DI::baseUrl()->redirect($return_path); } $datarray = Item::selectFirst(Item::ITEM_FIELDLIST, ['id' => $post_id]); if (!DBA::isResult($datarray)) { Logger::log("Item with id ".$post_id." couldn't be fetched."); - $a->internalRedirect($return_path); + DI::baseUrl()->redirect($return_path); } // update filetags in pconfig @@ -855,7 +855,7 @@ function item_post_return($baseurl, $api_source, $return_path) } if ($return_path) { - $a->internalRedirect($return_path); + DI::baseUrl()->redirect($return_path); } $json = ['success' => 1]; diff --git a/mod/lostpass.php b/mod/lostpass.php index ecab0982c8..5d28143fea 100644 --- a/mod/lostpass.php +++ b/mod/lostpass.php @@ -10,6 +10,7 @@ use Friendica\Core\L10n; use Friendica\Core\Renderer; use Friendica\Core\System; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Model\User; use Friendica\Util\DateTimeFormat; use Friendica\Util\Strings; @@ -18,14 +19,14 @@ function lostpass_post(App $a) { $loginame = Strings::escapeTags(trim($_POST['login-name'])); if (!$loginame) { - $a->internalRedirect(); + DI::baseUrl()->redirect(); } $condition = ['(`email` = ? OR `nickname` = ?) AND `verified` = 1 AND `blocked` = 0', $loginame, $loginame]; $user = DBA::selectFirst('user', ['uid', 'username', 'nickname', 'email', 'language'], $condition); if (!DBA::isResult($user)) { notice(L10n::t('No valid account found.') . EOL); - $a->internalRedirect(); + DI::baseUrl()->redirect(); } $pwdreset_token = Strings::getRandomName(12) . random_int(1000, 9999); @@ -77,7 +78,7 @@ function lostpass_post(App $a) 'body' => $body ]); - $a->internalRedirect(); + DI::baseUrl()->redirect(); } function lostpass_content(App $a) diff --git a/mod/message.php b/mod/message.php index 8efe825cd9..6944dfa679 100644 --- a/mod/message.php +++ b/mod/message.php @@ -13,6 +13,7 @@ use Friendica\Core\L10n; use Friendica\Core\Renderer; use Friendica\Core\System; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\Mail; use Friendica\Module\Security\Login; @@ -88,7 +89,7 @@ function message_post(App $a) $a->argc = 2; $a->argv[1] = 'new'; } else { - $a->internalRedirect($a->cmd . '/' . $ret); + DI::baseUrl()->redirect($a->cmd . '/' . $ret); } } @@ -156,7 +157,7 @@ function message_content(App $a) // Now check how the user responded to the confirmation query if (!empty($_REQUEST['canceled'])) { - $a->internalRedirect('message'); + DI::baseUrl()->redirect('message'); } $cmd = $a->argv[1]; @@ -164,7 +165,7 @@ function message_content(App $a) $message = DBA::selectFirst('mail', ['convid'], ['id' => $a->argv[2], 'uid' => local_user()]); if(!DBA::isResult($message)){ info(L10n::t('Conversation not found.') . EOL); - $a->internalRedirect('message'); + DI::baseUrl()->redirect('message'); } if (DBA::delete('mail', ['id' => $a->argv[2], 'uid' => local_user()])) { @@ -174,10 +175,10 @@ function message_content(App $a) $conversation = DBA::selectFirst('mail', ['id'], ['convid' => $message['convid'], 'uid' => local_user()]); if(!DBA::isResult($conversation)){ info(L10n::t('Conversation removed.') . EOL); - $a->internalRedirect('message'); + DI::baseUrl()->redirect('message'); } - $a->internalRedirect('message/' . $conversation['id'] ); + DI::baseUrl()->redirectinternalRedirect('message/' . $conversation['id'] ); } else { $r = q("SELECT `parent-uri`,`convid` FROM `mail` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($a->argv[2]), @@ -190,7 +191,7 @@ function message_content(App $a) info(L10n::t('Conversation removed.') . EOL); } } - $a->internalRedirect('message'); + DI::baseUrl()->redirect('message'); } } diff --git a/mod/network.php b/mod/network.php index 0376203401..14f70c9d65 100644 --- a/mod/network.php +++ b/mod/network.php @@ -128,7 +128,7 @@ function network_init(App $a) $redir_url = ($net_queries ? $net_baseurl . '?' . $net_queries : $net_baseurl); - $a->internalRedirect($redir_url); + DI::baseUrl()->redirect($redir_url); } } @@ -587,7 +587,7 @@ function networkThreadedView(App $a, $update, $parent) exit(); } notice(L10n::t('No such group') . EOL); - $a->internalRedirect('network/0'); + DI::baseUrl()->redirect('network/0'); // NOTREACHED } @@ -641,7 +641,7 @@ function networkThreadedView(App $a, $update, $parent) } } else { notice(L10n::t('Invalid contact.') . EOL); - $a->internalRedirect('network'); + DI::baseUrl()->redirect('network'); // NOTREACHED } } diff --git a/mod/notifications.php b/mod/notifications.php index e083e3b44c..7e1d2cff9e 100644 --- a/mod/notifications.php +++ b/mod/notifications.php @@ -17,12 +17,11 @@ use Friendica\DI; use Friendica\Module\Security\Login; use Friendica\Model\Contact; use Friendica\Model\Introduction; -use Friendica\Model\Notify; function notifications_post(App $a) { if (!local_user()) { - $a->internalRedirect(); + DI::baseUrl()->redirect(); } $request_id = (($a->argc > 1) ? $a->argv[1] : 0); @@ -45,7 +44,7 @@ function notifications_post(App $a) break; } - $a->internalRedirect('notifications/intros'); + DI::baseUrl()->redirect('notifications/intros'); } } @@ -113,7 +112,7 @@ function notifications_content(App $a) $notifs = $nm->getHomeList($show, $startrec, $perpage); // fallback - redirect to main page } else { - $a->internalRedirect('notifications'); + DI::baseUrl()->redirect('notifications'); } // Set the pager diff --git a/mod/ostatus_subscribe.php b/mod/ostatus_subscribe.php index 7f9725b853..f112a2ef91 100644 --- a/mod/ostatus_subscribe.php +++ b/mod/ostatus_subscribe.php @@ -8,6 +8,7 @@ use Friendica\Core\L10n; use Friendica\Core\PConfig; use Friendica\Core\Protocol; use Friendica\Core\System; +use Friendica\DI; use Friendica\Model\Contact; use Friendica\Network\Probe; use Friendica\Util\Network; @@ -16,7 +17,7 @@ function ostatus_subscribe_content(App $a) { if (!local_user()) { notice(L10n::t('Permission denied.') . EOL); - $a->internalRedirect('ostatus_subscribe'); + DI::baseUrl()->redirect('ostatus_subscribe'); // NOTREACHED } diff --git a/mod/photos.php b/mod/photos.php index a3d81c041d..fd1d6200f3 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -173,12 +173,12 @@ function photos_post(App $a) if ($a->argc > 3 && $a->argv[2] === 'album') { if (!Strings::isHex($a->argv[3])) { - $a->internalRedirect('photos/' . $a->data['user']['nickname'] . '/album'); + DI::baseUrl()->redirect('photos/' . $a->data['user']['nickname'] . '/album'); } $album = hex2bin($a->argv[3]); if ($album === L10n::t('Profile Photos') || $album === 'Contact Photos' || $album === L10n::t('Contact Photos')) { - $a->internalRedirect($_SESSION['photo_return']); + DI::baseUrl()->redirect($_SESSION['photo_return']); return; // NOTREACHED } @@ -189,13 +189,13 @@ function photos_post(App $a) if (!DBA::isResult($r)) { notice(L10n::t('Album not found.') . EOL); - $a->internalRedirect($_SESSION['photo_return']); + DI::baseUrl()->redirect($_SESSION['photo_return']); return; // NOTREACHED } // Check if the user has responded to a delete confirmation query if (!empty($_REQUEST['canceled'])) { - $a->internalRedirect($_SESSION['photo_return']); + DI::baseUrl()->redirect($_SESSION['photo_return']); } // RENAME photo album @@ -209,7 +209,7 @@ function photos_post(App $a) // Update the photo albums cache Photo::clearAlbumCache($page_owner_uid); - $a->internalRedirect('photos/' . $a->user['nickname'] . '/album/' . bin2hex($newalbum)); + DI::baseUrl()->redirect('photos/' . $a->user['nickname'] . '/album/' . bin2hex($newalbum)); return; // NOTREACHED } @@ -252,13 +252,13 @@ function photos_post(App $a) } } - $a->internalRedirect('photos/' . $a->argv[1]); + DI::baseUrl()->redirect('photos/' . $a->argv[1]); } if ($a->argc > 3 && $a->argv[2] === 'image') { // Check if the user has responded to a delete confirmation query for a single photo if (!empty($_POST['canceled'])) { - $a->internalRedirect('photos/' . $a->argv[1] . '/image/' . $a->argv[3]); + DI::baseUrl()->redirect('photos/' . $a->argv[1] . '/image/' . $a->argv[3]); } if (!empty($_POST['delete'])) { @@ -282,10 +282,10 @@ function photos_post(App $a) notice('Successfully deleted the photo.'); } else { notice('Failed to delete the photo.'); - $a->internalRedirect('photos/' . $a->argv[1] . '/image/' . $a->argv[3]); + DI::baseUrl()->redirect('photos/' . $a->argv[1] . '/image/' . $a->argv[3]); } - $a->internalRedirect('photos/' . $a->argv[1]); + DI::baseUrl()->redirect('photos/' . $a->argv[1]); return; // NOTREACHED } } @@ -591,7 +591,7 @@ function photos_post(App $a) } } } - $a->internalRedirect($_SESSION['photo_return']); + DI::baseUrl()->redirect($_SESSION['photo_return']); return; // NOTREACHED } @@ -817,7 +817,7 @@ function photos_post(App $a) // addon uploaders should call "killme()" [e.g. exit] within the photo_post_end hook // if they do not wish to be redirected - $a->internalRedirect($_SESSION['photo_return']); + DI::baseUrl()->redirect($_SESSION['photo_return']); // NOTREACHED } @@ -994,7 +994,7 @@ function photos_content(App $a) if ($datatype === 'album') { // if $datum is not a valid hex, redirect to the default page if (!Strings::isHex($datum)) { - $a->internalRedirect('photos/' . $a->data['user']['nickname']. '/album'); + DI::baseUrl()->redirect('photos/' . $a->data['user']['nickname']. '/album'); } $album = hex2bin($datum); diff --git a/mod/profile_photo.php b/mod/profile_photo.php index 97d2da349c..412d19029e 100644 --- a/mod/profile_photo.php +++ b/mod/profile_photo.php @@ -11,6 +11,7 @@ use Friendica\Core\Renderer; use Friendica\Core\System; use Friendica\Core\Worker; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\Photo; use Friendica\Model\Profile; @@ -134,7 +135,7 @@ function profile_photo_post(App $a) } } - $a->internalRedirect($path); + DI::baseUrl()->redirect($path); return; // NOTREACHED } @@ -167,7 +168,7 @@ function profile_photo_post(App $a) @unlink($src); $imagecrop = profile_photo_crop_ui_head($a, $ph); - $a->internalRedirect('profile_photo/use/' . $imagecrop['hash']); + DI::baseUrl()->redirect('profile_photo/use/' . $imagecrop['hash']); } function profile_photo_content(App $a) @@ -222,7 +223,7 @@ function profile_photo_content(App $a) Worker::add(PRIORITY_LOW, "Directory", $url); } - $a->internalRedirect('profile/' . $a->user['nickname']); + DI::baseUrl()->redirect('profile/' . $a->user['nickname']); return; // NOTREACHED } $ph = Photo::getImageForPhoto($r[0]); diff --git a/mod/profiles.php b/mod/profiles.php index 46bc36db53..e298df668c 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -16,6 +16,7 @@ use Friendica\Core\Renderer; use Friendica\Core\System; use Friendica\Core\Worker; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\GContact; use Friendica\Model\Profile; @@ -41,7 +42,7 @@ function profiles_init(App $a) { ); if (! DBA::isResult($r)) { notice(L10n::t('Profile not found.') . EOL); - $a->internalRedirect('profiles'); + DI::baseUrl()->redirect('profiles'); return; // NOTREACHED } @@ -62,7 +63,7 @@ function profiles_init(App $a) { info(L10n::t('Profile deleted.').EOL); } - $a->internalRedirect('profiles'); + DI::baseUrl()->redirect('profiles'); return; // NOTREACHED } @@ -96,10 +97,10 @@ function profiles_init(App $a) { info(L10n::t('New profile created.') . EOL); if (DBA::isResult($r3) && count($r3) == 1) { - $a->internalRedirect('profiles/' . $r3[0]['id']); + DI::baseUrl()->redirect('profiles/' . $r3[0]['id']); } - $a->internalRedirect('profiles'); + DI::baseUrl()->redirect('profiles'); } if (($a->argc > 2) && ($a->argv[1] === 'clone')) { @@ -134,10 +135,10 @@ function profiles_init(App $a) { ); info(L10n::t('New profile created.') . EOL); if ((DBA::isResult($r3)) && (count($r3) == 1)) { - $a->internalRedirect('profiles/'.$r3[0]['id']); + DI::baseUrl()->redirect('profiles/'.$r3[0]['id']); } - $a->internalRedirect('profiles'); + DI::baseUrl()->redirect('profiles'); return; // NOTREACHED } @@ -640,7 +641,7 @@ function profiles_content(App $a) { ); if (DBA::isResult($r)) { //Go to the default profile. - $a->internalRedirect('profiles/' . $r[0]['id']); + DI::baseUrl()->redirect('profiles/' . $r[0]['id']); } } diff --git a/mod/redir.php b/mod/redir.php index 9d86f27a96..57f96a7ac6 100644 --- a/mod/redir.php +++ b/mod/redir.php @@ -6,6 +6,7 @@ use Friendica\Core\Logger; use Friendica\Core\Session; use Friendica\Core\System; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\Profile; use Friendica\Util\Network; @@ -30,7 +31,7 @@ function redir_init(App $a) { $contact = DBA::selectFirst('contact', $fields, ['id' => $cid, 'uid' => [0, local_user()]]); if (!DBA::isResult($contact)) { notice(L10n::t('Contact not found.')); - $a->internalRedirect(); + DI::baseUrl()->redirect(); } $contact_url = $contact['url']; @@ -120,7 +121,7 @@ function redir_init(App $a) { } notice(L10n::t('Contact not found.')); - $a->internalRedirect(); + DI::baseUrl()->redirect(); } function redir_magic($a, $cid, $url) diff --git a/mod/regmod.php b/mod/regmod.php index 78cba8a2ab..0fc5a88994 100644 --- a/mod/regmod.php +++ b/mod/regmod.php @@ -9,6 +9,7 @@ use Friendica\Core\L10n; use Friendica\Core\System; use Friendica\Core\Worker; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Model\Register; use Friendica\Model\User; use Friendica\Module\Security\Login; @@ -98,11 +99,11 @@ function regmod_content(App $a) if ($cmd === 'deny') { user_deny($hash); - $a->internalRedirect('admin/users/'); + DI::baseUrl()->redirect('admin/users/'); } if ($cmd === 'allow') { user_allow($hash); - $a->internalRedirect('admin/users/'); + DI::baseUrl()->redirect('admin/users/'); } } diff --git a/mod/removeme.php b/mod/removeme.php index 7ed0d1da90..30e332d328 100644 --- a/mod/removeme.php +++ b/mod/removeme.php @@ -8,6 +8,7 @@ use Friendica\Core\Config; use Friendica\Core\L10n; use Friendica\Core\Renderer; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Model\User; use Friendica\Util\Strings; @@ -59,7 +60,7 @@ function removeme_post(App $a) unset($_SESSION['authenticated']); unset($_SESSION['uid']); - $a->internalRedirect(); + DI::baseUrl()->redirect(); // NOTREACHED } } @@ -67,7 +68,7 @@ function removeme_post(App $a) function removeme_content(App $a) { if (!local_user()) { - $a->internalRedirect(); + DI::baseUrl()->redirect(); } $hash = Strings::getRandomHex(); diff --git a/mod/repair_ostatus.php b/mod/repair_ostatus.php index 51a6aadaad..f1a86e6b23 100644 --- a/mod/repair_ostatus.php +++ b/mod/repair_ostatus.php @@ -8,13 +8,14 @@ use Friendica\Core\L10n; use Friendica\Core\Protocol; use Friendica\Core\System; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Model\Contact; function repair_ostatus_content(App $a) { if (! local_user()) { notice(L10n::t('Permission denied.') . EOL); - $a->internalRedirect('ostatus_repair'); + DI::baseUrl()->redirect('ostatus_repair'); // NOTREACHED } diff --git a/mod/settings.php b/mod/settings.php index b126defcba..416a8adcda 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -173,7 +173,7 @@ function settings_post(App $a) $key = $_POST['remove']; DBA::delete('tokens', ['id' => $key, 'uid' => local_user()]); - $a->internalRedirect('settings/oauth/', true); + DI::baseUrl()->redirect('settings/oauth/', true); return; } @@ -219,7 +219,7 @@ function settings_post(App $a) ); } } - $a->internalRedirect('settings/oauth/', true); + DI::baseUrl()->redirect('settings/oauth/', true); return; } @@ -383,7 +383,7 @@ function settings_post(App $a) } Hook::callAll('display_settings_post', $_POST); - $a->internalRedirect('settings/display'); + DI::baseUrl()->redirect('settings/display'); return; // NOTREACHED } @@ -419,7 +419,7 @@ function settings_post(App $a) if (!empty($_POST['resend_relocate'])) { Worker::add(PRIORITY_HIGH, 'Notifier', Delivery::RELOCATION, local_user()); info(L10n::t("Relocate message has been send to your contacts")); - $a->internalRedirect('settings'); + DI::baseUrl()->redirect('settings'); } Hook::callAll('settings_post', $_POST); @@ -638,7 +638,7 @@ function settings_post(App $a) // Update the global contact for the user GContact::updateForUser(local_user()); - $a->internalRedirect('settings'); + DI::baseUrl()->redirect('settings'); return; // NOTREACHED } @@ -705,7 +705,7 @@ function settings_content(App $a) BaseModule::checkFormSecurityTokenRedirectOnError('/settings/oauth', 'settings_oauth', 't'); DBA::delete('clients', ['client_id' => $a->argv[3], 'uid' => local_user()]); - $a->internalRedirect('settings/oauth/', true); + DI::baseUrl()->redirect('settings/oauth/', true); return; } diff --git a/mod/suggest.php b/mod/suggest.php index 4b67dd6eb8..86c7f7afdf 100644 --- a/mod/suggest.php +++ b/mod/suggest.php @@ -10,6 +10,7 @@ use Friendica\Core\L10n; use Friendica\Core\Renderer; use Friendica\Core\System; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\GContact; use Friendica\Util\Proxy as ProxyUtils; @@ -28,7 +29,7 @@ function suggest_post(App $a) notice(L10n::t('Contact suggestion successfully ignored.')); } - $a->internalRedirect('suggest'); + DI::baseUrl()->redirect('suggest'); } function suggest_content(App $a) diff --git a/mod/tagrm.php b/mod/tagrm.php index 3f091f298a..267ee718cc 100644 --- a/mod/tagrm.php +++ b/mod/tagrm.php @@ -7,6 +7,7 @@ use Friendica\App; use Friendica\Content\Text\BBCode; use Friendica\Core\L10n; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Model\Item; use Friendica\Model\Term; use Friendica\Util\Strings; @@ -14,11 +15,11 @@ use Friendica\Util\Strings; function tagrm_post(App $a) { if (!local_user()) { - $a->internalRedirect($_SESSION['photo_return']); + DI::baseUrl()->redirect($_SESSION['photo_return']); } if (!empty($_POST['submit']) && ($_POST['submit'] === L10n::t('Cancel'))) { - $a->internalRedirect($_SESSION['photo_return']); + DI::baseUrl()->redirect($_SESSION['photo_return']); } $tags = []; @@ -30,7 +31,7 @@ function tagrm_post(App $a) update_tags($item_id, $tags); info(L10n::t('Tag(s) removed') . EOL); - $a->internalRedirect($_SESSION['photo_return']); + DI::baseUrl()->redirect($_SESSION['photo_return']); // NOTREACHED } @@ -71,31 +72,31 @@ function tagrm_content(App $a) $o = ''; if (!local_user()) { - $a->internalRedirect($_SESSION['photo_return']); + DI::baseUrl()->redirect($_SESSION['photo_return']); // NOTREACHED } if ($a->argc == 3) { update_tags($a->argv[1], [Strings::escapeTags(trim(hex2bin($a->argv[2])))]); - $a->internalRedirect($_SESSION['photo_return']); + DI::baseUrl()->redirect($_SESSION['photo_return']); } $item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0); if (!$item_id) { - $a->internalRedirect($_SESSION['photo_return']); + DI::baseUrl()->redirect($_SESSION['photo_return']); // NOTREACHED } $item = Item::selectFirst(['tag'], ['id' => $item_id, 'uid' => local_user()]); if (!DBA::isResult($item)) { - $a->internalRedirect($_SESSION['photo_return']); + DI::baseUrl()->redirect($_SESSION['photo_return']); } $arr = explode(',', $item['tag']); if (empty($item['tag'])) { - $a->internalRedirect($_SESSION['photo_return']); + DI::baseUrl()->redirect($_SESSION['photo_return']); } $o .= '

' . L10n::t('Remove Item Tag') . '

'; diff --git a/mod/uimport.php b/mod/uimport.php index 436802265b..b1cb8f82a5 100644 --- a/mod/uimport.php +++ b/mod/uimport.php @@ -19,7 +19,7 @@ function uimport_post(App $a) } if (!empty($_FILES['accountfile'])) { - UserImport::importAccount($a, $_FILES['accountfile']); + UserImport::importAccount($_FILES['accountfile']); return; } } diff --git a/mod/unfollow.php b/mod/unfollow.php index 7afd82c98a..c7ad413d22 100644 --- a/mod/unfollow.php +++ b/mod/unfollow.php @@ -9,6 +9,7 @@ use Friendica\Core\Protocol; use Friendica\Core\Renderer; use Friendica\Core\System; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\Profile; use Friendica\Model\User; @@ -20,7 +21,7 @@ function unfollow_post(App $a) if (!local_user()) { notice(L10n::t('Permission denied.')); - $a->internalRedirect('login'); + DI::baseUrl()->redirect('login'); // NOTREACHED } @@ -34,17 +35,17 @@ function unfollow_post(App $a) if (!DBA::isResult($contact)) { notice(L10n::t("You aren't following this contact.")); - $a->internalRedirect($base_return_path); + DI::baseUrl()->redirect($base_return_path); // NOTREACHED } if (!empty($_REQUEST['cancel'])) { - $a->internalRedirect($base_return_path . '/' . $contact['id']); + DI::baseUrl()->redirect($base_return_path . '/' . $contact['id']); } if (!in_array($contact['network'], Protocol::NATIVE_SUPPORT)) { notice(L10n::t('Unfollowing is currently not supported by your network.')); - $a->internalRedirect($base_return_path . '/' . $contact['id']); + DI::baseUrl()->redirect($base_return_path . '/' . $contact['id']); // NOTREACHED } @@ -65,7 +66,7 @@ function unfollow_post(App $a) } info(L10n::t('Contact unfollowed')); - $a->internalRedirect($return_path); + DI::baseUrl()->redirect($return_path); // NOTREACHED } @@ -75,7 +76,7 @@ function unfollow_content(App $a) if (!local_user()) { notice(L10n::t('Permission denied.')); - $a->internalRedirect('login'); + DI::baseUrl()->redirect('login'); // NOTREACHED } @@ -90,13 +91,13 @@ function unfollow_content(App $a) if (!DBA::isResult($contact)) { notice(L10n::t("You aren't following this contact.")); - $a->internalRedirect($base_return_path); + DI::baseUrl()->redirect($base_return_path); // NOTREACHED } if (!in_array($contact['network'], Protocol::NATIVE_SUPPORT)) { notice(L10n::t('Unfollowing is currently not supported by your network.')); - $a->internalRedirect($base_return_path . '/' . $contact['id']); + DI::baseUrl()->redirect($base_return_path . '/' . $contact['id']); // NOTREACHED } @@ -107,7 +108,7 @@ function unfollow_content(App $a) if (!DBA::isResult($self)) { notice(L10n::t('Permission denied.')); - $a->internalRedirect($base_return_path); + DI::baseUrl()->redirect($base_return_path); // NOTREACHED } diff --git a/mod/videos.php b/mod/videos.php index 4174c7f48a..c6f342aa70 100644 --- a/mod/videos.php +++ b/mod/videos.php @@ -12,6 +12,7 @@ use Friendica\Core\Renderer; use Friendica\Core\System; use Friendica\Core\Session; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Model\Attach; use Friendica\Model\Contact; use Friendica\Model\Group; @@ -75,7 +76,7 @@ function videos_post(App $a) $owner_uid = $a->data['user']['uid']; if (local_user() != $owner_uid) { - $a->internalRedirect('videos/' . $a->data['user']['nickname']); + DI::baseUrl()->redirect('videos/' . $a->data['user']['nickname']); } if (($a->argc == 2) && !empty($_POST['delete']) && !empty($_POST['id'])) { @@ -92,11 +93,11 @@ function videos_post(App $a) ], local_user()); } - $a->internalRedirect('videos/' . $a->data['user']['nickname']); + DI::baseUrl()->redirect('videos/' . $a->data['user']['nickname']); return; // NOTREACHED } - $a->internalRedirect('videos/' . $a->data['user']['nickname']); + DI::baseUrl()->redirect('videos/' . $a->data['user']['nickname']); } function videos_content(App $a) diff --git a/mod/wallmessage.php b/mod/wallmessage.php index ad8ca96675..eaa3174f4a 100644 --- a/mod/wallmessage.php +++ b/mod/wallmessage.php @@ -8,6 +8,7 @@ use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\Core\System; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Model\Mail; use Friendica\Model\Profile; use Friendica\Util\Strings; @@ -72,7 +73,7 @@ function wallmessage_post(App $a) { info(L10n::t('Message sent.') . EOL); } - $a->internalRedirect('profile/'.$user['nickname']); + DI::baseUrl()->redirect('profile/'.$user['nickname']); } diff --git a/src/App.php b/src/App.php index c0c3878538..65ab3be53d 100644 --- a/src/App.php +++ b/src/App.php @@ -681,9 +681,9 @@ class App // in install mode, any url loads install module // but we need "view" module for stylesheet if ($this->mode->isInstall() && $moduleName !== 'install') { - $this->internalRedirect('install'); + $this->baseURL->redirect('install'); } elseif (!$this->mode->isInstall() && !$this->mode->has(App\Mode::MAINTENANCEDISABLED) && $moduleName !== 'maintenance') { - $this->internalRedirect('maintenance'); + $this->baseURL->redirect('maintenance'); } else { $this->checkURL(); Core\Update::check($this->getBasePath(), false, $this->mode); @@ -693,35 +693,35 @@ class App // Compatibility with the Android Diaspora client if ($moduleName == 'stream') { - $this->internalRedirect('network?order=post'); + $this->baseURL->redirect('network?order=post'); } if ($moduleName == 'conversations') { - $this->internalRedirect('message'); + $this->baseURL->redirect('message'); } if ($moduleName == 'commented') { - $this->internalRedirect('network?order=comment'); + $this->baseURL->redirect('network?order=comment'); } if ($moduleName == 'liked') { - $this->internalRedirect('network?order=comment'); + $this->baseURL->redirect('network?order=comment'); } if ($moduleName == 'activity') { - $this->internalRedirect('network?conv=1'); + $this->baseURL->redirect('network?conv=1'); } if (($moduleName == 'status_messages') && ($this->args->getCommand() == 'status_messages/new')) { - $this->internalRedirect('bookmarklet'); + $this->baseURL->redirect('bookmarklet'); } if (($moduleName == 'user') && ($this->args->getCommand() == 'user/edit')) { - $this->internalRedirect('settings'); + $this->baseURL->redirect('settings'); } if (($moduleName == 'tag_followings') && ($this->args->getCommand() == 'tag_followings/manage')) { - $this->internalRedirect('search'); + $this->baseURL->redirect('search'); } // Initialize module that can set the current theme in the init() method, either directly or via App->profile_uid @@ -732,7 +732,7 @@ class App $module = $module->determineClass($this->args, $router, $this->config); // Let the module run it's internal process (init, get, post, ...) - $module->run($this->l10n, $this, $this->logger, $_SERVER, $_POST); + $module->run($this->l10n, $this->baseURL, $this->logger, $_SERVER, $_POST); } catch (HTTPException $e) { ModuleHTTPException::rawContent($e); } @@ -740,15 +740,6 @@ class App $this->page->run($this, $this->baseURL, $this->mode, $module, $this->l10n, $this->config, $pconfig); } - /** - * @deprecated 2019.12 use BaseUrl::redirect instead - * @see BaseURL::redirect() - */ - public function internalRedirect($toUrl = '', $ssl = false) - { - $this->baseURL->redirect($toUrl, $ssl); - } - /** * Automatically redirects to relative or absolute URL * Should only be used if it isn't clear if the URL is either internal or external diff --git a/src/App/Authentication.php b/src/App/Authentication.php index b1424e0fd6..f9d14171e9 100644 --- a/src/App/Authentication.php +++ b/src/App/Authentication.php @@ -407,7 +407,7 @@ class Authentication if ($a->isAjax()) { throw new HTTPException\ForbiddenException(); } else { - $a->internalRedirect('2fa'); + $this->baseUrl->redirect('2fa'); } } } diff --git a/src/App/Module.php b/src/App/Module.php index 39111c9501..51be234937 100644 --- a/src/App/Module.php +++ b/src/App/Module.php @@ -208,14 +208,14 @@ class Module * Run the determined module class and calls all hooks applied to * * @param Core\L10n\L10n $l10n The L10n instance - * @param App $app The whole Friendica app (for method arguments) + * @param App\BaseURL $baseUrl The Friendica Base URL * @param LoggerInterface $logger The Friendica logger * @param array $server The $_SERVER variable * @param array $post The $_POST variables * * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function run(Core\L10n\L10n $l10n, App $app, LoggerInterface $logger, array $server, array $post) + public function run(Core\L10n\L10n $l10n, App\BaseURL $baseUrl, LoggerInterface $logger, array $server, array $post) { if ($this->printNotAllowedAddon) { info($l10n->t("You must be logged in to use addons. ")); @@ -239,7 +239,7 @@ class Module if (!empty($queryString) && ($queryString === 'q=internal_error.html') && isset($dreamhost_error_hack)) { $logger->info('index.php: dreamhost_error_hack invoked.', ['Original URI' => $server['REQUEST_URI']]); - $app->internalRedirect($server['REQUEST_URI']); + $baseUrl->redirect($server['REQUEST_URI']); } $logger->debug('index.php: page not found.', ['request_uri' => $server['REQUEST_URI'], 'address' => $server['REMOTE_ADDR'], 'query' => $server['QUERY_STRING']]); diff --git a/src/BaseModule.php b/src/BaseModule.php index 3d6a3f691f..dcacce78bb 100644 --- a/src/BaseModule.php +++ b/src/BaseModule.php @@ -140,7 +140,7 @@ abstract class BaseModule Logger::log('checkFormSecurityToken failed: user ' . $a->user['guid'] . ' - form element ' . $typename); Logger::log('checkFormSecurityToken failed: _REQUEST data: ' . print_r($_REQUEST, true), Logger::DATA); notice(self::getFormSecurityStandardErrorMessage()); - $a->internalRedirect($err_redirect); + DI::baseUrl()->redirect($err_redirect); } } diff --git a/src/Core/UserImport.php b/src/Core/UserImport.php index 71767e8cef..b06e01e9f7 100644 --- a/src/Core/UserImport.php +++ b/src/Core/UserImport.php @@ -7,6 +7,7 @@ namespace Friendica\Core; use Friendica\App; use Friendica\Database\DBA; use Friendica\Database\DBStructure; +use Friendica\DI; use Friendica\Model\Photo; use Friendica\Object\Image; use Friendica\Util\Strings; @@ -85,12 +86,11 @@ class UserImport /** * @brief Import account file exported from mod/uexport * - * @param App $a Friendica App Class * @param array $file array from $_FILES * @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \ImagickException */ - public static function importAccount(App $a, $file) + public static function importAccount($file) { Logger::log("Start user import from " . $file['tmp_name']); /* @@ -282,6 +282,6 @@ class UserImport Worker::add(PRIORITY_HIGH, 'Notifier', Delivery::RELOCATION, $newuid); info(L10n::t("Done. You can now login with your username and password")); - $a->internalRedirect('login'); + DI::baseUrl()->redirect('login'); } } diff --git a/src/Model/Contact.php b/src/Model/Contact.php index 577f3da1df..8d4b8c6312 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -2272,7 +2272,7 @@ class Contact $myaddr = bin2hex($a->user['nickname'] . '@' . $a->getHostName()); } - $a->internalRedirect($ret['request'] . "&addr=$myaddr"); + DI::baseUrl()->redirect($ret['request'] . "&addr=$myaddr"); // NOTREACHED } diff --git a/src/Module/Admin/Addons/Details.php b/src/Module/Admin/Addons/Details.php index b7c9b68c28..afca0b150c 100644 --- a/src/Module/Admin/Addons/Details.php +++ b/src/Module/Admin/Addons/Details.php @@ -29,11 +29,11 @@ class Details extends BaseAdminModule $func($a); } - $a->internalRedirect('admin/addons/' . $addon); + DI::baseUrl()->redirect('admin/addons/' . $addon); } } - $a->internalRedirect('admin/addons'); + DI::baseUrl()->redirect('admin/addons'); } public static function content(array $parameters = []) @@ -51,7 +51,7 @@ class Details extends BaseAdminModule if (!is_file("addon/$addon/$addon.php")) { notice(L10n::t('Addon not found.')); Addon::uninstall($addon); - $a->internalRedirect('admin/addons'); + DI::baseUrl()->redirect('admin/addons'); } if (($_GET['action'] ?? '') == 'toggle') { @@ -68,7 +68,7 @@ class Details extends BaseAdminModule Addon::saveEnabledList(); - $a->internalRedirect('admin/addons/' . $addon); + DI::baseUrl()->redirect('admin/addons/' . $addon); } // display addon details @@ -119,6 +119,6 @@ class Details extends BaseAdminModule ]); } - $a->internalRedirect('admin/addons'); + DI::baseUrl()->redirect('admin/addons'); } } diff --git a/src/Module/Admin/Addons/Index.php b/src/Module/Admin/Addons/Index.php index 237eb73255..bc28aaa8fe 100644 --- a/src/Module/Admin/Addons/Index.php +++ b/src/Module/Admin/Addons/Index.php @@ -41,7 +41,7 @@ class Index extends BaseAdminModule } - $a->internalRedirect('admin/addons'); + DI::baseUrl()->redirect('admin/addons'); } $addons = Addon::getAvailableList(); diff --git a/src/Module/Admin/Blocklist/Contact.php b/src/Module/Admin/Blocklist/Contact.php index e21c0ed959..71e96834b6 100644 --- a/src/Module/Admin/Blocklist/Contact.php +++ b/src/Module/Admin/Blocklist/Contact.php @@ -39,7 +39,7 @@ class Contact extends BaseAdminModule notice(L10n::tt('%s contact unblocked', '%s contacts unblocked', count($contacts))); } - DI::app()->internalRedirect('admin/blocklist/contact'); + DI::baseUrl()->redirect('admin/blocklist/contact'); } public static function content(array $parameters = []) diff --git a/src/Module/Admin/Blocklist/Server.php b/src/Module/Admin/Blocklist/Server.php index 5b84e40653..87cb8709db 100644 --- a/src/Module/Admin/Blocklist/Server.php +++ b/src/Module/Admin/Blocklist/Server.php @@ -48,7 +48,7 @@ class Server extends BaseAdminModule info(L10n::t('Site blocklist updated.') . EOL); } - DI::app()->internalRedirect('admin/blocklist/server'); + DI::baseUrl()->redirect('admin/blocklist/server'); } public static function content(array $parameters = []) diff --git a/src/Module/Admin/DBSync.php b/src/Module/Admin/DBSync.php index 7aeba4e1b1..6f6ebe3d00 100644 --- a/src/Module/Admin/DBSync.php +++ b/src/Module/Admin/DBSync.php @@ -32,7 +32,7 @@ class DBSync extends BaseAdminModule } info(L10n::t('Update has been marked successful') . EOL); } - $a->internalRedirect('admin/dbsync'); + DI::baseUrl()->redirect('admin/dbsync'); } if ($a->argc > 2) { diff --git a/src/Module/Admin/Features.php b/src/Module/Admin/Features.php index c9a5a9813d..7cc7932af8 100644 --- a/src/Module/Admin/Features.php +++ b/src/Module/Admin/Features.php @@ -40,7 +40,7 @@ class Features extends BaseAdminModule } } - DI::app()->internalRedirect('admin/features'); + DI::baseUrl()->redirect('admin/features'); } public static function content(array $parameters = []) diff --git a/src/Module/Admin/Item/Delete.php b/src/Module/Admin/Item/Delete.php index 77849a9aa9..744a57f073 100644 --- a/src/Module/Admin/Item/Delete.php +++ b/src/Module/Admin/Item/Delete.php @@ -34,7 +34,7 @@ class Delete extends BaseAdminModule } info(L10n::t('Item marked for deletion.') . EOL); - DI::app()->internalRedirect('admin/item/delete'); + DI::baseUrl()->redirect('admin/item/delete'); } public static function content(array $parameters = []) diff --git a/src/Module/Admin/Logs/Settings.php b/src/Module/Admin/Logs/Settings.php index 0617c1c217..ccddf69a1d 100644 --- a/src/Module/Admin/Logs/Settings.php +++ b/src/Module/Admin/Logs/Settings.php @@ -35,7 +35,7 @@ class Settings extends BaseAdminModule } info(L10n::t("Log settings updated.")); - DI::app()->internalRedirect('admin/logs'); + DI::baseUrl()->redirect('admin/logs'); } public static function content(array $parameters = []) diff --git a/src/Module/Admin/Site.php b/src/Module/Admin/Site.php index abf9d95edb..42b35edff3 100644 --- a/src/Module/Admin/Site.php +++ b/src/Module/Admin/Site.php @@ -48,7 +48,7 @@ class Site extends BaseAdminModule $parsed = @parse_url($new_url); if (!is_array($parsed) || empty($parsed['host']) || empty($parsed['scheme'])) { notice(L10n::t("Can not parse base url. Must have at least ://")); - $a->internalRedirect('admin/site'); + DI::baseUrl()->redirect('admin/site'); } /* steps: @@ -77,7 +77,7 @@ class Site extends BaseAdminModule $r = DBA::e(sprintf("UPDATE %s SET %s;", $table_name, $upds)); if (!DBA::isResult($r)) { notice("Failed updating '$table_name': " . DBA::errorMessage()); - $a->internalRedirect('admin/site'); + DI::baseUrl()->redirect('admin/site'); } } @@ -105,7 +105,7 @@ class Site extends BaseAdminModule info("Relocation started. Could take a while to complete."); - $a->internalRedirect('admin/site'); + DI::baseUrl()->redirect('admin/site'); } // end relocate @@ -229,7 +229,7 @@ class Site extends BaseAdminModule foreach ($storage_form_errors as $name => $err) { notice('Storage backend, ' . $storage_opts[$name][1] . ': ' . $err); } - $a->internalRedirect('admin/site' . $active_panel); + DI::baseUrl()->redirect('admin/site' . $active_panel); } } else { info(L10n::t('Invalid storage backend setting value.')); @@ -410,7 +410,7 @@ class Site extends BaseAdminModule info(L10n::t('Site settings updated.') . EOL); - $a->internalRedirect('admin/site' . $active_panel); + DI::baseUrl()->redirect('admin/site' . $active_panel); } public static function content(array $parameters = []) diff --git a/src/Module/Admin/Themes/Details.php b/src/Module/Admin/Themes/Details.php index 0e9fa08f52..c45204e98a 100644 --- a/src/Module/Admin/Themes/Details.php +++ b/src/Module/Admin/Themes/Details.php @@ -36,7 +36,7 @@ class Details extends BaseAdminModule return; } - $a->internalRedirect('admin/themes/' . $theme); + DI::baseUrl()->redirect('admin/themes/' . $theme); } } @@ -76,7 +76,7 @@ class Details extends BaseAdminModule info(L10n::t('Theme %s failed to install.', $theme)); } - $a->internalRedirect('admin/themes/' . $theme); + DI::baseUrl()->redirect('admin/themes/' . $theme); } $readme = null; @@ -122,6 +122,6 @@ class Details extends BaseAdminModule ]); } - $a->internalRedirect('admin/themes'); + DI::baseUrl()->redirect('admin/themes'); } } diff --git a/src/Module/Admin/Themes/Embed.php b/src/Module/Admin/Themes/Embed.php index 8a7b5c19ea..0ef72773d2 100644 --- a/src/Module/Admin/Themes/Embed.php +++ b/src/Module/Admin/Themes/Embed.php @@ -50,7 +50,7 @@ class Embed extends BaseAdminModule return; } - $a->internalRedirect('admin/themes/' . $theme . '/embed?mode=minimal'); + DI::baseUrl()->redirect('admin/themes/' . $theme . '/embed?mode=minimal'); } } diff --git a/src/Module/Admin/Themes/Index.php b/src/Module/Admin/Themes/Index.php index db6c4bc60b..63b3d6f39e 100644 --- a/src/Module/Admin/Themes/Index.php +++ b/src/Module/Admin/Themes/Index.php @@ -59,7 +59,7 @@ class Index extends BaseAdminModule } - $a->internalRedirect('admin/themes'); + DI::baseUrl()->redirect('admin/themes'); } $themes = []; diff --git a/src/Module/Admin/Tos.php b/src/Module/Admin/Tos.php index 5c7d592253..5e434bc0d0 100644 --- a/src/Module/Admin/Tos.php +++ b/src/Module/Admin/Tos.php @@ -30,7 +30,7 @@ class Tos extends BaseAdminModule info(L10n::t('The Terms of Service settings have been updated.')); - DI::app()->internalRedirect('admin/tos'); + DI::baseUrl()->redirect('admin/tos'); } public static function content(array $parameters = []) diff --git a/src/Module/Admin/Users.php b/src/Module/Admin/Users.php index e6162ae858..7d8574e56b 100644 --- a/src/Module/Admin/Users.php +++ b/src/Module/Admin/Users.php @@ -129,7 +129,7 @@ class Users extends BaseAdminModule } } - $a->internalRedirect('admin/users'); + DI::baseUrl()->redirect('admin/users'); } public static function content(array $parameters = []) @@ -145,7 +145,7 @@ class Users extends BaseAdminModule $user = User::getById($uid, ['username', 'blocked']); if (!DBA::isResult($user)) { notice('User not found' . EOL); - $a->internalRedirect('admin/users'); + DI::baseUrl()->redirect('admin/users'); return ''; // NOTREACHED } @@ -175,7 +175,7 @@ class Users extends BaseAdminModule break; } - $a->internalRedirect('admin/users'); + DI::baseUrl()->redirect('admin/users'); } /* get pending */ diff --git a/src/Module/Apps.php b/src/Module/Apps.php index be0b60f6e1..d7cd0fc72e 100644 --- a/src/Module/Apps.php +++ b/src/Module/Apps.php @@ -18,7 +18,7 @@ class Apps extends BaseModule { $privateaddons = Config::get('config', 'private_addons'); if ($privateaddons === "1" && !local_user()) { - DI::app()->internalRedirect(); + DI::baseUrl()->redirect(); } } diff --git a/src/Module/BaseAdminModule.php b/src/Module/BaseAdminModule.php index 08db0a98c4..3a5cde24c8 100644 --- a/src/Module/BaseAdminModule.php +++ b/src/Module/BaseAdminModule.php @@ -56,7 +56,7 @@ abstract class BaseAdminModule extends BaseModule if (!is_site_admin()) { notice(L10n::t('Please login to continue.')); Session::set('return_path', $a->query_string); - $a->internalRedirect('login'); + DI::baseUrl()->redirect('login'); } if (!empty($_SESSION['submanage'])) { diff --git a/src/Module/Contact.php b/src/Module/Contact.php index d366eaf0bd..45e4900ac2 100644 --- a/src/Module/Contact.php +++ b/src/Module/Contact.php @@ -22,7 +22,6 @@ use Friendica\Model; use Friendica\Module\Security\Login; use Friendica\Network\HTTPException\BadRequestException; use Friendica\Network\HTTPException\NotFoundException; -use Friendica\Network\Probe; use Friendica\Util\DateTimeFormat; use Friendica\Util\Proxy as ProxyUtils; use Friendica\Util\Strings; @@ -34,7 +33,7 @@ use Friendica\Util\Strings; */ class Contact extends BaseModule { - private static function batchActions(App $a) + private static function batchActions() { if (empty($_POST['contact_batch']) || !is_array($_POST['contact_batch'])) { return; @@ -74,7 +73,7 @@ class Contact extends BaseModule info(L10n::tt('%d contact edited.', '%d contacts edited.', $count_actions)); } - $a->internalRedirect('contact'); + DI::baseUrl()->redirect('contact'); } public static function post(array $parameters = []) @@ -87,7 +86,7 @@ class Contact extends BaseModule // @TODO: Replace with parameter from router if ($a->argv[1] === 'batch') { - self::batchActions($a); + self::batchActions(); return; } @@ -99,7 +98,7 @@ class Contact extends BaseModule if (!DBA::exists('contact', ['id' => $contact_id, 'uid' => local_user(), 'deleted' => false])) { notice(L10n::t('Could not access contact record.') . EOL); - $a->internalRedirect('contact'); + DI::baseUrl()->redirect('contact'); return; // NOTREACHED } @@ -280,9 +279,9 @@ class Contact extends BaseModule if ($contact['self']) { // @TODO: Replace with parameter from router if (($a->argc == 3) && intval($a->argv[1]) && in_array($a->argv[2], ['posts', 'conversations'])) { - $a->internalRedirect('profile/' . $contact['nick']); + DI::baseUrl()->redirect('profile/' . $contact['nick']); } else { - $a->internalRedirect('profile/' . $contact['nick'] . '?tab=profile'); + DI::baseUrl()->redirect('profile/' . $contact['nick'] . '?tab=profile'); } } @@ -380,13 +379,13 @@ class Contact extends BaseModule if ($cmd === 'update' && ($orig_record['uid'] != 0)) { self::updateContactFromPoll($contact_id); - $a->internalRedirect('contact/' . $contact_id); + DI::baseUrl()->redirect('contact/' . $contact_id); // NOTREACHED } if ($cmd === 'updateprofile' && ($orig_record['uid'] != 0)) { self::updateContactFromProbe($contact_id); - $a->internalRedirect('crepair/' . $contact_id); + DI::baseUrl()->redirect('crepair/' . $contact_id); // NOTREACHED } @@ -396,7 +395,7 @@ class Contact extends BaseModule $blocked = Model\Contact::isBlockedByUser($contact_id, local_user()); info(($blocked ? L10n::t('Contact has been blocked') : L10n::t('Contact has been unblocked')) . EOL); - $a->internalRedirect('contact/' . $contact_id); + DI::baseUrl()->redirect('contact/' . $contact_id); // NOTREACHED } @@ -406,7 +405,7 @@ class Contact extends BaseModule $ignored = Model\Contact::isIgnoredByUser($contact_id, local_user()); info(($ignored ? L10n::t('Contact has been ignored') : L10n::t('Contact has been unignored')) . EOL); - $a->internalRedirect('contact/' . $contact_id); + DI::baseUrl()->redirect('contact/' . $contact_id); // NOTREACHED } @@ -417,7 +416,7 @@ class Contact extends BaseModule info((($archived) ? L10n::t('Contact has been archived') : L10n::t('Contact has been unarchived')) . EOL); } - $a->internalRedirect('contact/' . $contact_id); + DI::baseUrl()->redirect('contact/' . $contact_id); // NOTREACHED } @@ -451,13 +450,13 @@ class Contact extends BaseModule } // Now check how the user responded to the confirmation query if (!empty($_REQUEST['canceled'])) { - $a->internalRedirect('contact'); + DI::baseUrl()->redirect('contact'); } self::dropContact($orig_record); info(L10n::t('Contact has been removed.') . EOL); - $a->internalRedirect('contact'); + DI::baseUrl()->redirect('contact'); // NOTREACHED } if ($cmd === 'posts') { diff --git a/src/Module/Debug/Feed.php b/src/Module/Debug/Feed.php index 48601d6bb3..9a48d743c8 100644 --- a/src/Module/Debug/Feed.php +++ b/src/Module/Debug/Feed.php @@ -19,7 +19,7 @@ class Feed extends BaseModule { if (!local_user()) { info(L10n::t('You must be logged in to use this module')); - DI::app()->internalRedirect(); + DI::baseUrl()->redirect(); } } diff --git a/src/Module/Delegation.php b/src/Module/Delegation.php index 32d02a00e9..cb2f24ce1e 100644 --- a/src/Module/Delegation.php +++ b/src/Module/Delegation.php @@ -89,7 +89,7 @@ class Delegation extends BaseModule $ret = []; Hook::callAll('home_init', $ret); - DI::app()->internalRedirect('profile/' . DI::app()->user['nickname']); + DI::baseUrl()->redirect('profile/' . DI::app()->user['nickname']); // NOTREACHED } diff --git a/src/Module/Filer/RemoveTag.php b/src/Module/Filer/RemoveTag.php index 5ecaf4c2f9..dfe548d817 100644 --- a/src/Module/Filer/RemoveTag.php +++ b/src/Module/Filer/RemoveTag.php @@ -47,6 +47,6 @@ class RemoveTag extends BaseModule info('Item was not deleted'); } - $app->internalRedirect('network?file=' . rawurlencode($term)); + DI::baseUrl()->redirect('network?file=' . rawurlencode($term)); } } diff --git a/src/Module/Filer/SaveTag.php b/src/Module/Filer/SaveTag.php index 9c0709db90..93f683744e 100644 --- a/src/Module/Filer/SaveTag.php +++ b/src/Module/Filer/SaveTag.php @@ -19,7 +19,7 @@ class SaveTag extends BaseModule { if (!local_user()) { info(L10n::t('You must be logged in to use this module')); - DI::app()->internalRedirect(); + DI::baseUrl()->redirect(); } } diff --git a/src/Module/FollowConfirm.php b/src/Module/FollowConfirm.php index a19f127376..b97b00944c 100644 --- a/src/Module/FollowConfirm.php +++ b/src/Module/FollowConfirm.php @@ -13,8 +13,6 @@ class FollowConfirm extends BaseModule { public static function post(array $parameters = []) { - $a = DI::app(); - $uid = local_user(); if (!$uid) { notice(L10n::t('Permission denied.') . EOL); @@ -33,6 +31,6 @@ class FollowConfirm extends BaseModule $Intro->confirm($duplex, $hidden); - $a->internalRedirect('contact/' . intval($cid)); + DI::baseUrl()->redirect('contact/' . intval($cid)); } } diff --git a/src/Module/Group.php b/src/Module/Group.php index e7e1978986..b3fe1ba53b 100644 --- a/src/Module/Group.php +++ b/src/Module/Group.php @@ -30,7 +30,7 @@ class Group extends BaseModule if (!local_user()) { notice(L10n::t('Permission denied.')); - $a->internalRedirect(); + DI::baseUrl()->redirect(); } // @TODO: Replace with parameter from router @@ -43,12 +43,12 @@ class Group extends BaseModule info(L10n::t('Group created.')); $r = Model\Group::getIdByName(local_user(), $name); if ($r) { - $a->internalRedirect('group/' . $r); + DI::baseUrl()->redirect('group/' . $r); } } else { notice(L10n::t('Could not create group.')); } - $a->internalRedirect('group'); + DI::baseUrl()->redirect('group'); } // @TODO: Replace with parameter from router @@ -58,7 +58,7 @@ class Group extends BaseModule $group = DBA::selectFirst('group', ['id', 'name'], ['id' => $a->argv[1], 'uid' => local_user()]); if (!DBA::isResult($group)) { notice(L10n::t('Group not found.')); - $a->internalRedirect('contact'); + DI::baseUrl()->redirect('contact'); } $groupname = Strings::escapeTags(trim($_POST['groupname'])); if (strlen($groupname) && ($groupname != $group['name'])) { @@ -142,7 +142,7 @@ class Group extends BaseModule // With no group number provided we jump to the unassigned contacts as a starting point // @TODO: Replace with parameter from router if ($a->argc == 1) { - $a->internalRedirect('group/none'); + DI::baseUrl()->redirect('group/none'); } // Switch to text mode interface if we have more than 'n' contacts or group members @@ -200,7 +200,7 @@ class Group extends BaseModule if (intval($a->argv[2])) { if (!Model\Group::exists($a->argv[2], local_user())) { notice(L10n::t('Group not found.')); - $a->internalRedirect('contact'); + DI::baseUrl()->redirect('contact'); } if (Model\Group::remove($a->argv[2])) { @@ -209,7 +209,7 @@ class Group extends BaseModule notice(L10n::t('Unable to remove group.')); } } - $a->internalRedirect('group'); + DI::baseUrl()->redirect('group'); } // @TODO: Replace with parameter from router @@ -226,7 +226,7 @@ class Group extends BaseModule $group = DBA::selectFirst('group', ['id', 'name'], ['id' => $a->argv[1], 'uid' => local_user(), 'deleted' => false]); if (!DBA::isResult($group)) { notice(L10n::t('Group not found.')); - $a->internalRedirect('contact'); + DI::baseUrl()->redirect('contact'); } $members = Model\Contact::getByGroupId($group['id']); diff --git a/src/Module/Home.php b/src/Module/Home.php index f5032f7c30..fc8817b31b 100644 --- a/src/Module/Home.php +++ b/src/Module/Home.php @@ -25,11 +25,11 @@ class Home extends BaseModule Hook::callAll('home_init', $ret); if (local_user() && ($app->user['nickname'])) { - $app->internalRedirect('network'); + DI::baseUrl()->redirect('network'); } if (strlen($config->get('system', 'singleuser'))) { - $app->internalRedirect('/profile/' . $config->get('system', 'singleuser')); + DI::baseUrl()->redirect('/profile/' . $config->get('system', 'singleuser')); } $customHome = ''; diff --git a/src/Module/Item/Ignore.php b/src/Module/Item/Ignore.php index f59ba229c1..b200741665 100644 --- a/src/Module/Item/Ignore.php +++ b/src/Module/Item/Ignore.php @@ -67,7 +67,7 @@ class Ignore extends BaseModule $rand = "?$rand"; } - DI::app()->internalRedirect($return_path . $rand); + DI::baseUrl()->redirect($return_path . $rand); } // the json doesn't really matter, it will either be 0 or 1 diff --git a/src/Module/Like.php b/src/Module/Like.php index 74a0b8d859..2c5f02b1f6 100644 --- a/src/Module/Like.php +++ b/src/Module/Like.php @@ -47,7 +47,7 @@ class Like extends BaseModule $rand = "?$rand"; } - $app->internalRedirect($returnPath . $rand); + DI::baseUrl()->redirect($returnPath . $rand); } } } diff --git a/src/Module/Notifications/Notify.php b/src/Module/Notifications/Notify.php index 5200c59114..bb52ce8124 100644 --- a/src/Module/Notifications/Notify.php +++ b/src/Module/Notifications/Notify.php @@ -58,10 +58,10 @@ class Notify extends BaseModule } } - $a->internalRedirect(); + DI::baseUrl()->redirect(); } // @TODO: Replace with parameter from router - $a->internalRedirect('notifications/system'); + DI::baseUrl()->redirect('notifications/system'); } } diff --git a/src/Module/Objects.php b/src/Module/Objects.php index 4817811a34..4113a545d5 100644 --- a/src/Module/Objects.php +++ b/src/Module/Objects.php @@ -25,7 +25,7 @@ class Objects extends BaseModule } if (!ActivityPub::isRequest()) { - $a->internalRedirect(str_replace('objects/', 'display/', $a->query_string)); + DI::baseUrl()->redirect(str_replace('objects/', 'display/', $a->query_string)); } /// @todo Add Authentication to enable fetching of non public content diff --git a/src/Module/Pinned.php b/src/Module/Pinned.php index 1bd25f2722..b28777516e 100644 --- a/src/Module/Pinned.php +++ b/src/Module/Pinned.php @@ -31,7 +31,7 @@ class Pinned extends BaseModule $returnPath = $_REQUEST['return'] ?? ''; if (!empty($returnPath)) { $rand = '_=' . time() . (strpos($returnPath, '?') ? '&' : '?') . 'rand'; - DI::app()->internalRedirect($returnPath . $rand); + DI::baseUrl()->redirect($returnPath . $rand); } // the json doesn't really matter, it will either be 0 or 1 diff --git a/src/Module/RandomProfile.php b/src/Module/RandomProfile.php index f595ae98ed..c14e9f6cac 100644 --- a/src/Module/RandomProfile.php +++ b/src/Module/RandomProfile.php @@ -23,6 +23,6 @@ class RandomProfile extends BaseModule $a->redirect($link); } - $a->internalRedirect('profile'); + DI::baseUrl()->redirect('profile'); } } diff --git a/src/Module/Register.php b/src/Module/Register.php index 9a6df2f634..2c9b00bf0c 100644 --- a/src/Module/Register.php +++ b/src/Module/Register.php @@ -238,7 +238,7 @@ class Register extends BaseModule if ($res) { \info(L10n::t('Registration successful. Please check your email for further instructions.') . EOL); - $a->internalRedirect(); + DI::baseUrl()->redirect(); } else { \notice( L10n::t('Failed to send email message. Here your accout details:
login: %s
password: %s

You can change your password after login.', @@ -248,12 +248,12 @@ class Register extends BaseModule } } else { \info(L10n::t('Registration successful.') . EOL); - $a->internalRedirect(); + DI::baseUrl()->redirect(); } } elseif (intval(Config::get('config', 'register_policy')) === self::APPROVE) { if (!strlen(Config::get('config', 'admin_email'))) { \notice(L10n::t('Your registration can not be processed.') . EOL); - $a->internalRedirect(); + DI::baseUrl()->redirect(); } // Check if the note to the admin is actually filled out @@ -261,12 +261,12 @@ class Register extends BaseModule \notice(L10n::t('You have to leave a request note for the admin.') . L10n::t('Your registration can not be processed.') . EOL); - $a->internalRedirect('register/'); + DI::baseUrl()->redirect('register/'); } // Is there text in the tar pit? if (!empty($_POST['registertarpit'])) { \notice(L10n::t('You have entered too much information.')); - $a->internalRedirect('register/'); + DI::baseUrl()->redirect('register/'); } Model\Register::createForApproval($user['uid'], Config::get('system', 'language'), $_POST['permonlybox']); @@ -312,7 +312,7 @@ class Register extends BaseModule ); \info(L10n::t('Your registration is pending approval by the site owner.') . EOL); - $a->internalRedirect(); + DI::baseUrl()->redirect(); } return; diff --git a/src/Module/Search/Saved.php b/src/Module/Search/Saved.php index c2d60bc5a3..47925b0ae1 100644 --- a/src/Module/Search/Saved.php +++ b/src/Module/Search/Saved.php @@ -36,6 +36,6 @@ class Saved extends BaseModule } } - DI::app()->internalRedirect($return_url); + DI::baseUrl()->redirect($return_url); } } diff --git a/src/Module/Security/Login.php b/src/Module/Security/Login.php index a049abc882..c525778985 100644 --- a/src/Module/Security/Login.php +++ b/src/Module/Security/Login.php @@ -25,10 +25,8 @@ class Login extends BaseModule { public static function content(array $parameters = []) { - $a = DI::app(); - if (local_user()) { - $a->internalRedirect(); + DI::baseUrl()->redirect(); } return self::form(Session::get('return_path'), intval(Config::get('config', 'register_policy')) !== \Friendica\Module\Register::CLOSED); diff --git a/src/Module/Security/Logout.php b/src/Module/Security/Logout.php index c0a0761087..abe409ca1d 100644 --- a/src/Module/Security/Logout.php +++ b/src/Module/Security/Logout.php @@ -40,7 +40,7 @@ class Logout extends BaseModule System::externalRedirect($visitor_home); } else { info(L10n::t('Logged out.')); - DI::app()->internalRedirect(); + DI::baseUrl()->redirect(); } } } diff --git a/src/Module/Security/TwoFactor/Recovery.php b/src/Module/Security/TwoFactor/Recovery.php index 9a6beb13ad..bbbb2d4451 100644 --- a/src/Module/Security/TwoFactor/Recovery.php +++ b/src/Module/Security/TwoFactor/Recovery.php @@ -52,12 +52,12 @@ class Recovery extends BaseModule public static function content(array $parameters = []) { if (!local_user()) { - DI::app()->internalRedirect(); + DI::baseUrl()->redirect(); } // Already authenticated with 2FA token if (Session::get('2fa')) { - DI::app()->internalRedirect(); + DI::baseUrl()->redirect(); } return Renderer::replaceMacros(Renderer::getMarkupTemplate('twofactor/recovery.tpl'), [ diff --git a/src/Module/Security/TwoFactor/Verify.php b/src/Module/Security/TwoFactor/Verify.php index ff494d7ca0..8fc647472d 100644 --- a/src/Module/Security/TwoFactor/Verify.php +++ b/src/Module/Security/TwoFactor/Verify.php @@ -50,12 +50,12 @@ class Verify extends BaseModule public static function content(array $parameters = []) { if (!local_user()) { - DI::app()->internalRedirect(); + DI::baseUrl()->redirect(); } // Already authenticated with 2FA token if (Session::get('2fa')) { - DI::app()->internalRedirect(); + DI::baseUrl()->redirect(); } return Renderer::replaceMacros(Renderer::getMarkupTemplate('twofactor/verify.tpl'), [ diff --git a/src/Module/Settings/Delegation.php b/src/Module/Settings/Delegation.php index 43d4857463..9884876566 100644 --- a/src/Module/Settings/Delegation.php +++ b/src/Module/Settings/Delegation.php @@ -64,7 +64,7 @@ class Delegation extends BaseSettingsModule if ($action === 'add' && $user_id) { if (Session::get('submanage')) { notice(L10n::t('Delegated administrators can view but not change delegation permissions.')); - DI::app()->internalRedirect('settings/delegation'); + DI::baseUrl()->redirect('settings/delegation'); } $user = User::getById($user_id, ['nickname']); @@ -80,17 +80,17 @@ class Delegation extends BaseSettingsModule notice(L10n::t('Delegate user not found.')); } - DI::app()->internalRedirect('settings/delegation'); + DI::baseUrl()->redirect('settings/delegation'); } if ($action === 'remove' && $user_id) { if (Session::get('submanage')) { notice(L10n::t('Delegated administrators can view but not change delegation permissions.')); - DI::app()->internalRedirect('settings/delegation'); + DI::baseUrl()->redirect('settings/delegation'); } DBA::delete('manage', ['uid' => $user_id, 'mid' => local_user()]); - DI::app()->internalRedirect('settings/delegation'); + DI::baseUrl()->redirect('settings/delegation'); } // find everybody that currently has delegated management to this account/page diff --git a/src/Module/Settings/TwoFactor/AppSpecific.php b/src/Module/Settings/TwoFactor/AppSpecific.php index 1823b56f0d..a303862712 100644 --- a/src/Module/Settings/TwoFactor/AppSpecific.php +++ b/src/Module/Settings/TwoFactor/AppSpecific.php @@ -30,12 +30,12 @@ class AppSpecific extends BaseSettingsModule $verified = PConfig::get(local_user(), '2fa', 'verified'); if (!$verified) { - DI::app()->internalRedirect('settings/2fa'); + DI::baseUrl()->redirect('settings/2fa'); } if (!self::checkFormSecurityToken('settings_2fa_password', 't')) { notice(L10n::t('Please enter your password to access this page.')); - DI::app()->internalRedirect('settings/2fa'); + DI::baseUrl()->redirect('settings/2fa'); } } @@ -53,10 +53,10 @@ class AppSpecific extends BaseSettingsModule $description = $_POST['description'] ?? ''; if (empty($description)) { notice(L10n::t('App-specific password generation failed: The description is empty.')); - DI::app()->internalRedirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password')); + DI::baseUrl()->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password')); } elseif (AppSpecificPassword::checkDuplicateForUser(local_user(), $description)) { notice(L10n::t('App-specific password generation failed: This description already exists.')); - DI::app()->internalRedirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password')); + DI::baseUrl()->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password')); } else { self::$appSpecificPassword = AppSpecificPassword::generateForUser(local_user(), $_POST['description'] ?? ''); notice(L10n::t('New app-specific password generated.')); @@ -66,7 +66,7 @@ class AppSpecific extends BaseSettingsModule case 'revoke_all' : AppSpecificPassword::deleteAllForUser(local_user()); notice(L10n::t('App-specific passwords successfully revoked.')); - DI::app()->internalRedirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password')); + DI::baseUrl()->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password')); break; } } @@ -78,7 +78,7 @@ class AppSpecific extends BaseSettingsModule notice(L10n::t('App-specific password successfully revoked.')); } - DI::app()->internalRedirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password')); + DI::baseUrl()->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password')); } } diff --git a/src/Module/Settings/TwoFactor/Index.php b/src/Module/Settings/TwoFactor/Index.php index 9e822e89ee..06e0e66d51 100644 --- a/src/Module/Settings/TwoFactor/Index.php +++ b/src/Module/Settings/TwoFactor/Index.php @@ -39,7 +39,7 @@ class Index extends BaseSettingsModule PConfig::set(local_user(), '2fa', 'secret', $Google2FA->generateSecretKey(32)); - DI::app()->internalRedirect('settings/2fa/recovery?t=' . self::getFormSecurityToken('settings_2fa_password')); + DI::baseUrl()->redirect('settings/2fa/recovery?t=' . self::getFormSecurityToken('settings_2fa_password')); } break; case 'disable': @@ -50,22 +50,22 @@ class Index extends BaseSettingsModule Session::remove('2fa'); notice(L10n::t('Two-factor authentication successfully disabled.')); - DI::app()->internalRedirect('settings/2fa'); + DI::baseUrl()->redirect('settings/2fa'); } break; case 'recovery': if ($has_secret) { - DI::app()->internalRedirect('settings/2fa/recovery?t=' . self::getFormSecurityToken('settings_2fa_password')); + DI::baseUrl()->redirect('settings/2fa/recovery?t=' . self::getFormSecurityToken('settings_2fa_password')); } break; case 'app_specific': if ($has_secret) { - DI::app()->internalRedirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password')); + DI::baseUrl()->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password')); } break; case 'configure': if (!$verified) { - DI::app()->internalRedirect('settings/2fa/verify?t=' . self::getFormSecurityToken('settings_2fa_password')); + DI::baseUrl()->redirect('settings/2fa/verify?t=' . self::getFormSecurityToken('settings_2fa_password')); } break; } diff --git a/src/Module/Settings/TwoFactor/Recovery.php b/src/Module/Settings/TwoFactor/Recovery.php index 28f839644c..492b96635b 100644 --- a/src/Module/Settings/TwoFactor/Recovery.php +++ b/src/Module/Settings/TwoFactor/Recovery.php @@ -28,12 +28,12 @@ class Recovery extends BaseSettingsModule $secret = PConfig::get(local_user(), '2fa', 'secret'); if (!$secret) { - DI::app()->internalRedirect('settings/2fa'); + DI::baseUrl()->redirect('settings/2fa'); } if (!self::checkFormSecurityToken('settings_2fa_password', 't')) { notice(L10n::t('Please enter your password to access this page.')); - DI::app()->internalRedirect('settings/2fa'); + DI::baseUrl()->redirect('settings/2fa'); } } @@ -49,7 +49,7 @@ class Recovery extends BaseSettingsModule if ($_POST['action'] == 'regenerate') { RecoveryCode::regenerateForUser(local_user()); notice(L10n::t('New recovery codes successfully generated.')); - DI::app()->internalRedirect('settings/2fa/recovery?t=' . self::getFormSecurityToken('settings_2fa_password')); + DI::baseUrl()->redirect('settings/2fa/recovery?t=' . self::getFormSecurityToken('settings_2fa_password')); } } } diff --git a/src/Module/Settings/TwoFactor/Verify.php b/src/Module/Settings/TwoFactor/Verify.php index b478632620..96feab825a 100644 --- a/src/Module/Settings/TwoFactor/Verify.php +++ b/src/Module/Settings/TwoFactor/Verify.php @@ -35,12 +35,12 @@ class Verify extends BaseSettingsModule $verified = PConfig::get(local_user(), '2fa', 'verified'); if ($secret && $verified) { - DI::app()->internalRedirect('settings/2fa'); + DI::baseUrl()->redirect('settings/2fa'); } if (!self::checkFormSecurityToken('settings_2fa_password', 't')) { notice(L10n::t('Please enter your password to access this page.')); - DI::app()->internalRedirect('settings/2fa'); + DI::baseUrl()->redirect('settings/2fa'); } } @@ -63,7 +63,7 @@ class Verify extends BaseSettingsModule notice(L10n::t('Two-factor authentication successfully activated.')); - DI::app()->internalRedirect('settings/2fa'); + DI::baseUrl()->redirect('settings/2fa'); } else { notice(L10n::t('Invalid code, please retry.')); } diff --git a/src/Module/Starred.php b/src/Module/Starred.php index d6ec19ea73..0f111b21e0 100644 --- a/src/Module/Starred.php +++ b/src/Module/Starred.php @@ -36,7 +36,7 @@ class Starred extends BaseModule $returnPath = $_REQUEST['return'] ?? ''; if (!empty($returnPath)) { $rand = '_=' . time() . (strpos($returnPath, '?') ? '&' : '?') . 'rand'; - DI::app()->internalRedirect($returnPath . $rand); + DI::baseUrl()->redirect($returnPath . $rand); } // the json doesn't really matter, it will either be 0 or 1 diff --git a/src/Module/Tos.php b/src/Module/Tos.php index 7adce79174..b28c98de7b 100644 --- a/src/Module/Tos.php +++ b/src/Module/Tos.php @@ -51,7 +51,7 @@ class Tos extends BaseModule public static function init(array $parameters = []) { if (strlen(Config::get('system','singleuser'))) { - DI::app()->internalRedirect('profile/' . Config::get('system','singleuser')); + DI::baseUrl()->redirect('profile/' . Config::get('system','singleuser')); } }