CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • civicrm_event_search strange changes
Pages: [1]

Author Topic: civicrm_event_search strange changes  (Read 1764 times)

najoory

  • Guest
civicrm_event_search strange changes
February 15, 2010, 03:18:53 am
I think you wrong here:
Code: [Select]
       
if ( $eventDAO->is_template ) {
          continue;
}

Function:
Code: [Select]
function civicrm_event_search( &$params )
{

    if ( ! is_array( $params ) ) {
        return civicrm_create_error( ts( 'Input parameters is not an array.' ) );
    }

    $inputParams            = array( );
    $returnProperties       = array( );
    $returnCustomProperties = array( );
    $otherVars              = array( 'sort', 'offset', 'rowCount' );

    $sort     = false;
    // don't check if empty, more meaningful error for API user instead of siletn defaults
    $offset   = array_key_exists( 'return.offset', $params ) ? $params['return.offset'] : 0;
    $rowCount = array_key_exists( 'return.max_results', $params ) ? $params['return.max_results'] : 25;
   
    foreach ( $params as $n => $v ) {
        if ( substr( $n, 0, 7 ) == 'return.' ) {
            if ( substr( $n, 0, 14 ) == 'return.custom_') {
                //take custom return properties separate
                $returnCustomProperties[] = substr( $n, 7 );
            } elseif( !in_array( substr( $n, 7 ) ,array( 'offset', 'max_results' ) ) ) {
                $returnProperties[] = substr( $n, 7 );
            }
        } elseif ( in_array( $n, $otherVars ) ) {
            $$n = $v;
        } else {
            $inputParams[$n] = $v;
        }
    }

    if ( !empty($returnProperties ) ) {
        $returnProperties[]='id';
        $returnProperties[]='event_type_id';
    }
   
    require_once 'CRM/Core/BAO/CustomGroup.php';
    require_once 'CRM/Event/BAO/Event.php';
    $eventDAO = new CRM_Event_BAO_Event( );
    $eventDAO->copyValues( $inputParams );
    $event = array();
    if ( !empty( $returnProperties ) ) {
        $eventDAO->selectAdd( );
        $eventDAO->selectAdd( implode( ',' , $returnProperties ) );
    }
   
    $eventDAO->orderBy( $sort );
    $eventDAO->limit( (int)$offset, (int)$rowCount );
    $eventDAO->find( );
    while ( $eventDAO->fetch( ) ) {
        // ignore event templates
        // ideally need to put this in the query, but not sure how to do this with the below
        // ( ( is_template IS NULL ) OR ( is_template = 0 ) )
        // hence doing this here for now, please fix on a future rewrite
       
        if ( $eventDAO->is_template ) {
            continue;
        }

        $event[$eventDAO->id] = array( );
        CRM_Core_DAO::storeValues( $eventDAO, $event[$eventDAO->id] );
        $groupTree =& CRM_Core_BAO_CustomGroup::getTree( 'Event', CRM_Core_DAO::$_nullObject, $eventDAO->id, false, $eventDAO->event_type_id );
        $groupTree = CRM_Core_BAO_CustomGroup::formatGroupTree( $groupTree, 1, CRM_Core_DAO::$_nullObject );
        $defaults  = array( );
        CRM_Core_BAO_CustomGroup::setDefaults( $groupTree, $defaults );
           
        if ( !empty( $defaults ) ) {
            foreach ( $defaults as $key => $val ) {
                if (! empty($returnCustomProperties ) ) {
                    $customKey  = explode('_', $key );
                    //show only return properties
                    if ( in_array( 'custom_'.$customKey['1'], $returnCustomProperties ) ) {
                        $event[$eventDAO->id][$key] = $val;
                    }
                } else {
                    $event[$eventDAO->id][$key] = $val;
                }
            }
        }
    }//end of the loop
    $eventDAO->free( );
    return $event;
}

Yashodha Chaku

  • Forum Godess / God
  • Ask me questions
  • *****
  • Posts: 755
  • Karma: 57
    • CiviCRM
Re: civicrm_event_search strange changes
February 15, 2010, 05:17:24 am
najoory :

civicrm_event_search is supposed to return the events and not the event templates.
The behavior is broken, can you file an issue w/ JIRA.

Thanks
-Yashodha
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

najoory

  • Guest
Re: civicrm_event_search strange changes
February 18, 2010, 03:16:17 pm
But it called by other function(s) so must have this feature to rid of code duplications. I can create request if you want but I don't now how. :)

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: civicrm_event_search strange changes
February 18, 2010, 03:28:18 pm

http://issues.civicrm.org/

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Yashodha Chaku

  • Forum Godess / God
  • Ask me questions
  • *****
  • Posts: 755
  • Karma: 57
    • CiviCRM
Re: civicrm_event_search strange changes
February 19, 2010, 12:06:11 am
najoory :

We have fixed this under http://issues.civicrm.org/jira/browse/CRM-5858 .
Here is the patch :
http://fisheye2.atlassian.com/changelog/CiviCRM/trunk?cs=26324

HTH
-Yashodha
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

najoory

  • Guest
Re: civicrm_event_search strange changes
February 21, 2010, 10:56:17 am
Thanks for help  :)

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • civicrm_event_search strange changes

This forum was archived on 2017-11-26.