You are here

pmperson.install in Drupal PM (Project Management) 7

File

pmperson/pmperson.install
View source
<?php

/**
 * @file
 */

/**
 * Implements hook_install().
 */
function pmperson_install() {
  variable_set('node_options_pmperson', array(
    'status',
  ));
  variable_set('node_permissions_pmperson', 0);

  // Uncache node types
  node_types_rebuild();

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

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

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

/**
 * Implements hook_uninstall().
 */
function pmperson_uninstall() {
  drupal_uninstall_schema('pmperson');
}

/**
 * Implements hook_schema().
 */
function pmperson_schema() {
  $schema['pmperson'] = 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' => 150,
      ),
      'prefix' => array(
        'type' => 'varchar',
        'length' => 100,
      ),
      'email' => array(
        'type' => 'varchar',
        'length' => 50,
      ),
      'www' => array(
        'type' => 'varchar',
        'length' => 100,
      ),
      'phone' => array(
        'type' => 'varchar',
        'length' => 100,
      ),
      'im' => array(
        'type' => 'varchar',
        'length' => 100,
      ),
      'user_uid' => array(
        'type' => 'int',
      ),
    ),
    'primary key' => array(
      'vid',
    ),
    'indexes' => array(
      'nid' => array(
        'nid',
      ),
      'organization_nid' => array(
        'organization_nid',
      ),
      'user_uid' => array(
        'user_uid',
      ),
    ),
  );
  return $schema;
}

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

/**
 * Adds Drupal 7 style body field to Project Management Person nodes.
 */
function pmperson_update_7100() {

  // Uncache node types
  node_types_rebuild();

  // Fetch list of current node types and add body field to pm person
  $types = node_type_get_types();
  node_add_body_field($types['pmperson'], 'Description');
  return 'Added D7 style body field to pm person nodes';
}

/**
 * Deletes fullname field from the person table (deprecated since 6.x-2.x).
 */
function pmperson_update_7101() {
  db_drop_field('pmperson', 'fullname');
}

/**
 * Allow Project Management to override the default Person content type CRUD.
 */
function pmperson_update_7102() {
  variable_set('node_permissions_pmperson', 0);
  return 'PM Person permissions overridden';
}

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

Functions

Namesort descending Description
pmperson_disable Implements hook_disable().
pmperson_enable Implements hook_enable().
pmperson_install Implements hook_install().
pmperson_schema Implements hook_schema().
pmperson_uninstall Implements hook_uninstall().
pmperson_update_7100 Adds Drupal 7 style body field to Project Management Person nodes.
pmperson_update_7101 Deletes fullname field from the person table (deprecated since 6.x-2.x).
pmperson_update_7102 Allow Project Management to override the default Person content type CRUD.
pmperson_update_7103 Display message to admin regarding need to rebuild permission.
pmperson_update_last_removed Implements hook_update_last_removed().