- Posts: 13
- Thank you received: 1
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
use VersionableControllerTrait;
protected function allowEdit($data = [], $key = 'id')
{
$recordId = (int) isset($data[$key]) ? $data[$key] : 0;
$user = $this->app->getIdentity();
// Zero record (id:0), return component edit permission by calling parent controller method
if (!$recordId) {
return parent::allowEdit($data, $key);
}
// Check edit on the record asset (explicit or inherited)
if ($user->authorise('core.edit', 'com_icagenda.event.' . $recordId)) {
return true;
}
// Check edit own on the record asset (explicit or inherited)
if ($user->authorise('core.edit.own', 'com_icagenda.event.' . $recordId)) {
// Existing record already has an owner, get it
$record = $this->getModel()->getItem($recordId);
if (empty($record)) {
return false;
}
// Grant if current user is owner of the record
return $user->id == $record->created_by;
}
return false;
}
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
// Grant if current user is owner of the record
if ($user->id == $record->created_by || $user->id == $record->userid) {
return true;
}
Please Log in or Create an account to join the conversation.