CC-2848: Misc bugs from demo service

- Handling concurrency issue playlist section and show(canlendar) section
This commit is contained in:
James 2011-11-10 15:35:27 -05:00
parent 17016e5d40
commit b04b7ff010
10 changed files with 317 additions and 72 deletions

View file

@ -36,9 +36,11 @@ class PlaylistController extends Zend_Controller_Action
$pl = Application_Model_Playlist::Recall($pl_sess->id);
if($pl === FALSE) {
unset($pl_sess->id);
return;
return false;
}
return $pl;
}else{
return false;
}
}
@ -84,7 +86,10 @@ class PlaylistController extends Zend_Controller_Action
$this->view->headLink()->appendStylesheet($baseUrl.'/css/playlist_builder.css');
$this->_helper->viewRenderer->setResponseSegment('spl');
$this->view->pl = $this->getPlaylist();
$pl = $this->getPlaylist();
if($pl !== false){
$this->view->pl = $pl;
}
}
public function newAction()
@ -113,6 +118,10 @@ class PlaylistController extends Zend_Controller_Action
$this->changePlaylist($pl_id);
$pl = $this->getPlaylist();
if($pl === false){
$this->view->playlist_error = true;
return false;
}
$title = $pl->getPLMetaData("dc:title");
$desc = $pl->getPLMetaData("dc:description");
@ -125,6 +134,10 @@ class PlaylistController extends Zend_Controller_Action
$description = $this->_getParam('description', null);
$pl = $this->getPlaylist();
if($pl === false){
$this->view->playlist_error = true;
return false;
}
if($title)
$pl->setName($title);
@ -152,6 +165,10 @@ class PlaylistController extends Zend_Controller_Action
}
$pl = $this->getPlaylist();
if($pl === false){
$this->view->playlist_error = true;
return false;
}
$this->view->pl = $pl;
$this->view->pl_id = $pl->getId();
@ -167,6 +184,10 @@ class PlaylistController extends Zend_Controller_Action
if (!is_null($id)) {
$pl = $this->getPlaylist();
if($pl === false){
$this->view->playlist_error = true;
return false;
}
$res = $pl->addAudioClip($id, $pos);
if (PEAR::isError($res)) {
@ -191,6 +212,10 @@ class PlaylistController extends Zend_Controller_Action
$newPos = $this->_getParam('newPos');
$pl = $this->getPlaylist();
if($pl === false){
$this->view->playlist_error = true;
return false;
}
$pl->moveAudioClip($oldPos, $newPos);
@ -215,6 +240,10 @@ class PlaylistController extends Zend_Controller_Action
$positions = array_reverse($positions);
$pl = $this->getPlaylist();
if($pl === false){
$this->view->playlist_error = true;
return false;
}
foreach ($positions as $pos) {
$pl->delAudioClip($pos);
@ -236,6 +265,10 @@ class PlaylistController extends Zend_Controller_Action
$request = $this->getRequest();
$pos = $this->_getParam('pos');
$pl = $this->getPlaylist();
if($pl === false){
$this->view->playlist_error = true;
return false;
}
if($request->isPost()) {
$cueIn = $this->_getParam('cueIn', null);
@ -261,6 +294,10 @@ class PlaylistController extends Zend_Controller_Action
$request = $this->getRequest();
$pos = $this->_getParam('pos');
$pl = $this->getPlaylist();
if($pl === false){
$this->view->playlist_error = true;
return false;
}
if($request->isPost()) {
$fadeIn = $this->_getParam('fadeIn', null);
@ -296,7 +333,10 @@ class PlaylistController extends Zend_Controller_Action
if($pl_sess->id === $id){
unset($pl_sess->id);
}
}
}else{
$this->view->playlist_error = true;
return false;
}
$this->view->id = $id;
$this->view->html = $this->view->render('playlist/index.phtml');
@ -305,6 +345,10 @@ class PlaylistController extends Zend_Controller_Action
public function deleteActiveAction()
{
$pl = $this->getPlaylist();
if($pl === false){
$this->view->playlist_error = true;
return false;
}
Application_Model_Playlist::Delete($pl->getId());
$pl_sess = $this->pl_sess;
@ -316,6 +360,10 @@ class PlaylistController extends Zend_Controller_Action
public function closeAction()
{
$pl = $this->getPlaylist();
if($pl === false){
$this->view->playlist_error = true;
return false;
}
$this->closePlaylist($pl);
$this->view->html = $this->view->render('playlist/index.phtml');
@ -325,6 +373,10 @@ class PlaylistController extends Zend_Controller_Action
{
$request = $this->getRequest();
$pl = $this->getPlaylist();
if($pl === false){
$this->view->playlist_error = true;
return false;
}
if($request->isPost()) {
$fadeIn = $this->_getParam('fadeIn', null);
@ -351,6 +403,10 @@ class PlaylistController extends Zend_Controller_Action
$name = $this->_getParam('name', 'Unknown Playlist');
$pl = $this->getPlaylist();
if($pl === false){
$this->view->playlist_error = true;
return false;
}
$pl->setName($name);
$this->view->playlistName = $name;
@ -360,6 +416,10 @@ class PlaylistController extends Zend_Controller_Action
{
$description = $this->_getParam('description', false);
$pl = $this->getPlaylist();
if($pl === false){
$this->view->playlist_error = true;
return false;
}
if($description != false) {
$pl->setDescription($description);
@ -374,27 +434,3 @@ class PlaylistController extends Zend_Controller_Action
}

View file

@ -91,7 +91,12 @@ class ScheduleController extends Zend_Controller_Action
$user = new Application_Model_User($userInfo->id);
if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
$showInstance = new Application_Model_ShowInstance($showInstanceId);
try{
$showInstance = new Application_Model_ShowInstance($showInstanceId);
}catch(Exception $e){
$this->view->show_error = true;
return false;
}
$error = $showInstance->moveShow($deltaDay, $deltaMin);
}
@ -110,7 +115,12 @@ class ScheduleController extends Zend_Controller_Action
$user = new Application_Model_User($userInfo->id);
if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
$show = new Application_Model_ShowInstance($showInstanceId);
try{
$show = new Application_Model_ShowInstance($showInstanceId);
}catch(Exception $e){
$this->view->show_error = true;
return false;
}
$error = $show->resizeShow($deltaDay, $deltaMin);
}
@ -126,7 +136,13 @@ class ScheduleController extends Zend_Controller_Action
$user = new Application_Model_User($userInfo->id);
if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
$show = new Application_Model_ShowInstance($showInstanceId);
try{
$show = new Application_Model_ShowInstance($showInstanceId);
}catch(Exception $e){
$this->view->show_error = true;
return false;
}
$show->deleteShow();
}
}
@ -135,7 +151,12 @@ class ScheduleController extends Zend_Controller_Action
{
global $CC_CONFIG;
$show_instance = $this->_getParam('id');
$show_inst = new Application_Model_ShowInstance($show_instance);
try{
$show_inst = new Application_Model_ShowInstance($show_instance);
}catch(Exception $e){
$this->view->show_error = true;
return false;
}
$file = $show_inst->getRecordedFile();
$id = $file->getId();
@ -151,13 +172,21 @@ class ScheduleController extends Zend_Controller_Action
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new Application_Model_User($userInfo->id);
$show = new Application_Model_ShowInstance($id);
try{
$show = new Application_Model_ShowInstance($id);
}catch(Exception $e){
$this->view->show_error = true;
return false;
}
$params = '/format/json/id/#id#';
$showStartDateHelper = Application_Model_DateHelper::ConvertToLocalDateTime($show->getShowStart());
$showEndDateHelper = Application_Model_DateHelper::ConvertToLocalDateTime($show->getShowEnd());
$menu = array();
if ($epochNow < $showStartDateHelper->getTimestamp()) {
if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER, UTYPE_HOST),$show->getShowId()) && !$show->isRecorded() && !$show->isRebroadcast()) {
@ -228,7 +257,12 @@ class ScheduleController extends Zend_Controller_Action
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new Application_Model_User($userInfo->id);
$show = new Application_Model_ShowInstance($showInstanceId);
try{
$show = new Application_Model_ShowInstance($showInstanceId);
}catch(Exception $e){
$this->view->show_error = true;
return false;
}
if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER, UTYPE_HOST),$show->getShowId())) {
$show->scheduleShow(array($plId));
@ -247,7 +281,12 @@ class ScheduleController extends Zend_Controller_Action
$showInstanceId = $this->_getParam('id');
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new Application_Model_User($userInfo->id);
$show = new Application_Model_ShowInstance($showInstanceId);
try{
$show = new Application_Model_ShowInstance($showInstanceId);
}catch(Exception $e){
$this->view->show_error = true;
return false;
}
if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER, UTYPE_HOST),$show->getShowId()))
$show->clearShow();
@ -261,8 +300,13 @@ class ScheduleController extends Zend_Controller_Action
public function findPlaylistsAction()
{
$post = $this->getRequest()->getPost();
$show = new Application_Model_ShowInstance($this->sched_sess->showInstanceId);
try{
$show = new Application_Model_ShowInstance($this->sched_sess->showInstanceId);
}catch(Exception $e){
$this->view->show_error = true;
return false;
}
$playlists = $show->searchPlaylistsForShow($post);
foreach( $playlists['aaData'] as &$data){
// calling two functions to format time to 1 decimal place
@ -282,7 +326,12 @@ class ScheduleController extends Zend_Controller_Action
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new Application_Model_User($userInfo->id);
$show = new Application_Model_ShowInstance($showInstanceId);
try{
$show = new Application_Model_ShowInstance($showInstanceId);
}catch(Exception $e){
$this->view->show_error = true;
return false;
}
if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER, UTYPE_HOST),$show->getShowId())) {
$show->removeGroupFromShow($group_id);
@ -300,7 +349,12 @@ class ScheduleController extends Zend_Controller_Action
$showInstanceId = $this->_getParam('id');
$this->sched_sess->showInstanceId = $showInstanceId;
$show = new Application_Model_ShowInstance($showInstanceId);
try{
$show = new Application_Model_ShowInstance($showInstanceId);
}catch(Exception $e){
$this->view->show_error = true;
return false;
}
$start_timestamp = $show->getShowStart();
$end_timestamp = $show->getShowEnd();
@ -336,11 +390,21 @@ class ScheduleController extends Zend_Controller_Action
public function showContentDialogAction()
{
$showInstanceId = $this->_getParam('id');
$show = new Application_Model_ShowInstance($showInstanceId);
try{
$show = new Application_Model_ShowInstance($showInstanceId);
}catch(Exception $e){
$this->view->show_error = true;
return false;
}
$originalShowId = $show->isRebroadcast();
if (!is_null($originalShowId)){
$originalShow = new Application_Model_ShowInstance($originalShowId);
try{
$originalShow = new Application_Model_ShowInstance($originalShowId);
}catch(Exception $e){
$this->view->show_error = true;
return false;
}
$originalShowName = $originalShow->getName();
$originalShowStart = $originalShow->getShowStart();
@ -365,6 +429,12 @@ class ScheduleController extends Zend_Controller_Action
$isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true;
$showInstanceId = $this->_getParam('id');
try{
$showInstance = new Application_Model_ShowInstance($showInstanceId);
}catch(Exception $e){
$this->view->show_error = true;
return false;
}
$formWhat = new Application_Form_AddShowWhat();
$formWho = new Application_Form_AddShowWho();
@ -385,7 +455,6 @@ class ScheduleController extends Zend_Controller_Action
$this->view->style = $formStyle;
$this->view->addNewShow = false;
$showInstance = new Application_Model_ShowInstance($showInstanceId);
$show = new Application_Model_Show($showInstance->getShowId());
$formWhat->populate(array('add_show_id' => $show->getId(),
@ -494,7 +563,7 @@ class ScheduleController extends Zend_Controller_Action
foreach($js as $j){
$data[$j["name"]] = $j["value"];
}
Logging::log("id:".$data['add_show_id']);
$show = new Application_Model_Show($data['add_show_id']);
$startDateModified = true;
@ -681,7 +750,12 @@ class ScheduleController extends Zend_Controller_Action
if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
$showInstanceId = $this->_getParam('id');
$showInstance = new Application_Model_ShowInstance($showInstanceId);
try{
$showInstance = new Application_Model_ShowInstance($showInstanceId);
}catch(Exception $e){
$this->view->show_error = true;
return false;
}
$show = new Application_Model_Show($showInstance->getShowId());
$show->cancelShow($showInstance->getShowStart());
@ -695,7 +769,12 @@ class ScheduleController extends Zend_Controller_Action
if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
$showInstanceId = $this->_getParam('id');
$show = new Application_Model_ShowInstance($showInstanceId);
try{
$show = new Application_Model_ShowInstance($showInstanceId);
}catch(Exception $e){
$this->view->show_error = true;
return false;
}
$show->clearShow();
$show->deleteShow();
// send 'cancel-current-show' command to pypo

View file

@ -119,6 +119,17 @@ class Application_Model_Show {
WHERE starts >= '{$day_timestamp}' AND show_id = {$this->_showId}";
$CC_DBC->query($sql);
// check if we can safely delete the show
$showInstancesRow = CcShowInstancesQuery::create()
->filterByDbShowId($this->_showId)
->findOne();
if(is_null($showInstancesRow)){
$sql = "DELETE FROM cc_show WHERE id = {$this->_showId}";
$CC_DBC->query($sql);
}
Application_Model_RabbitMq::PushSchedule();
}
@ -1002,7 +1013,6 @@ class Application_Model_Show {
}
$sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id={$show_id}";
Logging::log($sql);
$rebroadcasts = $CC_DBC->GetAll($sql);
self::createRebroadcastInstances($rebroadcasts, $currentUtcTimestamp, $show_id, $show_instance_id, $utcStartDateTime, $duration);

View file

@ -144,7 +144,6 @@ class Application_Model_Subjects {
global $CC_CONFIG, $CC_DBC;
$sql = "SELECT login_attempts FROM ".$CC_CONFIG['subjTable']." WHERE login='$login'";
$res = $CC_DBC->getOne($sql);
Logging::log($res);
if (PEAR::isError($res)) {
return $res;
}