function role_expire_add_expiration_input in Role Expire 6
Same name and namespace in other branches
- 8 role_expire.module \role_expire_add_expiration_input()
- 7 role_expire.module \role_expire_add_expiration_input()
- 2.x role_expire.module \role_expire_add_expiration_input()
Add form element that accepts the role expiration time.
Parameters
$account: The user object.
Return value
Form element.
2 calls to role_expire_add_expiration_input()
- role_expire_form_user_register_alter in ./
role_expire.module - Implementation of hook_form_FORM-ID_alter().
- role_expire_user in ./
role_expire.module - Implementation of hook_user().
File
- ./
role_expire.module, line 391 - Role Expire module
Code
function role_expire_add_expiration_input($account = NULL) {
$form = array();
if (user_access('administer users') || user_access('administer role expire')) {
drupal_add_js(drupal_get_path('module', 'role_expire') . '/role_expire.js', 'module');
$form['roles']['#attributes'] = array(
'class' => 'role-expire-roles',
);
foreach (_role_expire_get_role() as $rid => $role) {
if (is_object($account) and array_key_exists('uid', $account)) {
$expiry_timestamp = role_expire_get_user_role_expiry_time($account->uid, $rid);
}
else {
$expiry_timestamp = '';
}
$form['role_expire_' . $rid] = array(
'#title' => t("%role role expiration time", array(
'%role' => drupal_ucfirst($role),
)),
'#type' => 'textfield',
'#default_value' => !empty($expiry_timestamp) ? date("d-m-Y G:i:s", $expiry_timestamp) : '',
'#attributes' => array(
'class' => 'role-expire-role-expiry',
),
'#description' => t("Leave blank for default role expiry (never, or the duration you have set for the role), enter date and time in format: <em>yyyy-mm-dd hh:mm:ss</em> or use relative time i.e. 1 day, 2 months, 1 year, 3 years."),
);
}
}
return $form;
}