IssuePublish::setPublishAction PHP Method

setPublishAction() public method

Set the published state to switch to when the "publish time" arrives: 'P' for Publish, or 'U' for Unpublish.
public setPublishAction ( string $p_value ) : void
$p_value string
return void
    public function setPublishAction($p_value)
    {
        $p_value = strtoupper($p_value);
        if ($p_value == 'P' || $p_value == 'U') {
            $this->setProperty('publish_action', $p_value);
        }
    }

Usage Example

$issueId = rand();
$issue = new Issue(1, 1, $issueId);
$issue->create($issueId);
$issue->fetch();
$issue->dumpToHtml();
$article1 = new Article(1, 1, $issueId, 1);
$article1->create('fastnews', 'issue schueduled publish test '.rand());
$article2 = new Article(1, 1, $issueId, 1);
$article2->create('fastnews', 'issue schueduled publish test '.rand());

// Create issue publish event
echo "Creating issue publish event...<br>";
$datetime = strftime("%Y-%m-%d %H:%M:00");
$issuePublishEvent = new IssuePublish(1, $issueId, 1, $datetime);
$issuePublishEvent->create();
$issuePublishEvent->setPublishAction('P');
$issuePublishEvent->setPublishArticlesAction('Y');
$issuePublishEvent->fetch();
$issuePublishEvent->dumpToHtml();

echo "Executing pending events:<br>";
$events = IssuePublish::GetPendingActions();
foreach ($events as $event) {
    $event->doAction();
    $event->dumpToHtml();
}

// Check if issues are published
echo "Is the issue published?<br>";
$issue->fetch();
$issue->dumpToHtml();
All Usage Examples Of IssuePublish::setPublishAction