public function readObjects()
 {
     if ($this->objectIDs === null) {
         $this->readObjectIDs();
     }
     parent::readObjects();
 }
 /**
  * @see	wcf\system\cronjob\ICronjob::execute()
  */
 public function execute(Cronjob $cronjob)
 {
     parent::execute($cronjob);
     // get delayed news
     $entryList = new EntryList();
     $entryList->getConditionBuilder()->add('news_entry.isPublished = 0');
     $entryList->getConditionBuilder()->add('news_entry.publicationDate <= ?', array(TIME_NOW));
     $entryList->readObjects();
     if (count($entryList->getObjects())) {
         // publish news
         $action = new EntryAction($entryList->getObjects(), 'publish');
         $action->executeAction();
     }
     // get outdated news
     $entryList = new EntryList();
     $entryList->getConditionBuilder()->add('news_entry.isArchived = 0');
     $entryList->getConditionBuilder()->add('news_entry.time <= ?', array(TIME_NOW - CMS_NEWS_DAYS_TO_ARCHIVE * 86400));
     $entryList->readObjects();
     if (count($entryList->getObjects())) {
         // archivate news
         $action = new EntryAction($entryList->getObjects(), 'archive');
         $action->executeAction();
     }
     // get outdated news in archive
     if (CMS_NEWS_DAYS_TO_DELETE_ARCHIVE) {
         $entryList = new NewsList();
         $entryList->getConditionBuilder()->add('news_entry.isArchived = 1');
         $entryList->getConditionBuilder()->add('news_entry.time <= ?', array(TIME_NOW - CMS_NEWS_DAYS_TO_ARCHIVE * 86400 - CMS_NEWS_DAYS_TO_DELETE_ARCHIVE * 86400));
         $entryList->readObjects();
         if (count($entryList->getObjects())) {
             // delete news
             $action = new EntryAction($entryList->getObjects(), 'delete');
             $action->executeAction();
         }
     }
 }
Пример #3
0
<?php

require_once '../class/nl-news-class.php';
require_once '../class/nl-auth-class.php';
//require_once '../class/nl-user-class.php';
require_once 'api_headers.php';
$newsID = _get("newsID", 0);
if ($newsID > 0) {
    $news = new News($newsID);
    echo $news->getJson();
} else {
    $num_per_page = _get("num_per_page", 5);
    $page_num = _get("page_num", 0);
    $categoryID = _get("categoryID", "");
    $summary_len = _get("summary_len", 0);
    $newsStatus = _get("newsStatus", "");
    $onlyFollowed = _get("onlyFollowed", 0);
    $newsList = new NewsList($page_num, $num_per_page, $categoryID, $summary_len);
    if ($newsStatus != "") {
        $newsList->setNewsStatus($newsStatus);
    }
    if ($onlyFollowed) {
        //$auth = Auth::getInstance();
        //$userID = $auth->getUserID();
        //if ($userID > 0)
        $newsList->onlyFollowed($onlyFollowed);
    }
    echo $newsList->getJson();
}