You are here

pmnote.module in Drupal PM (Project Management) 8

Functions for the PM Note module.

File

pmnote/pmnote.module
View source
<?php

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

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

/**
 * Implements hook_permission().
 */
function pmnote_permission() {
  return array(
    'Project Management note: access' => array(
      'title' => t('Access PM Note'),
      'description' => t('Allows the user to see pages and blocks associated with the PM Note module, but does not control which notes are shown within them.'),
    ),
  );
}

/**
 * Implements hook_node_info().
 */
function pmnote_node_info() {
  return array(
    'pmnote' => array(
      'name' => t('Note'),
      'base' => 'pmnote',
      'description' => t('Use <em>notes</em> for free text that can be attached to another element within <em>Project Management</em>.'),
    ),
  );
}

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

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

/**
 * Implements hook_pm_contextual_links().
 */
function pmnote_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('pmnote_parent');
    $target_bundles = $field_info['settings']['handler_settings']['target_bundles'];
    if (in_array($bundle, $target_bundles)) {
      $links[t('Add Note')] = array(
        'title' => t('Add Note'),
        'href' => 'node/add/pmnote',
        'query' => array(
          'pmnote_parent' => $id,
        ),
      );
    }
  }
  return $links;
}

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

/**
 * Implements hook_pm_dashboard_links().
 */
function pmnote_pm_dashboard_links($type) {
  $links = array();
  if ($type == 'page' || $type == 'block') {
    $links[] = array(
      'theme' => 'pm_dashboard_link',
      'title' => t('Notes'),
      'icon' => 'pmnotes',
      'path' => 'pm/notes',
      'params' => array(),
      'node_type' => 'pmnote',
      'add_type' => 'pmnote',
      'map' => array(),
      'weight' => 9,
    );
  }
  return $links;
}

Functions

Namesort descending Description
pmnote_form Implements hook_form().
pmnote_help Implements hook_help().
pmnote_node_info Implements hook_node_info().
pmnote_permission Implements hook_permission().
pmnote_pm_contextual_links Implements hook_pm_contextual_links().
pmnote_pm_dashboard_links Implements hook_pm_dashboard_links().
pmnote_view Implements hook_view().
pmnote_views_api Implements hook_views_api().