public function canEditAnnotation(ElggEntity $entity, $user_guid = 0, ElggAnnotation $annotation = null)
{
if (!$annotation) {
return false;
}
try {
$user = $this->entities->getUserForPermissionsCheck($user_guid);
} catch (UserFetchFailureException $e) {
return false;
}
$result = false;
if ($user) {
// If the owner of annotation is the specified user, they can edit.
if ($annotation->owner_guid == $user->guid) {
$result = true;
}
// If the user can edit the entity this is attached to, they can edit.
if ($result == false && $entity->canEdit($user->guid)) {
$result = true;
}
}
// Trigger plugin hook - note that $user may be null
$params = ['entity' => $entity, 'user' => $user, 'annotation' => $annotation];
return $this->hooks->trigger('permissions_check', 'annotation', $params, $result);
}