Пример #1
0
 /**
  * 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;
 }
Пример #2
0
 /**
  * Return an info-text explaining the visit-status of the passed topic_di
  * which has the passed number of new entries.
  * 
  * @param string $num_entries  the number of new entries
  * @param string $topic_id     the id of the topic 
  * 
  * @return string  a human readable, localized text
  */
 static function getVisitText($num_entries, $topic_id)
 {
     if ($num_entries > 0) {
         $text = sprintf(_('Seit ihrem letzten Besuch gibt es %s neue Beiträge'), $num_entries);
     } else {
         $all_entries = max(ForumEntry::countEntries($topic_id) - 1, 0);
         if ($all_entries == 0) {
             $text = sprintf(_('Es gibt bisher keine Beiträge.'));
         } else {
             if ($all_entries == 1) {
                 $text = sprintf(_('Seit ihrem letzten Besuch gab es nichts neues.' . ' Es ist ein alter Beitrag vorhanden.'));
             } else {
                 $text = sprintf(_('Seit ihrem letzten Besuch gab es nichts neues.' . ' Es sind %s alte Beiträge vorhanden.'), $all_entries);
             }
         }
     }
     return $text;
 }
Пример #3
0
 function getNumberOfPostingsForSeminar($seminar_id)
 {
     $this->setupAutoload();
     return floor(ForumEntry::countEntries($seminar_id));
 }