In order to support locking of content items, you need to have implemented comments.
How to implement locking
To support locking and unlocking content items in your application, you first need to implement the interface in your content item model:
implements \IPS\Content\Lockable
Next, you need to add a locked key to your $databaseColumnMap property, with the value being the name of the database column that stores the locked state of your content items.
Finally, you need to add support for locking and unlocking in your templates. For example:
{{if $item->canLock()}} <a href='{$item->url()->setQueryString( array( 'do' => 'moderate', 'action' => 'lock' ) )}'>{lang="lock"}</a> {{endif}} {{if $item->canUnlock()}} <a href='{$item->url()->setQueryString( array( 'do' => 'moderate', 'action' => 'unlock' ) )}'>{lang="unlock"}</a> {{endif}}
Changes after implementation
- Locked items will no longer allow comments, unless the user has permission to comment on locked items.
- Moderators with the appropriate permission will be able to see and use tools to lock and unlock content when selecting items in content item tables.
Additional model methods available
Indicates whether the user has permission to lock the item. This method takes into account whether the item is already locked.
-
$member (\IPS\Member, optional)
If provided, this member's permissions will be checked. By default, the currently-logged in member will be used.
Indicates whether the user has permission to unlock the item. This method takes into account whether the item is already unlocked.
-
$member (\IPS\Member, optional)
If provided, this member's permissions will be checked. By default, the currently-logged in member will be used.
Report Document