You are here

function user_permissions_form_alter in User Permissions 5

Same name and namespace in other branches
  1. 8 user_permissions.module \user_permissions_form_alter()

File

./user_permissions.module, line 146

Code

function user_permissions_form_alter($form_id, &$form) {
  if ($form_id == 'user_filter_form') {
    if (is_array($form['filters']['status']['role']['#options'])) {
      foreach ($form['filters']['status']['role']['#options'] as $key => $value) {
        if (strpos($value, "_user_role_") !== FALSE) {
          unset($form['filters']['status']['role']['#options'][$key]);
        }
      }
    }
  }
  if ($form_id == 'user_admin_account') {
    if (is_array($form['options']['operation']['#options']['Add a role to the selected users']) && is_array($form['options']['operation']['#options']['Remove a role from the selected users'])) {
      foreach ($form['options']['operation']['#options']['Add a role to the selected users'] as $key => $value) {
        if (strpos($value, "_user_role_") !== FALSE) {
          unset($form['options']['operation']['#options']['Add a role to the selected users'][$key]);
        }
      }
      foreach ($form['options']['operation']['#options']['Remove a role from the selected users'] as $key => $value) {
        if (strpos($value, "_user_role_") !== FALSE) {
          unset($form['options']['operation']['#options']['Remove a role from the selected users'][$key]);
        }
      }
    }
  }
  if ($form_id == 'user_admin_perm') {
    $role_id_filter = array();
    foreach (user_roles() as $key => $value) {
      if (strpos($value, "_user_role_") !== FALSE) {
        $role_id_filter[] = $key;
      }
    }
    foreach ($form['checkboxes'] as $key => $value) {
      if (in_array($key, $role_id_filter)) {
        unset($form['checkboxes'][$key]);
      }
    }
    foreach ($form['role_names'] as $key => $value) {
      if (in_array($key, $role_id_filter)) {
        unset($form['role_names'][$key]);
      }
    }
  }
}