You are here

relation_add.install in Relation add 7

Relation Add install file.

File

relation_add.install
View source
<?php

/**
 * @file
 * Relation Add install file.
 */

/**
 * Implements hook_install().
 */
function relation_add_install() {
  $rids = db_select('role', 'r')
    ->fields('r', array(
    'rid',
  ))
    ->condition('name', array(
    'anonymous user',
    'authenticated user',
  ), 'IN')
    ->execute()
    ->fetchAllAssoc('rid', 'array');
  foreach (array_keys($rids) as $rid) {
    user_role_grant_permissions($rid, array(
      'relation add endpoint autocomplete access',
    ));
  }
}

/**
 * Implements hook_uninstall().
 */
function relation_add_uninstall() {
  variable_del('relation_add_iso_language_codes');
}

/**
 * Implements hook_update_N().
 *
 * Add endpoint autocomplete menu callback access to
 * the anonymousandauthenticated user roles.
 */
function relation_add_update_7001() {
  $rids = db_select('role', 'r')
    ->fields('r', array(
    'rid',
  ))
    ->condition('name', array(
    'anonymous user',
    'authenticated user',
  ), 'IN')
    ->execute()
    ->fetchAllAssoc('rid', 'array');
  foreach (array_keys($rids) as $rid) {
    user_role_grant_permissions($rid, array(
      'relation add endpoint autocomplete access',
    ));
  }
  return t('Added endpoint autocomplete menu callback access to the anonymous and authenticated user roles.');
}

/**
 * Drupal menu rebuild.
 */
function relation_add_update_7002() {
  menu_rebuild();
}

/**
 * Move relation global settings to the instance setting.
 */
function relation_add_update_7003() {
  $fields = field_info_fields();
  $relation_fields = array();
  foreach ($fields as $name => $field) {
    if ('relation_add' == $field['type']) {
      $relation_fields[$name] = $field;
    }
  }
  $bundle_display = variable_get('relation_add_bundle_display', FALSE);
  $iso_language_codes = variable_get('relation_add_iso_language_codes', array(
    'iso_choice' => 0,
  ));
  foreach ($relation_fields as $field_name => $field) {
    foreach ($field['bundles'] as $entity_type => $bundles) {
      foreach ($bundles as $bundle) {
        $instance = field_info_instance($entity_type, $field_name, $bundle);
        $instance['widget']['settings']['relation_endpoint_bundle_display'] = $bundle_display;
        $instance['widget']['settings']['relation_endpoint_iso_language_codes'] = $iso_language_codes['iso_choice'];
        field_update_instance($instance);
      }
    }
  }
  variable_del('relation_add_bundle_display');
  variable_del('relation_add_iso_language_codes');
  return t('Move relation global settings to the instance setting.');
}

Functions

Namesort descending Description
relation_add_install Implements hook_install().
relation_add_uninstall Implements hook_uninstall().
relation_add_update_7001 Implements hook_update_N().
relation_add_update_7002 Drupal menu rebuild.
relation_add_update_7003 Move relation global settings to the instance setting.