From 0a699be3c0d505762f24843c3939fe97ad300563 Mon Sep 17 00:00:00 2001 From: Jonny Tischbein Date: Sun, 30 Sep 2018 19:03:05 +0200 Subject: [PATCH 1/6] replace session return url by static pages --- mod/follow.php | 10 ++++++---- mod/unfollow.php | 12 +++++++----- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/mod/follow.php b/mod/follow.php index 627ab52033..f70a8610e4 100644 --- a/mod/follow.php +++ b/mod/follow.php @@ -25,7 +25,7 @@ function follow_post(App $a) $uid = local_user(); $url = notags(trim($_REQUEST['url'])); - $return_url = $_SESSION['return_url']; + $return_url = 'contacts'; // Makes the connection request for friendica contacts easier // This is just a precaution if maybe this page is called somewhere directly via POST @@ -39,7 +39,7 @@ function follow_post(App $a) } goaway($return_url); } elseif ($result['cid']) { - goaway(System::baseUrl() . '/contacts/' . $result['cid']); + goaway('contacts/' . $result['cid']); } info(L10n::t('The contact could not be added.')); @@ -50,9 +50,11 @@ function follow_post(App $a) function follow_content(App $a) { + $return_url = 'contacts'; + if (!local_user()) { notice(L10n::t('Permission denied.')); - goaway($_SESSION['return_url']); + goaway($return_url); // NOTREACHED } @@ -116,7 +118,7 @@ function follow_content(App $a) if (!$r) { notice(L10n::t('Permission denied.')); - goaway($_SESSION['return_url']); + goaway($return_url); // NOTREACHED } diff --git a/mod/unfollow.php b/mod/unfollow.php index b80263a3ec..61f99ee489 100644 --- a/mod/unfollow.php +++ b/mod/unfollow.php @@ -14,7 +14,7 @@ use Friendica\Model\User; function unfollow_post() { - $return_url = $_SESSION['return_url']; + $return_url = 'contacts'; if (!local_user()) { notice(L10n::t('Permission denied.')); @@ -42,7 +42,7 @@ function unfollow_post() if (!in_array($contact['network'], Protocol::NATIVE_SUPPORT)) { notice(L10n::t('Unfollowing is currently not supported by your network.')); - goaway($return_url); + goaway($return_url.'/'.$contact['id']); // NOTREACHED } @@ -69,9 +69,11 @@ function unfollow_post() function unfollow_content(App $a) { + $return_url = 'contacts'; + if (!local_user()) { notice(L10n::t('Permission denied.')); - goaway($_SESSION['return_url']); + goaway($return_url); // NOTREACHED } @@ -86,7 +88,7 @@ function unfollow_content(App $a) if (!DBA::isResult($contact)) { notice(L10n::t("You aren't following this contact.")); - goaway('contacts'); + goaway($return_url); // NOTREACHED } @@ -103,7 +105,7 @@ function unfollow_content(App $a) if (!DBA::isResult($self)) { notice(L10n::t('Permission denied.')); - goaway($_SESSION['return_url']); + goaway($return_url); // NOTREACHED } From 57fe36e9a3e414b21544335dad4484193edc36ae Mon Sep 17 00:00:00 2001 From: Jonny Tischbein Date: Sun, 30 Sep 2018 19:26:29 +0200 Subject: [PATCH 2/6] replace session return url by static pages --- mod/contacts.php | 19 ++++--------------- mod/follow.php | 2 +- mod/message.php | 8 +++----- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/mod/contacts.php b/mod/contacts.php index 1604f0b660..fb57ce6aee 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -168,11 +168,7 @@ function contacts_batch_actions(App $a) info(L10n::tt("%d contact edited.", "%d contacts edited.", $count_actions)); } - if (x($_SESSION, 'return_url')) { - goaway('' . $_SESSION['return_url']); - } else { - goaway('contacts'); - } + goaway('contacts'); } function contacts_post(App $a) @@ -476,20 +472,13 @@ function contacts_content(App $a, $update = 0) } // Now check how the user responded to the confirmation query if (x($_REQUEST, 'canceled')) { - if (x($_SESSION, 'return_url')) { - goaway('' . $_SESSION['return_url']); - } else { - goaway('contacts'); - } + goaway('contacts'); } _contact_drop($orig_record); info(L10n::t('Contact has been removed.') . EOL); - if (x($_SESSION, 'return_url')) { - goaway('' . $_SESSION['return_url']); - } else { - goaway('contacts'); - } + + goaway('contacts'); return; // NOTREACHED } if ($cmd === 'posts') { diff --git a/mod/follow.php b/mod/follow.php index f70a8610e4..04c279c5b6 100644 --- a/mod/follow.php +++ b/mod/follow.php @@ -20,7 +20,7 @@ function follow_post(App $a) } if (isset($_REQUEST['cancel'])) { - goaway($_SESSION['return_url']); + goaway('contacts'); } $uid = local_user(); diff --git a/mod/message.php b/mod/message.php index d0a583967b..e2380fdb5c 100644 --- a/mod/message.php +++ b/mod/message.php @@ -160,7 +160,7 @@ function message_content(App $a) // Now check how the user responded to the confirmation query if (!empty($_REQUEST['canceled'])) { - goaway($_SESSION['return_url']); + goaway('/message'); } $cmd = $a->argv[1]; @@ -169,8 +169,7 @@ function message_content(App $a) info(L10n::t('Message deleted.') . EOL); } - //goaway(System::baseUrl(true) . '/message' ); - goaway($_SESSION['return_url']); + goaway('/message' ); } else { $r = q("SELECT `parent-uri`,`convid` FROM `mail` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($a->argv[2]), @@ -184,8 +183,7 @@ function message_content(App $a) info(L10n::t('Conversation removed.') . EOL); } } - //goaway(System::baseUrl(true) . '/message' ); - goaway($_SESSION['return_url']); + goaway('/message' ); } } From 9915523490e6547e9f6971884a7f502cc90d897a Mon Sep 17 00:00:00 2001 From: Jonny Tischbein Date: Tue, 2 Oct 2018 13:16:43 +0200 Subject: [PATCH 3/6] mod/message return to conversation if message deleted --- mod/message.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/mod/message.php b/mod/message.php index e2380fdb5c..bf1895f67d 100644 --- a/mod/message.php +++ b/mod/message.php @@ -165,11 +165,23 @@ function message_content(App $a) $cmd = $a->argv[1]; if ($cmd === 'drop') { + $r = DBA::SelectFirst('mail', ['convid'], ['id' => $a->argv[2], 'uid' => local_user()]); + if(!DBA::isResult($r)){ + info(L10n::t('Conversation not founded.') . EOL); + goaway('/message'); + } + if (DBA::delete('mail', ['id' => $a->argv[2], 'uid' => local_user()])) { info(L10n::t('Message deleted.') . EOL); } - goaway('/message' ); + $rr = DBA::SelectFirst('mail', ['id'], ['convid' => $r['convid'], 'uid' => local_user()]); + if(!DBA::isResult($rr)){ + info(L10n::t('Conversation removed.') . EOL); + goaway('/message'); + } + + goaway('/message/'.$rr['id'] ); } else { $r = q("SELECT `parent-uri`,`convid` FROM `mail` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($a->argv[2]), From fa3bbc5f4575eb8cd97026d6dc3d87d44b72422d Mon Sep 17 00:00:00 2001 From: Jonny Tischbein Date: Tue, 2 Oct 2018 18:13:58 +0200 Subject: [PATCH 4/6] Code Standards + return path for \!local_user() and cancel --- mod/message.php | 10 +++++----- mod/unfollow.php | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/mod/message.php b/mod/message.php index bf1895f67d..4a569155b5 100644 --- a/mod/message.php +++ b/mod/message.php @@ -165,9 +165,9 @@ function message_content(App $a) $cmd = $a->argv[1]; if ($cmd === 'drop') { - $r = DBA::SelectFirst('mail', ['convid'], ['id' => $a->argv[2], 'uid' => local_user()]); + $message = DBA::selectFirst('mail', ['convid'], ['id' => $a->argv[2], 'uid' => local_user()]); if(!DBA::isResult($r)){ - info(L10n::t('Conversation not founded.') . EOL); + info(L10n::t('Conversation not found.') . EOL); goaway('/message'); } @@ -175,13 +175,13 @@ function message_content(App $a) info(L10n::t('Message deleted.') . EOL); } - $rr = DBA::SelectFirst('mail', ['id'], ['convid' => $r['convid'], 'uid' => local_user()]); - if(!DBA::isResult($rr)){ + $conversation = DBA::selectFirst('mail', ['id'], ['convid' => $message['convid'], 'uid' => local_user()]); + if(!DBA::isResult($conversation)){ info(L10n::t('Conversation removed.') . EOL); goaway('/message'); } - goaway('/message/'.$rr['id'] ); + goaway('/message/' . $conversation'id'] ); } else { $r = q("SELECT `parent-uri`,`convid` FROM `mail` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($a->argv[2]), diff --git a/mod/unfollow.php b/mod/unfollow.php index 61f99ee489..9b0e206904 100644 --- a/mod/unfollow.php +++ b/mod/unfollow.php @@ -18,14 +18,10 @@ function unfollow_post() if (!local_user()) { notice(L10n::t('Permission denied.')); - goaway($return_url); + goaway('/login'); // NOTREACHED } - if (!empty($_REQUEST['cancel'])) { - goaway($return_url); - } - $uid = local_user(); $url = notags(trim(defaults($_REQUEST, 'url', ''))); @@ -40,9 +36,13 @@ function unfollow_post() // NOTREACHED } + if (!empty($_REQUEST['cancel'])) { + goaway($return_url . '/' . $contact['id']); + } + if (!in_array($contact['network'], Protocol::NATIVE_SUPPORT)) { notice(L10n::t('Unfollowing is currently not supported by your network.')); - goaway($return_url.'/'.$contact['id']); + goaway($return_url . '/' . $contact['id']); // NOTREACHED } @@ -73,7 +73,7 @@ function unfollow_content(App $a) if (!local_user()) { notice(L10n::t('Permission denied.')); - goaway($return_url); + goaway('/login'); // NOTREACHED } From ecb67cfcb465e3d5a987f20647bd17e81256d8b2 Mon Sep 17 00:00:00 2001 From: Jonny Tischbein Date: Tue, 2 Oct 2018 18:22:23 +0200 Subject: [PATCH 5/6] syntax typo --- mod/message.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod/message.php b/mod/message.php index 4a569155b5..38a9ecd9c2 100644 --- a/mod/message.php +++ b/mod/message.php @@ -181,7 +181,7 @@ function message_content(App $a) goaway('/message'); } - goaway('/message/' . $conversation'id'] ); + goaway('/message/' . $conversation['id'] ); } else { $r = q("SELECT `parent-uri`,`convid` FROM `mail` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($a->argv[2]), From 6d1b98dc0e951445e447a60d3ee17368891d17b8 Mon Sep 17 00:00:00 2001 From: Jonny Tischbein Date: Tue, 2 Oct 2018 18:24:16 +0200 Subject: [PATCH 6/6] wrong var name - conversation not found --- mod/message.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod/message.php b/mod/message.php index 38a9ecd9c2..264912da67 100644 --- a/mod/message.php +++ b/mod/message.php @@ -166,7 +166,7 @@ function message_content(App $a) $cmd = $a->argv[1]; if ($cmd === 'drop') { $message = DBA::selectFirst('mail', ['convid'], ['id' => $a->argv[2], 'uid' => local_user()]); - if(!DBA::isResult($r)){ + if(!DBA::isResult($message)){ info(L10n::t('Conversation not found.') . EOL); goaway('/message'); }