Temporarily disable page edit

hello,

i want temporary disable page edit feature for several users/roles.

Maybe is it possible to set a temporary permission before a page is loaded
in panel?

or any oter ideas?

greetings,
Svnt

What do you mean by ā€œtemporarilyā€? Something based on date? Then you could use a condition in your roles code.

https://getkirby.com/docs/panel/permissions

No. Not date. In my case a value of a hidden field.
There is a value if a page is in a audit processā€¦ then it should only be viewable
untill audit is done and the page is released/published.

It works if i put this into the role definition:

'panel.page.update' => function() {
  return $this->target()->page()->auditpending() === '0';
}

But at the end it doesnā€™t help much. I have to catch this with a hookā€¦ perform some kind of rollback due the new values are already written

Sadly there is no ā€œbefore page updateā€ hook.

Example:

<?php
// site/roles/editor.php
return [
  'name'        => 'Editor',
  'default'     => false,
  'permissions' => [
    '*'                 => true,
    'panel.page.update' => function() {
      if($this->target()->page()->audit()->bool()) {
        return false;
      } else {
        return true;
      }
    },
  ]
];

ā€˜Rollbackā€™ in the hook worksā€¦ push saveā€¦boomā€¦old content back.

  try {
    $page->update($oldPage->content()->toArray());
  } catch (Exception $e) {echo $e->getMessage();}

What? I donā€™t see the connection to the above questionā€¦

i have to prevent editing of all fields except the ā€œauditā€¦changes accepted or notā€ fields so i canā€™t disable the complete form.
Within the hook i can now process the audit fields, set the content to old (overwrite all changes) and write the old content back.

A special save message would be niceā€¦ is there a way to alter the ā€œsmileyā€ message in the green ā€œsavedā€ box message top/right after hitting save?