-CC-1805 Ability to edit a show
Initial check-in...still incomplete.
This commit is contained in:
parent
eed8c95343
commit
b4f1a6b3b0
|
@ -6,8 +6,8 @@ class NowplayingController extends Zend_Controller_Action
|
|||
public function init()
|
||||
{
|
||||
$ajaxContext = $this->_helper->getHelper('AjaxContext');
|
||||
$ajaxContext->addActionContext('get-data-grid-data', 'json')
|
||||
->initContext();
|
||||
$ajaxContext->addActionContext('get-data-grid-data', 'json')
|
||||
->initContext();
|
||||
}
|
||||
|
||||
public function indexAction()
|
||||
|
@ -21,7 +21,7 @@ class NowplayingController extends Zend_Controller_Action
|
|||
{
|
||||
$viewType = $this->_request->getParam('view');
|
||||
$dateString = $this->_request->getParam('date');
|
||||
$this->view->entries = Application_Model_Nowplaying::GetDataGridData($viewType, $dateString);
|
||||
$this->view->entries = Application_Model_Nowplaying::GetDataGridData($viewType, $dateString);
|
||||
}
|
||||
|
||||
public function livestreamAction()
|
||||
|
|
|
@ -75,6 +75,9 @@ class ScheduleController extends Zend_Controller_Action
|
|||
$this->view->rr = $formRecord;
|
||||
$this->view->absoluteRebroadcast = $formAbsoluteRebroadcast;
|
||||
$this->view->rebroadcast = $formRebroadcast;
|
||||
$this->view->addNewShow = true;
|
||||
|
||||
$formWhat->populate(array('add_show_id' => '-1'));
|
||||
|
||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
$user = new User($userInfo->id);
|
||||
|
@ -233,15 +236,19 @@ class ScheduleController extends Zend_Controller_Action
|
|||
if (strtotime($show->getShowStart()) <= strtotime($today_timestamp) &&
|
||||
strtotime($today_timestamp) < strtotime($show->getShowEnd()) &&
|
||||
$user->isAdmin() && !$show->isRecorded()) {
|
||||
$menu[] = array('action' => array('type' => 'fn',
|
||||
'callback' => "window['confirmCancelShow']($id)"),
|
||||
'title' => 'Cancel Current Show');
|
||||
$menu[] = array('action' => array('type' => 'fn',
|
||||
'callback' => "window['confirmCancelShow']($id)"),
|
||||
'title' => 'Cancel Current Show');
|
||||
}
|
||||
|
||||
if (strtotime($today_timestamp) < strtotime($show->getShowStart())) {
|
||||
|
||||
if ($user->isAdmin()) {
|
||||
|
||||
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/edit-show/format/json/id/'.$id,
|
||||
'callback' => 'window["beginEditShow"]'), 'title' => 'Edit This Instance');
|
||||
//$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/cancel-show'.$params,
|
||||
// 'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Edit 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,
|
||||
|
@ -393,9 +400,76 @@ class ScheduleController extends Zend_Controller_Action
|
|||
public function editShowAction()
|
||||
{
|
||||
$showInstanceId = $this->_getParam('id');
|
||||
$showInstance = new ShowInstance($showInstanceId);
|
||||
|
||||
$formWhat = new Application_Form_AddShowWhat();
|
||||
$formWho = new Application_Form_AddShowWho();
|
||||
$formWhen = new Application_Form_AddShowWhen();
|
||||
$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');
|
||||
$formWho->removeDecorator('DtDdWrapper');
|
||||
$formWhen->removeDecorator('DtDdWrapper');
|
||||
$formRepeats->removeDecorator('DtDdWrapper');
|
||||
$formStyle->removeDecorator('DtDdWrapper');
|
||||
$formRecord->removeDecorator('DtDdWrapper');
|
||||
$formAbsoluteRebroadcast->removeDecorator('DtDdWrapper');
|
||||
$formRebroadcast->removeDecorator('DtDdWrapper');
|
||||
|
||||
$this->view->what = $formWhat;
|
||||
$this->view->when = $formWhen;
|
||||
$this->view->repeats = $formRepeats;
|
||||
$this->view->who = $formWho;
|
||||
$this->view->style = $formStyle;
|
||||
$this->view->rr = $formRecord;
|
||||
$this->view->absoluteRebroadcast = $formAbsoluteRebroadcast;
|
||||
$this->view->rebroadcast = $formRebroadcast;
|
||||
$this->view->addNewShow = false;
|
||||
|
||||
$showInstance = new ShowInstance($showInstanceId);
|
||||
$show = new Show($showInstance->getShowId());
|
||||
|
||||
$formWhat->populate(array('add_show_id' => $show->getId(),
|
||||
'add_show_name' => $show->getName(),
|
||||
'add_show_url' => $show->getUrl(),
|
||||
'add_show_genre' => $show->getGenre(),
|
||||
'add_show_description' => $show->getDescription()));
|
||||
|
||||
$formWhen->populate(array('add_show_start_date' => $show->getStartDate(),
|
||||
'add_show_start_time' => Show::removeSecondsFromTime($show->getStartTime()),
|
||||
'add_show_duration' => $show->getDuration(),
|
||||
'add_show_repeats' => $show->isRepeating() ? 1 : 0));
|
||||
|
||||
$days = array();
|
||||
$showDays = CcShowDaysQuery::create()->filterByDbShowId($showInstance->getShowId())->find();
|
||||
foreach($showDays as $showDay){
|
||||
array_push($days, $showDay->getDbDay());
|
||||
}
|
||||
|
||||
$formRepeats->populate(array('add_show_repeat_type' => $show->getRepeatType(),
|
||||
'add_show_day_check' => $days,
|
||||
'add_show_end_date' => $show->getRepeatingEndDate(),
|
||||
'add_show_no_end' => ($show->getRepeatingEndDate() == '')));
|
||||
|
||||
$formRecord->populate(array('add_show_record' => $show->isRecorded(),
|
||||
'add_show_rebroadcast' => $show->isRebroadcast()));
|
||||
|
||||
$hosts = array();
|
||||
$showHosts = CcShowHostsQuery::create()->filterByDbShow($showInstance->getShowId())->find();
|
||||
foreach($showHosts as $showHost){
|
||||
array_push($hosts, $showHost->getDbHost());
|
||||
}
|
||||
$formWho->populate(array('add_show_hosts' => $hosts));
|
||||
|
||||
|
||||
$formStyle->populate(array('add_show_background_color' => $show->getBackgroundColor(),
|
||||
'add_show_color' => $show->getColor()));
|
||||
|
||||
$this->view->newForm = $this->view->render('schedule/add-show-form.phtml');
|
||||
$this->view->entries = 5;
|
||||
}
|
||||
|
||||
public function addShowAction()
|
||||
|
@ -407,6 +481,7 @@ class ScheduleController extends Zend_Controller_Action
|
|||
foreach($js as $j){
|
||||
$data[$j["name"]] = $j["value"];
|
||||
}
|
||||
|
||||
$data['add_show_hosts'] = $this->_getParam('hosts');
|
||||
$data['add_show_day_check'] = $this->_getParam('days');
|
||||
|
||||
|
@ -440,6 +515,7 @@ class ScheduleController extends Zend_Controller_Action
|
|||
$this->view->rr = $formRecord;
|
||||
$this->view->absoluteRebroadcast = $formAbsoluteRebroadcast;
|
||||
$this->view->rebroadcast = $formRebroadcast;
|
||||
$this->view->addNewShow = true;
|
||||
|
||||
$what = $formWhat->isValid($data);
|
||||
$when = $formWhen->isValid($data);
|
||||
|
@ -494,11 +570,13 @@ class ScheduleController extends Zend_Controller_Action
|
|||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
$user = new User($userInfo->id);
|
||||
if ($user->isAdmin()) {
|
||||
Show::create($data);
|
||||
Show::create($data);
|
||||
}
|
||||
|
||||
//send back a new form for the user.
|
||||
$formWhat->reset();
|
||||
$formWhat->populate(array('add_show_id' => '-1'));
|
||||
|
||||
$formWho->reset();
|
||||
$formWhen->reset();
|
||||
$formWhen->populate(array('add_show_start_date' => date("Y-m-d"),
|
||||
|
|
|
@ -57,15 +57,17 @@ class Application_Form_AddShowRepeats extends Zend_Form_SubForm
|
|||
|
||||
public function checkReliantFields($formData) {
|
||||
|
||||
$start_timestamp = $formData['add_show_start_date'];
|
||||
$end_timestamp = $formData['add_show_end_date'];
|
||||
if (!$formData['add_show_no_end']){
|
||||
$start_timestamp = $formData['add_show_start_date'];
|
||||
$end_timestamp = $formData['add_show_end_date'];
|
||||
|
||||
$start_epoch = strtotime($start_timestamp);
|
||||
$end_epoch = strtotime($end_timestamp);
|
||||
|
||||
$start_epoch = strtotime($start_timestamp);
|
||||
$end_epoch = strtotime($end_timestamp);
|
||||
|
||||
if($end_epoch < $start_epoch) {
|
||||
$this->getElement('add_show_end_date')->setErrors(array('End date must be after start date'));
|
||||
return false;
|
||||
if($end_epoch < $start_epoch) {
|
||||
$this->getElement('add_show_end_date')->setErrors(array('End date must be after start date'));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -5,6 +5,12 @@ class Application_Form_AddShowWhat extends Zend_Form_SubForm
|
|||
|
||||
public function init()
|
||||
{
|
||||
// Hidden element to indicate whether the show is new or
|
||||
// whether we are updating an existing show.
|
||||
$this->addElement('hidden', 'add_show_id', array(
|
||||
'decorators' => array('ViewHelper')
|
||||
));
|
||||
|
||||
// Add name element
|
||||
$this->addElement('text', 'add_show_name', array(
|
||||
'label' => 'Name:',
|
||||
|
|
|
@ -46,8 +46,32 @@ class Show {
|
|||
$show->setDbColor($color);
|
||||
}
|
||||
|
||||
public function getBackgroundColor()
|
||||
{
|
||||
public function getUrl()
|
||||
{
|
||||
$show = CcShowQuery::create()->findPK($this->_showId);
|
||||
return $show->getDbUrl();
|
||||
}
|
||||
|
||||
public function setUrl($p_url)
|
||||
{
|
||||
$show = CcShowQuery::create()->findPK($this->_showId);
|
||||
$show->setDbUrl($p_url);
|
||||
}
|
||||
|
||||
public function getGenre()
|
||||
{
|
||||
$show = CcShowQuery::create()->findPK($this->_showId);
|
||||
return $show->getDbGenre();
|
||||
}
|
||||
|
||||
public function setGenre($p_genre)
|
||||
{
|
||||
$show = CcShowQuery::create()->findPK($this->_showId);
|
||||
$show->setDbGenre($p_genre);
|
||||
}
|
||||
|
||||
public function getBackgroundColor()
|
||||
{
|
||||
$show = CcShowQuery::create()->findPK($this->_showId);
|
||||
return $show->getDbBackgroundColor();
|
||||
}
|
||||
|
@ -98,6 +122,348 @@ class Show {
|
|||
RabbitMq::PushSchedule();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove Show Instances that occur on days of the week specified
|
||||
* by input array. For example, if array contains one value of "0",
|
||||
* then all show instances that occur on Sunday are removed.
|
||||
*
|
||||
* @param array p_uncheckedDays
|
||||
* An array specifying which days
|
||||
*/
|
||||
public function removeUncheckedDaysInstances($p_uncheckedDays)
|
||||
{
|
||||
global $CC_DBC;
|
||||
|
||||
$uncheckedDaysImploded = implode(",", $p_uncheckedDays);
|
||||
$showId = $this->getId();
|
||||
$sql = "DELETE FROM cc_show_instances"
|
||||
." WHERE EXTRACT(DOW FROM starts) IN ($uncheckedDaysImploded)"
|
||||
." AND show_id = $showId";
|
||||
|
||||
$CC_DBC->query($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the current show originated
|
||||
* from a recording.
|
||||
*
|
||||
* @return boolean
|
||||
* true if originated from recording, otherwise false.
|
||||
*/
|
||||
public function isRecorded(){
|
||||
$showInstancesRow = CcShowInstancesQuery::create()
|
||||
->filterByDbShowId($this->_showId)
|
||||
->filterByDbRecord(1)
|
||||
->findOne();
|
||||
|
||||
return !is_null($showInstancesRow);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the current show has rebroadcasts of a recorded
|
||||
* show. Should be used in conjunction with isRecorded().
|
||||
*
|
||||
* @return boolean
|
||||
* true if show has rebroadcasts, otherwise false.
|
||||
*/
|
||||
public function isRebroadcast()
|
||||
{
|
||||
$showInstancesRow = CcShowInstancesQuery::create()
|
||||
->filterByDbShowId($this->_showId)
|
||||
->filterByDbRebroadcast(1)
|
||||
->findOne();
|
||||
|
||||
return !is_null($showInstancesRow);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the current show is set to repeat
|
||||
* repeating shows.
|
||||
*
|
||||
* @return boolean
|
||||
* true if repeating shows, otherwise false.
|
||||
*/
|
||||
public function isRepeating()
|
||||
{
|
||||
$showDaysRow = CcShowDaysQuery::create()
|
||||
->filterByDbShowId($this->_showId)
|
||||
->findOne();
|
||||
|
||||
if (!is_null($showDaysRow)){
|
||||
return ($showDaysRow->getDbRepeatType() != -1);
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the repeat type of the show. Show can have repeat
|
||||
* type of "weekly", "bi-weekly" and "monthly". These values
|
||||
* are represented by 0, 1, and 2 respectively.
|
||||
*
|
||||
* @return int
|
||||
* Return the integer corresponding to the repeat type.
|
||||
*/
|
||||
public function getRepeatType()
|
||||
{
|
||||
$showDaysRow = CcShowDaysQuery::create()
|
||||
->filterByDbShowId($this->_showId)
|
||||
->findOne();
|
||||
|
||||
if (!is_null($showDaysRow)){
|
||||
return $showDaysRow->getDbRepeatType();
|
||||
} else
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the end date for a repeating show in the format yyyy-mm-dd
|
||||
*
|
||||
* @return string
|
||||
* Return the end date for the repeating show or the empty
|
||||
* string if there is no end.
|
||||
*/
|
||||
public function getRepeatingEndDate(){
|
||||
global $CC_DBC;
|
||||
|
||||
$showId = $this->getId();
|
||||
$sql = "SELECT last_show FROM cc_show_days"
|
||||
." WHERE show_id = $showId";
|
||||
|
||||
$endDate = $CC_DBC->GetOne($sql);
|
||||
|
||||
if (is_null($endDate)){
|
||||
return "";
|
||||
} else {
|
||||
return $endDate;
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteAllInstances(){
|
||||
CcShowInstancesQuery::create()
|
||||
->filterByDbShowId($this->getId())
|
||||
->find()
|
||||
->delete();
|
||||
}
|
||||
|
||||
public function removeAllInstancesAfterDate($p_date){
|
||||
global $CC_DBC;
|
||||
|
||||
$showId = $this->getId();
|
||||
$sql = "DELETE FROM cc_show_instances "
|
||||
."WHERE date(starts) > DATE '$p_date' "
|
||||
."AND show_id = $showId";
|
||||
|
||||
$CC_DBC->query($sql);
|
||||
}
|
||||
|
||||
public function getStartDate(){
|
||||
global $CC_DBC;
|
||||
|
||||
$showId = $this->getId();
|
||||
$sql = "SELECT first_show FROM cc_show_days"
|
||||
." WHERE show_id = $showId";
|
||||
|
||||
$firstDate = $CC_DBC->GetOne($sql);
|
||||
|
||||
if (is_null($firstDate)){
|
||||
return "";
|
||||
} else {
|
||||
return $firstDate;
|
||||
}
|
||||
}
|
||||
|
||||
public function getStartTime(){
|
||||
global $CC_DBC;
|
||||
|
||||
$showId = $this->getId();
|
||||
$sql = "SELECT start_time FROM cc_show_days"
|
||||
." WHERE show_id = $showId";
|
||||
|
||||
$startTime = $CC_DBC->GetOne($sql);
|
||||
|
||||
if (is_null($startTime)){
|
||||
return "";
|
||||
} else {
|
||||
return $startTime;
|
||||
}
|
||||
}
|
||||
|
||||
public function getAllInstanceIds(){
|
||||
global $CC_DBC;
|
||||
|
||||
$showId = $this->getId();
|
||||
$sql = "SELECT id from cc_show_instances "
|
||||
." WHERE show_id = $showId";
|
||||
|
||||
$rows = $CC_DBC->GetAll($sql);
|
||||
|
||||
$instance_ids = array();
|
||||
foreach ($rows as $row){
|
||||
$instance_ids[] = $row["id"];
|
||||
}
|
||||
return $instance_ids;
|
||||
}
|
||||
|
||||
private function updateDurationTime($p_data){
|
||||
//need to update cc_show_instances, cc_show_days
|
||||
|
||||
global $CC_DBC;
|
||||
|
||||
$sql = "UPDATE cc_show_days "
|
||||
."SET duration = '$p_data[add_show_duration]' "
|
||||
."WHERE show_id = $p_data[add_show_id]";
|
||||
$CC_DBC->query($sql);
|
||||
|
||||
$sql = "UPDATE cc_show_instances "
|
||||
."SET ends = starts + INTERVAL '$p_data[add_show_duration]' "
|
||||
."WHERE show_id = $p_data[add_show_id]";
|
||||
$CC_DBC->query($sql);
|
||||
|
||||
}
|
||||
|
||||
private function updateStartDateTime($p_data, $p_endDate){
|
||||
//need to update cc_schedule, cc_show_instances, cc_show_days
|
||||
|
||||
global $CC_DBC;
|
||||
|
||||
$sql = "UPDATE cc_show_days "
|
||||
."SET start_time = TIME '$p_data[add_show_start_time]', "
|
||||
."first_show = DATE '$p_data[add_show_start_date]', ";
|
||||
if (strlen ($p_endDate) == 0){
|
||||
$sql .= "last_show = NULL ";
|
||||
} else {
|
||||
$sql .= "last_show = DATE '$p_endDate' ";
|
||||
}
|
||||
$sql .= "WHERE show_id = $p_data[add_show_id]";
|
||||
$CC_DBC->query($sql);
|
||||
|
||||
$oldStartDateTimeEpoch = strtotime($this->getStartDate()." ".$this->getStartTime());
|
||||
$newStartDateTimeEpoch = strtotime($p_data['add_show_start_date']." ".$p_data['add_show_start_time']);
|
||||
$diff = $newStartDateTimeEpoch - $oldStartDateTimeEpoch;
|
||||
|
||||
$sql = "UPDATE cc_show_instances "
|
||||
."SET starts = starts + INTERVAL '$diff sec', "
|
||||
."ends = ends + INTERVAL '$diff sec' "
|
||||
."WHERE show_id = $p_data[add_show_id]";
|
||||
$CC_DBC->query($sql);
|
||||
|
||||
$showInstanceIds = $this->getAllInstanceIds();
|
||||
if (count($showInstanceIds) > 0 && $diff != 0){
|
||||
$showIdsImploded = implode(",", $showInstanceIds);
|
||||
$sql = "UPDATE cc_schedule "
|
||||
."SET starts = starts + INTERVAL '$diff sec', "
|
||||
."ends = ends + INTERVAL '$diff sec' "
|
||||
."WHERE instance_id IN ($showIdsImploded)";
|
||||
$CC_DBC->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
public function getDuration(){
|
||||
$showDay = CcShowDaysQuery::create()->filterByDbShowId($this->getId())->findOne();
|
||||
return $showDay->getDbDuration();
|
||||
}
|
||||
|
||||
public function getShowDays(){
|
||||
$showDays = CcShowDaysQuery::create()->filterByDbShowId($this->getId())->find();
|
||||
|
||||
$days = array();
|
||||
foreach ($showDays as $showDay){
|
||||
array_push($days, $showDay->getDbDay());
|
||||
}
|
||||
|
||||
return $days;
|
||||
}
|
||||
|
||||
public function hasInstance(){
|
||||
return (!is_null($this->getInstance()));
|
||||
}
|
||||
|
||||
public function getInstance(){
|
||||
$showInstances = CcShowInstancesQuery::create()->filterByDbShowId($this->getId())->findOne();
|
||||
return $showInstances;
|
||||
}
|
||||
|
||||
public function hasInstanceOnDate($p_timestamp){
|
||||
return (!is_null($this->getInstanceOnDate($p_timestamp)));
|
||||
}
|
||||
|
||||
public function getInstanceOnDate($p_timestamp){
|
||||
global $CC_DBC;
|
||||
|
||||
$showId = $this->getId();
|
||||
$sql = "SELECT id FROM cc_show_instances"
|
||||
." WHERE date(starts) = date(TIMESTAMP '$p_timestamp') "
|
||||
." AND show_id = $showId";
|
||||
|
||||
$row = $CC_DBC->GetOne($sql);
|
||||
return CcShowInstancesQuery::create()->findPk($row);
|
||||
}
|
||||
|
||||
public static function deletePossiblyInvalidInstances($p_data, $p_show, $p_endDate)
|
||||
{
|
||||
|
||||
if ($p_data['add_show_repeats'] != $p_show->isRepeating()){
|
||||
//repeat option was toggled.
|
||||
$p_show->deleteAllInstances();
|
||||
}
|
||||
if ($p_data['add_show_start_date'] != $p_show->getStartDate()
|
||||
|| $p_data['add_show_start_time'] != $p_show->getStartTime()){
|
||||
//start date/time has changed
|
||||
|
||||
$p_show->updateStartDateTime($p_data, $p_endDate);
|
||||
}
|
||||
if ($p_data['add_show_duration'] != $p_show->getDuration()){
|
||||
//duration has changed
|
||||
$p_show->updateDurationTime($p_data);
|
||||
}
|
||||
|
||||
if ($p_data['add_show_repeats']){
|
||||
if ($p_data['add_show_repeat_type'] != $p_show->getRepeatType()){
|
||||
//repeat type changed.
|
||||
$p_show->deleteAllInstances();
|
||||
} else {
|
||||
//repeat type is the same, check if the days of the week are the same
|
||||
$repeatingDaysChanged = false;
|
||||
$showDaysArray = $p_show->getShowDays();
|
||||
if (count($p_data['add_show_day_check']) == count($showDaysArray)){
|
||||
//same number of days checked, lets see if they are the same numbers
|
||||
$intersect = array_intersect($p_data['add_show_day_check'], $showDaysArray);
|
||||
if (count($intersect) != count($p_data['add_show_day_check'])){
|
||||
$repeatingDaysChanged = true;
|
||||
}
|
||||
} else {
|
||||
$repeatingDaysChanged = true;
|
||||
}
|
||||
|
||||
if ($repeatingDaysChanged){
|
||||
$daysRemoved = array_diff($showDaysArray, $p_data['add_show_day_check']);
|
||||
|
||||
if (count($daysRemoved) > 0){
|
||||
$p_show->removeUncheckedDaysInstances($daysRemoved);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Check if end date for the repeat option has changed. If so, need to take care
|
||||
//of deleting possible invalid Show Instances.
|
||||
if ((strlen($p_show->getRepeatingEndDate()) == 0) == $p_data['add_show_no_end']){
|
||||
//show "Never Ends" option was toggled.
|
||||
if ($p_data['add_show_no_end']){
|
||||
} else {
|
||||
$p_show->removeAllInstancesAfterDate($p_endDate);
|
||||
}
|
||||
}
|
||||
if ($p_show->getRepeatingEndDate() != $p_data['add_show_end_date']){
|
||||
//end date was changed.
|
||||
|
||||
$newDate = strtotime($p_data['add_show_end_date']);
|
||||
$oldDate = strtotime($p_show->getRepeatingEndDate());
|
||||
if ($newDate < $oldDate){
|
||||
$p_show->removeAllInstancesAfterDate($p_endDate);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a show.
|
||||
|
@ -112,10 +478,6 @@ class Show {
|
|||
{
|
||||
$con = Propel::getConnection(CcShowPeer::DATABASE_NAME);
|
||||
|
||||
$sql = "SELECT time '{$data['add_show_start_time']}' + INTERVAL '{$data['add_show_duration']} hour' ";
|
||||
$r = $con->query($sql);
|
||||
$endTime = $r->fetchColumn(0);
|
||||
|
||||
$sql = "SELECT EXTRACT(DOW FROM TIMESTAMP '{$data['add_show_start_date']} {$data['add_show_start_time']}')";
|
||||
$r = $con->query($sql);
|
||||
$startDow = $r->fetchColumn(0);
|
||||
|
@ -151,26 +513,36 @@ class Show {
|
|||
$repeat_type = -1;
|
||||
}
|
||||
|
||||
$show = new CcShow();
|
||||
$show->setDbName($data['add_show_name']);
|
||||
$show->setDbDescription($data['add_show_description']);
|
||||
$show->setDbUrl($data['add_show_url']);
|
||||
$show->setDbGenre($data['add_show_genre']);
|
||||
$show->setDbColor($data['add_show_color']);
|
||||
$show->setDbBackgroundColor($data['add_show_background_color']);
|
||||
$show->save();
|
||||
|
||||
$showId = $show->getDbId();
|
||||
|
||||
if ($data['add_show_record']){
|
||||
$isRecorded = 1;
|
||||
}
|
||||
else {
|
||||
$isRecorded = 0;
|
||||
if ($data['add_show_id'] == -1){
|
||||
$ccShow = new CcShow();
|
||||
} else {
|
||||
$ccShow = CcShowQuery::create()->findPK($data['add_show_id']);
|
||||
}
|
||||
$ccShow->setDbName($data['add_show_name']);
|
||||
$ccShow->setDbDescription($data['add_show_description']);
|
||||
$ccShow->setDbUrl($data['add_show_url']);
|
||||
$ccShow->setDbGenre($data['add_show_genre']);
|
||||
$ccShow->setDbColor($data['add_show_color']);
|
||||
$ccShow->setDbBackgroundColor($data['add_show_background_color']);
|
||||
$ccShow->save();
|
||||
|
||||
$isRecorded = ($data['add_show_record']) ? 1 : 0;
|
||||
|
||||
$showId = $ccShow->getDbId();
|
||||
$show = new Show($showId);
|
||||
|
||||
if ($data['add_show_id'] != -1){
|
||||
Show::deletePossiblyInvalidInstances($data, $show, $endDate);
|
||||
}
|
||||
|
||||
//check if we are adding or updating a show, and if updating
|
||||
//erase all the show's show_days information first.
|
||||
if ($data['add_show_id'] != -1){
|
||||
CcShowDaysQuery::create()->filterByDbShowId($data['add_show_id'])->delete();
|
||||
}
|
||||
|
||||
//don't set day for monthly repeat type, it's invalid.
|
||||
if ($data['add_show_repeats'] && $data["add_show_repeat_type"] == 2) {
|
||||
if ($data['add_show_repeats'] && $data['add_show_repeat_type'] == 2) {
|
||||
$showDay = new CcShowDays();
|
||||
$showDay->setDbFirstShow($data['add_show_start_date']);
|
||||
$showDay->setDbLastShow($endDate);
|
||||
|
@ -213,6 +585,11 @@ class Show {
|
|||
}
|
||||
}
|
||||
|
||||
//check if we are adding or updating a show, and if updating
|
||||
//erase all the show's show_rebroadcast information first.
|
||||
if ($data['add_show_id'] != -1){
|
||||
CcShowRebroadcastQuery::create()->filterByDbShowId($data['add_show_id'])->delete();
|
||||
}
|
||||
//adding rows to cc_show_rebroadcast
|
||||
if ($data['add_show_record'] && $data['add_show_rebroadcast'] && $repeat_type != -1) {
|
||||
|
||||
|
@ -245,6 +622,11 @@ class Show {
|
|||
}
|
||||
}
|
||||
|
||||
//check if we are adding or updating a show, and if updating
|
||||
//erase all the show's show_rebroadcast information first.
|
||||
if ($data['add_show_id'] != -1){
|
||||
CcShowHostsQuery::create()->filterByDbShow($data['add_show_id'])->delete();
|
||||
}
|
||||
if (is_array($data['add_show_hosts'])) {
|
||||
//add selected hosts to cc_show_hosts table.
|
||||
foreach ($data['add_show_hosts'] as $host) {
|
||||
|
@ -312,7 +694,6 @@ class Show {
|
|||
$sql = $sql." AND ({$exclude})";
|
||||
}
|
||||
|
||||
//echo $sql;
|
||||
return $CC_DBC->GetAll($sql);
|
||||
}
|
||||
|
||||
|
@ -342,15 +723,23 @@ class Show {
|
|||
|
||||
$sql = "SELECT timestamp '{$start}' + interval '{$duration}'";
|
||||
$end = $CC_DBC->GetOne($sql);
|
||||
|
||||
$show = new Show($show_id);
|
||||
if ($show->hasInstance()){
|
||||
$showInstance = $show->getInstance();
|
||||
} else {
|
||||
$showInstance = new CcShowInstances();
|
||||
}
|
||||
|
||||
$showInstance->setDbShowId($show_id);
|
||||
$showInstance->setDbStarts($start);
|
||||
$showInstance->setDbEnds($end);
|
||||
$showInstance->setDbRecord($record);
|
||||
$showInstance->save();
|
||||
//$show->addInstance($showInstance);
|
||||
|
||||
|
||||
$newShow = new CcShowInstances();
|
||||
$newShow->setDbShowId($show_id);
|
||||
$newShow->setDbStarts($start);
|
||||
$newShow->setDbEnds($end);
|
||||
$newShow->setDbRecord($record);
|
||||
$newShow->save();
|
||||
|
||||
$show_instance_id = $newShow->getDbId();
|
||||
$show_instance_id = $showInstance->getDbId();
|
||||
|
||||
$sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id={$show_id}";
|
||||
$rebroadcasts = $CC_DBC->GetAll($sql);
|
||||
|
@ -393,6 +782,7 @@ class Show {
|
|||
|
||||
$sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id={$show_id}";
|
||||
$rebroadcasts = $CC_DBC->GetAll($sql);
|
||||
$show = new Show($show_id);
|
||||
|
||||
while(strtotime($next_date) < strtotime($end_timestamp) && (strtotime($last_show) > strtotime($next_date) || is_null($last_show))) {
|
||||
|
||||
|
@ -400,15 +790,21 @@ class Show {
|
|||
|
||||
$sql = "SELECT timestamp '{$start}' + interval '{$duration}'";
|
||||
$end = $CC_DBC->GetOne($sql);
|
||||
|
||||
if ($show->hasInstanceOnDate($start)){
|
||||
$showInstance = $show->getInstanceOnDate($start);
|
||||
} else {
|
||||
$showInstance = new CcShowInstances();
|
||||
}
|
||||
$showInstance->setDbShowId($show_id);
|
||||
$showInstance->setDbStarts($start);
|
||||
$showInstance->setDbEnds($end);
|
||||
$showInstance->setDbRecord($record);
|
||||
$showInstance->save();
|
||||
//$show->addInstance($showInstance);
|
||||
|
||||
|
||||
$newShow = new CcShowInstances();
|
||||
$newShow->setDbShowId($show_id);
|
||||
$newShow->setDbStarts($start);
|
||||
$newShow->setDbEnds($end);
|
||||
$newShow->setDbRecord($record);
|
||||
$newShow->save();
|
||||
|
||||
$show_instance_id = $newShow->getDbId();
|
||||
$show_instance_id = $showInstance->getDbId();
|
||||
|
||||
foreach($rebroadcasts as $rebroadcast) {
|
||||
|
||||
|
@ -481,7 +877,7 @@ class Show {
|
|||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM cc_show_days WHERE show_id = {$p_showId}";
|
||||
$sql = "SELECT * FROM cc_show_days WHERE show_id = $p_showId";
|
||||
$res = $CC_DBC->GetAll($sql);
|
||||
|
||||
foreach ($res as $row) {
|
||||
|
@ -547,7 +943,8 @@ class Show {
|
|||
return $events;
|
||||
}
|
||||
|
||||
private static function makeFullCalendarEvent($show, $options=array()) {
|
||||
private static function makeFullCalendarEvent($show, $options=array())
|
||||
{
|
||||
global $CC_DBC;
|
||||
|
||||
$event = array();
|
||||
|
@ -584,6 +981,41 @@ class Show {
|
|||
|
||||
return $event;
|
||||
}
|
||||
|
||||
public static function getDateFromTimestamp($p_timestamp){
|
||||
$explode = explode(" ", $p_timestamp);
|
||||
return $explode[0];
|
||||
}
|
||||
|
||||
public static function getTimeFromTimestamp($p_timestamp){
|
||||
$explode = explode(" ", $p_timestamp);
|
||||
return $explode[1];
|
||||
}
|
||||
|
||||
/**
|
||||
* This function formats a time by removing seconds
|
||||
*
|
||||
* When we receive a time from the database we get the
|
||||
* format "hh:mm:ss". But when dealing with show times, we
|
||||
* do not care about the seconds.
|
||||
*
|
||||
* @param int $p_timestamp
|
||||
* The value which to format.
|
||||
* @return int
|
||||
* The timestamp with the new format "hh:mm", or
|
||||
* the original input parameter, if it does not have
|
||||
* the correct format.
|
||||
*/
|
||||
public static function removeSecondsFromTime($p_timestamp)
|
||||
{
|
||||
//Format is in hh:mm:ss. We want hh:mm
|
||||
$timeExplode = explode(":", $p_timestamp);
|
||||
|
||||
if (count($timeExplode) == 3)
|
||||
return $timeExplode[0].":".$timeExplode[1];
|
||||
else
|
||||
return $p_timestamp;
|
||||
}
|
||||
}
|
||||
|
||||
class ShowInstance {
|
||||
|
@ -642,6 +1074,21 @@ class ShowInstance {
|
|||
return $showInstance->getDbEnds();
|
||||
}
|
||||
|
||||
public function getStartDate()
|
||||
{
|
||||
$showStart = $this->getShowStart();
|
||||
$showStartExplode = explode(" ", $showStart);
|
||||
return $showStartExplode[0];
|
||||
}
|
||||
|
||||
public function getStartTime()
|
||||
{
|
||||
$showStart = $this->getShowStart();
|
||||
$showStartExplode = explode(" ", $showStart);
|
||||
|
||||
return $showStartExplode[1];
|
||||
}
|
||||
|
||||
public function setSoundCloudFileId($p_soundcloud_id)
|
||||
{
|
||||
$showInstance = CcShowInstancesQuery::create()->findPK($this->_instanceId);
|
||||
|
@ -1101,5 +1548,4 @@ class Show_DAL {
|
|||
|
||||
return $CC_DBC->GetAll($sql);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
<?php
|
||||
echo $this->entries;
|
||||
?>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<a href="#" id="add-show-close" class="icon-link"><span class="ui-icon ui-icon-circle-close"></span>Close</a>
|
||||
<button aria-disabled="false" role="button" class="add-show-submit right-floated ui-button ui-widget ui-state-default ui-button-text-icon-primary">
|
||||
<span class="ui-icon ui-icon-plusthick"></span>
|
||||
<span class="ui-button-text">Add this show</span>
|
||||
<span class="ui-button-text"><?php echo ($this->addNewShow ? "Add this show" : "Update show"); ?></span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
|
@ -33,7 +33,7 @@
|
|||
<div class="button-bar bottom">
|
||||
<button aria-disabled="false" role="button" class="add-show-submit right-floated ui-button ui-widget ui-state-default ui-button-text-icon-primary">
|
||||
<span class="ui-icon ui-icon-plusthick"></span>
|
||||
<span class="ui-button-text">Add this show</span>
|
||||
<span class="ui-button-text"><?php echo ($this->addNewShow ? "Add this show" : "Update show"); ?></span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,11 +1,2 @@
|
|||
<div>
|
||||
<div id="schedule-show-what">
|
||||
<?php echo $this->what ?>
|
||||
</div>
|
||||
<div id="schedule-show-who">
|
||||
<?php echo $this->who ?>
|
||||
</div>
|
||||
<div id="schedule-show-style">
|
||||
<?php echo $this->style ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
//$this->entries;
|
||||
|
|
Binary file not shown.
|
@ -56,7 +56,7 @@ function findHosts(request, callback) {
|
|||
}
|
||||
|
||||
function setAddShowEvents() {
|
||||
|
||||
|
||||
var form = $("#add-show-form");
|
||||
|
||||
form.find("h3").click(function(){
|
||||
|
@ -129,9 +129,15 @@ function setAddShowEvents() {
|
|||
form.find("#add_show_day_check-element label").addClass("wrapp-label");
|
||||
form.find("#add_show_day_check-element br").remove();
|
||||
|
||||
form.find("#add_show_no_end").click(function(){
|
||||
form.find("#add_show_end_date").toggle();
|
||||
});
|
||||
function endDateVisibility(){
|
||||
if(form.find("#add_show_no_end").is(':checked')){
|
||||
form.find("#add_show_end_date").hide();
|
||||
} else {
|
||||
form.find("#add_show_end_date").show();
|
||||
}
|
||||
}
|
||||
endDateVisibility();
|
||||
form.find("#add_show_no_end").click(endDateVisibility);
|
||||
|
||||
createDateInput(form.find("#add_show_start_date"), startDpSelect);
|
||||
createDateInput(form.find("#add_show_end_date"), endDpSelect);
|
||||
|
|
|
@ -33,6 +33,17 @@ function makeAddShowButton(){
|
|||
});
|
||||
}
|
||||
|
||||
function beginEditShow(data){
|
||||
//alert (data.entries);
|
||||
|
||||
$("#add-show-form")
|
||||
.empty()
|
||||
.append(data.newForm);
|
||||
|
||||
setAddShowEvents();
|
||||
openAddShowForm();
|
||||
}
|
||||
|
||||
function makeTimeStamp(date){
|
||||
var sy, sm, sd, h, m, s, timestamp;
|
||||
sy = date.getFullYear();
|
||||
|
|
Loading…
Reference in New Issue