summaryrefslogtreecommitdiff
path: root/modules/user/user.install
diff options
context:
space:
mode:
Diffstat (limited to 'modules/user/user.install')
-rw-r--r--modules/user/user.install52
1 files changed, 52 insertions, 0 deletions
diff --git a/modules/user/user.install b/modules/user/user.install
index 9c7de82c3..d9d017661 100644
--- a/modules/user/user.install
+++ b/modules/user/user.install
@@ -252,6 +252,58 @@ function user_schema() {
}
/**
+ * Implements hook_install().
+ */
+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' => serialize(array()),
+ ))
+ ->execute();
+
+ // Built-in roles.
+ $rid_anonymous = db_insert('role')
+ ->fields(array('name' => 'anonymous user'))
+ ->execute();
+ $rid_authenticated = db_insert('role')
+ ->fields(array('name' => 'authenticated user'))
+ ->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();
+ }
+}
+
+/**
* @defgroup user-updates-6.x-to-7.x User updates from 6.x to 7.x
* @{
*/