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
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.
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?