You are here

function uc_roles_deletion_form in Ubercart 7.3

Same name and namespace in other branches
  1. 5 uc_roles/uc_roles.module \uc_roles_deletion_form()
  2. 6.2 uc_roles/uc_roles.admin.inc \uc_roles_deletion_form()

Form builder for role deletions.

See also

uc_roles_deletion_form_submit()

1 string reference to 'uc_roles_deletion_form'
uc_roles_menu in uc_roles/uc_roles.module
Implements hook_menu().

File

uc_roles/uc_roles.admin.inc, line 100
Roles administration menu items.

Code

function uc_roles_deletion_form($form, &$form_state, $account, $rid) {
  $expiration = db_query("SELECT expiration FROM {uc_roles_expirations} WHERE uid = :uid AND rid = :rid", array(
    ':uid' => $account->uid,
    ':rid' => $rid,
  ))
    ->fetchField();
  if ($expiration) {
    $role_name = _uc_roles_get_name($rid);
    $form['user'] = array(
      '#type' => 'value',
      '#value' => format_username($account),
    );
    $form['uid'] = array(
      '#type' => 'value',
      '#value' => $account->uid,
    );
    $form['role'] = array(
      '#type' => 'value',
      '#value' => $role_name,
    );
    $form['rid'] = array(
      '#type' => 'value',
      '#value' => $rid,
    );
    $form = confirm_form($form, t('Delete expiration of %role_name role for the user !user?', array(
      '!user' => theme('username', array(
        'account' => $account,
        'name' => check_plain(format_username($account)),
        'link_path' => 'user/' . $account->uid,
      )),
      '%role_name' => $role_name,
    )), 'admin/people/expiration', t('Deleting the expiration will give !user privileges set by the %role_name role indefinitely unless manually removed.', array(
      '!user' => theme('username', array(
        'account' => $account,
        'name' => check_plain(format_username($account)),
        'link_path' => 'user/' . $account->uid,
      )),
      '%role_name' => $role_name,
    )), t('Yes'), t('No'));
  }
  else {
    $form['error'] = array(
      '#markup' => t('Invalid user id or role id.'),
    );
  }
  return $form;
}