You are here

function spaces_og_enable in Spaces 7

Same name and namespace in other branches
  1. 5.2 spaces_og.install \spaces_og_enable()
  2. 6.3 spaces_og/spaces_og.module \spaces_og_enable()
  3. 6 spaces_og/spaces_og.install \spaces_og_enable()
  4. 6.2 spaces_og/spaces_og.install \spaces_og_enable()
  5. 7.3 spaces_og/spaces_og.module \spaces_og_enable()

Implements hook_enable().

File

spaces_og/spaces_og.module, line 18

Code

function spaces_og_enable() {

  // Configure purl, grab OG method, set to path if not configured.
  $purl_types = variable_get('purl_types', array());
  if (!variable_get('purl_method_spaces_og', FALSE)) {
    $purl_types['path'] = 'path';
    variable_set('purl_types', $purl_types);
    variable_set('purl_method_spaces_og', 'path');
  }

  // The next 2 lines are for Simpletest, it won't have it otherwise.
  // variable_get up top retrieves the settings from the host, while
  // variable_set here writes into the test site. As a result,
  // variable_get('purl_method_spaces_og') will retrieve the value of the host
  // site. If it is present in the host site, the initial configuration is not
  // being executed and the tests fail.
  variable_set('purl_types', $purl_types);
  variable_set('purl_method_spaces_og', variable_get('purl_method_spaces_og', FALSE));

  // Weight spaces_og to be after OG
  $weight = db_query("SELECT weight FROM {system} WHERE type = :type AND name = :name", array(
    ':type' => 'module',
    ':name' => 'og',
  ))
    ->fetchField();

  // TODO Please review the conversion of this statement to the D7 database API syntax.

  /* db_query("UPDATE {system} SET weight = %d WHERE name = 'spaces_og'", ($weight + 1)) */
  db_update('system')
    ->fields(array(
    'weight' => $weight + 1,
  ))
    ->condition('name', 'spaces_og')
    ->execute();
}