You are here

og_access.install in Organic groups 5.7

Same filename and directory in other branches
  1. 5.8 og_access.install
  2. 5 og_access.install
  3. 5.3 og_access.install

File

og_access.install
View source
<?php

/**
 * An implementation of hook_install().
 */
function og_access_install() {

  // Put this module after OG so it can form_alter as needed.
  db_query("UPDATE {system} SET weight = 1 WHERE name = 'og_access'");
}

/**
 * Implementation of hook_enable().
 *
 * A node access module needs to force a rebuild of the node access table
 * when it is enabled to ensure that things are set up.
 */
function og_access_enable() {
  node_access_rebuild();
  drupal_set_message(t('The node access table has been rebuilt.'));
}

/**
 * Implementation of hook_disable().
 *
 * A node access module needs to force a rebuild of the node access table
 * when it is disabled to ensure that its entries are removed from the table.
 */
function og_access_disable() {

  // This dodginess is fixed in core D6. Basically, we can't rebuild because we are still enabled.
  if (count(module_implements('node_grants')) == 1) {

    // Not using any other node_access modules. add the default grant.
    db_query("DELETE FROM {node_access}");
    db_query("INSERT INTO {node_access} VALUES (0, 0, 'all', 1, 0, 0)");
    cache_clear_all();
  }
  else {
    og_access_disabling(TRUE);
    node_access_rebuild();
  }
  drupal_set_message(t('The node access table has been rebuilt.'));
}

/**
 * Simple function to make sure we don't respond with grants when disabling
 * ourselves.
 */
function og_access_disabling($set = NULL) {
  static $disabling = false;
  if ($set !== NULL) {
    $disabling = $set;
  }
  return $disabling;
}
function og_access_uninstall() {

  // Delete variables
  $variables = array(
    'og_private_groups',
    'og_visibility',
  );
  foreach ($variables as $variable) {
    variable_del($variable);
  }
}

Functions

Namesort descending Description
og_access_disable Implementation of hook_disable().
og_access_disabling Simple function to make sure we don't respond with grants when disabling ourselves.
og_access_enable Implementation of hook_enable().
og_access_install An implementation of hook_install().
og_access_uninstall