pmtimetracking.install in Drupal PM (Project Management) 8
Same filename and directory in other branches
Install functions for PM Timetracking.
File
pmtimetracking/pmtimetracking.installView source
<?php
/**
* @file
* Install functions for PM Timetracking.
*/
/**
* Implements hook_install().
*/
function pmtimetracking_install() {
variable_set('node_options_pmtimetracking', array(
'status',
));
// PM Permissions default configurations.
variable_set('pm_permission_field_parent_reference_for_pmtimetracking', 'pmtimetracking_parent');
variable_set('pm_permission_node_pmtimetracking_enabled', TRUE);
// Create and attaches fields to pmtimetracking content type.
module_load_include('inc', 'pmtimetracking', 'includes/pmtimetracking.migrate');
// Parameter $sandbox is passed as a placeholder.
$sandbox = array();
pmtimetracking_migrate_create_fields($sandbox);
}
/**
* Implements hook_disable().
*/
function pmtimetracking_disable() {
module_load_include('inc', 'pm', 'includes/pm.install');
$module = 'pmtimetracking';
// Set standardised message.
pm_disable_message($module, 'timetrackings');
}
/**
* Implements hook_uninstall().
*/
function pmtimetracking_uninstall() {
module_load_include('inc', 'pm', 'includes/pm.install');
$module = 'pmtimetracking';
// Delete items created by his module.
pm_uninstall_variables($module);
pm_uninstall_fields($module);
// Set standardised message.
pm_uninstall_message($module, 'timetrackings');
}
/**
* Implements hook_update_last_removed().
*/
function pmtimetracking_update_last_removed() {
return 6201;
}
/**
* Migrate PM Timetracking nodes to field_api fields.
*/
function pmtimetracking_update_7106(&$sandbox) {
module_load_include('inc', 'pmtimetracking', 'includes/pmtimetracking.migrate');
if (pmtimetracking_migrate_update_could_be_performed()) {
return pmtimetracking_migrate($sandbox);
}
}
/**
* Deactivate auto duration settings to maintain behaviour of existing sites.
*/
function pmtimetracking_update_7201() {
variable_set('pmtimetracking_auto_duration', FALSE);
variable_set('pmtimetracking_auto_billing_duration', FALSE);
}
/**
* Add entityreference_prepopulate behaviour to pmtimetracking_parent.
*/
function pmtimetracking_update_7300() {
$entity_type = 'node';
$field_name = 'pmtimetracking_parent';
$bundle_name = 'pmtimetracking';
// Get defaults from the configurations.
module_load_include('inc', 'pmtimetracking', 'includes/pmtimetracking.field_instance');
$field_instances = pmtimetracking_default_field_instances();
$field_instance = $field_instances['node-pmtimetracking-pmtimetracking_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);
}
/**
* Implements hook_update_dependencies().
*/
function pmtimetracking_update_dependencies() {
// pmperson_update_7104() migrates pmperson data to drupal user.
// pmtimetracking migration depends on its completion.
$dependencies['pmtimetracking'][7106] = array(
'pmproject' => 7104,
);
return $dependencies;
}
Functions
Name | Description |
---|---|
pmtimetracking_disable | Implements hook_disable(). |
pmtimetracking_install | Implements hook_install(). |
pmtimetracking_uninstall | Implements hook_uninstall(). |
pmtimetracking_update_7106 | Migrate PM Timetracking nodes to field_api fields. |
pmtimetracking_update_7201 | Deactivate auto duration settings to maintain behaviour of existing sites. |
pmtimetracking_update_7300 | Add entityreference_prepopulate behaviour to pmtimetracking_parent. |
pmtimetracking_update_dependencies | Implements hook_update_dependencies(). |
pmtimetracking_update_last_removed | Implements hook_update_last_removed(). |