You are here

pmticket.install in Drupal PM (Project Management) 7.2

Installation functions for the Project Management project module.

File

pmticket/pmticket.install
View source
<?php

/**
 * @file
 * Installation functions for the Project Management project module.
 */

/**
 * Implements hook_install().
 */
function pmticket_install() {
  variable_set('node_options_pmticket', array(
    'status',
  ));

  // PM Permissions default configurations.
  variable_set('pmpermission_field_assigned_reference', 'pm_assigned');
  variable_set('pmpermission_field_pm_reference', 'pm_manager');
  variable_set('pmpermission_field_parent_reference_for_pmticket', 'pmticket_parent');
  variable_set('pmpermission_node_pmticket_enabled', TRUE);

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

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

/**
 * Implements hook_disable().
 */
function pmticket_disable() {
  drupal_set_message(t('Nodes of type "Ticket" have not been deleted on disabling Project Management Ticket. Please note that they will now have reduced functionality, and will not be protected by Project Management Ticket access controls.'), 'warning');
}

/**
 * Implements hook_uninstall().
 */
function pmticket_uninstall() {
  variable_del('pmpermission_field_parent_reference_for_pmticket');
  variable_del('pmpermission_node_pmticket_enabled');

  // Clean up field instances (and field) and its data.
  module_load_include('inc', 'pmticket', 'includes/pmticket.field_instance');
  module_load_include('inc', 'pmticket', 'includes/pmticket.field_base');
  $declared_field_bases = pmticket_default_field_bases();
  $declared_field_instances = pmticket_default_field_instances();
  $field_instance = field_info_instances('node', 'pmticket');
  foreach ($declared_field_instances as $declared_instance) {
    $instance = $field_instance[$declared_instance['field_name']];
    if ($instance) {

      // Only delete field base if declared by this module.
      $delete_field_base = isset($declared_field_bases[$declared_instance['field_name']]);
      field_delete_instance($instance, $delete_field_base);
    }
  }
}

/**
 * Implements hook_update_last_removed().
 */
function pmticket_update_last_removed() {
  return 6202;
}

/**
 * Migrate PM Ticket nodes to field_api fields.
 */
function pmticket_update_7105(&$sandbox) {
  module_load_include('inc', 'pmticket', 'includes/pmticket.migrate');
  if (pmticket_migrate_update_could_be_performed()) {
    return pmticket_migrate($sandbox);
  }
}

/**
 * Implements hook_update_dependencies().
 */
function pmticket_update_dependencies() {

  // pmperson_update_7104() migrates pmperson data to drupal user.
  // pmticket migration depends on its completion.
  $dependencies['pmticket'][7105] = array(
    'pmproject' => 7104,
  );
  return $dependencies;
}

Functions