Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
6a488035 TO |
2 | /* |
3 | +--------------------------------------------------------------------+ | |
bc77d7c0 | 4 | | Copyright CiviCRM LLC. All rights reserved. | |
6a488035 | 5 | | | |
bc77d7c0 TO |
6 | | This work is published under the GNU AGPLv3 license with some | |
7 | | permitted exceptions and without any warranty. For full license | | |
8 | | and copyright information, see https://civicrm.org/licensing | | |
6a488035 | 9 | +--------------------------------------------------------------------+ |
d25dd0ee | 10 | */ |
6a488035 TO |
11 | |
12 | /** | |
13 | * | |
14 | * @package CRM | |
ca5cec67 | 15 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
6a488035 TO |
16 | */ |
17 | ||
18 | /** | |
9be11d83 | 19 | * Page for invoking report templates. |
6a488035 TO |
20 | */ |
21 | class CRM_Report_Page_Report extends CRM_Core_Page { | |
22 | ||
23 | /** | |
100fef9d | 24 | * Run this page (figure out the action needed and perform it). |
6a488035 | 25 | */ |
00be9182 | 26 | public function run() { |
6a488035 | 27 | if (!CRM_Core_Permission::check('administer Reports')) { |
496f1dc4 | 28 | return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/report/list', 'reset=1')); |
6a488035 TO |
29 | } |
30 | ||
31 | $optionVal = CRM_Report_Utils_Report::getValueFromUrl(); | |
32 | ||
6a488035 | 33 | $templateInfo = CRM_Core_OptionGroup::getRowValues('report_template', "{$optionVal}", 'value', |
bc3364a9 | 34 | 'String', FALSE, TRUE |
6a488035 TO |
35 | ); |
36 | ||
496f1dc4 | 37 | $extKey = strpos(CRM_Utils_Array::value('name', $templateInfo), '.'); |
6a488035 TO |
38 | |
39 | $reportClass = NULL; | |
40 | ||
41 | if ($extKey !== FALSE) { | |
42 | $ext = CRM_Extension_System::singleton()->getMapper(); | |
43 | $reportClass = $ext->keyToClass($templateInfo['name'], 'report'); | |
44 | $templateInfo['name'] = $reportClass; | |
45 | } | |
46 | ||
47 | if (strstr(CRM_Utils_Array::value('name', $templateInfo), '_Form') || !is_null($reportClass)) { | |
be2fb01f | 48 | CRM_Utils_System::setTitle(ts('%1 - Template', [1 => $templateInfo['label']])); |
6a488035 TO |
49 | $this->assign('reportTitle', $templateInfo['label']); |
50 | ||
51 | $session = CRM_Core_Session::singleton(); | |
52 | $session->set('reportDescription', $templateInfo['description']); | |
53 | ||
54 | $wrapper = new CRM_Utils_Wrapper(); | |
55 | ||
56 | return $wrapper->run($templateInfo['name'], NULL, NULL); | |
57 | } | |
58 | ||
59 | if ($optionVal) { | |
60 | 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'); | |
61 | } | |
496f1dc4 | 62 | return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/report/list', 'reset=1')); |
6a488035 | 63 | } |
96025800 | 64 | |
6a488035 | 65 | } |