forked from CiviWare/com.dpci.constituentsonly
		
	fixed contact toggling
This commit is contained in:
		@@ -161,9 +161,11 @@ class CRM_ConstituentsOnly_BAO_ConstituentsOnly {
 | 
				
			|||||||
      $url = CRM_Utils_Array::value('q', $_GET);
 | 
					      $url = CRM_Utils_Array::value('q', $_GET);
 | 
				
			||||||
      $returnProperties = NULL;
 | 
					      $returnProperties = NULL;
 | 
				
			||||||
      $request = $_REQUEST;
 | 
					      $request = $_REQUEST;
 | 
				
			||||||
      if (!empty($_REQUEST['has_js'])) {
 | 
					
 | 
				
			||||||
      $qfKey = $_REQUEST['qfKey'];
 | 
					      $qfKey = $_REQUEST['qfKey'];
 | 
				
			||||||
        $formValuesFromSession = CRM_Core_Session::singleton()->get("CRM_Contact_Controller_Search_{$qfKey}");
 | 
					      $cache = "CRM_Contact_Controller_Search_{$qfKey}";
 | 
				
			||||||
 | 
					      if (!empty($_REQUEST['has_js'])) {
 | 
				
			||||||
 | 
					        $formValuesFromSession = CRM_Core_Session::singleton()->get($cache);
 | 
				
			||||||
        if (!empty($formValuesFromSession['formValues'])) {
 | 
					        if (!empty($formValuesFromSession['formValues'])) {
 | 
				
			||||||
          $request = $formValuesFromSession['formValues'];
 | 
					          $request = $formValuesFromSession['formValues'];
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -192,6 +194,32 @@ class CRM_ConstituentsOnly_BAO_ConstituentsOnly {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        $newRows[$cid]['sort_name'] .= "({$rows[$ogContactId]['sort_name']})";
 | 
					        $newRows[$cid]['sort_name'] .= "({$rows[$ogContactId]['sort_name']})";
 | 
				
			||||||
        $rows[$ogContactId] = $newRows[$cid];
 | 
					        $rows[$ogContactId] = $newRows[$cid];
 | 
				
			||||||
 | 
					        $prevCacheKey = "civicrm search {$qfKey}";
 | 
				
			||||||
 | 
					        $exists = CRM_Core_DAO::singleValueQuery(
 | 
				
			||||||
 | 
					          "SELECT count(id) FROM civicrm_prevnext_cache
 | 
				
			||||||
 | 
					            WHERE (
 | 
				
			||||||
 | 
					              entity_id1 = %1 OR entity_id2 = %1
 | 
				
			||||||
 | 
					            )
 | 
				
			||||||
 | 
					            AND cacheKey = %2
 | 
				
			||||||
 | 
					            AND entity_table = 'civicrm_contact'
 | 
				
			||||||
 | 
					          ",
 | 
				
			||||||
 | 
					          [
 | 
				
			||||||
 | 
					            1 => [$cid, 'Integer'],
 | 
				
			||||||
 | 
					            2 => [$prevCacheKey, 'String'],
 | 
				
			||||||
 | 
					          ]
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (!$exists) {
 | 
				
			||||||
 | 
					          $prevCache = [
 | 
				
			||||||
 | 
					            "('civicrm_contact'",
 | 
				
			||||||
 | 
					            "'{$cid}'",
 | 
				
			||||||
 | 
					            "'{$cid}'",
 | 
				
			||||||
 | 
					            "'{$prevCacheKey}'",
 | 
				
			||||||
 | 
					            "'" . $newRows[$cid]['sort_name'] . "')",
 | 
				
			||||||
 | 
					          ];
 | 
				
			||||||
 | 
					          CRM_Core_BAO_PrevNextCache::setItem($prevCache);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        CRM_Core_BAO_PrevNextCache::deleteItem($ogContactId, $prevCacheKey);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return $rows;
 | 
					    return $rows;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user