You are here

pmissue.module in Drupal PM (Project Management) 8

Same filename and directory in other branches
  1. 7.3 pmissue/pmissue.module
  2. 7.2 pmissue/pmissue.module

Hook implementations for PM Issue.

File

pmissue/pmissue.module
View source
<?php

/**
 * @file
 * Hook implementations for PM Issue.
 */

/**
 * Implements hook_help().
 */
function pmissue_help($path, $arg) {
  $o = '';
  switch ($path) {
    case "admin/help#pmissue":
      $o = '<p>' . t("Provides task support for Project Management") . '</p>';
      break;
  }
  return $o;
}

/**
 * Implements hook_permission().
 */
function pmissue_permission() {
  $name = 'Project Management Issue';
  return array(
    "Project Management Issue: access" => array(
      'title' => t('Access %type_name.', array(
        '%type_name' => $name,
      )),
      'description' => t('Allows the user to see pages and blocks associated with the %type_name, but does not control specific item that is shown within them.', array(
        '%type_name' => $name,
      )),
    ),
  );
}

/**
 * Implements hook_node_info().
 */
function pmissue_node_info() {
  return array(
    'pmissue' => array(
      'name' => t('Issue'),
      'base' => 'pmissue',
      'description' => t('Use <em>issues</em> for tracking items that need resolution and granular work requirements within <em>Project Management</em>.'),
      'title_label' => t('Title'),
    ),
  );
}

/**
 * Implements hook_form().
 */
function pmissue_form($node, &$form_state) {
  $breadcrumb = array(
    l(t('Project Management'), 'pm'),
    l(t('Issues'), 'pm/issues'),
  );
  drupal_set_breadcrumb($breadcrumb);
  return node_content_form($node, $form_state);
}

/**
 * Implements hook_view().
 */
function pmissue_view($node, $view_mode) {
  if ($view_mode == 'full' && node_is_page($node)) {
    $breadcrumb = array(
      l(t('Project Management'), 'pm'),
      l(t('Issues'), 'pm/issues'),
    );
    drupal_set_breadcrumb($breadcrumb);
  }
  return $node;
}

/**
 * Implements hook_pm_contextual_links().
 */
function pmissue_pm_contextual_links($entity, $type, $view_mode, $langcode) {
  $links = array();
  list($id, $vid, $bundle) = entity_extract_ids($type, $entity);
  if ($type == 'node') {
    $field_info = field_info_field('pmissue_parent');
    $target_bundles = $field_info['settings']['handler_settings']['target_bundles'];
    if (in_array($bundle, $target_bundles)) {
      $links[t('Add Issue')] = array(
        'title' => t('Add Issue'),
        'href' => 'node/add/pmissue',
        'query' => array(
          'pmissue_parent' => $id,
        ),
      );
    }
  }
  return $links;
}

/**
 * Implements hook_views_api().
 */
function pmissue_views_api() {
  return array(
    'api' => 2,
    'path' => drupal_get_path('module', 'pmissue'),
  );
}

/**
 * Implements hook_token_list().
 */
function pmissue_token_list($type = 'all') {
  $tokens = array();
  if ($type == 'node' || $type == 'all') {
    $tokens['node']['pmissue-organization-nid'] = t('Project Management Issue: Organization Node ID.');
    $tokens['node']['pmissue-organization-title'] = t('Project Management Issue: Organization Title.');
    $tokens['node']['pmissue-project-nid'] = t('Project Management Issue: Project Node ID.');
    $tokens['node']['pmissue-project-title'] = t('Project Management Issue: Project Title.');
  }
  return $tokens;
}

/**
 * Implements hook_token_values().
 */
function pmissue_token_values($type, $object = NULL) {
  $values = array();
  $node = $object;
  if (($type == 'node' || $type == 'all') && $node->type === 'pmissue') {
    $values['pmissue-organization-nid'] = $node->organization_nid;
    $values['pmissue-organization-title'] = $node->organization_title;
    $values['pmissue-project-nid'] = $node->project_nid;
    $values['pmissue-project-title'] = $node->project_title;
  }
  return $values;
}

/**
 * Implements hook_pm_dashboard_links().
 */
function pmissue_pm_dashboard_links($type) {
  $links = array();
  if ($type == 'page' || $type == 'block') {
    $links[] = array(
      'theme' => 'pm_dashboard_link',
      'title' => t('Issues'),
      'icon' => 'pmissues',
      'path' => 'pm/issues',
      'params' => array(),
      'node_type' => 'pmissue',
      'add_type' => 'pmissue',
      'map' => array(),
      'weight' => 5,
    );
  }
  return $links;
}

Functions

Namesort descending Description
pmissue_form Implements hook_form().
pmissue_help Implements hook_help().
pmissue_node_info Implements hook_node_info().
pmissue_permission Implements hook_permission().
pmissue_pm_contextual_links Implements hook_pm_contextual_links().
pmissue_pm_dashboard_links Implements hook_pm_dashboard_links().
pmissue_token_list Implements hook_token_list().
pmissue_token_values Implements hook_token_values().
pmissue_view Implements hook_view().
pmissue_views_api Implements hook_views_api().