/** * Run this page (figure out the action needed and perform it). */ public function run() { $instanceId = CRM_Report_Utils_Report::getInstanceID(); if (!$instanceId) { $instanceId = CRM_Report_Utils_Report::getInstanceIDForPath(); } $action = CRM_Utils_Request::retrieve('action', 'String', $this); $reportUrl = CRM_Utils_System::url('civicrm/report/list', "reset=1"); if ($action & CRM_Core_Action::DELETE) { CRM_Report_BAO_ReportInstance::doFormDelete($instanceId, $reportUrl); return CRM_Utils_System::redirect($reportUrl); } if (is_numeric($instanceId)) { $instanceURL = CRM_Utils_System::url("civicrm/report/instance/{$instanceId}", 'reset=1'); CRM_Core_Session::singleton()->replaceUserContext($instanceURL); } $optionVal = CRM_Report_Utils_Report::getValueFromUrl($instanceId); $templateInfo = CRM_Core_OptionGroup::getRowValues('report_template', "{$optionVal}", 'value'); if (empty($templateInfo)) { CRM_Core_Error::statusBounce('You have tried to access a report that does not exist.'); } $extKey = strpos($templateInfo['name'], '.'); $reportClass = NULL; if ($extKey !== FALSE) { $ext = CRM_Extension_System::singleton()->getMapper(); $reportClass = $ext->keyToClass($templateInfo['name'], 'report'); $templateInfo['name'] = $reportClass; } if (strstr($templateInfo['name'], '_Form') || !is_null($reportClass)) { $instanceInfo = array(); CRM_Report_BAO_ReportInstance::retrieve(array('id' => $instanceId), $instanceInfo); if (!empty($instanceInfo['title'])) { CRM_Utils_System::setTitle($instanceInfo['title']); $this->assign('reportTitle', $instanceInfo['title']); } else { CRM_Utils_System::setTitle($templateInfo['label']); $this->assign('reportTitle', $templateInfo['label']); } $wrapper = new CRM_Utils_Wrapper(); return $wrapper->run($templateInfo['name'], NULL, NULL); } CRM_Core_Session::setStatus(ts('Could not find template for the instance.'), ts('Template Not Found'), 'error'); return CRM_Utils_System::redirect($reportUrl); }
/** * Post Processing function for Form. * * postProcessCommon should be used to set other variables from input as the api accesses that function. * This function is not accessed when the api calls the report. */ public function beginPostProcess() { $this->setParams($this->controller->exportValues($this->_name)); if (empty($this->_params) && $this->_force) { $this->setParams($this->_formValues); } // hack to fix params when submitted from dashboard, CRM-8532 // fields array is missing because form building etc is skipped // in dashboard mode for report //@todo - this could be done in the dashboard no we have a setter if (empty($this->_params['fields']) && !$this->_noFields) { $this->setParams($this->_formValues); } $this->processReportMode(); if ($this->_outputMode == 'save' || $this->_outputMode == 'copy') { $this->_createNew = $this->_outputMode == 'copy'; CRM_Report_Form_Instance::postProcess($this); } if ($this->_outputMode == 'delete') { CRM_Report_BAO_ReportInstance::doFormDelete($this->_id, 'civicrm/report/list?reset=1', 'civicrm/report/list?reset=1'); } $this->_formValues = $this->_params; $this->beginPostProcessCommon(); }