/** * Takes a posting-array like the one generated by ForumEntry::getList() * and adds the child-posting with the freshest creation-date to it. * * @param array $postings * @return array */ function getLastPostings($postings) { foreach ($postings as $key => $posting) { if ($data = ForumEntry::getLatestPosting($posting['topic_id'])) { $last_posting['topic_id'] = $data['topic_id']; $last_posting['date'] = $data['mkdate']; $last_posting['user_id'] = $data['user_id']; $last_posting['user_fullname'] = $data['author']; $last_posting['username'] = get_username($data['user_id']); $last_posting['anonymous'] = $data['anonymous']; // we throw away all formatting stuff, tags, etc, so we have just the important bit of information $text = strip_tags($data['name']); $text = ForumEntry::br2space($text); $text = ForumEntry::killFormat(ForumEntry::killQuotes($text)); if (strlen($text) > 42) { $text = substr($text, 0, 40) . '...'; } $last_posting['text'] = $text; } $postings[$key]['last_posting'] = $last_posting; if (!($postings[$key]['last_unread'] = ForumEntry::getLastUnread($posting['topic_id']))) { $postings[$key]['last_unread'] = $last_posting['topic_id']; } $postings[$key]['num_postings'] = ForumEntry::countEntries($posting['topic_id']); unset($last_posting); } return $postings; }