3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
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 |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 * Page for invoking report instances
21 class CRM_Report_Page_Instance
extends CRM_Core_Page
{
24 * Run this page (figure out the action needed and perform it).
26 public function run() {
27 $instanceId = CRM_Report_Utils_Report
::getInstanceID();
29 $instanceId = CRM_Report_Utils_Report
::getInstanceIDForPath();
32 $action = CRM_Utils_Request
::retrieve('action', 'String', $this);
33 $reportUrl = CRM_Utils_System
::url('civicrm/report/list', "reset=1");
35 if ($action & CRM_Core_Action
::DELETE
) {
36 CRM_Report_BAO_ReportInstance
::doFormDelete($instanceId, $reportUrl);
37 return CRM_Utils_System
::redirect($reportUrl);
40 if (is_numeric($instanceId)) {
41 $instanceURL = CRM_Utils_System
::url("civicrm/report/instance/{$instanceId}", 'reset=1');
42 CRM_Core_Session
::singleton()->replaceUserContext($instanceURL);
44 $optionVal = CRM_Report_Utils_Report
::getValueFromUrl($instanceId);
45 $templateInfo = CRM_Core_OptionGroup
::getRowValues('report_template', "{$optionVal}", 'value');
46 if (empty($templateInfo)) {
47 CRM_Core_Error
::statusBounce('You have tried to access a report that does not exist.');
50 $extKey = strpos($templateInfo['name'], '.');
54 if ($extKey !== FALSE) {
55 $ext = CRM_Extension_System
::singleton()->getMapper();
56 $reportClass = $ext->keyToClass($templateInfo['name'], 'report');
57 $templateInfo['name'] = $reportClass;
60 if (strstr($templateInfo['name'], '_Form') ||
!is_null($reportClass)) {
62 CRM_Report_BAO_ReportInstance
::retrieve(['id' => $instanceId], $instanceInfo);
64 if (!empty($instanceInfo['title'])) {
65 CRM_Utils_System
::setTitle($instanceInfo['title']);
66 $this->assign('reportTitle', $instanceInfo['title']);
69 CRM_Utils_System
::setTitle($templateInfo['label']);
70 $this->assign('reportTitle', $templateInfo['label']);
73 $wrapper = new CRM_Utils_Wrapper();
74 return $wrapper->run($templateInfo['name'], NULL, NULL);
77 CRM_Core_Session
::setStatus(ts('Could not find template for the instance.'), ts('Template Not Found'), 'error');
79 return CRM_Utils_System
::redirect($reportUrl);