node_access_example.install

  1. drupal
    1. 5

Functions & methods

NameDescription
node_access_example_disableImplementation of hook_disable().
node_access_example_enableImplementation of hook_enable().
node_access_example_installImplementation of hook_install().
node_access_example_uninstallImplementation of hook_uninstall().
View source
<?php

/**
 * Implementation of hook_install().
 */
function node_access_example_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("
          CREATE TABLE {node_access_example} (
            nid int(10) unsigned NOT NULL default '0' PRIMARY KEY,
            private int,
            KEY node_example_nid (nid)
          ) /*!40100 DEFAULT CHARACTER SET utf8 */;
      ");
      break;
    case 'pgsql':
      db_query("
          CREATE TABLE {node_access_example} (
            nid int NOT NULL default '0',
            private int,
            PRIMARY KEY (nid));
      ");
      break;
  }
}

/**
 * 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 node_access_example_enable() {
  node_access_rebuild();
}

/**
 * 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 node_access_example_disable() {
  node_access_example_disabling(TRUE);
  node_access_rebuild();
}

/**
 * Implementation of hook_uninstall().
 */
function node_access_example_uninstall() {
  if (db_table_exists('node_access_example')) {
    db_query("DROP TABLE {node_access_example}");
  }
}