diff --git a/.zfproject.xml b/.zfproject.xml index 8c6983c52..08da65b1e 100644 --- a/.zfproject.xml +++ b/.zfproject.xml @@ -123,6 +123,7 @@ + diff --git a/application/controllers/ScheduleController.php b/application/controllers/ScheduleController.php index 8e935dbf1..d9e580edc 100644 --- a/application/controllers/ScheduleController.php +++ b/application/controllers/ScheduleController.php @@ -55,6 +55,7 @@ class ScheduleController extends Zend_Controller_Action $formRepeats = new Application_Form_AddShowRepeats(); $formStyle = new Application_Form_AddShowStyle(); $formRecord = new Application_Form_AddShowRR(); + $formAbsoluteRebroadcast = new Application_Form_AddShowAbsoluteRebroadcastDates(); $formRebroadcast = new Application_Form_AddShowRebroadcastDates(); $formWhat->removeDecorator('DtDdWrapper'); @@ -63,6 +64,7 @@ class ScheduleController extends Zend_Controller_Action $formRepeats->removeDecorator('DtDdWrapper'); $formStyle->removeDecorator('DtDdWrapper'); $formRecord->removeDecorator('DtDdWrapper'); + $formAbsoluteRebroadcast->removeDecorator('DtDdWrapper'); $formRebroadcast->removeDecorator('DtDdWrapper'); $this->view->what = $formWhat; @@ -71,6 +73,7 @@ class ScheduleController extends Zend_Controller_Action $this->view->who = $formWho; $this->view->style = $formStyle; $this->view->rr = $formRecord; + $this->view->absoluteRebroadcast = $formAbsoluteRebroadcast; $this->view->rebroadcast = $formRebroadcast; $userInfo = Zend_Auth::getInstance()->getStorage()->read(); @@ -149,28 +152,38 @@ class ScheduleController extends Zend_Controller_Action $userInfo = Zend_Auth::getInstance()->getStorage()->read(); $user = new User($userInfo->id); - $show = new ShowInstance($id); $params = '/format/json/id/#id#'; 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 ($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()) { - $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. die(json_encode($menu)); diff --git a/application/forms/AddShowAbsoluteRebroadcastDates.php b/application/forms/AddShowAbsoluteRebroadcastDates.php new file mode 100644 index 000000000..322f8843d --- /dev/null +++ b/application/forms/AddShowAbsoluteRebroadcastDates.php @@ -0,0 +1,37 @@ +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')) + ) + )); + } + + +} + diff --git a/application/models/Shows.php b/application/models/Shows.php index f25ea9fb4..63915dc4f 100644 --- a/application/models/Shows.php +++ b/application/models/Shows.php @@ -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(); diff --git a/application/models/airtime/map/CcShowInstancesTableMap.php b/application/models/airtime/map/CcShowInstancesTableMap.php index a4d6300ea..b826c19ce 100644 --- a/application/models/airtime/map/CcShowInstancesTableMap.php +++ b/application/models/airtime/map/CcShowInstancesTableMap.php @@ -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 diff --git a/application/models/airtime/om/BaseCcShowInstances.php b/application/models/airtime/om/BaseCcShowInstances.php index c0247846d..9a0578dd4 100644 --- a/application/models/airtime/om/BaseCcShowInstances.php +++ b/application/models/airtime/om/BaseCcShowInstances.php @@ -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); diff --git a/application/views/scripts/schedule/add-show-form.phtml b/application/views/scripts/schedule/add-show-form.phtml index 98c1791b5..2a111448b 100644 --- a/application/views/scripts/schedule/add-show-form.phtml +++ b/application/views/scripts/schedule/add-show-form.phtml @@ -6,25 +6,26 @@

What

- what ?> + what; ?>

When

- when ?> - repeats ?> + when; ?> + repeats; ?>

Record & Rebroadcast

- rr ?> - rebroadcast ?> + rr; ?> + absoluteRebroadcast; ?> + rebroadcast; ?>

Who

- who ?> + who; ?>

Style

- style ?> + style; ?>
diff --git a/build/schema.xml b/build/schema.xml index 309c16121..1e32c58fa 100644 --- a/build/schema.xml +++ b/build/schema.xml @@ -133,8 +133,8 @@ - - + + diff --git a/build/sql/schema.sql b/build/sql/schema.sql index 14505af8e..9eb57a4e0 100644 --- a/build/sql/schema.sql +++ b/build/sql/schema.sql @@ -185,8 +185,8 @@ CREATE TABLE "cc_show_instances" "starts" TIMESTAMP NOT NULL, "ends" TIMESTAMP NOT NULL, "show_id" INTEGER NOT NULL, - "record" INT2, - "rebroadcast" INT2, + "record" INT2 default 0, + "rebroadcast" INT2 default 0, "instance_id" INTEGER, "file_id" INTEGER, PRIMARY KEY ("id")