/** * Get all the show instances in the given time range. * * @param string $start_timestamp * In the format "YYYY-MM-DD HH:mm:ss". This time is inclusive. * @param string $end_timestamp * In the format "YYYY-MM-DD HH:mm:ss". This time is inclusive. * @param unknown_type $excludeInstance * @param boolean $onlyRecord * @return array */ public static function getShows($start_timestamp, $end_timestamp, $excludeInstance = NULL, $onlyRecord = FALSE) { global $CC_DBC; $showsPopUntil = Application_Model_Preference::GetShowsPopulatedUntil(); //if application is requesting shows past our previous populated until date, generate shows up until this point. if ($showsPopUntil == "" || strtotime($showsPopUntil) < strtotime($end_timestamp)) { Show::populateAllShowsInRange($showsPopUntil, $end_timestamp); Application_Model_Preference::SetShowsPopulatedUntil($end_timestamp); } $sql = "SELECT starts, ends, record, rebroadcast, soundcloud_id, instance_id, show_id, name, description,\n color, background_color, cc_show_instances.id AS instance_id\n FROM cc_show_instances\n LEFT JOIN cc_show ON cc_show.id = cc_show_instances.show_id"; //only want shows that are starting at the time or later. if ($onlyRecord) { $sql = $sql . " WHERE (starts >= '{$start_timestamp}' AND starts < timestamp '{$end_timestamp}')"; $sql = $sql . " AND (record = 1)"; } else { $sql = $sql . " WHERE ((starts >= '{$start_timestamp}' AND starts < '{$end_timestamp}')\n OR (ends > '{$start_timestamp}' AND ends <= '{$end_timestamp}')\n OR (starts <= '{$start_timestamp}' AND ends >= '{$end_timestamp}'))"; } if (isset($excludeInstance)) { foreach ($excludeInstance as $instance) { $sql_exclude[] = "cc_show_instances.id != {$instance}"; } $exclude = join(" OR ", $sql_exclude); $sql = $sql . " AND ({$exclude})"; } return $CC_DBC->GetAll($sql); }