You are here

pmticket.install in Drupal PM (Project Management) 7.3

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('pm_permission_field_assigned_reference', 'pm_assigned');
  variable_set('pm_permission_field_pm_reference', 'pm_manager');
  variable_set('pm_permission_field_parent_reference_for_pmticket', 'pmticket_parent');
  variable_set('pm_permission_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() {
  module_load_include('inc', 'pm', 'includes/pm.install');
  $module = 'pmticket';

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

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

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

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

/**
 * 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);
  }
}

/**
 * Add entityreference_prepopulate behaviour to pmticket_parent.
 */
function pmticket_update_7300() {
  $entity_type = 'node';
  $field_name = 'pmticket_parent';
  $bundle_name = 'pmticket';

  // Get defaults from the configurations.
  module_load_include('inc', 'pmticket', 'includes/pmticket.field_instance');
  $field_instances = pmticket_default_field_instances();
  $field_instance = $field_instances['node-pmticket-pmticket_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);
}

/**
 * Add entityreference_prepopulate behaviour to pm_assigned.
 */
function pmticket_update_7301() {
  $entity_type = 'node';
  $bundle_name = 'pmticket';

  // Get defaults from the configurations.
  module_load_include('inc', 'pmticket', 'includes/pmticket.field_base');
  module_load_include('inc', 'pmticket', 'includes/pmticket.field_instance');
  $field_bases = pmticket_default_field_bases();
  $field_instances = pmticket_default_field_instances();

  // Update pm_assigned.
  $field_name = 'pm_assigned';
  $field_base = $field_bases[$field_name];
  $base_info = array(
    'field_name' => $field_name,
    'settings' => $field_base['settings'],
  );
  field_update_field($base_info);

  // Update Field Instance.
  $field_instance = $field_instances['node-pmticket-pm_assigned'];
  $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);
}

/**
 * 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

Namesort descending Description
pmticket_disable Implements hook_disable().
pmticket_install Implements hook_install().
pmticket_uninstall Implements hook_uninstall().
pmticket_update_7105 Migrate PM Ticket nodes to field_api fields.
pmticket_update_7300 Add entityreference_prepopulate behaviour to pmticket_parent.
pmticket_update_7301 Add entityreference_prepopulate behaviour to pm_assigned.
pmticket_update_dependencies Implements hook_update_dependencies().
pmticket_update_last_removed Implements hook_update_last_removed().