Details
Description
The function civicrm_event_search does not support 'sort', 'offset', 'rowCount'. The following drop-in replacement adds those features:
function civicrm_event_search( &$params )
{
$inputParams = array( );
$returnProperties = array( );
$otherVars = array( 'sort', 'offset', 'rowCount' );
$sort = false;
$offset = 0;
$rowCount = 25;
foreach ( $params as $n => $v ) {
if ( substr( $n, 0, 7 ) == 'return.' )
elseif ( in_array( $n, $otherVars ) )
{ $$n = $v; }else
{ $inputParams[$n] = $v; } }
if( !empty($returnProperties ) )
$event = array();
require_once 'CRM/Core/BAO/CustomGroup.php';
require_once 'CRM/Event/BAO/Event.php';
$eventDAO = new CRM_Event_BAO_Event( );
$eventDAO->copyValues( $inputParams );
if ( !empty( $returnProperties ) )
$eventDAO->orderBy( $sort );
$eventDAO->limit( (int)$offset, (int)$rowCount );
$eventDAO->find( );
while ( $eventDAO->fetch( ) ) {
$event[$eventDAO->id] = array( );
CRM_Core_DAO::storeValues( $eventDAO, $event[$eventDAO->id] );
$groupTree =& CRM_Core_BAO_CustomGroup::getTree( 'Event', $eventDAO->id, false, $eventDAO->event_type_id );
$defaults = array( );
CRM_Core_BAO_CustomGroup::setDefaults( $groupTree, $defaults );
if ( !empty( $defaults ) ) {
foreach ( $defaults as $key => $val )
}
}
$eventDAO->free( );
return $event;
}