You are here

function imce_validate_quota in IMCE 6

Same name and namespace in other branches
  1. 6.2 inc/imce.page.inc \imce_validate_quota()
  2. 7 inc/imce.page.inc \imce_validate_quota()

Validate filesize for directory and total user quota.

2 calls to imce_validate_quota()
imce_validate_all in inc/page.inc
Validate uploaded file.
imce_validate_quotas in inc/page.inc
Validate both directory and total user quota. Returns true/false not errors.

File

inc/page.inc, line 601

Code

function imce_validate_quota($file, $quota = 0, $current = 0, $type = 0) {
  $errors = array();
  if ($quota && $current + $file->filesize > $quota) {
    $qtypes = array(
      'Directory quota',
      'Total user quota',
    );
    $errors[] = t('%filename is %filesize which would exceed your %quota_type. You are currently using %size of %quota.', array(
      '%size' => format_size($current),
      '%quota' => format_size($quota),
      '%filesize' => format_size($file->filesize),
      '%filename' => utf8_encode($file->filename),
      '%quota_type' => t(isset($qtypes[$type]) ? $qtypes[$type] : 'quota'),
    ));
  }
  return $errors;
}