pmissue.install in Drupal PM (Project Management) 7.3
Same filename and directory in other branches
Install, disable, uninstall and update functions for PM Issue module.
File
pmissue/pmissue.installView source
<?php
/**
* @file
* Install, disable, uninstall and update functions for PM Issue module.
*/
/**
* Implements hook_install().
*/
function pmissue_install() {
variable_set('node_options_pmissue', 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_pmissue', 'pmissue_parent');
variable_set('pm_permission_node_pmissue_enabled', TRUE);
// Create and attaches fields to pmissue content type.
module_load_include('inc', 'pmissue', 'includes/pmissue.migrate');
pmissue_migrate_create_fields();
}
/**
* Implements hook_disable().
*/
function pmissue_disable() {
module_load_include('inc', 'pm', 'includes/pm.install');
$module = 'pmissue';
// Set standardised message.
pm_disable_message($module, 'issues');
}
/**
* Implements hook_uninstall().
*/
function pmissue_uninstall() {
module_load_include('inc', 'pm', 'includes/pm.install');
$module = 'pmissue';
// Delete items created by his module.
pm_uninstall_variables($module);
pm_uninstall_fields($module);
// Set standardised message.
pm_uninstall_message($module, 'issues');
}
/**
* Add entityreference_prepopulate behaviour to pmissue fields.
*
* Fields altered pmissue_parent & pmissue_parent_issue.
*/
function pmissue_update_7300() {
$entity_type = 'node';
$field_name = 'pmissue_parent';
$bundle_name = 'pmissue';
// Get defaults from the configurations.
module_load_include('inc', 'pmissue', 'includes/pmissue.field_instance');
$field_instances = pmissue_default_field_instances();
$field_instance = $field_instances['node-pmissue-pmissue_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);
$field_name = 'pmissue_parent_issue';
$field_instance = $field_instances['node-pmissue-pmissue_parent_issue'];
$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 pmissue_update_7301() {
$entity_type = 'node';
$bundle_name = 'pmissue';
// Get defaults from the configurations.
module_load_include('inc', 'pmissue', 'includes/pmissue.field_base');
module_load_include('inc', 'pmissue', 'includes/pmissue.field_instance');
$field_bases = pmissue_default_field_bases();
$field_instances = pmissue_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-pmissue-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);
}
/**
* Change the widget used for Related and Parent issue to autocomplete.
*/
function pmissue_update_7302() {
$entity_type = 'node';
$bundle_name = 'pmissue';
// Get defaults from the configurations.
module_load_include('inc', 'pmissue', 'includes/pmissue.field_base');
module_load_include('inc', 'pmissue', 'includes/pmissue.field_instance');
$field_bases = pmissue_default_field_bases();
$field_instances = pmissue_default_field_instances();
$field_name = 'pmissue_parent_issue';
$field_instance = $field_instances['node-pmissue-' . $field_name];
$instance_info = field_info_instance($entity_type, $field_name, $bundle_name);
$instance_info['widget'] = $field_instance['widget'];
field_update_instance($instance_info);
$field_name = 'pmissue_related';
$field_instance = $field_instances['node-pmissue-' . $field_name];
$instance_info = field_info_instance($entity_type, $field_name, $bundle_name);
$instance_info['widget'] = $field_instance['widget'];
field_update_instance($instance_info);
}
Functions
Name | Description |
---|---|
pmissue_disable | Implements hook_disable(). |
pmissue_install | Implements hook_install(). |
pmissue_uninstall | Implements hook_uninstall(). |
pmissue_update_7300 | Add entityreference_prepopulate behaviour to pmissue fields. |
pmissue_update_7301 | Add entityreference_prepopulate behaviour to pm_assigned. |
pmissue_update_7302 | Change the widget used for Related and Parent issue to autocomplete. |