function user_install
7.x user.install | user_install() |
Implements hook_install().
File
- drupal-7.x/
modules/ user/ user.install, line 293 - Install, update and uninstall functions for the user module.
Code
function user_install() {
// Insert a row for the anonymous user.
db_insert('users')
->fields(array(
'uid' => 0,
'name' => '',
'mail' => '',
))
->execute();
// We need some placeholders here as name and mail are uniques and data is
// presumed to be a serialized array. This will be changed by the settings
// form in the installer.
db_insert('users')
->fields(array(
'uid' => 1,
'name' => 'placeholder-for-uid-1',
'mail' => 'placeholder-for-uid-1',
'created' => REQUEST_TIME,
'status' => 1,
'data' => NULL,
))
->execute();
// Built-in roles.
$rid_anonymous = db_insert('role')
->fields(array('name' => 'anonymous user', 'weight' => 0))
->execute();
$rid_authenticated = db_insert('role')
->fields(array('name' => 'authenticated user', 'weight' => 1))
->execute();
// Sanity check to ensure the anonymous and authenticated role IDs are the
// same as the drupal defined constants. In certain situations, this will
// not be true.
if ($rid_anonymous != DRUPAL_ANONYMOUS_RID) {
db_update('role')
->fields(array('rid' => DRUPAL_ANONYMOUS_RID))
->condition('rid', $rid_anonymous)
->execute();
}
if ($rid_authenticated != DRUPAL_AUTHENTICATED_RID) {
db_update('role')
->fields(array('rid' => DRUPAL_AUTHENTICATED_RID))
->condition('rid', $rid_authenticated)
->execute();
}
}