better handling of interactive likes

This commit is contained in:
friendica 2014-07-17 19:07:39 -07:00
parent 39632f65b6
commit 0cb81714d8
2 changed files with 19 additions and 14 deletions

View File

@ -7,13 +7,16 @@ require_once('include/items.php');
function like_content(&$a) { function like_content(&$a) {
$o = '';
$observer = $a->get_observer(); $observer = $a->get_observer();
$interactive = $_REQUEST['interactive']; $interactive = $_REQUEST['interactive'];
if($interactive) { if($interactive) {
if(! $observer) {
$o .= '<h1>' . t('Like/Dislike') . '</h1>'; $o .= '<h1>' . t('Like/Dislike') . '</h1>';
$o .= EOL . EOL; $o .= EOL . EOL;
if(! $observer) {
$_SESSION['return_url'] = $a->query_string;
$o .= t('This action is restricted to members.') . EOL; $o .= t('This action is restricted to members.') . EOL;
$o .= t('Please <a href="rmagic">login with your RedMatrix ID</a> or <a href="register">register as a new RedMatrix member</a> to continue.') . EOL; $o .= t('Please <a href="rmagic">login with your RedMatrix ID</a> or <a href="register">register as a new RedMatrix member</a> to continue.') . EOL;
return $o; return $o;
@ -72,7 +75,7 @@ function like_content(&$a) {
// forgery - illegal // forgery - illegal
if($interactive) { if($interactive) {
notice( t('Invalid request.') . EOL); notice( t('Invalid request.') . EOL);
return; return $o;
} }
killme(); killme();
} }
@ -99,7 +102,7 @@ function like_content(&$a) {
if(! $r) { if(! $r) {
if($interactive) { if($interactive) {
notice( t('Invalid request.') . EOL); notice( t('Invalid request.') . EOL);
return; return $o;
} }
killme(); killme();
} }
@ -137,7 +140,7 @@ function like_content(&$a) {
if(! ($owner_uid && $r)) { if(! ($owner_uid && $r)) {
if($interactive) { if($interactive) {
notice( t('Invalid request.') . EOL); notice( t('Invalid request.') . EOL);
return; return $o;
} }
killme(); killme();
} }
@ -149,7 +152,7 @@ function like_content(&$a) {
if(! ($perms['post_wall'] && $perms['view_profile'])) { if(! ($perms['post_wall'] && $perms['view_profile'])) {
if($interactive) { if($interactive) {
notice( t('Permission denied.') . EOL); notice( t('Permission denied.') . EOL);
return; return $o;
} }
killme(); killme();
} }
@ -160,7 +163,7 @@ function like_content(&$a) {
if(! $ch) { if(! $ch) {
if($interactive) { if($interactive) {
notice( t('Channel unavailable.') . EOL); notice( t('Channel unavailable.') . EOL);
return; return $o;
} }
killme(); killme();
} }
@ -199,7 +202,7 @@ function like_content(&$a) {
drop_item($z[0]['iid'],false); drop_item($z[0]['iid'],false);
if($interactive) { if($interactive) {
notice( t('Previous action reversed.') . EOL); notice( t('Previous action reversed.') . EOL);
return; return $o;
} }
killme(); killme();
} }
@ -412,8 +415,6 @@ function like_content(&$a) {
if($interactive) { if($interactive) {
notice( t('Action completed.') . EOL); notice( t('Action completed.') . EOL);
$o .= '<h1>' . t('Like/Dislike') . '</h1>';
$o .= EOL . EOL;
$o .= t('Thank you.'); $o .= t('Thank you.');
return $o; return $o;
} }

View File

@ -65,7 +65,11 @@ function rmagic_post(&$a) {
} }
if($url) { 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); goaway($url . '/magic' . '?f=&dest=' . $dest);
} }
} }