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