function system_enable

6.x system.install system_enable()
4.x system.install system_enable()
5.x system.install system_enable()

Implementation of hook_enable.

This is meant to be called during initial installation. We will make all of the database changes we need to make in order to have FlightPath up and running.

1 call to system_enable()
install_perform_install in ./install.php
Actually performs the installation of FlightPath

File

modules/system/system.install, line 18
The install file for the System module

Code

function system_enable() {

  // Set up our default roles
  db_query("INSERT INTO roles (rid, name)
            VALUES (1, 'anonymous user'), 
                   (2, 'authenticated user')");

  // Add in the anonymous user into the users table (uid = 0)
  db_query("INSERT INTO users (user_id, cwid, user_name) VALUES (0, 0, 'anonymous')");

  // Let's figure out what the current schema value is for this system module...
  $info_contents = file_get_contents("modules/system/system.info");
  // From the info_contents variable, split up and place into an array.
  $info_details_array = array();
  $lines = explode("\n", $info_contents);
  foreach ($lines as $line) {
    if (trim($line) == "") {
      continue;
    }
    $temp = explode("=", trim($line));
    $info_details_array [trim($temp [0])] = trim(substr($line, strlen($temp [0]) + 1));
  }

  // Set up the modules table-- add the system module first.    
  db_query("INSERT INTO modules (path, name, version, enabled, weight, type, `schema`)
            VALUES ('modules/system', 'system', 'core', 1, '-999', 'module', '?') ", $info_details_array ["schema"]);


  // Let's perform installations on the other modules we want enabled by default.
  $modules = array("admin", "advise", "blocks", "comments", "student_search", "update_status", "content", "announcements", "tinymce", "course_search", "blank_degrees", "user");
  foreach ($modules as $module) {
    system_enable_module(array("module" => $module, "path" => "modules/$module", "version" => "core"));
  }

  // Set up some blocks for the system module by default.
  db_query("INSERT INTO blocks (section, region, module, delta, weight)
            VALUES ('system_main', 'right_col', 'system', 'tools', 1),
                   ('system_main', 'right_col', 'system', 'admin_tools', 2), 
                   ('system_main', 'left_col', 'announcements', 'primary', 0), 
                   ('system_login', 'left_col', 'blocks', 'block_1', 0), 
                   ('system_login', 'right_col', 'system', 'login_form', 0),
                   ('system_login', 'top', 'blocks', 'block_2', 0)
                   
                   ");


  // Set up some basic permissions for authenticated user.
  db_query("INSERT INTO role_permissions (rid, perm)
            VALUES 
              (2, 'access_logged_in_content'),
              (2, 'view_comments') ");


}