You are here

function role_expire_get_default_duration in Role Expire 7

Same name and namespace in other branches
  1. 6 role_expire.module \role_expire_get_default_duration()

API function; Get the default duration for a role.

Parameters

$rid: Required. The role_id to check.

Return value

String containing the strtotime compatible default duration of the role or empty string if not set.

3 calls to role_expire_get_default_duration()
role_expire_form_user_admin_role_alter in ./role_expire.module
Implements hook_form_FORM-ID_alter().
role_expire_process_default_role_duration_for_user in ./role_expire.module
Sets the default role duration for the current user/role combination.
role_expire_set_default_duration in ./role_expire.module
API function; Set the default expiry duration for a role.

File

./role_expire.module, line 135
Role Expire module

Code

function role_expire_get_default_duration($rid) {

  // Because this function is called a couple times during the same page load,
  // remember the result from the first call.
  static $default_duration = array();
  if (!isset($default_duration[$rid])) {
    $result = db_query("SELECT duration FROM {role_expire_length} WHERE rid = :rid", array(
      ':rid' => $rid,
    ))
      ->fetchField();
    $default_duration[$rid] = $result;
  }
  return $default_duration[$rid];
}