You are here

function userprotect_protected_users_delete_form in User protect 5

Same name and namespace in other branches
  1. 6 userprotect.module \userprotect_protected_users_delete_form()
  2. 7 userprotect.admin.inc \userprotect_protected_users_delete_form()

Menu callback. Removes a user from being protected, or removes an administrator bypass.

1 string reference to 'userprotect_protected_users_delete_form'
userprotect_menu in ./userprotect.module
Implementation of hook_menu().

File

./userprotect.module, line 655

Code

function userprotect_protected_users_delete_form($uid, $type = 'user') {
  if ($uid) {
    $username = userprotect_get_username($uid);
    if ($type == 'user') {
      $type_display = t('protections');
      $admin_page = 'protected_users';
    }
    elseif ($type == 'admin') {
      $type_display = t('administrator bypass');
      $admin_page = 'administrator_bypass';
    }
    $form = array();
    $form['uid'] = array(
      '#type' => 'value',
      '#value' => $uid,
    );
    $form['username'] = array(
      '#type' => 'value',
      '#value' => $username,
    );
    $form['type'] = array(
      '#type' => 'value',
      '#value' => $type,
    );
    $form['type_display'] = array(
      '#type' => 'value',
      '#value' => $type_display,
    );
    $form['admin_page'] = array(
      '#type' => 'value',
      '#value' => $admin_page,
    );
    return confirm_form($form, t('Are you sure you want to delete the individual !type for %user?', array(
      '!type' => $type_display,
      '%user' => $username,
    )), "admin/user/userprotect/{$admin_page}");
  }
  else {
    drupal_set_message(t('Invalid selection.'), 'error');
    drupal_goto('admin/user/userprotect');
  }
}