From dc6285d5647b22e0522f1a54475358c20e40b0ff Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 9 Aug 2016 18:53:30 +1200 Subject: [PATCH] CRM-19197 Stop Merge links from dropping the limit parameter Note that I decided that we did not need to avoid adding parameters to the url if they were empty. The code is simpler with &reset=1&rgid=&gid=9 and I think that is equally valid. I had to change one place in the code to make that work - but it was a change that should have been made. --- CRM/Contact/Form/Merge.php | 48 ++++++++-------------- CRM/Contact/Page/AJAX.php | 6 +-- CRM/Contact/Page/DedupeFind.php | 50 ++++++----------------- templates/CRM/Contact/Page/DedupeFind.tpl | 6 +-- 4 files changed, 34 insertions(+), 76 deletions(-) diff --git a/CRM/Contact/Form/Merge.php b/CRM/Contact/Form/Merge.php index 1bf9a44d2f..52e97b1806 100644 --- a/CRM/Contact/Form/Merge.php +++ b/CRM/Contact/Form/Merge.php @@ -44,6 +44,13 @@ class CRM_Contact_Form_Merge extends CRM_Core_Form { var $_contactType = NULL; + /** + * Query limit to be retained in the urls. + * + * @var int + */ + var $limit; + // FIXME: QuickForm can't create advcheckboxes with value set to 0 or '0' :( // see HTML_QuickForm_advcheckbox::setValues() - but patching that doesn't // help, as QF doesn't put the 0-value elements in exportValues() anyway... @@ -55,7 +62,6 @@ class CRM_Contact_Form_Merge extends CRM_Core_Form { CRM_Core_Error::fatal(ts('You do not have access to this page')); } - $rows = array(); $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE); $oid = CRM_Utils_Request::retrieve('oid', 'Positive', $this, TRUE); $flip = CRM_Utils_Request::retrieve('flip', 'Positive', $this, FALSE); @@ -63,6 +69,8 @@ class CRM_Contact_Form_Merge extends CRM_Core_Form { $this->_rgid = CRM_Utils_Request::retrieve('rgid', 'Positive', $this, FALSE); $this->_gid = $gid = CRM_Utils_Request::retrieve('gid', 'Positive', $this, FALSE); $this->_mergeId = CRM_Utils_Request::retrieve('mergeId', 'Positive', $this, FALSE); + $this->limit = CRM_Utils_Request::retrieve('limit', 'Positive', $this, FALSE); + $urlParams = "reset=1&rgid={$this->_rgid}&gid={$this->_gid}&limit=" . $this->limit; // Sanity check if ($cid == $oid) { @@ -133,16 +141,8 @@ class CRM_Contact_Form_Merge extends CRM_Core_Form { ) as $position) { if (!empty($pos[$position])) { if ($pos[$position]['id1'] && $pos[$position]['id2']) { - $urlParam = "reset=1&cid={$pos[$position]['id1']}&oid={$pos[$position]['id2']}&mergeId={$pos[$position]['mergeId']}&action=update"; - - if ($this->_rgid) { - $urlParam .= "&rgid={$this->_rgid}"; - } - if ($gid) { - $urlParam .= "&gid={$gid}"; - } - - $this->$position = CRM_Utils_System::url('civicrm/contact/merge', $urlParam); + $urlParams .= "&cid={$pos[$position]['id1']}&oid={$pos[$position]['id2']}&mergeId={$pos[$position]['mergeId']}&action=update"; + $this->$position = CRM_Utils_System::url('civicrm/contact/merge', $urlParams); $this->assign($position, $this->$position); } } @@ -172,11 +172,7 @@ class CRM_Contact_Form_Merge extends CRM_Core_Form { // context fixed. if ($isFromDedupeScreen) { - $urlParam = "reset=1&action=browse&rgid={$this->_rgid}"; - if ($gid) { - $urlParam .= "&gid={$gid}"; - } - $browseUrl = CRM_Utils_System::url('civicrm/contact/dedupefind', $urlParam); + $browseUrl = CRM_Utils_System::url('civicrm/contact/dedupefind', $urlParams . '&action=browse'); $session->pushUserContext($browseUrl); } $this->assign('browseUrl', empty($browseUrl) ? '' : $browseUrl); @@ -329,13 +325,12 @@ class CRM_Contact_Form_Merge extends CRM_Core_Form { CRM_Core_Session::setStatus($message, ts('Contacts Merged'), 'success'); $url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$this->_cid}"); + $urlParams = "reset=1&gid={$this->_gid}&rgid={$this->_rgid}&limit={$this->limit}"; + if (!empty($formValues['_qf_Merge_submit'])) { - $listParamsURL = "reset=1&action=update&rgid={$this->_rgid}"; - if ($this->_gid) { - $listParamsURL .= "&gid={$this->_gid}"; - } + $urlParams .= "&action=update"; $lisitingURL = CRM_Utils_System::url('civicrm/contact/dedupefind', - $listParamsURL + $urlParams ); CRM_Utils_System::redirect($lisitingURL); } @@ -356,15 +351,8 @@ class CRM_Contact_Form_Merge extends CRM_Core_Form { $pos['next']['id2'] ) { - $urlParam = "reset=1&cid={$pos['next']['id1']}&oid={$pos['next']['id2']}&mergeId={$pos['next']['mergeId']}&action=update"; - if ($this->_rgid) { - $urlParam .= "&rgid={$this->_rgid}"; - } - if ($this->_gid) { - $urlParam .= "&gid={$this->_gid}"; - } - - $url = CRM_Utils_System::url('civicrm/contact/merge', $urlParam); + $urlParams .= "&cid={$pos['next']['id1']}&oid={$pos['next']['id2']}&mergeId={$pos['next']['mergeId']}&action=update"; + $url = CRM_Utils_System::url('civicrm/contact/merge', $urlParams); } } diff --git a/CRM/Contact/Page/AJAX.php b/CRM/Contact/Page/AJAX.php index bb6eddd5b2..a5344f9d0e 100644 --- a/CRM/Contact/Page/AJAX.php +++ b/CRM/Contact/Page/AJAX.php @@ -640,8 +640,8 @@ LIMIT {$offset}, {$rowCount} $offset = isset($_REQUEST['start']) ? CRM_Utils_Type::escape($_REQUEST['start'], 'Integer') : 0; $rowCount = isset($_REQUEST['length']) ? CRM_Utils_Type::escape($_REQUEST['length'], 'Integer') : 25; - $gid = isset($_REQUEST['gid']) ? CRM_Utils_Type::escape($_REQUEST['gid'], 'Integer') : 0; - $rgid = isset($_REQUEST['rgid']) ? CRM_Utils_Type::escape($_REQUEST['rgid'], 'Integer') : 0; + $gid = CRM_Utils_Request::retrieve('gid', 'Positive'); + $rgid = CRM_Utils_Request::retrieve('rgid', 'Positive'); $selected = isset($_REQUEST['selected']) ? CRM_Utils_Type::escape($_REQUEST['selected'], 'Integer') : 0; if ($rowCount < 0) { $rowCount = 0; @@ -802,7 +802,7 @@ LIMIT {$offset}, {$rowCount} $searchRows[$count]['weight'] = CRM_Utils_Array::value('weight', $pair); if (!empty($pairInfo['data']['canMerge'])) { - $mergeParams = "reset=1&cid={$pairInfo['entity_id1']}&oid={$pairInfo['entity_id2']}&action=update&rgid={$rgid}"; + $mergeParams = "reset=1&cid={$pairInfo['entity_id1']}&oid={$pairInfo['entity_id2']}&action=update&rgid={$rgid}&limit=" . CRM_Utils_Request::retrieve('limit', 'Integer'); if ($gid) { $mergeParams .= "&gid={$gid}"; } diff --git a/CRM/Contact/Page/DedupeFind.php b/CRM/Contact/Page/DedupeFind.php index 7567270707..2555693399 100644 --- a/CRM/Contact/Page/DedupeFind.php +++ b/CRM/Contact/Page/DedupeFind.php @@ -60,6 +60,9 @@ class CRM_Contact_Page_DedupeFind extends CRM_Core_Page_Basic { $action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 0); $context = CRM_Utils_Request::retrieve('context', 'String', $this); $limit = CRM_Utils_Request::retrieve('limit', 'Integer', $this); + $rgid = CRM_Utils_Request::retrieve('rgid', 'Positive'); + $urlQry = "reset=1&rgid={$rgid}&gid={$gid}&limit={$limit}"; + $this->assign('urlQuery', $urlQry); $session = CRM_Core_Session::singleton(); $contactIds = $session->get('selectedSearchContactIds'); @@ -70,20 +73,14 @@ class CRM_Contact_Page_DedupeFind extends CRM_Core_Page_Basic { if ($action & CRM_Core_Action::RENEW) { // empty cache - $rgid = CRM_Utils_Request::retrieve('rgid', 'Positive', $this, FALSE, 0); if ($rgid) { CRM_Core_BAO_PrevNextCache::deleteItem(NULL, CRM_Dedupe_Merger::getMergeCacheKeyString($rgid, $gid)); } - $urlQry = "reset=1&action=update&rgid={$rgid}"; - if ($gid) { - $urlQry .= "&gid={$gid}"; - } - CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/dedupefind', $urlQry)); + CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/dedupefind', $urlQry . "&action=update")); } elseif ($action & CRM_Core_Action::MAP) { // do a batch merge if requested - $rgid = CRM_Utils_Request::retrieve('rgid', 'Positive', $this, FALSE, 0); $result = CRM_Dedupe_Merger::batchMerge($rgid, $gid, 'safe', TRUE, 75); $skippedCount = CRM_Utils_Request::retrieve('skipped', 'Positive', $this, FALSE, 0); @@ -104,19 +101,10 @@ class CRM_Contact_Page_DedupeFind extends CRM_Core_Page_Basic { } $message .= ts(" during the batch merge process with safe mode."); CRM_Core_Session::setStatus($message, ts('Merge Complete'), 'success'); - - $urlQry = "reset=1&action=update&rgid={$rgid}"; - if ($gid) { - $urlQry .= "&gid={$gid}"; - } - CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/dedupefind', $urlQry)); + CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/dedupefind', $urlQry . "&action=update")); } else { - $urlQry = "reset=1&action=map&rgid={$rgid}"; - if ($gid) { - $urlQry .= "&gid={$gid}"; - } - $urlQry .= "&skipped={$skippedCount}&merged={$mergedCount}"; + $urlQry .= "&action=map&skipped={$skippedCount}&merged={$mergedCount}"; CRM_Utils_System::jsRedirect( CRM_Utils_System::url('civicrm/contact/dedupefind', $urlQry), ts('Batch Merge Task in progress'), @@ -129,21 +117,14 @@ class CRM_Contact_Page_DedupeFind extends CRM_Core_Page_Basic { $action & CRM_Core_Action::BROWSE ) { $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE, 0); - $rgid = CRM_Utils_Request::retrieve('rgid', 'Positive', $this, FALSE, 0); $this->action = CRM_Core_Action::UPDATE; - $sourceParams = 'snippet=4'; - if ($gid) { - $sourceParams .= "&gid={$gid}"; - } - if ($rgid) { - $sourceParams .= "&rgid={$rgid}"; - } + $urlQry .= '&snippet=4'; if ($context == 'conflicts') { - $sourceParams .= "&selected=1"; + $urlQry .= "&selected=1"; } - $this->assign('sourceUrl', CRM_Utils_System::url('civicrm/ajax/dedupefind', $sourceParams, FALSE, NULL, FALSE)); + $this->assign('sourceUrl', CRM_Utils_System::url('civicrm/ajax/dedupefind', $urlQry, FALSE, NULL, FALSE)); //reload from cache table $cacheKeyString = CRM_Dedupe_Merger::getMergeCacheKeyString($rgid, $gid); @@ -163,14 +144,7 @@ class CRM_Contact_Page_DedupeFind extends CRM_Core_Page_Basic { if (empty($this->_mainContacts)) { if ($context == 'conflicts') { // if the current screen was intended to list only selected contacts, move back to full dupe list - $sourceParams = 'reset=1&action=update'; - if ($gid) { - $sourceParams .= "&gid={$gid}"; - } - if ($rgid) { - $sourceParams .= "&rgid={$rgid}"; - } - CRM_Utils_System::redirect(CRM_Utils_System::url(CRM_Utils_System::currentPath(), $sourceParams)); + CRM_Utils_System::redirect(CRM_Utils_System::url(CRM_Utils_System::currentPath(), $urlQry . '&action=update')); } if ($gid) { $foundDupes = $this->get("dedupe_dupes_$gid"); @@ -221,12 +195,12 @@ class CRM_Contact_Page_DedupeFind extends CRM_Core_Page_Basic { $session = CRM_Core_Session::singleton(); if ($this->_cid) { $session->pushUserContext(CRM_Utils_System::url('civicrm/contact/deduperules', - "action=update&rgid={$this->_rgid}&gid={$this->_gid}&cid={$this->_cid}" + $urlQry . "&action=update&cid={$this->_cid}" )); } else { $session->pushUserContext(CRM_Utils_System::url('civicrm/contact/dedupefind', - "reset=1&action=update&rgid={$this->_rgid}" + $urlQry . "&action=update" )); } } diff --git a/templates/CRM/Contact/Page/DedupeFind.tpl b/templates/CRM/Contact/Page/DedupeFind.tpl index 034efb3b99..158b057ffe 100644 --- a/templates/CRM/Contact/Page/DedupeFind.tpl +++ b/templates/CRM/Contact/Page/DedupeFind.tpl @@ -160,11 +160,7 @@ {/if} {ts}List All Duplicates{/ts} {else} - {if $gid} - {capture assign=backURL}{crmURL p="civicrm/contact/dedupefind" q="reset=1&rgid=`$rgid`&gid=`$gid`&action=renew" a=1}{/capture} - {else} - {capture assign=backURL}{crmURL p="civicrm/contact/dedupefind" q="reset=1&rgid=`$rgid`&action=renew" a=1}{/capture} - {/if} + {capture assign=backURL}{crmURL p="civicrm/contact/dedupefind" q="`$urlQuery`&action=renew" a=1}{/capture} {ts}Refresh Duplicates{/ts} -- 2.25.1