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 (Moderator: Donald Lobo) »
  • html listing of past events
Pages: [1]

Author Topic: html listing of past events  (Read 2326 times)

figover

  • Guest
html listing of past events
March 12, 2009, 07:14:04 am
I want html listing of past events. http://www.mysite.com/civicrm/event/ical?reset=1&page=1&html=1 shows upcoming events . Kurund told me solution that use this http://www.mysite.com/civicrm/event/ical?reset=1&page=1&html=1&start=20080101 . Thanks . But it is showing all events . I want only past events . plz guide me about it . Kurund told me that we can also use end parapeter but i do not know, how can we use end parameter. plz guide me about it.
Thanks Kurund.

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: html listing of past events
March 12, 2009, 08:03:02 am

that url does not take the end parameter. If you want to show events only to a certain date, you will need to modify the code or write a custom search

the relevant page to modify is: CRM/Event/Page/ICalendar.php

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

figover

  • Guest
Re: html listing of past events
March 13, 2009, 03:10:37 am
one of our developer 'asim' has done this job.
Now any one can use another parameter end
plz check with this url after editing.
http://www.yoursite.com/civicrm/event/ical?reset=1&page=1&html=1&start=20080101&end=20090313
he has edited to files
1) /CRM/Event/Page/ICalendar.php
and edited function  run( )
2) /CRM/Event/BAO/Event.php
and edited function  getCompleteInfo( )

After editing function is this....

function run( )
    {
     
        require_once "CRM/Utils/Request.php";
        $id       = CRM_Utils_Request::retrieve('id'   , 'Positive', $this, false, null, 'GET' );
        $type     = CRM_Utils_Request::retrieve('type' , 'Positive', $this, false, 0);
        $start    = CRM_Utils_Request::retrieve('start', 'Positive', $this, false, 0);
        $end      = CRM_Utils_Request::retrieve('end'  , 'Positive', $this, false, 0);
        $iCalPage = CRM_Utils_Request::retrieve('page' , 'Positive', $this, false, 0);
        $gData    = CRM_Utils_Request::retrieve('gData', 'Positive', $this, false, 0);
        $html     = CRM_Utils_Request::retrieve('html' , 'Positive', $this, false, 0);
        $rss      = CRM_Utils_Request::retrieve('rss'  , 'Positive', $this, false, 0);
       
        require_once "CRM/Event/BAO/Event.php";
        $info = CRM_Event_BAO_Event::getCompleteInfo( $start, $end, $type, $id );
        $this->assign( 'events', $info );
       
        // Send data to the correct template for formatting (iCal vs. gData)
        $template =& CRM_Core_Smarty::singleton( );
        $config =& CRM_Core_Config::singleton( );
        if ( $rss ) {
            // rss 2.0 requires lower case dash delimited locale
            $this->assign( 'rssLang', str_replace( '_', '-', strtolower($config->lcMessages) ) );
            $calendar = $template->fetch( 'CRM/Core/Calendar/Rss.tpl' );
        } else if ( $gData ) {
            $calendar = $template->fetch( 'CRM/Core/Calendar/GData.tpl' );
        } else if ( $html ) {
            return parent::run( );
        } else {
            $calendar = $template->fetch( 'CRM/Core/Calendar/ICal.tpl' );
        }

        // Push output for feed or download
        require_once "CRM/Utils/ICalendar.php";
        if( $iCalPage == 1) {
            if ( $gData || $rss ) {
                CRM_Utils_ICalendar::send( $calendar, 'text/xml', 'utf-8' );
            } else {
                CRM_Utils_ICalendar::send( $calendar, 'text/plain', 'utf-8' );
            }
        } else {
            CRM_Utils_ICalendar::send( $calendar, 'text/calendar', 'utf-8', 'civicrm_ical.ics', 'attachment' );
        }
        exit( );
    }


and



static function &getCompleteInfo( $start = null, $end = null, $type =null, $eventId = null )
    {
        if ( $start ) {
            // get events with start_date >= requested start
            $condition =  CRM_Utils_Type::escape( $start, 'Date' );
        } else {
            // get events with start date >= today
            $condition =  date("Ymd");
        }                   
        if ( $end ) {
            // get events with end_date <= requested start
            $condition1 = "  AND civicrm_event.end_date   <= ".CRM_Utils_Type::escape( $end, 'Date' );                   
        } else {
            // get events with end date is null
            $condition1 =  " '';
        }                 
        if ( $type ) {
            $condition = $condition . " AND civicrm_event.event_type_id = " . CRM_Utils_Type::escape( $type, 'Integer' );

        }

        // Get the Id of Option Group for Event Types
        require_once 'CRM/Core/DAO/OptionGroup.php';
        $optionGroupDAO = new CRM_Core_DAO_OptionGroup();
        $optionGroupDAO->name = 'event_type';
        $optionGroupId = null;
        if ($optionGroupDAO->find(true) ) {
            $optionGroupId = $optionGroupDAO->id;
        }
       
        $query = "
SELECT
  civicrm_event.id as event_id,
  civicrm_email.email as email,
  civicrm_event.title as title,
  civicrm_event.summary as summary,
  civicrm_event.start_date as start,
  civicrm_event.end_date as end,
  civicrm_event.description as description,
  civicrm_event.is_show_location as is_show_location,
  civicrm_option_value.label as event_type,
  civicrm_address.name as address_name,
  civicrm_address.street_address as street_address,
  civicrm_address.supplemental_address_1 as supplemental_address_1,
  civicrm_address.supplemental_address_2 as supplemental_address_2,
  civicrm_address.city as city,
  civicrm_address.postal_code as postal_code,
  civicrm_address.postal_code_suffix as postal_code_suffix,
  civicrm_state_province.abbreviation as state,
  civicrm_country.name AS country
FROM civicrm_event
LEFT JOIN civicrm_loc_block ON civicrm_event.loc_block_id = civicrm_loc_block.id
LEFT JOIN civicrm_address ON civicrm_loc_block.address_id = civicrm_address.id
LEFT JOIN civicrm_state_province ON civicrm_address.state_province_id = civicrm_state_province.id
LEFT JOIN civicrm_country ON civicrm_address.country_id = civicrm_country.id
LEFT JOIN civicrm_email ON civicrm_loc_block.email_id = civicrm_email.id
LEFT JOIN civicrm_option_value ON (
                                    civicrm_event.event_type_id = civicrm_option_value.value AND
                                    civicrm_option_value.option_group_id = %1 )
WHERE civicrm_event.is_active = 1
      AND civicrm_event.is_public = 1
      AND civicrm_event.start_date >= {$condition}.{$condition1}";
    //echo $query;
        if(isset( $eventId )) {
            $query .= " AND civicrm_event.id =$eventId ";
        }
        $query .=" ORDER BY   civicrm_event.start_date ASC";


        $params = array( 1 => array( $optionGroupId, 'Integer' ) );
        $dao =& CRM_Core_DAO::executeQuery( $query, $params );
        $all = array( );
        $config =& CRM_Core_Config::singleton( );
       
        while ( $dao->fetch( ) ) {
       
            $info                     = array( );
            $info['event_id'     ]    = $dao->event_id;
            $info['uid'          ]    =
         "CiviCRM_EventID_{$dao->event_id}_" . md5( uniqid( rand( ), true ) ) .
         "@{$config->userFrameworkBaseURL}";
            $info['title'        ]    = $dao->title;
            $info['summary'      ]    = $dao->summary;
            $info['description'  ]    = $dao->description;
            $info['start_date'   ]    = $dao->start;
            $info['end_date'     ]    = $dao->end;
            $info['contact_email']    = $dao->email;
            $info['event_type'   ]    = $dao->event_type;
            $info['is_show_location'] = $dao->is_show_location;
 
 
            $address = '';

            $addrFields = array(
                                'address_name'           => $dao->address_name,
                                'street_address'         => $dao->street_address,
                                'supplemental_address_1' => $dao->supplemental_address_1,
                                'supplemental_address_2' => $dao->supplemental_address_2,
                                'city'                   => $dao->city,
                                'state_province'         => $dao->state,
                                'postal_code'            => $dao->postal_code,
                                'postal_code_suffix'     => $dao->postal_code_suffix,
                                'country'                => $dao->country,
                                'county'                 => null
                                );           
           
            require_once 'CRM/Utils/Address.php';
            CRM_Utils_String::append( $address, ', ',
                                      CRM_Utils_Address::format($addrFields) );
            $info['location'     ] = $address;
            $info['url'          ] = CRM_Utils_System::url( 'civicrm/event/info', 'reset=1&id=' . $dao->event_id, true, null, false );
           
            $all[] = $info;
        }
       
        return $all;
    }


thanks kurund, lobo.

plz add this code in next release of civicrm2.2 so that it will be useful for any other person.
« Last Edit: March 13, 2009, 03:17:40 am by figover »

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: html listing of past events
March 13, 2009, 06:48:29 am

Can you please file an issue and attach a 'patch' (http://en.wikipedia.org/wiki/Patch_(Unix)) to the issue. We'll integrate the change in a 2.2 / 2.3 version

thanx for taking the initiative to do so

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

bonhommie

  • I’m new here
  • *
  • Posts: 18
  • Karma: 0
Re: html listing of past events
March 24, 2009, 02:14:15 pm
I have searched all over the forums, but I don't see my issue.
The html listing page mentioned here is active, but empty. I do have public events, but the page is blank. Any clues?

thanks

bonhommie

  • I’m new here
  • *
  • Posts: 18
  • Karma: 0
Re: html listing of past events
March 26, 2009, 11:54:55 am
Can anybody help me with this ... please?

thanks

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: html listing of past events
March 26, 2009, 12:13:08 pm

1. in general piggybacking on an existing topic is avoided

2. Both of your forum posts dont have a lot of infomation for us to reply. Can u set up a similar event on drupal.demo.civicrm.org and see if that show up on the html listing. That might give us a clue as to whats happening

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

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • html listing of past events

This forum was archived on 2017-11-26.