You are here

function forum_access_install in Forum Access 7

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

Implements hook_install().

File

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

Code

function forum_access_install() {
  db_update('system')
    ->fields(array(
    'weight' => 2,
  ))
    ->condition('name', 'forum_access')
    ->execute();
  if ($vid = variable_get('forum_nav_vocabulary', FALSE)) {
    $result = db_query("SELECT t.tid FROM {taxonomy_term_data} t LEFT JOIN {forum_access} fa ON t.tid = fa.tid WHERE fa.tid IS NULL AND t.vid = :vid", array(
      ':vid' => $vid,
    ));
    $grant_create_by_rid = array(
      DRUPAL_ANONYMOUS_RID => 0,
      DRUPAL_AUTHENTICATED_RID => 1,
    );
    foreach ($result as $td) {
      foreach ($grant_create_by_rid as $rid => $grant_create) {
        db_insert('forum_access')
          ->fields(array(
          'tid' => $td->tid,
          'rid' => $rid,
          'grant_view' => 1,
          'grant_update' => 0,
          'grant_delete' => 0,
          'grant_create' => $grant_create,
          'priority' => 0,
        ))
          ->execute();
      }
    }
  }
}