From c0ad4763b30238aead8f1187efd669080c52a149 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 17 Nov 2014 15:18:06 -0800 Subject: add unseen count and way to mark unseen to list mode. Also fix automatic mark of unseen so as to work with list mode. --- include/ItemObject.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'include') diff --git a/include/ItemObject.php b/include/ItemObject.php index 4aa6857c1..6f1c76fa1 100644 --- a/include/ItemObject.php +++ b/include/ItemObject.php @@ -79,6 +79,7 @@ class Item extends BaseObject { $indent = ''; $osparkle = ''; $total_children = $this->count_descendants(); + $unseen_comments = (($item->real_uid) ? 0 : $this->count_unseen_descendants()); $conv = $this->get_conversation(); $observer = $conv->get_observer(); @@ -233,6 +234,8 @@ class Item extends BaseObject { $comment_count_txt = sprintf( tt('%d comment','%d comments',$total_children),$total_children ); + $list_unseen_txt = (($unseen_comments) ? sprintf('%d unseen',$unseen_comments) : ''); + $children = $this->get_children(); $tmp_item = array( @@ -290,8 +293,12 @@ class Item extends BaseObject { 'drop' => $drop, 'multidrop' => ((feature_enabled($conv->get_profile_owner(),'multi_delete')) ? $multidrop : ''), // end toolbar buttons + + 'unseen_comments' => $unseen_comments, 'comment_count' => $total_children, 'comment_count_txt' => $comment_count_txt, + 'list_unseen_txt' => $list_unseen_txt, + 'markseen' => t('Mark all seen'), 'like_count' => $like_count, 'like_list' => $like_list, 'like_list_part' => $like_list_part, @@ -545,6 +552,23 @@ class Item extends BaseObject { return $total; } + private function count_unseen_descendants() { + $children = $this->get_children(); + $total = count($children); + if($total > 0) { + $total = 0; + foreach($children as $child) { + if((! visible_activity($child->data)) || array_key_exists('author_blocked',$child->data)) { + continue; + } + if($child->data['item_flags'] & ITEM_UNSEEN) + $total ++; + } + } + return $total; + } + + /** * Get the template for the comment box */ -- cgit v1.2.3