Skip to content

Commit

Permalink
Non friend may able to add like to friend photo only [huntr.dev] #1979
Browse files Browse the repository at this point in the history
  • Loading branch information
lianglee committed Jul 22, 2021
1 parent 6bcc654 commit 17e951b
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions components/OssnPhotos/ossn_com.php
Expand Up @@ -85,22 +85,23 @@ function ossn_photos_initialize(){
'icon' => $icon,
));
//Non friend may able to add comment to friend photo only [huntr.dev] #1979
ossn_register_callback('comment', 'before:created', 'ossn_photos_comment_permission_check');
ossn_register_callback('comment', 'before:created', 'ossn_photos_like_comment_permission_check');
ossn_register_callback('like', 'before:created', 'ossn_photos_like_comment_permission_check');
}
//gallery plugin dist include
ossn_new_external_js('jquery.fancybox.min.js', '//cdnjs.cloudflare.com/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.js', false);
ossn_new_external_css('jquery.fancybox.min.css', '//cdnjs.cloudflare.com/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.css', false);
}
/**
* Comment photos check before comment
* Like & Comment on photos check before like & comment
*
* @param string $callback comment
* @param string $type before:created
* @param array $params option values
*
* @access private
*/
function ossn_photos_comment_permission_check($callback, $type, $params){
function ossn_photos_like_comment_permission_check($callback, $type, $params){
if(isset($params['type']) && $params['type'] == 'entity'){
if(isset($params['entity']) && isset($params['entity']->subtype) && $params['entity']->subtype == 'file:ossn:aphoto'){
$album = ossn_get_object($params['entity']->owner_guid);
Expand All @@ -112,9 +113,18 @@ function ossn_photos_comment_permission_check($callback, $type, $params){
redirect(REF);
} else {
header('Content-Type: application/json');
echo json_encode(array(
'process' => 0,
));
if($callback == 'comment'){
echo json_encode(array(
'process' => 0,
));
}
if($callback == 'like'){
echo json_encode(array(
'done' => 0,
'container' => false,
'button' => ossn_print('ossn:like'),
));
}
exit();
}
}
Expand Down Expand Up @@ -598,6 +608,7 @@ function ossn_album_page_handler($album){
'text' => ossn_print('back'),
'href' => ossn_site_url("u/{$user['user']->username}/photos"),
'class' => 'button-grey',

);
$control = ossn_plugin_view('output/url', $back);
//view profile photos in module layout
Expand Down

0 comments on commit 17e951b

Please sign in to comment.