public function read() { global $ilDB; $this->news = array(); $types = array(); $data = array(); $query = 'SELECT * FROM payment_news WHERE 1 = 1 '; if ($this->isPublicSection()) { $query .= "AND visibility = %s "; $types[] = 'text'; $data[] = 'public'; } if ($this->getArchiveDate() !== null && $this->getArchiveDate() > 0) { switch ($this->getMode()) { case self::TYPE_NEWS: $query .= "AND creation_date >= %s "; $types[] = 'timestamp'; $data[] = date('Y-m-d H:i:s', $this->getArchiveDate()); break; case self::TYPE_ARCHIVE: $query .= "AND creation_date < %s "; $types[] = 'timestamp'; $data[] = date('Y-m-d H:i:s', $this->getArchiveDate()); break; } } $query .= 'ORDER BY update_date DESC '; $result = $ilDB->queryF($query, $types, $data); while ($record = $ilDB->fetchAssoc($result)) { $oNewsItem = new ilShopNewsItem(); $oNewsItem->setId($record['news_id']); $oNewsItem->setCreationDate($record['creation_date']); $oNewsItem->setUpdateDate($record['update_date']); $oNewsItem->setTitle($record['news_title']); $oNewsItem->setContent($record['news_content']); $oNewsItem->setVisibility($record['visibility']); $oNewsItem->setUserId($record['user_id']); $this->news[] = $oNewsItem; } return $this; }
public function confirmDelete($view) { global $ilUser, $rbacreview; if (!$rbacreview->isAssigned($ilUser->getId(), SYSTEM_ROLE_ID)) { $this->ilErr->raiseError($this->lng->txt('permission_denied'), $this->ilErr->MESSAGE); } if (!isset($_GET['news_id'])) { ilUtil::sendInfo($this->lng->txt('payment_news_missing_id')); switch ($view) { case 'archive': return $this->showArchive(); break; case 'news': default: return $this->showNews(); break; } } include_once 'Services/Utilities/classes/class.ilConfirmationGUI.php'; $c_gui = new ilConfirmationGUI(); $c_gui->setHeaderText($this->lng->txt('payment_news_delete_sure')); $c_gui->addHiddenItem('news_id', (int) $_GET['news_id']); $oNewsItem = new ilShopNewsItem($_GET['news_id']); $title = $oNewsItem->getTitle(); $c_gui->addItem($news_title, $_GET['news_id'], $title); switch ($view) { case 'archive': $c_gui->setFormAction($this->ctrl->getFormAction($this, 'performDeleteArchiveNews')); $c_gui->setConfirm($this->lng->txt('confirm'), 'performDeleteArchiveNews'); $c_gui->setCancel($this->lng->txt('cancel'), 'showArchive'); $this->showArchive($c_gui->getHTML()); break; case 'news': default: $c_gui->setFormAction($this->ctrl->getFormAction($this, 'performDeleteNews')); $c_gui->setConfirm($this->lng->txt('confirm'), 'performDeleteNews'); $c_gui->setCancel($this->lng->txt('cancel'), 'showNews'); $this->showNews($c_gui->getHTML()); break; } return true; }