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 { ...@@ -79,7 +79,7 @@ class CRM_AdvancedEvents_Form_Search extends CRM_Core_Form_Search {
* @return void * @return void
*/ */
public function preProcess() { public function preProcess() {
$this->set('searchFormName', 'Search'); $this->_selectedChild = CRM_Utils_Request::retrieve('selectedChild', 'Alphanumeric', $this);
/** /**
* set the button names * set the button names
...@@ -100,7 +100,31 @@ class CRM_AdvancedEvents_Form_Search extends CRM_Core_Form_Search { ...@@ -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->_context = CRM_Utils_Request::retrieve('context', 'Alphanumeric', $this, FALSE, 'search');
$this->assign("context", $this->_context); $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 user submitted values
// get it from controller only if form has been submitted, else preProcess has set this // 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 { ...@@ -116,6 +140,13 @@ class CRM_AdvancedEvents_Form_Search extends CRM_Core_Form_Search {
$this->set('force', 0); $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(); $sortID = $this->getSortId();
$this->setQueryParams(); $this->setQueryParams();
...@@ -126,7 +157,7 @@ class CRM_AdvancedEvents_Form_Search extends CRM_Core_Form_Search { ...@@ -126,7 +157,7 @@ class CRM_AdvancedEvents_Form_Search extends CRM_Core_Form_Search {
$selector->setKey($this->controller->_key); $selector->setKey($this->controller->_key);
$this->assign('context', 'Search'); $this->assign('context', $this->_context);
$prefix = NULL; $prefix = NULL;
if ($this->_context == 'user') { if ($this->_context == 'user') {
...@@ -260,7 +291,7 @@ class CRM_AdvancedEvents_Form_Search extends CRM_Core_Form_Search { ...@@ -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')); $this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues, 0, FALSE, NULL, array('id'));
if (!empty($this->_templateId)) { if (!empty($this->_templateId)) {
$this->assign('hideSearch', TRUE); $this->assign('single', TRUE);
$this->_queryParams = [[ $this->_queryParams = [[
0 => 'event_template_id', 0 => 'event_template_id',
1 => '=', 1 => '=',
...@@ -298,7 +329,6 @@ class CRM_AdvancedEvents_Form_Search extends CRM_Core_Form_Search { ...@@ -298,7 +329,6 @@ class CRM_AdvancedEvents_Form_Search extends CRM_Core_Form_Search {
* the default array reference * the default array reference
*/ */
public function setDefaultValues() { public function setDefaultValues() {
$defaults = array();
$defaults = $this->_formValues; $defaults = $this->_formValues;
return $defaults; return $defaults;
} }
...@@ -318,12 +348,12 @@ class CRM_AdvancedEvents_Form_Search extends CRM_Core_Form_Search { ...@@ -318,12 +348,12 @@ class CRM_AdvancedEvents_Form_Search extends CRM_Core_Form_Search {
$this->_formValues['event_type'] = $type; $this->_formValues['event_type'] = $type;
} }
$cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this); $templateId = CRM_Utils_Request::retrieve('template_id', 'Positive', $this);
if ($cid) { if ($templateId) {
$cid = CRM_Utils_Type::escape($cid, 'Integer'); $templateId = CRM_Utils_Type::escape($templateId, 'Positive');
if ($cid > 0) { if ($templateId > 0) {
$this->_formValues['contact_id'] = $cid; $this->_formValues['template_id'] = $templateId;
// also assign individual mode to the template // also assign individual mode to the template
$this->_single = TRUE; $this->_single = TRUE;
......
...@@ -94,20 +94,6 @@ class CRM_AdvancedEvents_Form_Task extends CRM_Core_Form_Task { ...@@ -94,20 +94,6 @@ class CRM_AdvancedEvents_Form_Task extends CRM_Core_Form_Task {
} }
$form->_eventIds = $form->_componentIds = $ids; $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 ...@@ -46,9 +46,9 @@ class CRM_AdvancedEvents_Form_Task_CopyParticipants extends CRM_AdvancedEvents_F
* @throws \Exception * @throws \Exception
*/ */
public function preProcess() { public function preProcess() {
//check for delete //check for edit participants
if (!CRM_Core_Permission::checkActionPermission('CiviEvent', CRM_Core_Action::DELETE)) { if (!CRM_Core_Permission::checkActionPermission('CiviEvent', CRM_Core_Action::UPDATE)) {
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(); parent::preProcess();
} }
......
...@@ -49,7 +49,7 @@ class CRM_AdvancedEvents_Form_Task_Delete extends CRM_AdvancedEvents_Form_Task { ...@@ -49,7 +49,7 @@ class CRM_AdvancedEvents_Form_Task_Delete extends CRM_AdvancedEvents_Form_Task {
//check for delete //check for delete
if (!CRM_Core_Permission::checkActionPermission('CiviEvent', CRM_Core_Action::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(); parent::preProcess();
} }
......
...@@ -194,8 +194,8 @@ function advanced_events_civicrm_tabset($tabsetName, &$tabs, $context) { ...@@ -194,8 +194,8 @@ function advanced_events_civicrm_tabset($tabsetName, &$tabs, $context) {
'class' => 'livePage', 'class' => 'livePage',
]; ];
$tabs['linkedevents'] = [ $tabs['linkedevents'] = [
'title' => 'Events', 'title' => 'Manage Linked Events',
'link' => CRM_Utils_System::url('civicrm/events/search', ['force' => 1, 'template_id' => $eventTemplate['id']]), 'link' => CRM_Utils_System::url('civicrm/events/search', ['force' => 1, 'template_id' => $eventTemplate['id'], 'selectedChild' => 'linkedevents']),
'valid' => TRUE, 'valid' => TRUE,
'active' => TRUE, 'active' => TRUE,
'current' => FALSE, 'current' => FALSE,
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
+--------------------------------------------------------------------+ +--------------------------------------------------------------------+
*} *}
{* Search form and results for Events *} {* 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-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-wrapper crm-advanced_search_form-accordion {if !empty($ssID) or $rows}collapsed{/if}">
<div class="crm-accordion-header crm-master-accordion-header"> <div class="crm-accordion-header crm-master-accordion-header">
......
...@@ -74,18 +74,6 @@ ...@@ -74,18 +74,6 @@
<td>{$row.action|replace:'xx':$id}</td> <td>{$row.action|replace:'xx':$id}</td>
</tr> </tr>
{/foreach} {/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> </table>
{/strip} {/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