studiobosco/wn-lockrecords-plugin

WinterCMS LockRecords Plugin

Installs: 13

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Forks: 2

Type:winter-plugin

dev-main 2024-05-14 10:01 UTC

This package is not auto-updated.

Last update: 2024-05-28 08:33:46 UTC


README

Provides lockable records in the backend. Lockabe records can only be edited by a single backend user at the same time. Locked records can be unlocked manually or will be unlocked automatically after a certain amount of time if no editing form is opened.

Usage

This plugin provides the StudioBosco\LockRecords\Traits\Lockable Model Trait and the StudioBosco\LockRecords\Behaviors\LockRecordsController controller behavior.

To make a model lockable

  1. Just add the trait or the behavior:
class MyModel {
    use \StudioBosco\LockRecords\Traits\Lockable;

    // or

    public $implement = [
        \StudioBosco\LockRecords\Behaviors\LockableModel::class,
    ];

    ...
}
  1. Add the behavior to the backend controller. It should contain the form and list behaviors.
class MyController extends Backend\Classes\Controller {

    /**
     * @var array Behaviors that are implemented by this controller.
     */
    public $implement = [
        \Backend.Behaviors.FormController::class,
        \Backend.Behaviors.ListController::class,
        \StudioBosco\LockRecords\Behaviors\LockRecordsController::class,
    ];

    ...
}
  1. Customize the duration after which records get unlocked automatically by visiting backend/system/settings/update/studiobosco/lockrecords/settings. It is 10 minutes by default.

  2. Set permissions to manually unlock records if desired.