This addon extends Cockpit CMS core functionality by introducing the possibility to have moderation of collections and singletons. It means that its possible to create collections and singletons with a status (Unpublished, Draft or Published) affecting the way that entries are retrieved:
- Unpublished - Any collection entry or singleton in unpublished state will be filtered out.
- Draft - Any collection entry or singleton in Draft that doesn't have a previous revision in published status will be also filtered out. If there is a previous revision with published status the revision will be returned instead. However on a scenario that we have a published > unpublished > draft sequence no entry will be returned.
- Published - They are always returned.
Download latest release and extract to COCKPIT_PATH/addons/Moderation directory
git clone https://github.com/pauloamgomes/CockpitCMS-Moderation.git ./addons/Moderationphp ./cp install/addon --name Moderation --url https://github.com/pauloamgomes/CockpitCMS-Moderation.git- Make sure path to cockpit addons is defined in your projects' composer.json file:
{
"name": "MY_PROJECT",
"extra": {
"installer-paths": {
"cockpit/addons/{$name}": ["type:cockpit-module"]
}
}
}- In your project root run:
composer require pauloamgomes/cockpitcms-moderationTo use the main functionality of the addon no extra configuration is required. To use the preview mode (Draft entries will be also returned) is required to configure an API key on the addon settings page. You can use the moderation api key in your requests like:
http://your-cockpit-site/api/collections/get/<name>?token=<api-key>&previewToken=<moderation-api-key>
Additional addon settings are available at: http://your-cockpit-site/settings/moderation
The following permissions (ACL's) are defined:
- manage - access to all moderation states and addons settings page
- publish - can change entries to Published state
- unpublish - can change entries to Unpublished state
Example of configuration for 3 groups of editors where editor can only create/update entries to Draft state, approver can create/update Draft and move to Published state, and finally manager can publish and unpublish entries.
groups:
editor:
approver:
moderation:
publish: true
manager:
moderation:
publish: true
unpublish: trueBy default admins have super access, any other groups that have not the permissions specificed in the configuration, can only create/edit entries only in Draft mode.
Scheduling is supported since version v1.3, to enable scheduling add a new entry in the config.yml like below:
moderation:
schedule:
- page
- articleabove configuration enables scheduling on collections page and article, if you want to enable for all collections by default use:
moderation:
schedule: *If using scheduling, its required to provide a schedule permission for non admin roles:
groups:
editor:
moderation:
schedule: trueThe Scheduling just defines in Cockpit the operation and date/time for a specific collection entry, to run the scheduling is required to invoke a REST API endpoint, that endpoing can be invoked using cron or other mechanism. By default when executed, it will run against all scheduled entries between a range of time in the past (default of 10m, but can be changed in the request) and current date.
The following example illustrates how that works:
In the above example, the schedule operation was executed at 22:55 and detected 2 operations to run at 22:52 (in the range of 10m) performing the defined moderation status change.
- Add a new field to your collection of type Moderation. You can name whatever you want for your moderation field, e.g. status, moderation, etc.. But you need to keep in mind if you change the field later you may need to manually update all existing collection entries.
- When creating a new collection entry the moderation value will be
Draft, can be changed toUnpublishedorPublished. - When editing an existing collection the moderation value will change automatically to
Draft. - When retrieving a collection entry (or list of entries) only entries with moderation value of
PublishedorDraft(if there is aPublishedrevision before theDraftone) will be returned.
The moderation field supports the following options:
autodraft(default: true) If set to false, entries that are being edited wont be set toDraft
The moderation fields supports localization as any other Cockpit field, just enable the localization option in the field configuration. When editing an entry, the moderation status will be saved according to the selected option on each language.
If Scheduling is enabled and the moderation field is set to be localized, the scheduling will be defined for each language.
Copyright since 2018 pauloamgomes under the MIT license.