<?php
// $Id: userplus.install,v 1.1.2.3 2010/01/22 22:30:40 marcp Exp $

/**
 * Implementation of hook_uninstall().
 */
function userplus_uninstall() {
  $variables = array(
    'userplus_add_multiple_roles',
    'userplus_assign_roles',
    'userplus_max_add_users',
    'userplus_max_show_user_roles',
    'userplus_show_required_profile_fields',
    'userplus_show_required_content_profile_fields',
  );

  foreach ($variables as $var) {
    variable_del($var);
  }
}

/**
 * Set it up so that all roles appear on the add multiple users
 * form as well as the the role assignment form to provide backwards
 * compatibility.
 */
function userplus_update_6200() {
  $ret = array();

  // Get the list of roles, excluding AUTHENTICATED and ANONYMOUS...
  $roles = user_roles(1);
  unset($roles[DRUPAL_AUTHENTICATED_RID]);

  foreach ($roles as $rid => $name) {
    $roles[$rid] = $rid;
  }

  $v = variable_get('userplus_add_multiple_roles', FALSE);
  if ($v === FALSE) {
    variable_set('userplus_add_multiple_roles', $roles);
  }

  $v = variable_get('userplus_assign_roles', FALSE);
  if ($v === FALSE) {
    variable_set('userplus_assign_roles', $roles);
  }

  return $ret;
}

/**
 * Rebuild the menu because we changed userplus_access() to
 * userplus_access_callback().
 */
function userplus_update_6201() {
  $ret = array();

  menu_rebuild();

  return $ret;
}
