Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-3660

Event API: civicrm_event_search does not support 'sort', 'offset', 'rowCount'

    Details

    • Type: Improvement
    • Status: Done/Fixed
    • Priority: Major
    • Resolution: Fixed/Completed
    • Affects Version/s: 2.1
    • Fix Version/s: 2.2.0
    • Component/s: CiviEvent
    • Labels:
      None

      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.' )

      { $returnProperties[ substr( $n, 7 ) ] = $v; }

      elseif ( in_array( $n, $otherVars ) )

      { $$n = $v; }

      else

      { $inputParams[$n] = $v; }

      }
      if( !empty($returnProperties ) )

      { $returnProperties[]='id'; $returnProperties[]='event_type_id'; }

      $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->selectAdd( ); $eventDAO->selectAdd( implode( ',' , $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 )

      { $event[$eventDAO->id][$key] = $val; }

      }
      }
      $eventDAO->free( );
      return $event;
      }

        Attachments

          Activity

            People

            • Assignee:
              kiran.jagtap Kiran Jagtap
              Reporter:
              mreinsch Michael Reinsch
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: