pmteam.module in Drupal PM (Project Management) 8
Same filename and directory in other branches
Main module file for the PM Team module.
File
pmteam/pmteam.moduleView source
<?php
/**
* @file
* Main module file for the PM Team module.
*/
/**
* Implements hook_node_info().
*/
function pmteam_node_info() {
return array(
'pmteam' => array(
'name' => t('Team'),
'base' => 'pmteam',
'description' => t('Use <em>teams</em> for groups of users within <em>Project Management</em>.'),
'title_label' => t('Team Name'),
'body_label' => t('Description'),
),
);
}
/**
* Implements hook_permission().
*/
function pmteam_permission() {
$name = 'Project Management Team';
return array(
"Project Management Team: 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_access().
*/
function pmteam_node_access($node, $op, $account = NULL) {
$type = is_string($node) ? $node : $node->type;
if ($type == 'pmteam') {
// If no account is specified, check against the currently logged in user.
if (is_null($account)) {
global $user;
$account = $user;
}
if ($op == 'create' and user_access('Project Management Team: add', $account)) {
return NODE_ACCESS_ALLOW;
}
}
return NODE_ACCESS_IGNORE;
}
/**
* Implements hook_views_api().
*/
function pmteam_views_api() {
return array(
'api' => 2,
'path' => drupal_get_path('module', 'pmteam'),
);
}
/**
* Implements hook_form().
*
* Drupal needs for us to provide a form that lets the user
* add content. This is the form that the user will see if
* they go to node/add/pmteam.
*/
function pmteam_form($node, &$form_state) {
$breadcrumb = array(
l(t('Project Management'), 'pm'),
l(t('Teams'), 'pm/teams'),
);
drupal_set_breadcrumb($breadcrumb);
return node_content_form($node, $form_state);
}
/**
* Implements hook_view().
*/
function pmteam_view($node, $view_mode) {
if ($view_mode == 'full' && node_is_page($node)) {
$breadcrumb = array(
l(t('Project Management'), 'pm'),
l(t('Teams'), 'pm/teams'),
);
drupal_set_breadcrumb($breadcrumb);
}
return $node;
}
/**
* Implements hook_pm_dashboard_links().
*/
function pmteam_pm_dashboard_links($type) {
$links = array();
if ($type == 'page' || $type == 'block') {
$links[] = array(
'theme' => 'pm_dashboard_link',
'title' => t('Teams'),
'icon' => 'pmteams',
'path' => 'pm/teams',
'params' => array(),
'node_type' => 'pmteam',
'add_type' => 'pmteam',
'map' => array(),
'weight' => 3,
);
}
return $links;
}
Functions
Name | Description |
---|---|
pmteam_form | Implements hook_form(). |
pmteam_node_access | Implements hook_node_access(). |
pmteam_node_info | Implements hook_node_info(). |
pmteam_permission | Implements hook_permission(). |
pmteam_pm_dashboard_links | Implements hook_pm_dashboard_links(). |
pmteam_view | Implements hook_view(). |
pmteam_views_api | Implements hook_views_api(). |