You are here

function _uc_file_number_accumulate_equation in Ubercart 8.4

Same name and namespace in other branches
  1. 6.2 uc_file/uc_file.module \_uc_file_number_accumulate_equation()
  2. 7.3 uc_file/uc_file.module \_uc_file_number_accumulate_equation()

Accumulates numeric limits (as of now, download and address).

We follow a couple simple rules here...

If proposing no limit, it always overrides current.

If proposal and current are limited, then accumulate, but only if it wasn't a forced overwrite. (Think on the user account admin page where you can set a download limit to '2'... you wouldn't then next time set it to '4' and expect it to accumulate to '6' . You'd expect it to overwrite with your '4'.)

If current is unlimited, then a limited proposal will only overwrite in the case of the forced overwrite explained above.

1 call to _uc_file_number_accumulate_equation()
_uc_file_accumulate_limits in uc_file/uc_file.module
Accumulates limits and store them to the file_user array.

File

uc_file/uc_file.module, line 263
Allows products to be associated with downloadable files.

Code

function _uc_file_number_accumulate_equation(&$current, $proposed, $force_overwrite) {

  // Right side 'unlimited' always succeeds.
  if (!$proposed) {
    $current = NULL;
  }
  elseif ($current && $proposed) {

    // We don't add forced limits...
    if ($force_overwrite) {
      $current = $proposed;
    }
    else {
      $current += $proposed;
    }
  }
  elseif ($force_overwrite && !$current && $proposed) {
    $current = $proposed;
  }
}