forked from CiviWare/com.dpci.constituentsonly
		
	fixed Contact ref and entity ref
This commit is contained in:
		
							
								
								
									
										23
									
								
								CRM/ConstituentsOnly/BAO/APIWrapper.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								CRM/ConstituentsOnly/BAO/APIWrapper.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,23 @@
 | 
				
			|||||||
 | 
					<?php
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class CRM_ConstituentsOnly_BAO_APIWrapper implements API_Wrapper {
 | 
				
			||||||
 | 
					  /**
 | 
				
			||||||
 | 
					   * the wrapper contains a method that allows you to alter the parameters of the api request (including the action and the entity)
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					  public function fromApiInput($apiRequest) {
 | 
				
			||||||
 | 
					    $params = &$apiRequest['params'];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (!array_key_exists('do_not_trade', $params['params'])) {
 | 
				
			||||||
 | 
					      $params['params']['do_not_trade'] = '0 AND (contact_a.do_not_trade IS NULL OR contact_a.do_not_trade = 0)';
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    return $apiRequest;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /**
 | 
				
			||||||
 | 
					   * alter the result before returning it to the caller.
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					  public function toApiOutput($apiRequest, $result) {
 | 
				
			||||||
 | 
					    return $result;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -134,6 +134,17 @@ function constituentsonly_civicrm_queryObjects(&$queryObjects, $type) {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Implements hook_civicrm_apiWrappers().
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_apiWrappers
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					function constituentsonly_civicrm_apiWrappers(&$wrappers, $apiRequest) {
 | 
				
			||||||
 | 
					  if ($apiRequest['entity'] == 'Contact' && strtolower($apiRequest['action']) == 'getlist') {
 | 
				
			||||||
 | 
					    $wrappers[] = new CRM_ConstituentsOnly_BAO_APIWrapper();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Implements hook_civicrm_contactListQuery().
 | 
					 * Implements hook_civicrm_contactListQuery().
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user