aboutsummaryrefslogtreecommitdiffstats
path: root/include/ItemObject.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2014-11-17 15:18:06 -0800
committerfriendica <info@friendica.com>2014-11-17 15:18:06 -0800
commitc0ad4763b30238aead8f1187efd669080c52a149 (patch)
tree7d9330457593d90f540004d09087fde59f2b4429 /include/ItemObject.php
parentb11ed7f88e4683315a4f5aa02692cb61facf32a7 (diff)
downloadvolse-hubzilla-c0ad4763b30238aead8f1187efd669080c52a149.tar.gz
volse-hubzilla-c0ad4763b30238aead8f1187efd669080c52a149.tar.bz2
volse-hubzilla-c0ad4763b30238aead8f1187efd669080c52a149.zip
add unseen count and way to mark unseen to list mode. Also fix automatic mark of unseen so as to work with list mode.
Diffstat (limited to 'include/ItemObject.php')
-rw-r--r--include/ItemObject.php24
1 files changed, 24 insertions, 0 deletions
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
*/