pmteam.install in Drupal PM (Project Management) 8
Same filename and directory in other branches
Install, uninstall and update functions for the PM Team module.
File
pmteam/pmteam.installView 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('pm_permission_field_parent_reference_for_pmteam', 'pmteam_organization');
// Parameter $sandbox is passed as a placeholder.
$sandbox = array();
pmteam_migrate_create_fields($sandbox);
variable_set("pm_permission_node_pmteam_enabled", TRUE);
}
/**
* Implements hook_disable().
*/
function pmteam_disable() {
module_load_include('inc', 'pm', 'includes/pm.install');
$module = 'pmteam';
// Set standardised message.
pm_disable_message($module, 'teams');
}
/**
* Implements hook_uninstall().
*/
function pmteam_uninstall() {
module_load_include('inc', 'pm', 'includes/pm.install');
$module = 'pmteam';
// Delete items created by his module.
pm_uninstall_variables($module);
pm_uninstall_fields($module);
// Set standardised message.
pm_uninstall_message($module, 'teams');
}
/**
* 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');
}
/**
* Use pm_entity_reference_user_filter for pmteam_user.
*/
function pmteam_update_7300() {
$entity_type = 'node';
$field_name = 'pmteam_user';
$bundle_name = 'pmteam';
// Get defaults from the configurations.
// Update Field Base.
module_load_include('inc', 'pmteam', 'includes/pmteam.field_base');
$field_bases = pmteam_default_field_bases();
$field_base = $field_bases[$field_name];
$base_info = array(
'field_name' => $field_name,
'settings' => $field_base['settings'],
);
field_update_field($base_info);
}
/**
* 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
Name | 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_7300 | Use pm_entity_reference_user_filter for pmteam_user. |
pmteam_update_dependencies | Implements hook_update_dependencies(). |
pmteam_update_last_removed | Implements hook_update_last_removed(). |