예제 #1
0
$newArticle = new Article(1, 1, 1, 1);
$newArticle->create('fastnews', 'autopublish test '.rand());
if (!$newArticle->exists()) {
    echo "failed to create article.<br>";
    die();
}

$newArticle->dumpToHtml();

// create an article event in the past
echo "Creating event to publish the article...<br>";
$datetime = strftime("%Y-%m-%d %H:%M:00");
$articlePublishObj = new ArticlePublish($newArticle->getArticleId(), 1, $datetime);
$articlePublishObj->create();
$articlePublishObj->setPublishAction('P');
$articlePublishObj->dumpToHtml();

echo "Getting events...<br>";
$events = ArticlePublish::GetPendingActions();
foreach ($events as $event) {
    $event->dumpToHtml();
    $event->doAction();
}

echo "Has the article been updated?<br>";
$newArticle->fetch();
$newArticle->dumpToHtml();

// Schedule future event
echo "Scheduling future event...<br>";
$datetime = strftime("2100-%m-%d %H:%M:00");