Пример #1
0
 /**
  * Fetches a news entry identified by its ID
  *
  * @param integer $id    ID of news
  * @param boolean $admin Is admin
  * 
  * @return array
  */
 function getNewsEntry($id, $admin = false)
 {
     $news = array();
     $query = sprintf("SELECT\n                *\n            FROM\n                %sfaqnews\n            WHERE\n                id = %d\n            AND\n                lang = '%s'", SQLPREFIX, $id, $this->language);
     $result = $this->db->query($query);
     if ($this->db->numRows($result) > 0) {
         if ($row = $this->db->fetchObject($result)) {
             $content = $row->artikel;
             $active = 'y' == $row->active;
             $allowComments = 'y' == $row->comment;
             $expired = date('YmdHis') > $row->date_end;
             if (!$admin) {
                 if (!$active) {
                     $content = $this->pmf_lang['err_inactiveNews'];
                 }
                 if ($expired) {
                     $content = $this->pmf_lang['err_expiredNews'];
                 }
             }
             $news = array('id' => $row->id, 'lang' => $row->lang, 'date' => PMF_Date::createIsoDate($row->datum), 'header' => $row->header, 'content' => $content, 'authorName' => $row->author_name, 'authorEmail' => $row->author_email, 'dateStart' => $row->date_start, 'dateEnd' => $row->date_end, 'active' => $active, 'allowComments' => $allowComments, 'link' => $row->link, 'linkTitle' => $row->linktitel, 'target' => $row->target);
         }
     }
     return $news;
 }