Commit 71fb6d1b authored by Michael Haggerty's avatar Michael Haggerty

by techsoldaten: adding crm_core_report to 7.x-1.x branch

parent 10109d87
name = CRM Core Report
description = Provides a basic structure for creating reports in CRM Core. Provides a reports tab that displays registered reports.
package = CRM
core = 7.x
configure = admin/structure/crm
dependencies[] = crm_core
<?php
/**
* @file
* Provides a simple reporting interface for CRM Core and related modules.
*/
/**
* Implements hook_hook_info().
*/
function crm_core_report_hook_info() {
$hooks = array(
// registers reports from submodules within CRM Core, for central display
'crm_core_report_register' => array(
'group' => 'crm_core_report',
),
);
}
/**
* Implements hook_permission().
*/
function crm_core_report_permission() {
return array(
'view crm report index' => array(
'title' => t('View CRM Core report index'),
'description' => t('Use dashboard.'),
),
);
}
/**
* Implements hook_menu().
*/
function crm_core_report_menu() {
$items = array();
/**
* Provides a listing of all reports registered for CRM Core
*/
$items['crm/report'] = array(
'title' => 'Reports',
'page callback' => 'crm_core_report_list',
'access arguments' => array('view crm report index'),
'type' => MENU_LOCAL_TASK,
'file' => 'pages/crm_core_report.pages.inc',
);
return $items;
}
/**
* Implements hook_theme().
*/
function crm_core_report_theme() {
// we want a themable function for
// - report items
// - widgets
// - report index
return array(
'crm_core_report_index' => array(
'template' => 'crm-core-report-index',
'variables' => array('report_index' => NULL),
'path' => drupal_get_path('module', 'crm_core_report') . '/templates',
),
'crm_core_report_index_item' => array(
'template' => 'crm-core-report-index-item',
'variables' => array('title' => NULL, 'report' => NULL),
'path' => drupal_get_path('module', 'crm_core_report') . '/templates',
),
);
}
/**
* Constructs a list of registered reports and widgets for CRM Core
*
* Reports registered via this hook will be listed on the reports page
* and should include appropriate access controls, unless you want
* everyone with access to the main reports page to see them.
*/
function hook_crm_core_report_register(){
$reports = array();
foreach (module_implements('crm_core_report_register') as $module) {
$function = $module . '_crm_core_report_register';
$reports = array_merge($reports, $function());
}
return $reports;
}
<?php
/**
* Provides a listing of all reports registered for CRM Core
*/
function crm_core_report_list(){
$reports = hook_crm_core_report_register();
return theme('crm_core_report_index', array('reports' => $reports));
}
<?php
/**
* @file
* Default display of reports for CRM Core
*
* Available variables:
*
* - $reports: associative array listing all reports available
* in the system. Each entry is an array with the following keys:
* - title: A title for the report grouping.
* - reports: A list of the reports to be found. This is an array
* keyed by individual reports, and includes the following keys:
* - title: title for the report
* - description: a description of the report
* - path: a path to the report
* - widgets: A list of widgets indexed by CRM Core.
*/
?>
<div class="crm_core_reports">
<?php
foreach($reports as $item => $listing){
print theme('crm_core_report_index_item', array('title' => $listing['title'], 'report' => $listing['reports']));
}
?>
</div>
<?php
/**
* @file
* Default display of reports for CRM Core
*
* Available variables:
*
* - $report: associative array listing reports registered under the
* current grouping.
* - title: A title for the report grouping.
* - reports: A list of the reports to be found. This is an array
* keyed by individual reports, and includes the following keys:
* - title: title for the report
* - description: a description of the report
* - path: a path to the report
* - widgets: A list of widgets indexed by CRM Core. These can be ignored
* in this template, or used if you want to be funny.
*/
?>
<h3><?php print $title; ?></h3>
<div class="item-info">
<?php
$reports = array();
foreach($report as $item => $val){
$reports[] = l(t($val['title']), $val['path']) . '<br>' . t($val['description']);
}
if(sizeof($reports) > 0) {
print theme_item_list(array('items' => $reports, 'title' => NULL, 'type' => 'ul', 'attributes' => array()));
}
?>
</div>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment