pmexpense.module in Drupal PM (Project Management) 7.3
Same filename and directory in other branches
Hook implementations and main functions for PM Expense.
File
pmexpense/pmexpense.moduleView source
<?php
/**
* @file
* Hook implementations and main functions for PM Expense.
*/
/**
* Implements hook_help().
*/
function pmexpense_help($path, $arg) {
$o = '';
switch ($path) {
case "admin/help#pmexpense":
$o = '<p>' . t("Provides expense support for Project Management") . '</p>';
break;
}
return $o;
}
/**
* Implements hook_permission().
*/
function pmexpense_permission() {
return array(
'Project Management expense: access' => array(
'title' => t('Access PM Expense'),
'description' => t('Allows the user to see pages and blocks associated with the PM Expense module, but does not control which expenses are shown within them.'),
),
);
}
/**
* Implements hook_node_info().
*/
function pmexpense_node_info() {
return array(
'pmexpense' => array(
'name' => t('Expense'),
'base' => 'pmexpense',
'description' => t('Use <em>expenses</em> for recording money spent and allocating to the relevant work within <em>Project Management</em>.'),
'title_label' => t('Title'),
),
);
}
/**
* Implements hook_pmexpense_form().
*/
function pmexpense_form($node, $form_state) {
$breadcrumb = array(
array(
'text' => t('Expenses'),
'path' => 'pm/expenses',
),
);
pm_set_breadcrumb($breadcrumb);
return node_content_form($node, $form_state);
}
/**
* Implements hook_view().
*/
function pmexpense_view($node, $view_mode) {
if ($view_mode == 'full' && node_is_page($node)) {
$breadcrumb = array(
array(
'text' => t('Expenses'),
'path' => 'pm/expenses',
),
);
pm_set_breadcrumb($breadcrumb);
}
return $node;
}
/**
* Implements hook_views_api().
*/
function pmexpense_views_api() {
return array(
'api' => 2,
'path' => drupal_get_path('module', 'pmexpense'),
);
}
/**
* Implements hook_pm_dashboard_links().
*/
function pmexpense_pm_dashboard_links($type) {
$links = array();
if ($type == 'page' || $type == 'block') {
$links[] = array(
'theme' => 'pm_dashboard_link',
'title' => t('Expenses'),
'icon' => 'pmexpenses',
'path' => 'pm/expenses',
'params' => array(),
'node_type' => 'pmexpense',
'add_type' => 'pmexpense',
'map' => array(),
'weight' => 11,
);
}
return $links;
}
/**
* Implements hook_pm_contextual_links().
*/
function pmexpense_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('pmexpense_parent');
if (isset($field_info['settings']['handler_settings']['target_bundles'])) {
$target_bundles = $field_info['settings']['handler_settings']['target_bundles'];
}
else {
$target_bundles = array(
'pmproject',
'pmorganization',
'pmtask',
'pmticket',
'pmissue',
);
}
if (in_array($bundle, $target_bundles)) {
$links[t('Add Expense')] = array(
'title' => t('Add Expense'),
'href' => 'node/add/pmexpense',
'query' => array(
'pmexpense_parent' => $id,
),
);
}
}
return $links;
}
Functions
Name | Description |
---|---|
pmexpense_form | Implements hook_pmexpense_form(). |
pmexpense_help | Implements hook_help(). |
pmexpense_node_info | Implements hook_node_info(). |
pmexpense_permission | Implements hook_permission(). |
pmexpense_pm_contextual_links | Implements hook_pm_contextual_links(). |
pmexpense_pm_dashboard_links | Implements hook_pm_dashboard_links(). |
pmexpense_view | Implements hook_view(). |
pmexpense_views_api | Implements hook_views_api(). |