You are here

pmnote.install in Drupal PM (Project Management) 7

Functions for the PM Note module.

File

pmnote/pmnote.install
View source
<?php

/**
 * @file
 * Functions for the PM Note module.
 */

/**
 * Implements hook_install().
 */
function pmnote_install() {
  variable_set('node_options_pmnote', array(
    'status',
  ));
  variable_set('node_permissions_pmnote', 0);

  // Uncache node types
  node_types_rebuild();

  // Fetch list of current node types and add body field to Project Management Task
  $types = node_type_get_types();
  node_add_body_field($types['pmnote'], 'Description');
}

/**
 * Implements hook_enable().
 */
function pmnote_enable() {
  node_access_needs_rebuild(TRUE);
}

/**
 * Implements hook_disable().
 */
function pmnote_disable() {
  node_access_needs_rebuild(TRUE);
  drupal_set_message(t('Nodes of type "Note" have not been deleted on disabling Project Management Note. Please note that they will now have reduced functionality, and will not be protected by Project Management Note access controls.'), 'warning');
}

/**
 * Implements hook_uninstall().
 */
function pmnote_uninstall() {
  drupal_uninstall_schema('pmnote');
}

/**
 * Implements hook_schema().
 */
function pmnote_schema() {
  $schema['pmnote'] = array(
    'fields' => array(
      'vid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'nid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'organization_nid' => array(
        'type' => 'int',
      ),
      'organization_title' => array(
        'type' => 'varchar',
        'length' => 128,
      ),
      'project_nid' => array(
        'type' => 'int',
      ),
      'project_title' => array(
        'type' => 'varchar',
        'length' => 128,
      ),
      'task_nid' => array(
        'type' => 'int',
      ),
      'task_title' => array(
        'type' => 'varchar',
        'length' => 128,
      ),
    ),
    'primary key' => array(
      'vid',
    ),
    'indexes' => array(
      'nid' => array(
        'nid',
      ),
      'organization_nid' => array(
        'organization_nid',
      ),
      'project_nid' => array(
        'project_nid',
      ),
      'task_nid' => array(
        'task_nid',
      ),
    ),
  );
  return $schema;
}

/**
 * Implements hook_update_last_removed().
 */
function pmnote_update_last_removed() {
  return 6201;
}

/**
 * Disable the default PM Note CRUD permissions so that they can be overridden.
 */
function pmnote_update_7101() {
  variable_set('node_permissions_pmnote', 0);
  return 'PM Note permissions overridden';
}

/**
 * Display message to admin regarding need to rebuild permission.
 */
function pmnote_update_7102() {
  node_access_needs_rebuild(TRUE);
}

/**
 * Adds Drupal 7 style body field to Project Management Note nodes
 */
function pmnote_update_7103() {

  // Uncache node types
  node_types_rebuild();

  // Fetch list of current node types and add body field to Project Management Task
  $types = node_type_get_types();
  node_add_body_field($types['pmnote'], 'Description');
  return 'Added D7 style body field to Project Management Note nodes';
}

Functions

Namesort descending Description
pmnote_disable Implements hook_disable().
pmnote_enable Implements hook_enable().
pmnote_install Implements hook_install().
pmnote_schema Implements hook_schema().
pmnote_uninstall Implements hook_uninstall().
pmnote_update_7101 Disable the default PM Note CRUD permissions so that they can be overridden.
pmnote_update_7102 Display message to admin regarding need to rebuild permission.
pmnote_update_7103 Adds Drupal 7 style body field to Project Management Note nodes
pmnote_update_last_removed Implements hook_update_last_removed().