You are here

public function BynderApi::hasUploadPermissions in Bynder 4.0.x

Same name and namespace in other branches
  1. 8.3 src/BynderApi.php \Drupal\bynder\BynderApi::hasUploadPermissions()
  2. 8 src/BynderApi.php \Drupal\bynder\BynderApi::hasUploadPermissions()
  3. 8.2 src/BynderApi.php \Drupal\bynder\BynderApi::hasUploadPermissions()

Checks if the current user has upload permissions.

Return value

string|false Name of the user's upload role if uploads are allowed and FALSE otherwise.

Overrides BynderApiInterface::hasUploadPermissions

1 call to BynderApi::hasUploadPermissions()
BynderApi::hasAccessToken in src/BynderApi.php
Gets if the current user has a valid oAuth access token.
1 method overrides BynderApi::hasUploadPermissions()
BynderApiTest::hasUploadPermissions in tests/modules/bynder_test_module/src/BynderApiTest.php
Simulate upload permissions check.

File

src/BynderApi.php, line 263

Class

BynderApi
Bynder API service.

Namespace

Drupal\bynder

Code

public function hasUploadPermissions() {
  $this
    ->getAssetBankManager();
  $user = $this->bynderApi
    ->getCurrentUser()
    ->wait();
  if (isset($user)) {
    $profileId = $user['profileId'];
    $userProfile = $this->bynderApi
      ->getSecurityProfile($profileId)
      ->wait();
    foreach ($userProfile['roles'] as $role) {
      if ($role == 'MEDIAUPLOAD' || $role == 'MEDIAUPLOADFORAPPROVAL') {
        return $role;
      }
    }
  }
  return FALSE;
}