You are here

protected function elFinderVolumeDrupal::CalculateUserAllowedSpace in elFinder file manager 8.2

Same name and namespace in other branches
  1. 6.2 inc/elfinder.drupalfs.driver.inc \elFinderVolumeDrupal::CalculateUserAllowedSpace()
  2. 7.3 inc/elfinder.drupalfs.driver.inc \elFinderVolumeDrupal::CalculateUserAllowedSpace()
  3. 7.2 inc/elfinder.drupalfs.driver.inc \elFinderVolumeDrupal::CalculateUserAllowedSpace()
1 call to elFinderVolumeDrupal::CalculateUserAllowedSpace()
elFinderVolumeDrupal::CheckUserQuota in src/Controller/elFinderVolumeDrupal.php

File

src/Controller/elFinderVolumeDrupal.php, line 443
elFinder driver for Drupal filesystem.

Class

elFinderVolumeDrupal
@file

Code

protected function CalculateUserAllowedSpace($checkuser = NULL) {
  $user = \Drupal::currentUser();
  $realUser = isset($checkuser) ? $checkuser : $user;
  $currentSpace = $this
    ->CalculateUserUsedSpace($realUser);
  $maxSpace = isset($this->options['userProfile']->settings['user_quota']) ? parse_size($this->options['userProfile']->settings['user_quota']) : NULL;
  $diff = $maxSpace - $currentSpace;
  if (isset($maxSpace) && $maxSpace > 0) {
    if ($diff > 0) {
      return $diff;
    }
    else {
      return 0;
    }
  }
  return -1;
}