You are here

public function BlogapiCommunicator::checkUserNodeAccess in Blog API 8

Returns true if a user is allowed to edit a node with BlogAPI. False otherwise.

Parameters

$user: Loaded user object.

$node: Loaded node object.

Return value

bool Return the access boolean.

4 calls to BlogapiCommunicator::checkUserNodeAccess()
BlogapiCommunicator::deletePost in src/BlogapiCommunicator.php
Callback for deleting a post.
BlogapiCommunicator::editPost in src/BlogapiCommunicator.php
Callback for editing a node.
BlogapiCommunicator::publishPost in src/BlogapiCommunicator.php
Method that sets a nodes status.
BlogapiCommunicator::setPostCategories in src/BlogapiCommunicator.php
Callback for saving tags on a node.

File

src/BlogapiCommunicator.php, line 481

Class

BlogapiCommunicator
Class BlogapiCommunicator.

Namespace

Drupal\blogapi

Code

public function checkUserNodeAccess($user, $node) {
  if ($user
    ->hasPermission('manage any content blogapi')) {
    return TRUE;
  }
  $owner = $node
    ->getOwnerId();
  if ($user
    ->id() === $owner) {
    if ($user
      ->hasPermission('manage own content blogapi')) {
      return TRUE;
    }
  }
  return FALSE;
}