pmproject.module in Drupal PM (Project Management) 7.2
Same filename and directory in other branches
Main module file for the PM Project module.
File
pmproject/pmproject.moduleView source
<?php
/**
* @file
* Main module file for the PM Project module.
*/
/**
* Implements hook_help().
*/
function pmproject_help($path, $arg) {
$o = '';
switch ($path) {
case "admin/help#pmproject":
$o = '<p>' . t("Provides project support for Project Management") . '</p>';
break;
}
return $o;
}
/**
* Implements hook_permission().
*/
function pmproject_permission() {
$name = 'Project Management Project';
return array(
"Project Management Project: 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 pmproject_node_info() {
return array(
'pmproject' => array(
'name' => t('Project'),
'base' => 'pmproject',
'description' => t('Use <em>projects</em> for recording high level work requirements within <em>Project Management</em>.'),
'title_label' => t('Title'),
),
);
}
/**
* Implements hook_form().
*/
function pmproject_form(&$node, &$form_state) {
$breadcrumb = array(
l(t('Project Management'), 'pm'),
l(t('Projects'), 'pm/projects'),
);
drupal_set_breadcrumb($breadcrumb);
return node_content_form($node, $form_state);
}
/**
* Implements hook_view().
*/
function pmproject_view($node, $view_mode) {
if ($view_mode == 'full' && node_is_page($node)) {
$breadcrumb = array(
l(t('Project Management'), 'pm'),
l(t('Projects'), 'pm/projects'),
);
drupal_set_breadcrumb($breadcrumb);
}
return $node;
}
/**
* Implements hook_views_api().
*/
function pmproject_views_api() {
return array(
'api' => 2,
'path' => drupal_get_path('module', 'pmproject'),
);
}
/**
* Implements hook_token_list().
*/
function pmproject_token_list($type = 'all') {
$tokens = array();
if ($type == 'node' || $type == 'all') {
$tokens['node']['pmproject-projectstatus'] = t('Project Management Project: Project Status.');
$tokens['node']['pmproject-projectcategory'] = t('Project Management Project: Project Category.');
$tokens['node']['pmproject-projectpriority'] = t('Project Management Project: Project Priority.');
$tokens['node']['pmproject-durationunit'] = t('Project Management Project: Project Duration Unit.');
$tokens['node']['pmproject-duration'] = t('Project Management Project: Project Duration.');
$tokens['node']['pmproject-price'] = t('Project Management Project: Project Price.');
$tokens['node']['pmproject-pricemode'] = t('Project Management Project: Project Price Mode.');
if (module_exists('pmorganization')) {
$tokens['node']['pmproject-organization-nid'] = t('Project Management Project: Organization Node ID.');
$tokens['node']['pmproject-organization-title'] = t('Project Management Project: Organization Title.');
}
if (module_exists('pmperson')) {
// Project Manager.
$tokens['node']['pmproject-manager-title'] = t('Project Management Project: Project Manager Title.');
$tokens['node']['pmproject-manager-uid'] = t('Project Management Project: Project Manager User ID.');
$tokens['node']['pmproject-manager-name'] = t('Project Management Project: Project Manager Name.');
$tokens['node']['pmproject-manager-fullname'] = t('Project Management Project: Project Manager Full Name.');
$tokens['node']['pmproject-manager-email'] = t('Project Management Project: Project Manager Email Address.');
// Assignee(s).
$tokens['node']['pmproject-assigned-to-email'] = t('Project Management Project: Project Assignee(s) Email Address(s).');
$tokens['node']['pmproject-assigned-title'] = t('Project Management Project: Project Assignee(s) Title(s).');
}
}
return $tokens;
}
/**
* Implements hook_token_values().
*/
function pmproject_token_values($type, $object = NULL) {
$values = array();
$node = $object;
if (($type == 'node' || $type == 'all') && $node->type === 'pmproject') {
$values['pmproject-projectstatus'] = $node->projectstatus;
$values['pmproject-projectpriority'] = $node->projectpriority;
$values['pmproject-projectcategory'] = $node->projectcategory;
$values['pmproject-durationunit'] = $node->durationunit;
$values['pmproject-duration'] = $node->duration;
$values['pmproject-price'] = $node->price;
$values['pmproject-pricemode'] = $node->pricemode;
if (module_exists('pmorganization')) {
$values['pmproject-organization-nid'] = $node->organization_nid;
$values['pmproject-organization-title'] = $node->organization_title;
}
if (module_exists('pmperson')) {
// Project Manager.
if ($node->manager_nid) {
$manager = node_load($node->manager_nid);
$values['pmproject-manager-uid'] = $manager->user_uid;
$values['pmproject-manager-name'] = $manager->title;
$values['pmproject-manager-fullname'] = $manager->fullname;
$values['pmproject-manager-email'] = pmperson_primary_email($manager);
$values['pmproject-manager-title'] = $node->manager_title;
}
else {
$values['pmproject-manager-email'] = NULL;
}
// Project Assignee(s) e-mail.
if ($node->assigned_nid) {
$values['pmproject-assigned-title'] = $node->assigned_title;
$assignees_node = node_load($node->assigned_nid);
// Assigned to one person.
if ($assignees_node->type === 'pmperson') {
$values['pmproject-assigned-to-email'] = pmperson_primary_email($assignees_node);
}
else {
$assignees_array = $assignees_node->members_array;
$assignees = array();
foreach ($assignees_array as $nid => $name) {
$assignee = node_load($nid);
$assignees[] = pmperson_primary_email($assignee);
}
$assigned = implode(", ", $assignees);
// Return comma separated list of emails.
$values['pmproject-assigned-to-email'] = $assigned;
}
}
else {
$values['pmproject-assigned-to-email'] = NULL;
}
}
}
return $values;
}
/**
* Implements hook_pm_dashboard_links().
*/
function pmproject_pm_dashboard_links($type) {
$links = array();
if ($type == 'page' || $type == 'block') {
$links[] = array(
'theme' => 'pm_dashboard_link',
'title' => t('Projects'),
'icon' => 'pmprojects',
'path' => 'pm/projects',
'params' => array(),
'node_type' => 'pmproject',
'add_type' => 'pmproject',
'map' => array(),
'weight' => 4,
);
}
return $links;
}
Functions
Name | Description |
---|---|
pmproject_form | Implements hook_form(). |
pmproject_help | Implements hook_help(). |
pmproject_node_info | Implements hook_node_info(). |
pmproject_permission | Implements hook_permission(). |
pmproject_pm_dashboard_links | Implements hook_pm_dashboard_links(). |
pmproject_token_list | Implements hook_token_list(). |
pmproject_token_values | Implements hook_token_values(). |
pmproject_view | Implements hook_view(). |
pmproject_views_api | Implements hook_views_api(). |