From f104fd73e2bc6be8b2c34e36c1c31a69d836f9f7 Mon Sep 17 00:00:00 2001 From: Tim Steiner <tsteiner2@unl.edu> Date: Tue, 13 Jul 2010 19:08:14 +0000 Subject: [PATCH] Initial version of the unl install profile. git-svn-id: file:///tmp/wdn_thm_drupal/branches/drupal-7.x@137 20a16fea-79d4-4915-8869-1ea9d5ebf173 --- profiles/unl_profile/unl_profile.info | 36 ++++++++ profiles/unl_profile/unl_profile.install | 103 +++++++++++++++++++++++ profiles/unl_profile/unl_profile.profile | 13 +++ 3 files changed, 152 insertions(+) create mode 100644 profiles/unl_profile/unl_profile.info create mode 100644 profiles/unl_profile/unl_profile.install create mode 100644 profiles/unl_profile/unl_profile.profile diff --git a/profiles/unl_profile/unl_profile.info b/profiles/unl_profile/unl_profile.info new file mode 100644 index 00000000..125079f5 --- /dev/null +++ b/profiles/unl_profile/unl_profile.info @@ -0,0 +1,36 @@ +name = UNL +description = Setup an empty UNL Drupal site. +version = VERSION +core = 7.x +dependencies[] = block +dependencies[] = color +dependencies[] = comment +dependencies[] = contextual +dependencies[] = dashboard +dependencies[] = help +dependencies[] = image +dependencies[] = menu +dependencies[] = path +dependencies[] = taxonomy +dependencies[] = dblog +dependencies[] = search +dependencies[] = shortcut +dependencies[] = toolbar +dependencies[] = overlay +dependencies[] = field_ui +dependencies[] = file +dependencies[] = rdf + +dependencies[] = wysiwyg +dependencies[] = imce +dependencies[] = imce_wysiwyg +dependencies[] = unl +dependencies[] = unl_blocks + +files[] = unl.profile + +; Information added by drupal.org packaging script on 2010-05-23 +version = "7.0-alpha5" +project = "drupal" +datestamp = "1274628610" + diff --git a/profiles/unl_profile/unl_profile.install b/profiles/unl_profile/unl_profile.install new file mode 100644 index 00000000..efb74bca --- /dev/null +++ b/profiles/unl_profile/unl_profile.install @@ -0,0 +1,103 @@ +<?php + +/** + * Implements hook_install(). + * + * Perform actions to set up the site for this profile. + */ +function unl_profile_install() +{ + // Start out by calling the standard profile's setup. + require_once dirname(__FILE__) . '/../standard/standard.install'; + standard_install(); + + // Enable some standard blocks. + $values = array( + array( + 'module' => 'system', + 'delta' => 'main', + 'theme' => 'unl_wdn', + 'status' => 1, + 'weight' => 0, + 'region' => 'content', + 'pages' => '', + 'cache' => -1, + ), + array( + 'module' => 'system', + 'delta' => 'main-menu', + 'theme' => 'unl_wdn', + 'status' => 1, + 'weight' => 0, + 'region' => 'navlinks', + 'pages' => '', + 'cache' => -1, + ), + ); + $query = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'pages', 'cache')); + foreach ($values as $record) { + $query->values($record); + } + $query->execute(); + + + theme_enable(array('unl_wdn')); + variable_set('theme_default', 'unl_wdn'); + + + // Update the settings file to use shared database tables (unless this is the default site) + if (conf_path() != 'sites/default') { + $shared_prefix = unl_profile_get_default_site_db_prefix(); + $settings['databases'] = array( + 'value' => $GLOBALS['databases'], + 'required' => TRUE + ); + $settings['databases']['value']['default']['default']['prefix'] = array( + 'default' => $GLOBALS['databases']['default']['default']['prefix'], + 'authmap' => $shared_prefix, + 'filter' => $shared_prefix, + 'filter_format' => $shared_prefix, + 'role' => $shared_prefix, + 'sessions' => $shared_prefix, + 'users' => $shared_prefix, + 'users_roles' => $shared_prefix, + 'wysiwyg' => $shared_prefix + ); + $settings['drupal_hash_salt'] = array( + 'value' => 'FOOBAR' . $GLOBALS['drupal_hash_salt'], + 'required' => TRUE, + ); + + $settings_dir = DRUPAL_ROOT . DIRECTORY_SEPARATOR . conf_path(); + $settings_file = $settings_dir . '/settings.php'; + $writable = drupal_verify_install_file($settings_file, FILE_READABLE|FILE_WRITABLE); + + drupal_rewrite_settings($settings); + + // Only enable CAS on subsites until we get some sort of bootstrap setup. + module_enable(array('unl_cas')); + } + + + //$permissions = array_keys(module_invoke_all('permission')); + //print_r($permissions); + //user_role_grant_permissions(3, array($permissions)); + + echo "\nducks\n"; + + return; +} + + + +/** + * Load the default site's config file and return the db_prefix value from it. + */ +function unl_profile_get_default_site_db_prefix() +{ + $default_site_settings_file = DRUPAL_ROOT . '/sites/default/settings.php'; + require $default_site_settings_file; + + return $databases['default']['default']['prefix']; +} + diff --git a/profiles/unl_profile/unl_profile.profile b/profiles/unl_profile/unl_profile.profile new file mode 100644 index 00000000..f9107426 --- /dev/null +++ b/profiles/unl_profile/unl_profile.profile @@ -0,0 +1,13 @@ +<?php + +/** + * Implements hook_form_alter(). + * + * Allows the profile to alter the site configuration form. + */ +function unl_wdn_form_alter(&$form, $form_state, $form_id) { + if ($form_id == 'install_configure_form') { + // Set default for site name field. + $form['site_information']['site_name']['#default_value'] = $_SERVER['SERVER_NAME']; + } +} -- GitLab