$message = 'success'; $catid = empty($_GET['catid']) ? 0 : intval($_GET['catid']); $data = catList($catid, $sql, $param); break; case 'list': $catid = empty($_GET['catid']) ? 0 : intval($_GET['catid']); $isHistory = empty($_GET['isHistory']) ? 0 : 1; if ($catid == 0) { json_error('分类不存在'); } $subids = C::t('news_cat')->getSonByCatid($catid); $sql .= ' and catid IN(%n)'; $param[] = $subids; $sql .= " and status='1'"; $sql = !$isHistory ? $sql . ' and v.vid is null' : $sql; $data = listView($sql, $param); $message = 'success'; break; case 'view': $newid = empty($_GET['newid']) ? 0 : intval($_GET['newid']); if (!($news = C::t('news')->fetch($newid))) { json_error('信息不存在或者已被删除'); } if (!getViewPerm($news)) { json_error('您没有查看此信息的权限,请联系管理员'); } //更新查阅 C::t('news')->increase($newid, array('views' => 1)); if ($_G['uid']) { if ($vid = DB::result_first("select vid from %t where newid=%d and uid=%d", array('news_viewer', $newid, $_G['uid']))) { DB::query("update %t SET views=views+1 where vid=%d", array('news_viewer', $vid));
/** * Creates an ul list of news items with its subjects as label. * * @return string */ function getAllNewsList() { global $privileges; $news = sql_select("SELECT * FROM `News` ORDER BY `Datum`"); if (0 === count($news)) { return ''; } $listItems = array(); foreach ($news as $article) { $title = $article['Betreff']; if (in_array('admin_news', $privileges)) { $title = sprintf("<h4>%s</h4><p>%s</p>", htmlspecialchars($title), htmlspecialchars($article['Text'])); } $listItems[] = sprintf("%s", $title); } return listView($listItems, array('class' => 'list-group', 'item_class' => 'list-group-item news-list')); }
function listEvents($eventIDs) { $IDs = array(); $results = array(); $query = "SELECT events.eventName, \n events.startTime,\n locations.locationName,\n categories.categoryName,\n events.eventID,\n events.public\n FROM events, locations, categories\n WHERE events.locationID=locations.locationID\n AND events.categoryID=categories.categoryID\n AND ("; foreach ($eventIDs as $id) { $IDs[] = "events.eventID=" . $id; } $query .= implode(" OR ", $IDs); $query .= ")"; $result = mysql_query($query); if (!$result) { mysql_close(); die("Sorry... There are no events matching your search criteria... " . mysql_error()); } while ($row = mysql_fetch_row($result)) { $results[] = $row; } listView($results); return $results; }