From 0cb81714d80e3d51dc4939664425b7d1978b5d06 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 17 Jul 2014 19:07:39 -0700 Subject: better handling of interactive likes --- mod/like.php | 27 ++++++++++++++------------- mod/rmagic.php | 6 +++++- 2 files changed, 19 insertions(+), 14 deletions(-) (limited to 'mod') diff --git a/mod/like.php b/mod/like.php index d0871f1be..f4feca279 100755 --- a/mod/like.php +++ b/mod/like.php @@ -7,13 +7,16 @@ require_once('include/items.php'); function like_content(&$a) { + $o = ''; $observer = $a->get_observer(); $interactive = $_REQUEST['interactive']; if($interactive) { + $o .= '

' . t('Like/Dislike') . '

'; + $o .= EOL . EOL; + if(! $observer) { - $o .= '

' . t('Like/Dislike') . '

'; - $o .= EOL . EOL; + $_SESSION['return_url'] = $a->query_string; $o .= t('This action is restricted to members.') . EOL; $o .= t('Please login with your RedMatrix ID or register as a new RedMatrix member to continue.') . EOL; return $o; @@ -72,7 +75,7 @@ function like_content(&$a) { // forgery - illegal if($interactive) { notice( t('Invalid request.') . EOL); - return; + return $o; } killme(); } @@ -99,7 +102,7 @@ function like_content(&$a) { if(! $r) { if($interactive) { notice( t('Invalid request.') . EOL); - return; + return $o; } killme(); } @@ -137,7 +140,7 @@ function like_content(&$a) { if(! ($owner_uid && $r)) { if($interactive) { notice( t('Invalid request.') . EOL); - return; + return $o; } killme(); } @@ -149,7 +152,7 @@ function like_content(&$a) { if(! ($perms['post_wall'] && $perms['view_profile'])) { if($interactive) { notice( t('Permission denied.') . EOL); - return; + return $o; } killme(); } @@ -160,7 +163,7 @@ function like_content(&$a) { if(! $ch) { if($interactive) { notice( t('Channel unavailable.') . EOL); - return; + return $o; } killme(); } @@ -199,7 +202,7 @@ function like_content(&$a) { drop_item($z[0]['iid'],false); if($interactive) { notice( t('Previous action reversed.') . EOL); - return; + return $o; } killme(); } @@ -411,11 +414,9 @@ function like_content(&$a) { proc_run('php',"include/notifier.php","like","$post_id"); if($interactive) { - notice( t('Action completed.') . EOL); - $o .= '

' . t('Like/Dislike') . '

'; - $o .= EOL . EOL; - $o .= t('Thank you.'); - return $o; + notice( t('Action completed.') . EOL); + $o .= t('Thank you.'); + return $o; } killme(); diff --git a/mod/rmagic.php b/mod/rmagic.php index 946277327..de81cdcde 100644 --- a/mod/rmagic.php +++ b/mod/rmagic.php @@ -65,7 +65,11 @@ function rmagic_post(&$a) { } if($url) { - $dest = z_root() . '/' . str_replace('zid=','zid_=',$a->query_string); + if($_SESSION['return_url']) + $dest = urlencode(z_root() . '/' . str_replace('zid=','zid_=',$_SESSION['return_url'])); + else + $dest = urlencode(z_root() . '/' . str_replace('zid=','zid_=',$a->query_string)); + goaway($url . '/magic' . '?f=&dest=' . $dest); } } -- cgit v1.2.3