You are here

pmtask.install in Drupal PM (Project Management) 7.2

Install, disable, uninstall and update functions for pmtask module.

File

pmtask/pmtask.install
View source
<?php

/**
 * @file
 * Install, disable, uninstall and update functions for pmtask module.
 */

/**
 * Implements hook_install().
 */
function pmtask_install() {
  variable_set('node_options_pmtask', array(
    'status',
  ));

  // PM Permissions default configurations.
  variable_set('pmpermission_field_assigned_reference', 'pm_assigned');
  variable_set('pmpermission_field_parent_reference_for_pmtask', 'pmtask_parent');
  variable_set('pmpermission_node_pmtask_enabled', TRUE);

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

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

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

/**
 * Implements hook_uninstall().
 */
function pmtask_uninstall() {
  variable_del('pmpermission_field_parent_reference_for_pmtask');
  variable_del('pmpermission_node_pmtask_enabled');

  // Clean up field instances (and field) and its data.
  module_load_include('inc', 'pmtask', 'includes/pmtask.field_instance');
  module_load_include('inc', 'pmtask', 'includes/pmtask.field_base');
  $declared_field_bases = pmtask_default_field_bases();
  $declared_field_instances = pmtask_default_field_instances();
  $field_instance = field_info_instances('node', 'pmtask');
  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 pmtask_update_last_removed() {
  return 6202;
}

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

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

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

Functions

Namesort descending Description
pmtask_disable Implements hook_disable().
pmtask_install Implements hook_install().
pmtask_uninstall Implements hook_uninstall().
pmtask_update_7105 Migrate PM Project nodes to field_api fields.
pmtask_update_dependencies Implements hook_update_dependencies().
pmtask_update_last_removed Implements hook_update_last_removed().