unset($params['is_navigation']);
}
+ $viewMode = !empty($params['view_mode']) ? $params['view_mode'] : FALSE;
+ if ($viewMode) {
+ // Do not save to the DB - it's saved in the url.
+ unset($params['view_mode']);
+ }
+
// add to dashboard
$dashletParams = array();
if (!empty($params['addToDashboard'])) {
if (empty($params['id']) && empty($params['instance_id']) && !empty($navigationParams['id'])) {
unset($navigationParams['id']);
}
- $navigationParams['url'] = "civicrm/report/instance/{$instance->id}?reset=1";
+ $navigationParams['url'] = "civicrm/report/instance/{$instance->id}" . ($viewMode == 'view' ? '?reset=1&force=1' : '?reset=1&output=criteria');
$navigation = CRM_Core_BAO_Navigation::add($navigationParams);
if (!empty($navigationParams['is_active'])) {
array('onclick' => "return showHideByValue('is_navigation','','navigation_menu','table-row','radio',false);")
);
+ $form->addElement('select', 'view_mode', ts('Configure link to...'), array(
+ 'view' => ts('View Results'),
+ 'criteria' => ts('Show Criteria'),
+ ));
+
$form->addElement('checkbox', 'addToDashboard', ts('Available for Dashboard?'), NULL,
array('onclick' => "return showHideByValue('addToDashboard','','limit_result','table-row','radio',false);"));
$form->addElement('checkbox', 'is_reserved', ts('Reserved Report?'));
</html>
";
+ // CRM-17225 view_mode currently supports 'view' or 'criteria'.
+ // Prior to 4.7 'view' meant reset=1 in the url & if not set
+ // then show criteria.
+ // From 4.7 we will pro-actively set 'force=1' but still respect the old behaviour.
+ // we may look to add pdf, print_view, csv & various charts as these could simply
+ // be added to the url allowing us to conceptualise 'view right now' vs saved view
+ // & using a multiselect (option value?) could help here.
+ // Note that accessing reports without reset=1 in the url turns out to be
+ // dangerous as it seems to carry actions like 'delete' from one report to another.
+ $defaults['view_mode'] = 'view';
+ $output = CRM_Utils_Request::retrieve('output', 'String');
+ if ($output == 'criteria') {
+ $defaults['view_mode'] = 'criteria';
+ }
+
if ($instanceID) {
// this is already retrieved via Form.php
$defaults['description'] = CRM_Utils_Array::value('description', $defaults);
CRM_Core_BAO_Navigation::retrieve($params, $navigationDefaults);
$defaults['is_navigation'] = 1;
$defaults['parent_id'] = CRM_Utils_Array::value('parent_id', $navigationDefaults);
-
if (!empty($navigationDefaults['is_active'])) {
$form->assign('is_navigation', TRUE);
}
+ // A saved view mode will over-ride any url assumptions.
+ if (strpos($navigationDefaults['url'], 'output=criteria')) {
+ $defaults['view_mode'] = 'criteria';
+ }
if (!empty($navigationDefaults['id'])) {
$form->_navigation['id'] = $navigationDefaults['id'];
foreach ($unsetFields as $field) {
unset($formValues[$field]);
}
+ $view_mode = $formValues['view_mode'];
// pass form_values as string
$params['form_values'] = serialize($formValues);
CRM_Core_Session::setStatus($statusMsg);
if ($redirect) {
- CRM_Utils_System::redirect(CRM_Utils_System::url("civicrm/report/instance/{$instance->id}", "reset=1"));
+ $urlParams = array('reset' => 1);
+ if ($view_mode == 'view') {
+ $urlParams['force'] = 1;
+ }
+ else {
+ $urlParams['output'] = 'criteria';
+ }
+ CRM_Utils_System::redirect(CRM_Utils_System::url("civicrm/report/instance/{$instance->id}", $urlParams));
}
}