From 9eeff0d891a4618200e8abfad8bef65b9712dfed Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 22 Feb 2015 17:34:04 +0100 Subject: [PATCH 1/2] Received "likes" and "dislikes" don't update the "commented" value anymore. --- include/items.php | 18 ++++++++++++------ mod/network.php | 6 +++--- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/include/items.php b/include/items.php index 3a9d850d4..53bacbcd0 100644 --- a/include/items.php +++ b/include/items.php @@ -1434,12 +1434,18 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa $arr['deleted'] = $parent_deleted; // update the commented timestamp on the parent - - q("UPDATE `item` set `commented` = '%s', `changed` = '%s' WHERE `id` = %d", - dbesc(datetime_convert()), - dbesc(datetime_convert()), - intval($parent_id) - ); + // Only update "commented" if it is really a comment + if ($arr['verb'] == ACTIVITY_POST) + q("UPDATE `item` SET `commented` = '%s', `changed` = '%s' WHERE `id` = %d", + dbesc(datetime_convert()), + dbesc(datetime_convert()), + intval($parent_id) + ); + else + q("UPDATE `item` SET `changed` = '%s' WHERE `id` = %d", + dbesc(datetime_convert()), + intval($parent_id) + ); if($dsprsig) { q("insert into sign (`iid`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ", diff --git a/mod/network.php b/mod/network.php index a28840dae..fb980f31b 100644 --- a/mod/network.php +++ b/mod/network.php @@ -22,7 +22,7 @@ function network_init(&$a) { parse_str($query_string, $query_array); array_shift($query_array); - + // fetch last used network view and redirect if needed if(! $is_a_date_query) { $sel_tabs = network_query_get_sel_tab($a); @@ -708,12 +708,12 @@ die("ss"); $r = q("SELECT `item`.`parent` AS `item_id`, `item`.`network` AS `item_network`, `contact`.`uid` AS `contact_uid` FROM $sql_table $sql_post_table INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 - WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND - (`item`.`deleted` = 0 OR `item`.`verb` = '" . ACTIVITY_LIKE ."' OR `item`.`verb` = '" . ACTIVITY_DISLIKE . "') + WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 and `item`.`unseen` = 1 $sql_extra3 $sql_extra $sql_nets ORDER BY `item_id` DESC LIMIT 100", intval(local_user()) ); + // (`item`.`deleted` = 0 OR `item`.`verb` = '" . ACTIVITY_LIKE ."' OR `item`.`verb` = '" . ACTIVITY_DISLIKE . "') } else { $r = q("SELECT `thread`.`iid` AS `item_id`, `thread`.`network` AS `item_network`, `contact`.`uid` AS `contact_uid` FROM $sql_table $sql_post_table STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id` From 440e2d82b16abde01ff931753ba3c27a09ac8ae6 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Mon, 23 Feb 2015 12:44:50 +0100 Subject: [PATCH 2/2] Global setting for the behaviour of likes. --- include/items.php | 2 +- mod/network.php | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/include/items.php b/include/items.php index 53bacbcd0..dd4021775 100644 --- a/include/items.php +++ b/include/items.php @@ -1435,7 +1435,7 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa // update the commented timestamp on the parent // Only update "commented" if it is really a comment - if ($arr['verb'] == ACTIVITY_POST) + if (($arr['verb'] == ACTIVITY_POST) OR !get_config("system", "like_no_comment")) q("UPDATE `item` SET `commented` = '%s', `changed` = '%s' WHERE `id` = %d", dbesc(datetime_convert()), dbesc(datetime_convert()), diff --git a/mod/network.php b/mod/network.php index fb980f31b..c180252f4 100644 --- a/mod/network.php +++ b/mod/network.php @@ -705,15 +705,19 @@ die("ss"); // Fetch a page full of parent items for this page if($update) { + if (!get_config("system", "like_no_comment")) + $sql_extra4 = "(`item`.`deleted` = 0 OR `item`.`verb` = '".ACTIVITY_LIKE."' OR `item`.`verb` = '".ACTIVITY_DISLIKE."')"; + else + $sql_extra4 = "`item`.`deleted` = 0"; + $r = q("SELECT `item`.`parent` AS `item_id`, `item`.`network` AS `item_network`, `contact`.`uid` AS `contact_uid` FROM $sql_table $sql_post_table INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 - WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 - and `item`.`moderated` = 0 and `item`.`unseen` = 1 + WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND $sql_extra4 + AND `item`.`moderated` = 0 AND `item`.`unseen` = 1 $sql_extra3 $sql_extra $sql_nets ORDER BY `item_id` DESC LIMIT 100", intval(local_user()) ); - // (`item`.`deleted` = 0 OR `item`.`verb` = '" . ACTIVITY_LIKE ."' OR `item`.`verb` = '" . ACTIVITY_DISLIKE . "') } else { $r = q("SELECT `thread`.`iid` AS `item_id`, `thread`.`network` AS `item_network`, `contact`.`uid` AS `contact_uid` FROM $sql_table $sql_post_table STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`