Workflow

Workflow controls how changes to versioned content are made available on the front-end.

An additional boolean parameter is added to the getX functions, by convention called $approvedOnly, which if true will retrieve the current live version rather than the working copy.

function getCustomThing($id, $approvedOnly = false)
{
    if ($approvedOnly) {
        $versions = new Versions(ABOUT_TABLE, $this->id);

        $liveVersion = $versions->getLiveVersion();

        if ($liveVersion !== null) {
            return $liveVersion;
        }
    }
}

For more specific examples of the $approvedOnly flag refer to /jadu/websections files.

Adding workflow to Control Center files

To get the approved version of an items of content, do the following. Add the following include:

include_once("../includes/workflow_restrictions.php");

Ensure the following Javascript/CSS files are available on the page:

addJavascript('javascript/lightbox.js');
addJavascript('javascript/workflow.php');
addCSS('css/lightbox.css');

Copy the logic to approve the latest version:

if (isset($_POST['approve'])) {
    $task = getAdminTask($_POST['taskID']);
    if ($THIS_WORKFLOW->id == -1 || $ADMIN_MUST_APPROVE) {
        // to create a new version and save any changes they may have made
        $vs = new Versions($task->dbTable, $task->objectID);
        $vs->addVersion($about);
        $vs->setLatestVersionCurrent();
    }
}

Copy the form elements to submit for approval:

<?php
    if (awaitingWebmasterAproval(ABOUT_TABLE, $about->id)) {
        $admin = getAdministrator($adminID);
        $task = getAwaitingWebmasterAprovalTask(ABOUT_TABLE, $about->id);

        if ($task->adminID == $adminID) {
?>
<tr>
    <td class="generic_desc">
        <em><?php print $stepCounter++; ? >.</em> <p>Submit for approval</p>
    </td>
    <td class="generic_action">
        <input type="hidden" name="taskID" value="<?php print $task->id;?>">
        <input type="submit" class="button" name="approve" value="Approve"
                onclick="return approveTask(<?php print $task->id;?>);">
        <input type="button" class="button" name="reject" value="Reject"
                onclick="loadTaskSubmit(
                        '<?php print $task->id;?>',
                        '<?php print ADMIN_TASK_ACTION_REJECT; ? >',
                        '<?php print encodeHtml($task->pageTitle) ?>',
                        '<? php print $THIS_WORKFLOW->id; ?>',
                        '<?php print encodeHtml($_SERVER['QUERY_STRING']); ?>')" />
    </td>
</tr>
<?php
        }
    }
?>

Finally, we need to enable workflow on this content type so that we can build custom workflows around it. To do this find the record for the main content type page in JaduModulePages database table and set the workflow flag to 1. This should be the parent page, for example News rather than News Item.

results matching ""

    No results matching ""