You are here

function nodeaccess_install in Nodeaccess 6

Same name and namespace in other branches
  1. 8.2 nodeaccess.install \nodeaccess_install()
  2. 8 nodeaccess.install \nodeaccess_install()
  3. 5 nodeaccess.install \nodeaccess_install()
  4. 6.2 nodeaccess.install \nodeaccess_install()
  5. 7 nodeaccess.install \nodeaccess_install()

Implementation of hook_install().

File

./nodeaccess.install, line 8

Code

function nodeaccess_install() {

  // Create tables.
  drupal_install_schema('nodeaccess');

  // Set up default permissions to be view for authenticated and
  // anonymous users, and no special permissions for author.
  $grants = array();
  $grants[] = array(
    'gid' => 1,
    'realm' => 'nodeaccess_rid',
    'grant_view' => 1,
    'grant_update' => 0,
    'grant_delete' => 0,
  );
  $grants[] = array(
    'gid' => 2,
    'realm' => 'nodeaccess_rid',
    'grant_view' => 1,
    'grant_update' => 0,
    'grant_delete' => 0,
  );
  $author_prefs = array();
  foreach (node_get_types() as $type => $name) {
    variable_set('nodeaccess_' . $type, $grants);
    $author_prefs[$type] = array(
      'grant_view' => 0,
      'grant_update' => 0,
      'grant_delete' => 0,
    );
  }
  variable_set('nodeaccess_authors', $author_prefs);

  // Set up all permissions to be editable by default.
  $grant_prefs = array(
    'view' => 1,
    'edit' => 1,
    'delete' => 1,
  );
  variable_set('nodeaccess-grants', $grant_prefs);
}