From bfe4bdc30badbb91a352380e0b38bf8f18e296b6 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 17 Jul 2014 18:20:12 -0700 Subject: make mod_like interactive if requested --- mod/like.php | 49 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 6 deletions(-) (limited to 'mod/like.php') diff --git a/mod/like.php b/mod/like.php index ececb31c7..55a436175 100755 --- a/mod/like.php +++ b/mod/like.php @@ -9,6 +9,16 @@ function like_content(&$a) { $observer = $a->get_observer(); + $interactive = $_REQUEST['interactive']; + if($interactive) { + if(! $observer) { + $o .= '

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

'; + $o .= EOL . EOL; + $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; + } + } $verb = notags(trim($_GET['verb'])); @@ -60,6 +70,10 @@ function like_content(&$a) { ); if(! $d) { // forgery - illegal + if($interactive) { + notice( t('Invalid request.') . EOL); + return; + } killme(); } // $d now contains a list of those who can see this profile - only send the status notification @@ -82,8 +96,13 @@ function like_content(&$a) { dbesc(argv(2)) ); - if(! $r) + if(! $r) { + if($interactive) { + notice( t('Invalid request.') . EOL); + return; + } killme(); + } $owner_uid = $r[0]['obj_channel']; @@ -115,23 +134,37 @@ function like_content(&$a) { } - if(! ($owner_uid && $r)) + if(! ($owner_uid && $r)) { + if($interactive) { + notice( t('Invalid request.') . EOL); + return; + } killme(); + } // The resultant activity is going to be a wall-to-wall post, so make sure this is allowed $perms = get_all_perms($owner_uid,$observer['xchan_hash']); - if(! ($perms['post_wall'] && $perms['view_profile'])) + if(! ($perms['post_wall'] && $perms['view_profile'])) { + if($interactive) { + notice( t('Permission denied.') . EOL); + return; + } killme(); + } $ch = q("select * from channel left join xchan on channel_hash = xchan_hash where channel_id = %d limit 1", intval($owner_uid) ); - if(! $ch) + if(! $ch) { + if($interactive) { + notice( t('Channel unavailable.') . EOL); + return; + } killme(); - - + } + if(! $plink) $plink = '[zrl=' . z_root() . '/profile/' . $ch[0]['channel_address'] . ']' . $post_type . '[/zrl]'; @@ -164,6 +197,10 @@ function like_content(&$a) { intval($z[0]['id']) ); drop_item($z[0]['iid'],false); + if($interactive) { + notice( t('Previous action reversed.') . EOL); + return; + } killme(); } } -- cgit v1.2.3