You are here

function forum_access_install in Forum Access 6

Same name and namespace in other branches
  1. 8 forum_access.install \forum_access_install()
  2. 5 forum_access.install \forum_access_install()
  3. 7 forum_access.install \forum_access_install()

Implementation of hook_install().

File

./forum_access.install, line 12
Install, update and uninstall functions for the forum_access module.

Code

function forum_access_install() {
  drupal_install_schema('forum_access');
  db_query("UPDATE {system} SET weight = 2 WHERE name = 'forum_access'");
  if ($vid = variable_get('forum_nav_vocabulary', FALSE)) {
    $result = db_query("\n      SELECT t.tid\n        FROM {term_data} t\n        LEFT JOIN {forum_access} fa ON t.tid = fa.tid\n        WHERE fa.tid IS NULL AND t.vid = %d\n      ", $vid);
    $grant_create_by_rid = array(
      DRUPAL_ANONYMOUS_RID => 0,
      DRUPAL_AUTHENTICATED_RID => 1,
    );
    while ($td = db_fetch_object($result)) {
      foreach ($grant_create_by_rid as $rid => $grant_create) {
        db_query("\n          INSERT INTO {forum_access}\n          (tid, rid, grant_view, grant_update, grant_delete, grant_create, priority)\n          VALUES(%d, %d, 1, 0, 0, %d, 0)\n        ", $td->tid, $rid, $grant_create);
      }
    }
  }
}