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