1.3. M2_Event

The client part of the event app allows you to retrieve events as well as accept event registrations and confirmations.

The typical usage of the app is to retrieve a list of events, either using M2_Event::getEvents() or M2_Event::getFutureEvents(), loop over them and present them as desired and then link off to a separate page for registrations where you use M2_Event::getRegistrationForm() to accept registrations.

M2_Event::getEvents()

Get the complete list of past, present and future events. You will get back an array of events, each represented by an associative array with the following keys:

Table 12. Array keys for events

KeyDescription
id

The ID of the event.

title

Value of title field.

description

Value of description field.

location

Value of location field.

start

Start time, as unix timestamp.

end

End time, as unix timestamp.

last_registration

Last registration time, as unix timestamp.

price

Total price, including any VAT.

currency

Currency.

vat_percent

Percent of the total price that is VAT.

payment_method

Options for payment: NONE, ONLINE, OFFLINE, BOTH.

n_slots

Maximum number of participants.

max_registrations

Maximum number of slots that can be reserved per registration.

type

Type of event: NORMAL, CANCELLED or EXTERNAL_NO_REG. This setting is used to determine how the event should be presented.

registration_fields

Fields in registration form - this is for M2_Event::getRegistrationForm(), and you shouldn't use any of this data directly.

associated_node_types

In the developer settings for the event app you can associate up to three content types to the event form, allowing users to choose items from the associated types.

For example you could have a content type representing regions, associate that with the event app and when creating new events the users could choose which region the event was for.

In this field you get the values of any associated content types. The content is an associative array, using the content type ids as keys and the corresponding content items as values.

Note

If the associated type is set to multiselect, the value for that key will be an array itself.

illustration

Illustration for the event. This is represented via an array of information about the illustration, identical to the one you get from M2_Content::get() when retrieving binary fields.

Note

This field is only available if the site is using event illustrations (can be enabled or disabled in the developer settings for the event app), and the event has an illustration.

caption

Caption for the event illustration - again, only if an illustration is available.


M2_Event::getFutureEvents()

Works exactly like M2_Event::getEvents(), only that it is restricted to events that have not yet begun.

M2_Event::getRegistrationForm($eventID, [$options])

This method does quite a bit of work - it takes the user through the following steps:

  1. Presents a form for event registration.

  2. Depending on the payment options chosen for the event:

    • No payment: Sends an email that the user must confirm before registration is final.

    • Offline: Sends an email that the user must confirm before registration is final. When the user confirms the registration, another email is sent with a PDF invoice.

    • Online: Takes the user onto online payment and sends a PDF receipt when the payment has been cleared.

    • Online & Offline: Lets the user choose which method to use and carry out one of the steps above.

  3. If Offline or No payment is chosen, the email sent to the user will contain a link back to the current page. The link holds a validation token that will mark the registration as final

All of this happens transparent to the developer - all you have to do is to put the registration form in your Web page and the rest is taken care of.

The developer settings for the event app allows you to customize the emails sent during the process and the confirmation messages shown on your Web page.

The first parameter, $eventID is the ID number for the event you wish to handle registrations for, and the second parameter, $options, is an associative array described below:

Table 13. Options for registration form

KeyDescriptionDefault value
rawHeaders

Set to TRUE if you want raw headers as described in Section 1.10.1, “Return Data for Presentation”.

FALSE
renderer

Can be one of Default and Tableless. Determines which renderer will be used for the HTML form. Tableless is built with div elements whereas Default is a traditional table based layout.

Default
prefilled

Important

This option is not yet implemented.

Set to TRUE to prefill the form with user data if a user is logged in.

FALSE
addToContactGroups

An optional array of IDs of contact groups that registered users will be added to.


M2_Event::getSingle($eventID)

Get information about a single event - the data is returned a s a single associative array like the ones returned by M2_Event::getEvents().