CRM-13863 - Double title removal
[civicrm-core.git] / CRM / Report / Page / Report.php
1 <?php
2
3 /*
4 +--------------------------------------------------------------------+
5 | CiviCRM version 4.5 |
6 +--------------------------------------------------------------------+
7 | Copyright CiviCRM LLC (c) 2004-2014 |
8 +--------------------------------------------------------------------+
9 | This file is a part of CiviCRM. |
10 | |
11 | CiviCRM is free software; you can copy, modify, and distribute it |
12 | under the terms of the GNU Affero General Public License |
13 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | |
15 | CiviCRM is distributed in the hope that it will be useful, but |
16 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. |
19 | |
20 | You should have received a copy of the GNU Affero General Public |
21 | License and the CiviCRM Licensing Exception along |
22 | with this program; if not, contact CiviCRM LLC |
23 | at info[AT]civicrm[DOT]org. If you have questions about the |
24 | GNU Affero General Public License or the licensing of CiviCRM, |
25 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
26 +--------------------------------------------------------------------+
27 */
28
29 /**
30 *
31 * @package CRM
32 * @copyright CiviCRM LLC (c) 2004-2014
33 * $Id$
34 *
35 */
36
37 /**
38 * Page for invoking report templates
39 */
40 class CRM_Report_Page_Report extends CRM_Core_Page {
41
42 /**
43 * run this page (figure out the action needed and perform it).
44 *
45 * @return void
46 */
47 function run() {
48 if (!CRM_Core_Permission::check('administer Reports')) {
49 return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/report/list', 'reset=1'));
50 }
51
52 $optionVal = CRM_Report_Utils_Report::getValueFromUrl();
53
54 $templateInfo = CRM_Core_OptionGroup::getRowValues('report_template', "{$optionVal}", 'value',
55 'String', FALSE
56 );
57
58 $extKey = strpos(CRM_Utils_Array::value('name', $templateInfo), '.');
59
60 $reportClass = NULL;
61
62 if ($extKey !== FALSE) {
63 $ext = CRM_Extension_System::singleton()->getMapper();
64 $reportClass = $ext->keyToClass($templateInfo['name'], 'report');
65 $templateInfo['name'] = $reportClass;
66 }
67
68 if (strstr(CRM_Utils_Array::value('name', $templateInfo), '_Form') || !is_null($reportClass)) {
69 CRM_Utils_System::setTitle($templateInfo['label'] . ' - Template');
70 $this->assign('reportTitle', $templateInfo['label']);
71
72 $session = CRM_Core_Session::singleton();
73 $session->set('reportDescription', $templateInfo['description']);
74
75 $wrapper = new CRM_Utils_Wrapper();
76
77 return $wrapper->run($templateInfo['name'], NULL, NULL);
78 }
79
80 if ($optionVal) {
81 CRM_Core_Session::setStatus(ts('Could not find the report template. Make sure the report template is registered and / or url is correct.'), ts('Template Not Found'), 'error');
82 }
83 return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/report/list', 'reset=1'));
84 }
85 }
86