5 * @author Sebastian Skejø
9 private $_storageObj = null;
10 private $_sort = null;
12 private function _restore() {
13 $this->_storageObj
->setTable("News");
14 $this->_storageObj
->setSort($this->_sort
);
17 public function __construct($core) {
18 parent
::__construct($core);
20 $this->_storageObj
= $this->core()->newStorageDevice();
21 $this->_storageObj
->setTable("News");
22 $this->_storageObj
->setSort("DESC");
25 public function getNewsList($fields = "*", $where = null, $limit = null, $order = "TIMESTAMP") {
26 return $this->_storageObj()->selectModel($fields, $where, $limit, $order);
30 * Returns a model containing the data of the current piece of news
32 public function getNews($newsID) {
37 $m = $this->getNewsList("*", $where);
43 * Returns an AOOSModel containing all data for comments to $newsID
46 public function getCommentList($newsID, $limit = null) {
47 $this->_storageObj
->setTable("News_comments");
48 $this->_storageObj
->setSort("ASC"); // We want comments to be in ascending order
54 $model = $this->_storageObj
->selectModel("*", $where, $limit, "TIMESTAMP");
61 public function setSort($sort) {
62 if ($this->_storageObj
->setSort($sort)) {
69 * Deletes a piece of news and all related comments
70 * @param int $newsID The piece of news to be deleted
72 public function deleteNews($newsID) {
73 if (!$this->core()->getModule("User")->checkLevel("admin")) {
74 throw new AOOSException($this->core(), $this->tr("access_denied", "User"), "", true, 1);
82 $this->_storageObj
->deleteFromArray($where);
85 $this->_storageObj
->setTable("News_comments");
86 $this->_storageObj
->deleteFromArray($where);
93 * Updates a piece of news
95 public function updateNews(AOOSModel
$news) {
100 * Creates a new piece of news in the database
102 public function createNews(AOOSModel
$news) {