You are here

pm.install in Drupal PM (Project Management) 7

Same filename and directory in other branches
  1. 8 pm.install
  2. 7.3 pm.install
  3. 7.2 pm.install

Install, update and uninstall functions for the Project Management module.

File

pm.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for the Project Management module.
 */

/**
 * Implements hook_install().
 */
function pm_install() {
  variable_set('pm_icons_path', drupal_get_path('module', 'pm') . '/icons');
  variable_set('pm_organization_nid', 0);

  // Set up billing status field.
  field_create_field(array(
    'field_name' => 'pm_billing_status',
    'type' => 'list_text',
    'settings' => array(
      'allowed_values' => array(
        'Not billable' => 'Not billable',
        'Billable' => 'Billable',
        'Billed' => 'Billed',
      ),
    ),
  ));

  // Set up date field.
  field_create_field(array(
    'type' => 'datetime',
    'field_name' => 'pm_date',
    'settings' => array(
      'granularity' => array(
        'year' => 'year',
        'month' => 'month',
        'day' => 'day',
        'hour' => 'hour',
        'minute' => 'minute',
        'second' => 0,
      ),
      'tz_handling' => 'none',
      'timezone_db' => '',
      'todate' => 'optional',
    ),
    'cardinality' => '1',
  ));
}

/**
 * Implements hook_uninstall().
 */
function pm_uninstall() {
  variable_del('pm_icons_path');
  variable_del('pm_organization_nid');
  drupal_uninstall_schema('pm');
}

/**
 * Implements hook_schema().
 */
function pm_schema() {
  $schema['pmattribute'] = array(
    'fields' => array(
      'aid' => array(
        'type' => 'serial',
        'not null' => TRUE,
      ),
      'domain' => array(
        'type' => 'varchar',
        'length' => 100,
      ),
      'akey' => array(
        'type' => 'varchar',
        'length' => 100,
      ),
      'avalue' => array(
        'type' => 'varchar',
        'length' => 100,
      ),
      'parent_domain' => array(
        'type' => 'varchar',
        'length' => 100,
      ),
      'weight' => array(
        'type' => 'int',
        'not null' => FALSE,
        'default' => 0,
        'size' => 'small',
      ),
      'isdefault' => array(
        'type' => 'int',
        'not null' => FALSE,
        'default' => 0,
        'size' => 'tiny',
      ),
      'isactive' => array(
        'type' => 'int',
        'not null' => FALSE,
        'default' => 1,
        'size' => 'tiny',
      ),
    ),
    'primary key' => array(
      'aid',
    ),
    'indexes' => array(
      'domain' => array(
        'domain',
      ),
    ),
  );
  return $schema;
}

/**
 * Implements hook_update_last_removed().
 */
function pm_update_last_removed() {
  return 6202;
}

/**
 * Enable new module dependencies. Make billing status field available to PM content types.
 */
function pm_update_7101() {

  // Enable new dependencies.
  if (!module_enable(array(
    'date',
    'entityreference',
    'list',
  ))) {
    throw new DrupalUpdateException('This version requires one or more modules that could not be enabled.');
  }

  // Combining these operations in one request means we have to clear the
  // field info cache.
  field_info_cache_clear();

  // Set up billing status field.
  field_create_field(array(
    'field_name' => 'pm_billing_status',
    'type' => 'list_text',
    'settings' => array(
      'allowed_values' => array(
        'Not billable' => 'Not billable',
        'Billable' => 'Billable',
        'Billed' => 'Billed',
      ),
    ),
  ));
}

/**
 * Make date field available to PM content types.
 */
function pm_update_7102() {

  // Set up date field.
  field_create_field(array(
    'type' => 'datetime',
    'field_name' => 'pm_date',
    'settings' => array(
      'granularity' => array(
        'year' => 'year',
        'month' => 'month',
        'day' => 'day',
        'hour' => 'hour',
        'minute' => 'minute',
        'second' => 0,
      ),
      'tz_handling' => 'none',
      'timezone_db' => '',
      'todate' => 'optional',
    ),
    'cardinality' => '1',
  ));
  variable_del('pm_yearsrangebegin');
  variable_del('pm_yearsrangeend');
}

Functions

Namesort descending Description
pm_install Implements hook_install().
pm_schema Implements hook_schema().
pm_uninstall Implements hook_uninstall().
pm_update_7101 Enable new module dependencies. Make billing status field available to PM content types.
pm_update_7102 Make date field available to PM content types.
pm_update_last_removed Implements hook_update_last_removed().