CC-1985 : Automatic rebroadcast of recorded content

can add absolute dates/times for non repeating show instances to rebroadcast.
This commit is contained in:
naomiaro 2011-03-15 15:20:10 -04:00
parent 6ef4169315
commit 29816f32fa
9 changed files with 176 additions and 32 deletions

View file

@ -123,6 +123,7 @@
<formFile formName="Preferences"/> <formFile formName="Preferences"/>
<formFile formName="AddShowRR"/> <formFile formName="AddShowRR"/>
<formFile formName="AddShowRebroadcastDates"/> <formFile formName="AddShowRebroadcastDates"/>
<formFile formName="AddShowAbsoluteRebroadcastDates"/>
</formsDirectory> </formsDirectory>
<layoutsDirectory enabled="false"/> <layoutsDirectory enabled="false"/>
<modelsDirectory> <modelsDirectory>

View file

@ -55,6 +55,7 @@ class ScheduleController extends Zend_Controller_Action
$formRepeats = new Application_Form_AddShowRepeats(); $formRepeats = new Application_Form_AddShowRepeats();
$formStyle = new Application_Form_AddShowStyle(); $formStyle = new Application_Form_AddShowStyle();
$formRecord = new Application_Form_AddShowRR(); $formRecord = new Application_Form_AddShowRR();
$formAbsoluteRebroadcast = new Application_Form_AddShowAbsoluteRebroadcastDates();
$formRebroadcast = new Application_Form_AddShowRebroadcastDates(); $formRebroadcast = new Application_Form_AddShowRebroadcastDates();
$formWhat->removeDecorator('DtDdWrapper'); $formWhat->removeDecorator('DtDdWrapper');
@ -63,6 +64,7 @@ class ScheduleController extends Zend_Controller_Action
$formRepeats->removeDecorator('DtDdWrapper'); $formRepeats->removeDecorator('DtDdWrapper');
$formStyle->removeDecorator('DtDdWrapper'); $formStyle->removeDecorator('DtDdWrapper');
$formRecord->removeDecorator('DtDdWrapper'); $formRecord->removeDecorator('DtDdWrapper');
$formAbsoluteRebroadcast->removeDecorator('DtDdWrapper');
$formRebroadcast->removeDecorator('DtDdWrapper'); $formRebroadcast->removeDecorator('DtDdWrapper');
$this->view->what = $formWhat; $this->view->what = $formWhat;
@ -71,6 +73,7 @@ class ScheduleController extends Zend_Controller_Action
$this->view->who = $formWho; $this->view->who = $formWho;
$this->view->style = $formStyle; $this->view->style = $formStyle;
$this->view->rr = $formRecord; $this->view->rr = $formRecord;
$this->view->absoluteRebroadcast = $formAbsoluteRebroadcast;
$this->view->rebroadcast = $formRebroadcast; $this->view->rebroadcast = $formRebroadcast;
$userInfo = Zend_Auth::getInstance()->getStorage()->read(); $userInfo = Zend_Auth::getInstance()->getStorage()->read();
@ -149,28 +152,38 @@ class ScheduleController extends Zend_Controller_Action
$userInfo = Zend_Auth::getInstance()->getStorage()->read(); $userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new User($userInfo->id); $user = new User($userInfo->id);
$show = new ShowInstance($id); $show = new ShowInstance($id);
$params = '/format/json/id/#id#'; $params = '/format/json/id/#id#';
if (strtotime($today_timestamp) < strtotime($show->getShowStart())) { if (strtotime($today_timestamp) < strtotime($show->getShowStart())) {
if ($user->isHost($show->getShowId()) || $user->isAdmin()) {
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/schedule-show-dialog'.$params, 'callback' => 'window["buildScheduleDialog"]'), 'title' => 'Add Content'); if (($user->isHost($show->getShowId()) || $user->isAdmin()) && !$show->isRecorded() && !$show->isRebroadcast()) {
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/schedule-show-dialog'.$params,
'callback' => 'window["buildScheduleDialog"]'), 'title' => 'Add Content');
} }
} }
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/show-content-dialog'.$params, 'callback' => 'window["buildContentDialog"]'),
'title' => 'Show Content'); $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/show-content-dialog'.$params,
'callback' => 'window["buildContentDialog"]'), 'title' => 'Show Content');
if (strtotime($today_timestamp) < strtotime($show->getShowStart())) { if (strtotime($today_timestamp) < strtotime($show->getShowStart())) {
if ($user->isAdmin()) { if ($user->isAdmin()) {
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/delete-show'.$params, 'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Delete This Instance');
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/cancel-show'.$params, 'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Delete This Instance and All Following'); $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/delete-show'.$params,
'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Delete This Instance');
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/cancel-show'.$params,
'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Delete This Instance and All Following');
} }
if ($user->isHost($show->getShowId()) || $user->isAdmin()) { if ($user->isHost($show->getShowId()) || $user->isAdmin()) {
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/clear-show'.$params, 'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Remove All Content');
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/clear-show'.$params,
'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Remove All Content');
} }
} }
//returns format jjmenu is looking for. //returns format jjmenu is looking for.
die(json_encode($menu)); die(json_encode($menu));

View file

@ -0,0 +1,37 @@
<?php
class Application_Form_AddShowAbsoluteRebroadcastDates extends Zend_Form_SubForm
{
public function init()
{
// Add start date element
$this->addElement('text', 'add_show_rebroadcast_absolute_date_1', array(
'label' => 'Rebroadcast Date:',
'class' => 'input_text',
'required' => true,
'value' => date("Y-m-d"),
'filters' => array('StringTrim'),
'validators' => array(
'NotEmpty',
array('date', false, array('YYYY-MM-DD'))
)
));
// Add start time element
$this->addElement('text', 'add_show_rebroadcast_absolute_time_1', array(
'label' => 'Rebroadcast Time:',
'class' => 'input_text',
'required' => true,
'value' => '0:00',
'filters' => array('StringTrim'),
'validators' => array(
'NotEmpty',
array('date', false, array('HH:mm'))
)
));
}
}

View file

@ -173,13 +173,35 @@ class Show {
} }
} }
if($data['add_show_rebroadcast']) { //adding rows to cc_show_rebroadcast
if($repeat_type != -1) {
$showRebroad = new CcShowRebroadcast(); for($i=1; $i<=1; $i++) {
$showRebroad->setDbDayOffset($data['add_show_rebroadcast_date_1']);
$showRebroad->setDbStartTime($data['add_show_start_time_1']); $showRebroad = new CcShowRebroadcast();
$showRebroad->setDbShowId($showId); $showRebroad->setDbDayOffset($data['add_show_rebroadcast_date_'.$i]);
$showRebroad->save(); $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'])) { if(is_array($data['add_show_hosts'])) {
@ -263,6 +285,31 @@ class Show {
$newShow->setDbEnds($end); $newShow->setDbEnds($end);
$newShow->setDbRecord($record); $newShow->setDbRecord($record);
$newShow->save(); $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"], "description" => $show["description"],
"color" => $show["color"], "color" => $show["color"],
"backgroundColor" => $show["background_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) { foreach($options as $key=>$value) {
@ -458,6 +507,16 @@ class ShowInstance {
return $this->_instanceId; 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() { public function getName() {
$show = CcShowQuery::create()->findPK($this->getShowId()); $show = CcShowQuery::create()->findPK($this->getShowId());
return $show->getDbName(); return $show->getDbName();

View file

@ -42,8 +42,8 @@ class CcShowInstancesTableMap extends TableMap {
$this->addColumn('STARTS', 'DbStarts', 'TIMESTAMP', true, null, null); $this->addColumn('STARTS', 'DbStarts', 'TIMESTAMP', true, null, null);
$this->addColumn('ENDS', 'DbEnds', '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->addForeignKey('SHOW_ID', 'DbShowId', 'INTEGER', 'cc_show', 'ID', true, null, null);
$this->addColumn('RECORD', 'DbRecord', 'TINYINT', false, null, null); $this->addColumn('RECORD', 'DbRecord', 'TINYINT', false, null, 0);
$this->addColumn('REBROADCAST', 'DbRebroadcast', 'TINYINT', false, null, null); $this->addColumn('REBROADCAST', 'DbRebroadcast', 'TINYINT', false, null, 0);
$this->addForeignKey('INSTANCE_ID', 'DbOriginalShow', 'INTEGER', 'cc_show_instances', 'ID', false, null, null); $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); $this->addForeignKey('FILE_ID', 'DbRecordedFile', 'INTEGER', 'cc_files', 'ID', false, null, null);
// validators // validators

View file

@ -50,12 +50,14 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
/** /**
* The value for the record field. * The value for the record field.
* Note: this column has a database default value of: 0
* @var int * @var int
*/ */
protected $record; protected $record;
/** /**
* The value for the rebroadcast field. * The value for the rebroadcast field.
* Note: this column has a database default value of: 0
* @var int * @var int
*/ */
protected $rebroadcast; protected $rebroadcast;
@ -111,6 +113,28 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
*/ */
protected $alreadyInValidation = false; 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. * Get the [id] column value.
* *
@ -391,7 +415,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
$v = (int) $v; $v = (int) $v;
} }
if ($this->record !== $v) { if ($this->record !== $v || $this->isNew()) {
$this->record = $v; $this->record = $v;
$this->modifiedColumns[] = CcShowInstancesPeer::RECORD; $this->modifiedColumns[] = CcShowInstancesPeer::RECORD;
} }
@ -411,7 +435,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
$v = (int) $v; $v = (int) $v;
} }
if ($this->rebroadcast !== $v) { if ($this->rebroadcast !== $v || $this->isNew()) {
$this->rebroadcast = $v; $this->rebroadcast = $v;
$this->modifiedColumns[] = CcShowInstancesPeer::REBROADCAST; $this->modifiedColumns[] = CcShowInstancesPeer::REBROADCAST;
} }
@ -477,6 +501,14 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
*/ */
public function hasOnlyDefaultValues() public function hasOnlyDefaultValues()
{ {
if ($this->record !== 0) {
return false;
}
if ($this->rebroadcast !== 0) {
return false;
}
// otherwise, everything was equal, so return TRUE // otherwise, everything was equal, so return TRUE
return true; return true;
} // hasOnlyDefaultValues() } // hasOnlyDefaultValues()
@ -1647,6 +1679,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
$this->alreadyInSave = false; $this->alreadyInSave = false;
$this->alreadyInValidation = false; $this->alreadyInValidation = false;
$this->clearAllReferences(); $this->clearAllReferences();
$this->applyDefaultValues();
$this->resetModified(); $this->resetModified();
$this->setNew(true); $this->setNew(true);
$this->setDeleted(false); $this->setDeleted(false);

View file

@ -6,25 +6,26 @@
<div class="clear"></div> <div class="clear"></div>
<h3 class="collapsible-header"><span class="arrow-icon"></span>What</h3> <h3 class="collapsible-header"><span class="arrow-icon"></span>What</h3>
<div id="schedule-show-what" class="collapsible-content"> <div id="schedule-show-what" class="collapsible-content">
<?php echo $this->what ?> <?php echo $this->what; ?>
</div> </div>
<h3 class="collapsible-header"><span class="arrow-icon"></span>When</h3> <h3 class="collapsible-header"><span class="arrow-icon"></span>When</h3>
<div id="schedule-show-when" class="collapsible-content"> <div id="schedule-show-when" class="collapsible-content">
<?php echo $this->when ?> <?php echo $this->when; ?>
<?php echo $this->repeats ?> <?php echo $this->repeats; ?>
</div> </div>
<h3 class="collapsible-header"><span class="arrow-icon"></span>Record & Rebroadcast</h3> <h3 class="collapsible-header"><span class="arrow-icon"></span>Record & Rebroadcast</h3>
<div id="schedule-record-rebroadcast" class="collapsible-content"> <div id="schedule-record-rebroadcast" class="collapsible-content">
<?php echo $this->rr ?> <?php echo $this->rr; ?>
<?php echo $this->rebroadcast ?> <?php echo $this->absoluteRebroadcast; ?>
<?php echo $this->rebroadcast; ?>
</div> </div>
<h3 class="collapsible-header"><span class="arrow-icon"></span>Who</h3> <h3 class="collapsible-header"><span class="arrow-icon"></span>Who</h3>
<div id="schedule-show-who" class="collapsible-content"> <div id="schedule-show-who" class="collapsible-content">
<?php echo $this->who ?> <?php echo $this->who; ?>
</div> </div>
<h3 class="collapsible-header"><span class="arrow-icon"></span>Style</h3> <h3 class="collapsible-header"><span class="arrow-icon"></span>Style</h3>
<div id="schedule-show-style" class="collapsible-content"> <div id="schedule-show-style" class="collapsible-content">
<?php echo $this->style ?> <?php echo $this->style; ?>
</div> </div>
</div> </div>

View file

@ -133,8 +133,8 @@
<column name="starts" phpName="DbStarts" type="TIMESTAMP" required="true"/> <column name="starts" phpName="DbStarts" type="TIMESTAMP" required="true"/>
<column name="ends" phpName="DbEnds" type="TIMESTAMP" required="true"/> <column name="ends" phpName="DbEnds" type="TIMESTAMP" required="true"/>
<column name="show_id" phpName="DbShowId" type="INTEGER" required="true"/> <column name="show_id" phpName="DbShowId" type="INTEGER" required="true"/>
<column name="record" phpName="DbRecord" type="TINYINT" required="false"/> <column name="record" phpName="DbRecord" type="TINYINT" required="false" defaultValue="0"/>
<column name="rebroadcast" phpName="DbRebroadcast" type="TINYINT" required="false"/> <column name="rebroadcast" phpName="DbRebroadcast" type="TINYINT" required="false" defaultValue="0"/>
<column name="instance_id" phpName="DbOriginalShow" type="INTEGER" required="false"/> <column name="instance_id" phpName="DbOriginalShow" type="INTEGER" required="false"/>
<column name="file_id" phpName="DbRecordedFile" type="INTEGER" required="false"/> <column name="file_id" phpName="DbRecordedFile" type="INTEGER" required="false"/>
<foreign-key foreignTable="cc_show" name="cc_show_fkey" onDelete="CASCADE"> <foreign-key foreignTable="cc_show" name="cc_show_fkey" onDelete="CASCADE">

View file

@ -185,8 +185,8 @@ CREATE TABLE "cc_show_instances"
"starts" TIMESTAMP NOT NULL, "starts" TIMESTAMP NOT NULL,
"ends" TIMESTAMP NOT NULL, "ends" TIMESTAMP NOT NULL,
"show_id" INTEGER NOT NULL, "show_id" INTEGER NOT NULL,
"record" INT2, "record" INT2 default 0,
"rebroadcast" INT2, "rebroadcast" INT2 default 0,
"instance_id" INTEGER, "instance_id" INTEGER,
"file_id" INTEGER, "file_id" INTEGER,
PRIMARY KEY ("id") PRIMARY KEY ("id")