You are here

function _uc_roles_get_expiration in Ubercart 7.3

Same name and namespace in other branches
  1. 6.2 uc_roles/uc_roles.module \_uc_roles_get_expiration()

Returns an expiration time stamp given a period of time.

Parameters

$duration: The amount of time until expiration.

$granularity: A string representing the granularity's name (e.g. "day", "month", etc.).

$start_time: (optional) The starting date for when the role will last. Defaults to the current time.

Return value

int|null A UNIX timestamp representing the second that expiration takes place, or NULL if the expiration should never occur.

5 calls to _uc_roles_get_expiration()
uc_roles_cron in uc_roles/uc_roles.module
Implements hook_cron().
uc_roles_feature_form in uc_roles/uc_roles.module
Form builder for hook_uc_product_feature().
uc_roles_user_presave in uc_roles/uc_roles.module
Implements hook_user_presave().
uc_roles_user_validate in uc_roles/uc_roles.module
User profile form validate handler.
_uc_roles_product_get_expiration in uc_roles/uc_roles.module
Calculates the expiration time using a role_product object.

File

uc_roles/uc_roles.module, line 1276
Grants roles upon accepted payment of products.

Code

function _uc_roles_get_expiration($duration, $granularity, $start_time = NULL) {

  // Never expires?
  if ($granularity == 'never') {
    return NULL;
  }
  $start_time = !is_null($start_time) ? $start_time : REQUEST_TIME;
  $operator = $duration < 0 ? '' : '+';
  return strtotime($operator . $duration . ' ' . $granularity, $start_time);
}