You are here

pmproject.install in Drupal PM (Project Management) 7.2

Installation functions for the Project Management project module.

File

pmproject/pmproject.install
View source
<?php

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

/**
 * Implements hook_install().
 */
function pmproject_install() {
  variable_set('node_options_pmproject', 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_pmproject', 'pmproject_parent');
  variable_set('pmpermission_node_pmproject_enabled', TRUE);

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

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

/**
 * Implements hook_uninstall().
 */
function pmproject_uninstall() {
  variable_del('pmpermission_field_assigned_reference');
  variable_del('pmpermission_field_pm_reference');
  variable_del('pmpermission_field_parent_reference_for_pmproject');
  variable_del('pmpermission_node_pmproject_enabled');

  // Clean up field instances (and field) and its data.
  module_load_include('inc', 'pmproject', 'includes/pmproject.field_instance');
  module_load_include('inc', 'pmproject', 'includes/pmproject.field_base');
  $declared_field_bases = pmproject_default_field_bases();
  $declared_field_instances = pmproject_default_field_instances();
  $field_instance = field_info_instances('node', 'pmproject');
  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_disable().
 */
function pmproject_disable() {
  drupal_set_message(t('Nodes of type "Project" have not been deleted on disabling Project Management Project. Please note that they will now have reduced functionality, and will not be protected by Project Management Project access controls.'), 'warning');
}

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

/**
 * Migrate PM Project nodes to field_api fields.
 */
function pmproject_update_7105(&$sandbox) {
  if (!module_exists('pmpermission')) {
    module_enable(array(
      'pmpermission',
    ));
  }
  module_load_include('inc', 'pmproject', 'includes/pmproject.migrate');
  if (pmproject_migrate_update_could_be_performed()) {
    return pmproject_migrate($sandbox);
  }
}

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

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

Functions