You are here

function user_permissions_profile_permissions_form in User Permissions 6

Same name and namespace in other branches
  1. 5 user_permissions.module \user_permissions_profile_permissions_form()
  2. 7 user_permissions.module \user_permissions_profile_permissions_form()

Create form on user's profile for assigning permissions

1 string reference to 'user_permissions_profile_permissions_form'
user_permissions_menu in ./user_permissions.module
Implementation of hook_menu().

File

./user_permissions.module, line 40

Code

function user_permissions_profile_permissions_form($form_state, $user) {
  $role_name = '_user_role_' . $user->uid;
  $rid = db_result(db_query("SELECT rid FROM {role} WHERE name = '%s'", $role_name));
  if ($rid) {
    $form = user_admin_perm($form_state, $rid);
  }
  else {
    $rid = DRUPAL_ANONYMOUS_RID;
    $form = user_admin_perm($form_state, $rid);
    $form['checkboxes'][$rid]['#default_value'] = array();
  }
  $form['role_names'][$rid]['#value'] = 'Enable?';
  $form['role_name'] = array(
    '#type' => 'hidden',
    '#value' => $role_name,
  );
  $form['rid'] = array(
    '#type' => 'hidden',
    '#value' => $rid,
  );
  return $form;
}