pmtask.install in Drupal PM (Project Management) 8
Same filename and directory in other branches
Install, disable, uninstall and update functions for pmtask module.
File
pmtask/pmtask.installView 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('pm_permission_field_assigned_reference', 'pm_assigned');
variable_set('pm_permission_field_parent_reference_for_pmtask', 'pmtask_parent');
variable_set('pm_permission_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() {
module_load_include('inc', 'pm', 'includes/pm.install');
$module = 'pmtask';
// Set standardised message.
pm_disable_message($module, 'tasks');
}
/**
* Implements hook_uninstall().
*/
function pmtask_uninstall() {
module_load_include('inc', 'pm', 'includes/pm.install');
$module = 'pmtask';
// Delete items created by his module.
pm_uninstall_variables($module);
pm_uninstall_fields($module);
// Set standardised message.
pm_uninstall_message($module, 'tasks');
}
/**
* 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);
}
}
/**
* Add entityreference_prepopulate behaviour to pmtask_parent.
*/
function pmtask_update_7300() {
$entity_type = 'node';
$field_name = 'pmtask_parent';
$bundle_name = 'pmtask';
// Get defaults from the configurations.
module_load_include('inc', 'pmtask', 'includes/pmtask.field_instance');
$field_instances = pmtask_default_field_instances();
$field_instance = $field_instances['node-pmtask-pmtask_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 pmtask_update_7301() {
$entity_type = 'node';
$bundle_name = 'pmtask';
// Get defaults from the configurations.
module_load_include('inc', 'pmtask', 'includes/pmtask.field_base');
module_load_include('inc', 'pmtask', 'includes/pmtask.field_instance');
$field_bases = pmtask_default_field_bases();
$field_instances = pmtask_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-pmtask-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 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
Name | 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_7300 | Add entityreference_prepopulate behaviour to pmtask_parent. |
pmtask_update_7301 | Add entityreference_prepopulate behaviour to pm_assigned. |
pmtask_update_dependencies | Implements hook_update_dependencies(). |
pmtask_update_last_removed | Implements hook_update_last_removed(). |