Merge pull request #3179 from webpartners/master
[civicrm-core.git] / CRM / Event / Cart / BAO / Conference.php
1 <?php
2
3 /**
4 * Class CRM_Event_Cart_BAO_Conference
5 */
6 class CRM_Event_Cart_BAO_Conference {
7 //XXX assumes we don't allow a contact to register for the same conference more than once
8 //XXX flattens the object tree for convenient templating
9 /**
10 * @param $main_event_participant_id
11 *
12 * @return array|null
13 */
14 static function get_participant_sessions($main_event_participant_id) {
15 $sql = <<<EOS
16 SELECT sub_event.* FROM civicrm_participant main_participant
17 JOIN civicrm_event sub_event ON sub_event.parent_event_id = main_participant.event_id
18 JOIN civicrm_participant sub_participant ON sub_participant.event_id = sub_event.id
19 LEFT JOIN
20 civicrm_option_value slot ON sub_event.slot_label_id = slot.value
21 LEFT JOIN
22 civicrm_option_group og ON slot.option_group_id = og.id
23 WHERE
24 main_participant.id = %1
25 AND sub_participant.contact_id = main_participant.contact_id
26 AND og.name = 'conference_slot'
27 ORDER BY
28 slot.weight,
29 sub_event.start_date
30 EOS;
31 $sql_args = array(1 => array($main_event_participant_id, 'Integer'));
32 $dao = CRM_Core_DAO::executeQuery($sql, $sql_args);
33 $smarty_sessions = array();
34 while ($dao->fetch()) {
35 $smarty_sessions[] = get_object_vars($dao);
36 }
37 if (empty($smarty_sessions)) {
38 return NULL;
39 }
40 return $smarty_sessions;
41 }
42 }
43