You are here

function userprotect_install in User protect 7

Same name and namespace in other branches
  1. 8 userprotect.install \userprotect_install()
  2. 5 userprotect.install \userprotect_install()
  3. 6 userprotect.install \userprotect_install()

Implements hook_install().

File

./userprotect.install, line 19
Install, update and uninstall functions for the userprotect module.

Code

function userprotect_install() {

  // Default protections.
  db_insert('userprotect')
    ->fields(array(
    'uid' => 0,
    'up_name' => 0,
    'up_mail' => 0,
    'up_pass' => 0,
    'up_status' => 0,
    'up_roles' => 0,
    'up_cancel' => 1,
    'up_edit' => 1,
    'up_type' => 'user',
    'up_openid' => 1,
  ))
    ->execute();
  db_insert('userprotect')
    ->fields(array(
    'uid' => 1,
    'up_name' => 0,
    'up_mail' => 0,
    'up_pass' => 0,
    'up_status' => 0,
    'up_roles' => 0,
    'up_cancel' => 1,
    'up_edit' => 0,
    'up_type' => 'user',
    'up_openid' => 0,
  ))
    ->execute();

  // Default administrator bypass.
  db_insert('userprotect')
    ->fields(array(
    'uid' => 1,
    'up_name' => 1,
    'up_mail' => 1,
    'up_pass' => 1,
    'up_status' => 1,
    'up_roles' => 1,
    'up_cancel' => 1,
    'up_edit' => 1,
    'up_type' => 'admin',
    'up_openid' => 1,
  ))
    ->execute();

  // Default permissions for authenticated users.
  $permissions = array(
    'change own e-mail',
    'change own password',
    'change own openid',
    'edit own account',
  );
  user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, $permissions);
}