You are here

pmexpense.install in Drupal PM (Project Management) 7.3

Installation file for pmexpense module.

File

pmexpense/pmexpense.install
View source
<?php

/**
 * @file
 * Installation file for pmexpense module.
 */

/**
 * Implements hook_install().
 */
function pmexpense_install() {
  variable_set('node_options_pmexpense', array(
    'status',
  ));

  // PM Permissions default configurations.
  variable_set('pm_permission_field_parent_reference_for_pmexpense', 'pmexpense_parent');
  variable_set('pm_permission_node_pmexpense_enabled', TRUE);

  // Create and attaches fields to pmexpense content type.
  module_load_include('inc', 'pmexpense', 'includes/pmexpense.migrate');

  // Parameter $sandbox is passed as a placeholder.
  $sandbox = array();
  pmexpense_migrate_create_fields($sandbox);
}

/**
 * Implements hook_disable().
 */
function pmexpense_disable() {
  module_load_include('inc', 'pm', 'includes/pm.install');
  $module = 'pmexpense';

  // Set standardised message.
  pm_disable_message($module, 'expenses');
}

/**
 * Implements hook_uninstall().
 */
function pmexpense_uninstall() {
  module_load_include('inc', 'pm', 'includes/pm.install');
  $module = 'pmexpense';

  // Delete items created by his module.
  pm_uninstall_variables($module);
  pm_uninstall_fields($module);

  // Set standardised message.
  pm_uninstall_message($module, 'expenses');
}

/**
 * Implements hook_update_last_removed().
 */
function pmexpense_update_last_removed() {
  return 7104;
}

/**
 * Migrate PM Expense nodes to field_api fields.
 */
function pmexpense_update_7200(&$sandbox) {
  module_load_include('inc', 'pmexpense', 'includes/pmexpense.migrate');
  if (pmexpense_migrate_update_could_be_performed()) {
    return pmexpense_migrate($sandbox);
  }
}

/**
 * Add entityreference_prepopulate behaviour to pmexpense_parent.
 */
function pmexpense_update_7300() {
  $entity_type = 'node';
  $field_name = 'pmexpense_parent';
  $bundle_name = 'pmexpense';

  // Get defaults from the configurations.
  module_load_include('inc', 'pmexpense', 'includes/pmexpense.field_instance');
  $field_instances = pmexpense_default_field_instances();
  $field_instance = $field_instances['node-pmexpense-pmexpense_parent'];
  $instance_info = field_info_instance($entity_type, $field_name, $bundle_name);
  $instance_info['settings']['behaviors']['prepopulate'] = $field_instance['settings']['behaviors']['prepopulate'];
  $instance_info['default_value_function'] = $field_instance['default_value_function'];
  field_update_instance($instance_info);
}

Functions

Namesort descending Description
pmexpense_disable Implements hook_disable().
pmexpense_install Implements hook_install().
pmexpense_uninstall Implements hook_uninstall().
pmexpense_update_7200 Migrate PM Expense nodes to field_api fields.
pmexpense_update_7300 Add entityreference_prepopulate behaviour to pmexpense_parent.
pmexpense_update_last_removed Implements hook_update_last_removed().