From 2ff67ef5ed7e67d048fb54e1d2af8de49b84434f Mon Sep 17 00:00:00 2001
From: rabuzarus <>
Date: Thu, 4 Jun 2015 04:19:06 +0200
Subject: [PATCH] fixes like/dislike for photos
---
include/conversation.php | 4 ++--
mod/photos.php | 20 ++++++++++++++++----
object/Item.php | 1 +
3 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/include/conversation.php b/include/conversation.php
index 492447087..0199bee5a 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -1364,8 +1364,8 @@ function get_responses($conv_responses,$response_verbs,$ob,$item) {
if(count($ret[$v]['list']) > MAX_LIKERS) {
$ret[$v]['list_part'] = array_slice($ret[$v]['list'], 0, MAX_LIKERS);
array_push($ret[$v]['list_part'], '' . t('View all') . '');
- }
+ . (($ob) ? $ob->get_id() : $item['id']) . '">' . t('View all') . '');
+ }
else {
$ret[$v]['list_part'] = '';
}
diff --git a/mod/photos.php b/mod/photos.php
index a19cfaaa7..2454f5d51 100644
--- a/mod/photos.php
+++ b/mod/photos.php
@@ -1601,18 +1601,23 @@ function photos_content(&$a) {
$like = '';
$dislike = '';
+ $conv_responses = array(
+ 'like' => array('title' => t('Likes','title')),'dislike' => array('title' => t('Dislikes','title')),
+ 'agree' => array('title' => t('Agree','title')),'disagree' => array('title' => t('Disagree','title')), 'abstain' => array('title' => t('Abstain','title')),
+ 'attendyes' => array('title' => t('Attending','title')), 'attendno' => array('title' => t('Not attending','title')), 'attendmaybe' => array('title' => t('Might attend','title'))
+ );
+
// display comments
if(count($r)) {
foreach($r as $item) {
- like_puller($a,$item,$alike,'like');
- like_puller($a,$item,$dlike,'dislike');
+ builtin_activity_puller($item, $conv_responses);
}
- $like = ((isset($alike[$link_item['id']])) ? format_like($alike[$link_item['id']],$alike[$link_item['id'] . '-l'],'like',$link_item['id']) : '');
- $dislike = ((isset($dlike[$link_item['id']])) ? format_like($dlike[$link_item['id']],$dlike[$link_item['id'] . '-l'],'dislike',$link_item['id']) : '');
+ $like = ((x($conv_responses['like'],$link_item['uri'])) ? format_like($conv_responses['like'][$link_item['uri']],$conv_responses['like'][$link_item['uri'] . '-l'],'like',$link_item['id']) : '');
+ $dislike = ((x($conv_responses['dislike'],$link_item['uri'])) ? format_like($conv_responses['dislike'][$link_item['uri']],$conv_responses['dislike'][$link_item['uri'] . '-l'],'dislike',$link_item['id']) : '');
@@ -1731,6 +1736,12 @@ function photos_content(&$a) {
$paginate = paginate($a);
}
+
+ $response_verbs = array('like');
+ if(feature_enabled($owner_uid,'dislike'))
+ $response_verbs[] = 'dislike';
+ $responses = get_responses($conv_responses,$response_verbs,'',$link_item);
+
$photo_tpl = get_markup_template('photo_view.tpl');
if($a->theme['template_engine'] === 'internal') {
@@ -1760,6 +1771,7 @@ function photos_content(&$a) {
'$likebuttons' => $likebuttons,
'$like' => $like_e,
'$dislike' => $dikslike_e,
+ 'responses' => $responses,
'$comments' => $comments,
'$paginate' => $paginate,
));
diff --git a/object/Item.php b/object/Item.php
index d27be50ee..8b51f420c 100644
--- a/object/Item.php
+++ b/object/Item.php
@@ -177,6 +177,7 @@ class Item extends BaseObject {
// process action responses - e.g. like/dislike/attend/agree/whatever
$response_verbs = array('like');
+ if(feature_enabled($conv->get_profile_owner(),'dislike'))
$response_verbs[] = 'dislike';
if($item['object-type'] === ACTIVITY_OBJ_EVENT) {
$response_verbs[] = 'attendyes';