Permissions: Stop writability, not readability

Currently I have a mechanism in place which changes readability with custom business logic by overwriting the Page::isReadable() method in page classes in site/models.

Now the desired behaviour would be to permit certain users to see the article, but not edit it. (preferred: the Edit Page with locked forms) How would I go about this?

Overwriting isLocked() does not seem to actually lock the page, also actually locking it using a .lock file just removes everything which is typed without showing an error or displaying to the user in any way that it’s locked, which is sure to gather complaints from users whom might think it’s a bug.

As an idea for future versions: Maybe implement Page::isWritable()?

You can set the blueprint update option to true/false based on user role. Wouldn’t work for individual users, though.

Yes this I already have done. But the plan is to enable writability based on the contents of a user field and publishing status, which is already working with readability.

Hm, doesn’t look like there is a method that would enable this. If only we could use query language with the page blueprint options, that would make all these things so much easier.

If you haven’t yet, you might want to upvote this feature request:

Done, thanks for the link.

Can you think of a way to use locking feature for my cause? This way I could weigh my options better.
I thought of something like this in the Page Childclass , but it doesn’t seem to work.
Using a callback works first, but the lock is lifted after the first try. Also removing the lock will probably be a pain, right?

try {
    $lock = $this->lock();
    $this->kirby()->impersonate('kirby');
    $lock->create();
    $this->kirby()->impersonate(null);
} catch (\Throwable $e) {
} finally {
    return parent::isReadable();
}

Even if it worked, I don’t think meddling with the locking feature to achieve what you want is a good idea. After all, that would make these pages unusable for anyone else.