Commit 82ce032a authored by mattwire's avatar mattwire
Browse files

Make sure we redirect back to where we came from when executing event search tasks

parent 67527343
......@@ -79,7 +79,7 @@ class CRM_AdvancedEvents_Form_Search extends CRM_Core_Form_Search {
* @return void
*/
public function preProcess() {
$this->set('searchFormName', 'Search');
$this->_selectedChild = CRM_Utils_Request::retrieve('selectedChild', 'Alphanumeric', $this);
/**
* set the button names
......@@ -100,7 +100,31 @@ class CRM_AdvancedEvents_Form_Search extends CRM_Core_Form_Search {
$this->_context = CRM_Utils_Request::retrieve('context', 'Alphanumeric', $this, FALSE, 'search');
$this->assign("context", $this->_context);
$this->_templateId = CRM_Utils_Request::retrieve('template_id', 'Positive');
$this->_templateId = CRM_Utils_Request::retrieve('template_id', 'Positive', $this);
//set the context for redirection for any task actions
$session = CRM_Core_Session::singleton();
if ($this->_templateId) {
$urlPath = 'civicrm/event/manage/settings';
$urlParams['id'] = $this->_templateId;
if ($this->_selectedChild) {
$urlParams['selectedChild'] = $this->_selectedChild;
}
}
else {
$qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $form);
if (CRM_Utils_Rule::qfKey($qfKey)) {
$urlParams['qfKey'] = $qfKey;
}
$urlPath = 'civicrm/events/search';
}
$urlParams['reset'] = 1;
if ($this->_action == CRM_Core_Action::UPDATE) {
$urlParams['action'] = 'update';
}
$url = CRM_Utils_System::url($urlPath, $urlParams);
$session->replaceUserContext($url);
// get user submitted values
// get it from controller only if form has been submitted, else preProcess has set this
......@@ -116,6 +140,13 @@ class CRM_AdvancedEvents_Form_Search extends CRM_Core_Form_Search {
$this->set('force', 0);
}
// This is a bit of a hack to ensure we reload the "Manage Linked Events" tab after
// executing a search task if we ran it from there.
if ($this->_selectedChild && !$this->_force
&& (CRM_Utils_Array::value('_qf_Search_next_action', $_POST) != 'Go')) {
CRM_Utils_System::redirect($url);
}
$sortID = $this->getSortId();
$this->setQueryParams();
......@@ -126,7 +157,7 @@ class CRM_AdvancedEvents_Form_Search extends CRM_Core_Form_Search {
$selector->setKey($this->controller->_key);
$this->assign('context', 'Search');
$this->assign('context', $this->_context);
$prefix = NULL;
if ($this->_context == 'user') {
......@@ -260,7 +291,7 @@ class CRM_AdvancedEvents_Form_Search extends CRM_Core_Form_Search {
$this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues, 0, FALSE, NULL, array('id'));
if (!empty($this->_templateId)) {
$this->assign('hideSearch', TRUE);
$this->assign('single', TRUE);
$this->_queryParams = [[
0 => 'event_template_id',
1 => '=',
......@@ -298,7 +329,6 @@ class CRM_AdvancedEvents_Form_Search extends CRM_Core_Form_Search {
* the default array reference
*/
public function setDefaultValues() {
$defaults = array();
$defaults = $this->_formValues;
return $defaults;
}
......@@ -318,12 +348,12 @@ class CRM_AdvancedEvents_Form_Search extends CRM_Core_Form_Search {
$this->_formValues['event_type'] = $type;
}
$cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
$templateId = CRM_Utils_Request::retrieve('template_id', 'Positive', $this);
if ($cid) {
$cid = CRM_Utils_Type::escape($cid, 'Integer');
if ($cid > 0) {
$this->_formValues['contact_id'] = $cid;
if ($templateId) {
$templateId = CRM_Utils_Type::escape($templateId, 'Positive');
if ($templateId > 0) {
$this->_formValues['template_id'] = $templateId;
// also assign individual mode to the template
$this->_single = TRUE;
......
......@@ -94,20 +94,6 @@ class CRM_AdvancedEvents_Form_Task extends CRM_Core_Form_Task {
}
$form->_eventIds = $form->_componentIds = $ids;
//set the context for redirection for any task actions
$session = CRM_Core_Session::singleton();
$qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $form);
$urlParams = 'force=1';
if (CRM_Utils_Rule::qfKey($qfKey)) {
$urlParams .= "&qfKey=$qfKey";
}
$searchFormName = strtolower($form->get('searchFormName'));
if ($searchFormName == 'search') {
$session->replaceUserContext(CRM_Utils_System::url('civicrm/events/search', $urlParams));
}
}
/**
......
......@@ -46,9 +46,9 @@ class CRM_AdvancedEvents_Form_Task_CopyParticipants extends CRM_AdvancedEvents_F
* @throws \Exception
*/
public function preProcess() {
//check for delete
if (!CRM_Core_Permission::checkActionPermission('CiviEvent', CRM_Core_Action::DELETE)) {
CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
//check for edit participants
if (!CRM_Core_Permission::checkActionPermission('CiviEvent', CRM_Core_Action::UPDATE)) {
CRM_Core_Error::statusBounce(ts('You do not have permission to access this page.'));
}
parent::preProcess();
}
......
......@@ -49,7 +49,7 @@ class CRM_AdvancedEvents_Form_Task_Delete extends CRM_AdvancedEvents_Form_Task {
//check for delete
if (!CRM_Core_Permission::checkActionPermission('CiviEvent', CRM_Core_Action::DELETE)) {
CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
CRM_Core_Error::statusBounce(ts('You do not have permission to access this page.'));
}
parent::preProcess();
}
......
......@@ -194,8 +194,8 @@ function advanced_events_civicrm_tabset($tabsetName, &$tabs, $context) {
'class' => 'livePage',
];
$tabs['linkedevents'] = [
'title' => 'Events',
'link' => CRM_Utils_System::url('civicrm/events/search', ['force' => 1, 'template_id' => $eventTemplate['id']]),
'title' => 'Manage Linked Events',
'link' => CRM_Utils_System::url('civicrm/events/search', ['force' => 1, 'template_id' => $eventTemplate['id'], 'selectedChild' => 'linkedevents']),
'valid' => TRUE,
'active' => TRUE,
'current' => FALSE,
......
......@@ -24,7 +24,7 @@
+--------------------------------------------------------------------+
*}
{* Search form and results for Events *}
{if empty($hideSearch)}
{if empty($single)}
<div class="crm-block crm-form-block crm-event-search-form-block">
<div class="crm-accordion-wrapper crm-advanced_search_form-accordion {if !empty($ssID) or $rows}collapsed{/if}">
<div class="crm-accordion-header crm-master-accordion-header">
......
......@@ -74,18 +74,6 @@
<td>{$row.action|replace:'xx':$id}</td>
</tr>
{/foreach}
{* Link to "View all participants" for Dashboard and Contact Summary *}
{if $limit and $pager->_totalItems GT $limit }
{if $context EQ 'event_dashboard' }
<tr class="even-row">
<td colspan="10"><a href="{crmURL p='civicrm/event/search' q='reset=1'}">&raquo; {ts}Find more event participants{/ts}...</a></td></tr>
</tr>
{elseif $context eq 'participant' }
<tr class="even-row">
<td colspan="7"><a href="{crmURL p='civicrm/contact/view' q="reset=1&force=1&selectedChild=participant&cid=$contactId"}">&raquo; {ts}View all events for this contact{/ts}...</a></td></tr>
</tr>
{/if}
{/if}
</table>
{/strip}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment