You are here

function user_permissions_profile_permissions_form in User Permissions 5

Same name and namespace in other branches
  1. 6 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 53

Code

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