Merge branch 'devel' of dev.sourcefabric.org:airtime into devel

This commit is contained in:
Naomi Aro 2011-11-26 13:32:05 +01:00
commit f1e1b747ad
14 changed files with 93 additions and 37 deletions

View file

@ -1538,23 +1538,44 @@ class Application_Model_Show {
return $event;
}
public function setShowFirstShow($s_date){
/* Takes in a UTC DateTime object.
* Converts this to local time, since cc_show days
* requires local time. */
public function setShowFirstShow($p_dt){
//clone object since we are modifying it and it was passed by reference.
$dt = clone $p_dt;
$dt->setTimezone(new DateTimeZone(date_default_timezone_get()));
$showDay = CcShowDaysQuery::create()
->filterByDbShowId($this->_showId)
->findOne();
$showDay->setDbFirstShow($s_date)
$showDay->setDbFirstShow($dt)
->save();
Logging::log("setting show's first show.");
}
public function setShowLastShow($e_date){
/* Takes in a UTC DateTime object
* Converts this to local time, since cc_show days
* requires local time. */
public function setShowLastShow($p_dt){
//clone object since we are modifying it and it was passed by reference.
$dt = clone $p_dt;
$dt->setTimezone(new DateTimeZone(date_default_timezone_get()));
//add one day since the Last Show date in CcShowDays is non-inclusive.
$dt->add(new DateInterval("P1D"));
$showDay = CcShowDaysQuery::create()
->filterByDbShowId($this->_showId)
->findOne();
$showDay->setDbLastShow($e_date)
$showDay->setDbLastShow($dt)
->save();
}
@ -1573,7 +1594,8 @@ class Application_Model_Show {
." FROM $CC_CONFIG[showInstances] si, $CC_CONFIG[showTable] s"
." WHERE si.show_id = s.id"
." AND si.starts <= TIMESTAMP '$timeNow'"
." AND si.ends > TIMESTAMP '$timeNow'";
." AND si.ends > TIMESTAMP '$timeNow'"
." AND modified_instance != TRUE";
// Convert back to local timezone
$rows = $CC_DBC->GetAll($sql);
@ -1611,6 +1633,7 @@ class Application_Model_Show {
." WHERE si.show_id = s.id"
." AND si.starts >= TIMESTAMP '$timeStart'"
." AND si.starts < TIMESTAMP $timeEnd"
." AND modified_instance != TRUE"
." ORDER BY si.starts";
// defaults to retrieve all shows within the interval if $limit not set
@ -1633,6 +1656,9 @@ class Application_Model_Show {
public static function ConvertToLocalTimeZone(&$rows, $columnsToConvert) {
$timezone = date_default_timezone_get();
if (!is_array($rows)) {
return;
}
foreach($rows as &$row) {
foreach($columnsToConvert as $column) {
$row[$column] = Application_Model_DateHelper::ConvertToLocalDateTimeString($row[$column]);

View file

@ -29,6 +29,10 @@ class Application_Model_ShowInstance {
return new Application_Model_Show($this->getShowId());
}
/* This function is weird. It should return a boolean, but instead returns
* an integer if it is a rebroadcast, or returns null if it isn't. You can convert
* it to boolean by using is_null(isRebroadcast), where true means isn't and false
* means that it is. */
public function isRebroadcast()
{
return $this->_showInstance->getDbOriginalShow();
@ -231,9 +235,9 @@ class Application_Model_ShowInstance {
$this->correctScheduleStartTimes();
$show = new Application_Model_Show($this->getShowId());
if(!$show->isRepeating()){
$show->setShowFirstShow($new_starts);
$show->setShowLastShow($new_ends);
if(!$show->isRepeating() && is_null($this->isRebroadcast())){
$show->setShowFirstShow($newStartsDateTime);
$show->setShowLastShow($newEndsDateTime);
}
Application_Model_RabbitMq::PushSchedule();

View file

@ -21,7 +21,23 @@ class Application_Model_StreamSetting {
return $ids;
}
/* Retruns only global data as array*/
public static function getGlobalData(){
global $CC_DBC;
$sql = "SELECT * "
."FROM cc_stream_setting "
."WHERE keyname IN ('output_sound_device', 'icecast_vorbis_metadata')";
$rows = $CC_DBC->getAll($sql);
$data = array();
foreach($rows as $row){
$data[$row["keyname"]] = $row["value"];
}
return $data;
}
/* Returns all information related to a specific stream. An example
* of a stream id is 's1' or 's2'. */
public static function getStreamData($p_streamId){
@ -66,7 +82,6 @@ class Application_Model_StreamSetting {
$CC_DBC->query($sql);
}
else{
var_dump($key);
$temp = explode('_', $key);
$prefix = $temp[0];
foreach($d as $k=>$v){