You are here

pmteam.install in Drupal PM (Project Management) 7.2

Install, uninstall and update functions for the PM Team module.

File

pmteam/pmteam.install
View source
<?php

/**
 * @file
 * Install, uninstall and update functions for the PM Team module.
 */

/**
 * Implements hook_install().
 */
function pmteam_install() {

  // Create and attaches fields to pmteam content type.
  module_load_include('inc', 'pmteam', 'includes/pmteam.migrate');
  variable_set('pmpermission_field_parent_reference_for_pmteam', 'pmteam_organization');

  // Parameter $sandbox is passed as a placeholder.
  $sandbox = array();
  pmteam_migrate_create_fields($sandbox);
  variable_set("pmpermission_node_pmteam_enabled", TRUE);
}

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

/**
 * Implements hook_uninstall().
 */
function pmteam_uninstall() {
  variable_del('pmpermission_node_pmteam_enabled');
  variable_del('pmpermission_field_parent_reference_for_pmteam');

  // Clean up field instances (and field) and its data.
  module_load_include('inc', 'pmteam', 'includes/pmteam.field_instance');
  module_load_include('inc', 'pmteam', 'includes/pmteam.field_base');
  $declared_field_bases = pmteam_default_field_bases();
  $declared_field_instances = pmteam_default_field_instances();
  $field_instance = field_info_instances('node', 'pmteam');
  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 pmteam_update_last_removed() {
  return 6201;
}

/**
 * Adds Drupal 7 style body field to PM Team nodes.
 */
function pmteam_update_7100() {

  // Uncache node types.
  node_types_rebuild();

  // Fetch a list of current node types and add a body field to PM Team.
  $types = node_type_get_types();
  node_add_body_field($types['pmteam'], 'Description');
}

/**
 * Allow Project Management to override the default content type permissions.
 */
function pmteam_update_7101() {
  variable_set('node_permissions_pmteam', 0);
  return 'PM Team permissions overridden';
}

/**
 * Display message to admin regarding need to rebuild permission.
 */
function pmteam_update_7102() {
  node_access_needs_rebuild(TRUE);
}

/**
 * Migrate PM Team nodes to field_api fields.
 */
function pmteam_update_7103(&$sandbox) {
  module_load_include('inc', 'pmteam', 'includes/pmteam.migrate');
  if (pmteam_migrate_update_could_be_performed()) {
    return pmteam_migrate($sandbox);
  }
}

/**
 * Change team parent field cardinality to 1.
 */
function pmteam_update_7200() {
  $field = array(
    'field_name' => 'pmteam_organization',
    'cardinality' => 1,
  );
  field_update_field($field);
}

/**
 * Set pmpermission_field_parent_reference_for_pmteam variable.
 */
function pmteam_update_7201() {
  variable_set('pmpermission_field_parent_reference_for_pmteam', 'pmteam_organization');
}

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

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

Functions

Namesort descending Description
pmteam_disable Implements hook_disable().
pmteam_install Implements hook_install().
pmteam_uninstall Implements hook_uninstall().
pmteam_update_7100 Adds Drupal 7 style body field to PM Team nodes.
pmteam_update_7101 Allow Project Management to override the default content type permissions.
pmteam_update_7102 Display message to admin regarding need to rebuild permission.
pmteam_update_7103 Migrate PM Team nodes to field_api fields.
pmteam_update_7200 Change team parent field cardinality to 1.
pmteam_update_7201 Set pmpermission_field_parent_reference_for_pmteam variable.
pmteam_update_dependencies Implements hook_update_dependencies().
pmteam_update_last_removed Implements hook_update_last_removed().