From 1c26e2cee1dfde11eb505db66ec2b97baa7244d9 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Mon, 1 Mar 2010 07:39:12 +0000 Subject: - Patch #728820 by David_Rothstein: clean up installation of required modules. --- modules/user/user.install | 52 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'modules/user/user.install') 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 @@ -251,6 +251,58 @@ function user_schema() { return $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 * @{ -- cgit v1.2.3