/** * Shared pre-process function. * * If overriding preProcess function this should still be called. * * @throws \Exception */ public function preProcessCommon() { $this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', CRM_Core_DAO::$_nullObject); $this->_dashBoardRowCount = CRM_Utils_Request::retrieve('rowCount', 'Integer', CRM_Core_DAO::$_nullObject); $this->_section = CRM_Utils_Request::retrieve('section', 'Integer', CRM_Core_DAO::$_nullObject); $this->assign('section', $this->_section); CRM_Core_Region::instance('page-header')->add(array('markup' => sprintf('<!-- Report class: [%s] -->', htmlentities(get_class($this))))); if (!$this->noController) { $this->setID($this->get('instanceId')); if (!$this->_id) { $this->setID(CRM_Report_Utils_Report::getInstanceID()); if (!$this->_id) { $this->setID(CRM_Report_Utils_Report::getInstanceIDForPath()); } } // set qfkey so that pager picks it up and use it in the "Next > Last >>" links. // FIXME: Note setting it in $_GET doesn't work, since pager generates link based on QUERY_STRING $_SERVER['QUERY_STRING'] .= "&qfKey={$this->controller->_key}"; } if ($this->_id) { $this->assign('instanceId', $this->_id); $params = array('id' => $this->_id); $this->_instanceValues = array(); CRM_Core_DAO::commonRetrieve('CRM_Report_DAO_ReportInstance', $params, $this->_instanceValues); if (empty($this->_instanceValues)) { CRM_Core_Error::fatal("Report could not be loaded."); } $this->_title = $this->_instanceValues['title']; if (!empty($this->_instanceValues['permission']) && !(CRM_Core_Permission::check($this->_instanceValues['permission']) || CRM_Core_Permission::check('administer Reports'))) { CRM_Utils_System::permissionDenied(); CRM_Utils_System::civiExit(); } $formValues = CRM_Utils_Array::value('form_values', $this->_instanceValues); if ($formValues) { $this->_formValues = unserialize($formValues); } else { $this->_formValues = NULL; } $this->setOutputMode(); if ($this->_outputMode == 'copy') { $this->_createNew = TRUE; $this->_params = $this->_formValues; $this->_params['view_mode'] = 'criteria'; $this->_params['title'] = ts('(copy)') . $this->getTitle(); // Do not pass go. Do not collect another chance to re-run the same query. CRM_Report_Form_Instance::postProcess($this); } // lets always do a force if reset is found in the url. // Hey why not? see CRM-17225 for more about this. The use of reset to be force is historical for reasons stated // in the comment line above these 2. if (!empty($_REQUEST['reset']) && !in_array(CRM_Utils_Request::retrieve('output', 'String'), array('save', 'criteria'))) { $this->_force = 1; } // set the mode $this->assign('mode', 'instance'); } elseif (!$this->noController) { list($optionValueID, $optionValue) = CRM_Report_Utils_Report::getValueIDFromUrl(); $instanceCount = CRM_Report_Utils_Report::getInstanceCount($optionValue); if ($instanceCount > 0 && $optionValueID) { $this->assign('instanceUrl', CRM_Utils_System::url('civicrm/report/list', "reset=1&ovid={$optionValueID}")); } if ($optionValueID) { $this->_description = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $optionValueID, 'description'); } // set the mode $this->assign('mode', 'template'); } // lets display the Report Settings section $this->_instanceForm = $this->_force || $this->_id || !empty($_POST); // Do not display Report Settings section if administer Reports permission is absent OR // if report instance is reserved and administer reserved reports absent if (!CRM_Core_Permission::check('administer Reports') || $this->_instanceValues['is_reserved'] && !CRM_Core_Permission::check('administer reserved reports')) { $this->_instanceForm = FALSE; } $this->assign('criteriaForm', FALSE); // Display Report Criteria section if user has access Report Criteria OR administer Reports AND report instance is not reserved if (CRM_Core_Permission::check('administer Reports') || CRM_Core_Permission::check('access Report Criteria')) { if (!$this->_instanceValues['is_reserved'] || CRM_Core_Permission::check('administer reserved reports')) { $this->assign('criteriaForm', TRUE); $this->_criteriaForm = TRUE; } } $this->_instanceButtonName = $this->getButtonName('submit', 'save'); $this->_createNewButtonName = $this->getButtonName('submit', 'next'); $this->_printButtonName = $this->getButtonName('submit', 'print'); $this->_pdfButtonName = $this->getButtonName('submit', 'pdf'); $this->_csvButtonName = $this->getButtonName('submit', 'csv'); $this->_groupButtonName = $this->getButtonName('submit', 'group'); $this->_chartButtonName = $this->getButtonName('submit', 'chart'); }
function preProcessCommon() { $this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', CRM_Core_DAO::$_nullObject); $this->_section = CRM_Utils_Request::retrieve('section', 'Integer', CRM_Core_DAO::$_nullObject); $this->assign('section', $this->_section); $this->_id = $this->get('instanceId'); if (!$this->_id) { $this->_id = CRM_Report_Utils_Report::getInstanceID(); if (!$this->_id) { $this->_id = CRM_Report_Utils_Report::getInstanceIDForPath(); } } // set qfkey so that pager picks it up and use it in the "Next > Last >>" links, $_GET['qfKey'] = $this->controller->_key; if ($this->_id) { $this->assign('instanceId', $this->_id); $params = array('id' => $this->_id); $this->_instanceValues = array(); CRM_Core_DAO::commonRetrieve('CRM_Report_DAO_Instance', $params, $this->_instanceValues); if (empty($this->_instanceValues)) { CRM_Core_Error::fatal("Report could not be loaded."); } if (!empty($this->_instanceValues['permission']) && !(CRM_Core_Permission::check($this->_instanceValues['permission']) || CRM_Core_Permission::check('administer Reports'))) { CRM_Utils_System::permissionDenied(); CRM_Utils_System::civiExit(); } $this->_formValues = unserialize($this->_instanceValues['form_values']); // lets always do a force if reset is found in the url. if (CRM_Utils_Array::value('reset', $_GET)) { $this->_force = 1; } // set the mode $this->assign('mode', 'instance'); } else { list($optionValueID, $optionValue) = CRM_Report_Utils_Report::getValueIDFromUrl(); $instanceCount = CRM_Report_Utils_Report::getInstanceCount($optionValue); if ($instanceCount > 0 && $optionValueID) { $this->assign('instanceUrl', CRM_Utils_System::url('civicrm/report/list', "reset=1&ovid={$optionValueID}")); } if ($optionValueID) { $this->_description = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $optionValueID, 'description'); } // set the mode $this->assign('mode', 'template'); } // lets display the $this->_instanceForm = $this->_force || $this->_id || !empty($_POST); // do not display instance form if administer Reports permission is absent if (!CRM_Core_Permission::check('administer Reports')) { $this->_instanceForm = false; } $this->assign('criteriaForm', false); if (CRM_Core_Permission::check('administer Reports') || CRM_Core_Permission::check('access Report Criteria')) { $this->assign('criteriaForm', true); } $this->_instanceButtonName = $this->getButtonName('submit', 'save'); $this->_printButtonName = $this->getButtonName('submit', 'print'); $this->_pdfButtonName = $this->getButtonName('submit', 'pdf'); $this->_csvButtonName = $this->getButtonName('submit', 'csv'); $this->_groupButtonName = $this->getButtonName('submit', 'group'); $this->_chartButtonName = $this->getButtonName('submit', 'chart'); }