CC-1985 : Automatic rebroadcast of recorded content
can add absolute dates/times for non repeating show instances to rebroadcast.
This commit is contained in:
parent
6ef4169315
commit
29816f32fa
9 changed files with 176 additions and 32 deletions
|
@ -173,13 +173,35 @@ class Show {
|
|||
}
|
||||
}
|
||||
|
||||
if($data['add_show_rebroadcast']) {
|
||||
//adding rows to cc_show_rebroadcast
|
||||
if($repeat_type != -1) {
|
||||
|
||||
$showRebroad = new CcShowRebroadcast();
|
||||
$showRebroad->setDbDayOffset($data['add_show_rebroadcast_date_1']);
|
||||
$showRebroad->setDbStartTime($data['add_show_start_time_1']);
|
||||
$showRebroad->setDbShowId($showId);
|
||||
$showRebroad->save();
|
||||
for($i=1; $i<=1; $i++) {
|
||||
|
||||
$showRebroad = new CcShowRebroadcast();
|
||||
$showRebroad->setDbDayOffset($data['add_show_rebroadcast_date_'.$i]);
|
||||
$showRebroad->setDbStartTime($data['add_show_start_time_'.$i]);
|
||||
$showRebroad->setDbShowId($showId);
|
||||
$showRebroad->save();
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
for($i=1; $i<=1; $i++) {
|
||||
|
||||
if($data['add_show_rebroadcast_absolute_date_'.$i]) {
|
||||
|
||||
$sql = "SELECT date '{$data['add_show_rebroadcast_absolute_date_'.$i]}' - date '{$data['add_show_start_date']}' ";
|
||||
$r = $con->query($sql);
|
||||
$offset_days = $r->fetchColumn(0);
|
||||
|
||||
$showRebroad = new CcShowRebroadcast();
|
||||
$showRebroad->setDbDayOffset($offset_days." days");
|
||||
$showRebroad->setDbStartTime($data['add_show_rebroadcast_absolute_time_'.$i]);
|
||||
$showRebroad->setDbShowId($showId);
|
||||
$showRebroad->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(is_array($data['add_show_hosts'])) {
|
||||
|
@ -263,6 +285,31 @@ class Show {
|
|||
$newShow->setDbEnds($end);
|
||||
$newShow->setDbRecord($record);
|
||||
$newShow->save();
|
||||
|
||||
$show_instance_id = $newShow->getDbId();
|
||||
|
||||
$sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id={$show_id}";
|
||||
$rebroadcasts = $CC_DBC->GetAll($sql);
|
||||
|
||||
foreach($rebroadcasts as $rebroadcast) {
|
||||
|
||||
$timeinfo = explode(" ", $start);
|
||||
|
||||
$sql = "SELECT timestamp '{$timeinfo[0]}' + interval '{$rebroadcast["day_offset"]}' + interval '{$rebroadcast["start_time"]}'";
|
||||
$rebroadcast_start_time = $CC_DBC->GetOne($sql);
|
||||
|
||||
$sql = "SELECT timestamp '{$rebroadcast_start_time}' + interval '{$duration}'";
|
||||
$rebroadcast_end_time = $CC_DBC->GetOne($sql);
|
||||
|
||||
$newRebroadcastInstance = new CcShowInstances();
|
||||
$newRebroadcastInstance->setDbShowId($show_id);
|
||||
$newRebroadcastInstance->setDbStarts($rebroadcast_start_time);
|
||||
$newRebroadcastInstance->setDbEnds($rebroadcast_end_time);
|
||||
$newRebroadcastInstance->setDbRecord(0);
|
||||
$newRebroadcastInstance->setDbRebroadcast(1);
|
||||
$newRebroadcastInstance->setDbOriginalShow($show_instance_id);
|
||||
$newRebroadcastInstance->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -426,7 +473,9 @@ class Show {
|
|||
"description" => $show["description"],
|
||||
"color" => $show["color"],
|
||||
"backgroundColor" => $show["background_color"],
|
||||
"showId" => $show["show_id"]
|
||||
"showId" => $show["show_id"],
|
||||
"record" => intval($show["record"]),
|
||||
"rebroadcast" => intval($show["rebroadcast"])
|
||||
);
|
||||
|
||||
foreach($options as $key=>$value) {
|
||||
|
@ -458,6 +507,16 @@ class ShowInstance {
|
|||
return $this->_instanceId;
|
||||
}
|
||||
|
||||
public function isRebroadcast() {
|
||||
$showInstance = CcShowInstancesQuery::create()->findPK($this->_instanceId);
|
||||
return $showInstance->getDbRebroadcast();
|
||||
}
|
||||
|
||||
public function isRecorded() {
|
||||
$showInstance = CcShowInstancesQuery::create()->findPK($this->_instanceId);
|
||||
return $showInstance->getDbRecord();
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
$show = CcShowQuery::create()->findPK($this->getShowId());
|
||||
return $show->getDbName();
|
||||
|
|
|
@ -42,8 +42,8 @@ class CcShowInstancesTableMap extends TableMap {
|
|||
$this->addColumn('STARTS', 'DbStarts', 'TIMESTAMP', true, null, null);
|
||||
$this->addColumn('ENDS', 'DbEnds', 'TIMESTAMP', true, null, null);
|
||||
$this->addForeignKey('SHOW_ID', 'DbShowId', 'INTEGER', 'cc_show', 'ID', true, null, null);
|
||||
$this->addColumn('RECORD', 'DbRecord', 'TINYINT', false, null, null);
|
||||
$this->addColumn('REBROADCAST', 'DbRebroadcast', 'TINYINT', false, null, null);
|
||||
$this->addColumn('RECORD', 'DbRecord', 'TINYINT', false, null, 0);
|
||||
$this->addColumn('REBROADCAST', 'DbRebroadcast', 'TINYINT', false, null, 0);
|
||||
$this->addForeignKey('INSTANCE_ID', 'DbOriginalShow', 'INTEGER', 'cc_show_instances', 'ID', false, null, null);
|
||||
$this->addForeignKey('FILE_ID', 'DbRecordedFile', 'INTEGER', 'cc_files', 'ID', false, null, null);
|
||||
// validators
|
||||
|
|
|
@ -50,12 +50,14 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
|
|||
|
||||
/**
|
||||
* The value for the record field.
|
||||
* Note: this column has a database default value of: 0
|
||||
* @var int
|
||||
*/
|
||||
protected $record;
|
||||
|
||||
/**
|
||||
* The value for the rebroadcast field.
|
||||
* Note: this column has a database default value of: 0
|
||||
* @var int
|
||||
*/
|
||||
protected $rebroadcast;
|
||||
|
@ -111,6 +113,28 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
|
|||
*/
|
||||
protected $alreadyInValidation = false;
|
||||
|
||||
/**
|
||||
* Applies default values to this object.
|
||||
* This method should be called from the object's constructor (or
|
||||
* equivalent initialization method).
|
||||
* @see __construct()
|
||||
*/
|
||||
public function applyDefaultValues()
|
||||
{
|
||||
$this->record = 0;
|
||||
$this->rebroadcast = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes internal state of BaseCcShowInstances object.
|
||||
* @see applyDefaults()
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->applyDefaultValues();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [id] column value.
|
||||
*
|
||||
|
@ -391,7 +415,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
|
|||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->record !== $v) {
|
||||
if ($this->record !== $v || $this->isNew()) {
|
||||
$this->record = $v;
|
||||
$this->modifiedColumns[] = CcShowInstancesPeer::RECORD;
|
||||
}
|
||||
|
@ -411,7 +435,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
|
|||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->rebroadcast !== $v) {
|
||||
if ($this->rebroadcast !== $v || $this->isNew()) {
|
||||
$this->rebroadcast = $v;
|
||||
$this->modifiedColumns[] = CcShowInstancesPeer::REBROADCAST;
|
||||
}
|
||||
|
@ -477,6 +501,14 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
|
|||
*/
|
||||
public function hasOnlyDefaultValues()
|
||||
{
|
||||
if ($this->record !== 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->rebroadcast !== 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// otherwise, everything was equal, so return TRUE
|
||||
return true;
|
||||
} // hasOnlyDefaultValues()
|
||||
|
@ -1647,6 +1679,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
|
|||
$this->alreadyInSave = false;
|
||||
$this->alreadyInValidation = false;
|
||||
$this->clearAllReferences();
|
||||
$this->applyDefaultValues();
|
||||
$this->resetModified();
|
||||
$this->setNew(true);
|
||||
$this->setDeleted(false);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue