You are here

public function ImceFM::validatePermissions in IMCE 8

Same name and namespace in other branches
  1. 8.2 src/ImceFM.php \Drupal\imce\ImceFM::validatePermissions()

Checks parent folder permissions of the given items.

File

src/ImceFM.php, line 540

Class

ImceFM
Imce File Manager.

Namespace

Drupal\imce

Code

public function validatePermissions(array $items, $file_perm = NULL, $subfolder_perm = NULL) {
  foreach ($this
    ->groupItems($items) as $path => $content) {
    $parent = $this
      ->getFolder($path);

    // Parent contains files but does not have the file permission.
    if (!empty($content['files'])) {
      if (!isset($file_perm) || !$parent
        ->getPermission($file_perm)) {
        return FALSE;
      }
    }

    // Parent contains subfolders but does not have the subfolder permission.
    if (!empty($content['subfolders'])) {
      if (!isset($subfolder_perm) || !$parent
        ->getPermission($subfolder_perm)) {
        return FALSE;
      }
    }
  }
  return TRUE;
}