public ForumManager::unreadTopics($term, $uid)
Calculates the number of new posts in a forum that the user has not yet read.
Nodes are new if they are newer than HISTORY_READ_LIMIT.
Parameters
int $term: The term ID of the forum.
int $uid: The user ID.
Return value
The number of new posts in the forum that have not been read by the user.
Overrides ForumManagerInterface::unreadTopics
File
- core/modules/forum/src/ForumManager.php, line 476
Class
- ForumManager
- Provides forum manager service.
Namespace
Drupal\forum
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | public function unreadTopics( $term , $uid ) { $query = $this ->connection->select( 'node_field_data' , 'n' ); $query ->join( 'forum' , 'f' , 'n.vid = f.vid AND f.tid = :tid' , array ( ':tid' => $term )); $query ->leftJoin( 'history' , 'h' , 'n.nid = h.nid AND h.uid = :uid' , array ( ':uid' => $uid )); $query ->addExpression( 'COUNT(n.nid)' , 'count' ); return $query ->condition( 'status' , 1) // @todo This should be actually filtering on the desired node status // field language and just fall back to the default language. ->condition( 'n.default_langcode' , 1) ->condition( 'n.created' , HISTORY_READ_LIMIT, '>' ) ->isNull( 'h.nid' ) ->addTag( 'node_access' ) ->execute() ->fetchField(); } |
Please login to continue.