Versioning and content approval

Versioning and approval in WebHare is based on a 'four eyes' principle - it enforces that all content that appears on a URL has been approved by someone else who offered the content. It also requires approval for actions that 'change' the URL of objects, eg moving or depublishing files, and tracks the history and actions taken.

Preparation

You'll need to set up a versioning policy object and a review app in your moduledefinition

  <publisher>
    <versioningpolicy name="site" objectname="lib/internal/versioningpolicy.whlib#SitePolicy" />
  </publisher>

  <portal>
    <application name="versioning" group="system:cms" tid="module.versioningapp" startmacro="lib/internal/versioningpolicy.whlib#StartVersioningApp" icon="tollium:applications/versioning">
      <accesscheck>
        <requireright right="system:sysop" />
      </accesscheck>
    </application>
  </portal>

An example policy object and app launcher could be

LOADLIB "mod::publisher/lib/versioning.whlib";

PUBLIC STATIC OBJECTTYPE SitePolicy EXTEND VersioningPolicyBase
<
  UPDATE PUBLIC RECORD FUNCTION GetReviewAppConfig(RECORD data)
  {
    RECORD rec := VersioningPolicyBase::GetReviewAppConfig(data);
    OBJECT site := OpenSiteByName(data.sitename);
    RETURN ValidateOptions(rec,
        [ canreview :=          data.controller->tolliumuser->HasRightOn("system:fs_fullaccess", site->id)
        ]);
  }

  UPDATE PUBLIC RECORD FUNCTION GetSubmitRequestData(OBJECT parentscreen, OBJECT policy, OBJECT file, RECORD options)
  {
    RECORD result := VersioningPolicyBase::GetSubmitRequestData(parentscreen, policy, file, options);
    IF(RecordExists(result))
      result.expirydate := AddMonthsToDate(12, GetCurrentDatetime());
    RETURN result;
  }
>;


PUBLIC MACRO StartVersioningApp(OBJECT controller, RECORD data)
{
  RunVersioningApplication("<sitename>", controller, data);
}

The actual conversion

Deleting a versioned site

Removing versioned content is intentionally made hard to prevent an accidental cascade from deleting history. To delete a site, find its id and:

wh sql 'delete from system.fs_versionevents where fs_site=<SITEID>'
wh sql 'delete from system.fs_objects where id=<SITEID>'