public function BynderApi::hasUploadPermissions in Bynder 8.2
Same name and namespace in other branches
- 8.3 src/BynderApi.php \Drupal\bynder\BynderApi::hasUploadPermissions()
- 8 src/BynderApi.php \Drupal\bynder\BynderApi::hasUploadPermissions()
- 4.0.x 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 method overrides BynderApi::hasUploadPermissions()
- BynderApiTest::hasUploadPermissions in tests/
modules/ bynder_test_module/ src/ BynderApiTest.php - Simulate upload permissions check.
File
- src/
BynderApi.php, line 247
Class
- BynderApi
- Bynder API service.
Namespace
Drupal\bynderCode
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;
}