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) »
  • Support »
  • Upgrading CiviCRM (Moderator: Deepak Srivastava) »
  • upgrading from 3.04 to 3.13 breaks API
Pages: [1]

Author Topic: upgrading from 3.04 to 3.13 breaks API  (Read 1415 times)

sonicthoughts

  • Ask me questions
  • ****
  • Posts: 498
  • Karma: 10
upgrading from 3.04 to 3.13 breaks API
March 23, 2010, 09:20:02 pm
We are using some custom code to show events.  The upgrade breaks the code.  Haven't done too much debugging, but has anyone had this issue?  Code is:

<?php
function cmp_date($a,$b) {
  if ($a['start_date'] > $b['start_date']) return 1;
  if ($a['start_date'] < $b['start_date']) return -1;
  return 0;
}

if (module_exists('civicrm')) {
  civicrm_initialize(TRUE);
  require_once 'api/v2/Event.php';
  // This example limits listing to public and active events
  $params = array ('is_public'     => 1, 'is_active'     => 1,'rowCount' => 100000);
  $myEvents = civicrm_event_search( $params );
  if ($myEvents) {
    $count = 0;
    $last = '';
    usort($myEvents,'cmp_date');
    foreach ($myEvents as $event) {
      $now = date('Y-m-d H:i:s');
      if ($now > $event['start_date']) continue;
      $startdate = date('D M j Y, g:i a',strtotime($event['start_date']));
      $enddate = date('D M j Y',strtotime($event['end_date']));
             
      $eventid = $event['id'];
      list($title_place, $title_desc) = split(":",$event['title'],2);
      $display = 'pausecontent['. $count . ']=\'';
   //  $display .= '<br /><b>'.l($title_place.' '.$title_desc, 'civicrm/event/info', array(), 'reset=1&id='.$event['id']).'</b><br />';
     $display .= '<br /><b>'.l($title_place.' '.$title_desc, 'civicrm/event/info', array('query'=> 'reset=1&id='.$event['id'])).'</b><br />';
      if ($last != $startdate) {
        $display .= $startdate.'<br />';
      }
      $display .= '\';';
      echo $display;
      $count++;
      $last = $startdate;
      if ($count > 10) break;
// this limits the number of events to 8 - put in whatever number suits you
    }
    if ($count > 0) {

    } else {
      echo 'pausecontent[0]=\'No events found.\'';
    }
  } else {
    echo 'pausecontent[0]=\'No events found.\'';
  }
}
?>

emilyf

  • Ask me questions
  • ****
  • Posts: 696
  • Karma: 54
  • CiviCRM version: 2.x - 4.x
  • CMS version: Drupal 5, 6, 7
Re: upgrading from 3.04 to 3.13 breaks API
March 24, 2010, 08:49:56 am
Yeah i remember this happening on my 3.0 upgrade from 2.0 but not from 3.0 to 3.1. anyway, you need to redo your date functions. try this instead:


      $now = time( );
      // Need to format the event end date in unix time, so we call a CiviCRM helper function
      $endDate = CRM_Utils_Date::unixTime( $event['end_date'] ); 
      $startDate = CRM_Utils_Date::unixTime( $event['start_date'] ); 


sonicthoughts

  • Ask me questions
  • ****
  • Posts: 498
  • Karma: 10
Re: upgrading from 3.04 to 3.13 breaks API
March 24, 2010, 03:26:51 pm
thanks!  Yes, that was the culprit.  Do you know what changed? we should probably have it documented somewhere.

emilyf

  • Ask me questions
  • ****
  • Posts: 696
  • Karma: 54
  • CiviCRM version: 2.x - 4.x
  • CMS version: Drupal 5, 6, 7
Re: upgrading from 3.04 to 3.13 breaks API
March 25, 2010, 11:48:45 am
yup, i think i made the change awhile back on the wiki. it's on this page: http://wiki.civicrm.org/confluence/display/CRMDOC/Using+CiviCRM+APIs+-+Code+Snippets#UsingCiviCRMAPIs-CodeSnippets-ListPublicEventsbyEventTypeinaBlock

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Upgrading CiviCRM (Moderator: Deepak Srivastava) »
  • upgrading from 3.04 to 3.13 breaks API

This forum was archived on 2017-11-26.