Details
-
Type: Bug
-
Status: Done/Fixed
-
Priority: Minor
-
Resolution: Fixed/Completed
-
Affects Version/s: 2.0
-
Fix Version/s: 3.0
-
Component/s: Core CiviCRM
-
Labels:None
Description
The civicrm_event_search api function isn't properly returning custom fields for events. I've posted an updated version of the function below that works correctly with custom fields (as far as I can tell). Essentially, what was happening was that only the custom fields for the last record in the loop were being returned. Hope this helps some people.
function civicrm_event_search( &$params )
{
foreach ( $params as $n => $v ) {
if ( substr( $n, 0, 7 ) == 'return.' )
}
require_once 'CRM/Event/BAO/Event.php';
require_once 'CRM/Core/BAO/CustomGroup.php'; //moved this up top s.t. it not in the loop
$eventDAO = new CRM_Event_BAO_Event( );
$eventDAO->copyValues( $params );
$eventDAO->find( );
$event = array( );
while ( $eventDAO->fetch( ) )
{ $event[$eventDAO->id] = array( ); CRM_Core_DAO::storeValues( $eventDAO, $event[$eventDAO->id] ); //}//commented out b/c we want to loop through the custom field stuff for each record (as opposed to just the last record)
//require_once 'CRM/Core/BAO/CustomGroup.php'; //commented out b/c I moved it up top
$groupTree =& CRM_Core_BAO_CustomGroup::getTree( 'Event', $eventDAO->id, false, 1 );
CRM_Core_BAO_CustomGroup::setDefaults( $groupTree, $defaults, false, false );
if ( is_array( $defaults ) ) {
foreach ( $defaults as $key => $val )
}
} //added to end the loop
$eventDAO->free( );
return $event;
}