Elgg\UserCapabilities::canAnnotate PHP Method

canAnnotate() public method

Can a user annotate an entity?
public canAnnotate ( ElggEntity $entity, integer $user_guid, string $annotation_name = '' ) : boolean
$entity ElggEntity Objet entity
$user_guid integer User guid (default is logged in user)
$annotation_name string The name of the annotation (default is unspecified)
return boolean
    public function canAnnotate(ElggEntity $entity, $user_guid = 0, $annotation_name = '')
    {
        if ($annotation_name === null || $annotation_name === false) {
            // accepting these for BC
            $annotation_name = '';
        } elseif (!is_string($annotation_name)) {
            throw new InvalidArgumentException(__METHOD__ . ' expects \\$annotation_name to be a string');
        }
        try {
            $user = $this->entities->getUserForPermissionsCheck($user_guid);
        } catch (UserFetchFailureException $e) {
            return false;
        }
        $return = (bool) $user;
        $params = ['entity' => $entity, 'user' => $user, 'annotation_name' => $annotation_name];
        if (!empty($annotation_name)) {
            $return = $this->hooks->trigger("permissions_check:annotate:{$annotation_name}", $entity->getType(), $params, $return);
        }
        return $this->hooks->trigger('permissions_check:annotate', $entity->getType(), $params, $return);
    }