Merge branch 'master' of dev.sourcefabric.org:airtime
This commit is contained in:
commit
88ba36601f
|
@ -266,7 +266,7 @@ class Application_Common_DateHelper
|
|||
|
||||
public static function ConvertToLocalDateTime($p_dateString){
|
||||
$dateTime = new DateTime($p_dateString, new DateTimeZone("UTC"));
|
||||
$dateTime->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
||||
$dateTime->setTimezone(new DateTimeZone(Application_Model_Preference::GetTimezone()));
|
||||
|
||||
return $dateTime;
|
||||
}
|
||||
|
|
|
@ -64,14 +64,8 @@ class ApiController extends Zend_Controller_Action
|
|||
|
||||
public function versionAction()
|
||||
{
|
||||
// disable the view and the layout
|
||||
$this->view->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender(true);
|
||||
|
||||
$jsonStr = json_encode( array(
|
||||
$this->_helper->json->sendJson( array(
|
||||
"version" => Application_Model_Preference::GetAirtimeVersion()));
|
||||
echo $jsonStr;
|
||||
die();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -80,9 +74,6 @@ class ApiController extends Zend_Controller_Action
|
|||
*/
|
||||
public function calendarInitAction()
|
||||
{
|
||||
$this->view->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender(true);
|
||||
|
||||
if (is_null(Zend_Auth::getInstance()->getStorage()->read())) {
|
||||
header('HTTP/1.0 401 Unauthorized');
|
||||
print _('You are not allowed to access this resource.');
|
||||
|
@ -97,6 +88,8 @@ class ApiController extends Zend_Controller_Action
|
|||
"timeInterval" => Application_Model_Preference::GetCalendarTimeInterval(),
|
||||
"weekStartDay" => Application_Model_Preference::GetWeekStartDay()
|
||||
);
|
||||
|
||||
$this->_helper->json->sendJson(array());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -107,10 +100,6 @@ class ApiController extends Zend_Controller_Action
|
|||
*/
|
||||
public function getMediaAction()
|
||||
{
|
||||
// disable the view and the layout
|
||||
$this->view->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender(true);
|
||||
|
||||
$fileId = $this->_getParam("file");
|
||||
|
||||
$media = Application_Model_StoredFile::RecallById($fileId);
|
||||
|
@ -151,7 +140,7 @@ class ApiController extends Zend_Controller_Action
|
|||
}
|
||||
}
|
||||
|
||||
return;
|
||||
$this->_helper->json->sendJson(array());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -359,22 +348,15 @@ class ApiController extends Zend_Controller_Action
|
|||
|
||||
public function scheduleAction()
|
||||
{
|
||||
// disable the view and the layout
|
||||
$this->view->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender(true);
|
||||
|
||||
$data = Application_Model_Schedule::getSchedule();
|
||||
header("Content-Type: application/json");
|
||||
|
||||
echo json_encode($data, JSON_FORCE_OBJECT);
|
||||
die();
|
||||
$this->_helper->json->sendJson($data, false, true);
|
||||
}
|
||||
|
||||
public function notifyMediaItemStartPlayAction()
|
||||
{
|
||||
// disable the view and the layout
|
||||
$this->view->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender(true);
|
||||
|
||||
$media_id = $this->_getParam("media_id");
|
||||
Logging::debug("Received notification of new media item start: $media_id");
|
||||
Application_Model_Schedule::UpdateMediaPlayedStatus($media_id);
|
||||
|
@ -404,8 +386,7 @@ class ApiController extends Zend_Controller_Action
|
|||
Logging::info($e);
|
||||
}
|
||||
|
||||
echo json_encode(array("status"=>1, "message"=>""));
|
||||
die();
|
||||
$this->_helper->json->sendJson(array("status"=>1, "message"=>""));
|
||||
}
|
||||
|
||||
public function recordedShowsAction()
|
||||
|
@ -493,10 +474,6 @@ class ApiController extends Zend_Controller_Action
|
|||
|
||||
public function mediaMonitorSetupAction()
|
||||
{
|
||||
// disable the view and the layout
|
||||
$this->view->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender(true);
|
||||
|
||||
$this->view->stor = Application_Model_MusicDir::getStorDir()->getDirectory();
|
||||
|
||||
$watchedDirs = Application_Model_MusicDir::getWatchedDirs();
|
||||
|
@ -612,8 +589,6 @@ class ApiController extends Zend_Controller_Action
|
|||
if ( !preg_match('/^md\d+$/', $k) ) { continue; }
|
||||
$info_json = json_decode($raw_json, $assoc = true);
|
||||
|
||||
Logging::info($info_json);
|
||||
|
||||
// Log invalid requests
|
||||
if ( !array_key_exists('mode', $info_json) ) {
|
||||
Logging::info("Received bad request(key=$k), no 'mode' parameter. Bad request is:");
|
||||
|
@ -940,38 +915,24 @@ class ApiController extends Zend_Controller_Action
|
|||
* out a message to pypo that a potential change has been made. */
|
||||
public function getFilesWithoutReplayGainAction()
|
||||
{
|
||||
// disable the view and the layout
|
||||
$this->view->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender(true);
|
||||
|
||||
$dir_id = $this->_getParam('dir_id');
|
||||
|
||||
//connect to db and get get sql
|
||||
$rows = Application_Model_StoredFile::listAllFiles2($dir_id, 100);
|
||||
|
||||
echo json_encode($rows);
|
||||
die();
|
||||
$this->_helper->json->sendJson($rows);
|
||||
}
|
||||
|
||||
public function getFilesWithoutSilanValueAction()
|
||||
{
|
||||
// disable the view and the layout
|
||||
$this->view->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender(true);
|
||||
|
||||
//connect to db and get get sql
|
||||
$rows = Application_Model_StoredFile::getAllFilesWithoutSilan();
|
||||
|
||||
echo json_encode($rows);
|
||||
die();
|
||||
$this->_helper->json->sendJson($rows);
|
||||
}
|
||||
|
||||
public function updateReplayGainValueAction()
|
||||
{
|
||||
// disable the view and the layout
|
||||
$this->view->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender(true);
|
||||
|
||||
$request = $this->getRequest();
|
||||
$data = json_decode($request->getParam('data'));
|
||||
|
||||
|
@ -983,16 +944,11 @@ class ApiController extends Zend_Controller_Action
|
|||
$file->save();
|
||||
}
|
||||
|
||||
echo json_encode(array());
|
||||
die();
|
||||
$this->_helper->json->sendJson(array());
|
||||
}
|
||||
|
||||
public function updateCueValuesBySilanAction()
|
||||
{
|
||||
// disable the view and the layout
|
||||
$this->view->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender(true);
|
||||
|
||||
$request = $this->getRequest();
|
||||
$data = json_decode($request->getParam('data'), $assoc = true);
|
||||
|
||||
|
@ -1024,8 +980,7 @@ class ApiController extends Zend_Controller_Action
|
|||
$file->save();
|
||||
}
|
||||
|
||||
echo json_encode(array());
|
||||
die();
|
||||
$this->_helper->json->sendJson(array());
|
||||
}
|
||||
|
||||
public function notifyWebstreamDataAction()
|
||||
|
@ -1094,5 +1049,4 @@ class ApiController extends Zend_Controller_Action
|
|||
Application_Model_StreamSetting::SetListenerStatError($k, $v);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -164,16 +164,25 @@ class PreferenceController extends Zend_Controller_Action
|
|||
foreach ($temp as $t) {
|
||||
$setting[$t['keyname']] = $t['value'];
|
||||
}
|
||||
|
||||
$name_map = array('ogg' => 'Ogg Vorbis',
|
||||
'aacplus' => 'AAC+',
|
||||
'aac' => 'AAC',
|
||||
'opus' => 'Opus',
|
||||
'mp3' => 'MP3'
|
||||
);
|
||||
|
||||
// get predefined type and bitrate from pref table
|
||||
$temp_types = Application_Model_Preference::GetStreamType();
|
||||
$stream_types = array();
|
||||
foreach ($temp_types as $type) {
|
||||
if (trim($type) == "ogg") {
|
||||
$temp = "OGG/VORBIS";
|
||||
$type = strtolower(trim($type));
|
||||
if (isset($name_map[$type])) {
|
||||
$name = $name_map[$type];
|
||||
} else {
|
||||
$temp = strtoupper(trim($type));
|
||||
$name = $type;
|
||||
}
|
||||
$stream_types[trim($type)] = $temp;
|
||||
$stream_types[$type] = $name;
|
||||
}
|
||||
|
||||
$temp_bitrate = Application_Model_Preference::GetStreamBitrate();
|
||||
|
|
|
@ -16,21 +16,21 @@ class ScheduleController extends Zend_Controller_Action
|
|||
->addActionContext('edit-show', 'json')
|
||||
->addActionContext('move-show', 'json')
|
||||
->addActionContext('resize-show', 'json')
|
||||
->addActionContext('delete-show', 'json')
|
||||
->addActionContext('delete-show-instance', 'json')
|
||||
->addActionContext('show-content-dialog', 'json')
|
||||
->addActionContext('clear-show', 'json')
|
||||
->addActionContext('get-current-playlist', 'json')
|
||||
->addActionContext('remove-group', 'json')
|
||||
->addActionContext('populate-show-form', 'json')
|
||||
->addActionContext('populate-show-instance-form', 'json')
|
||||
->addActionContext('cancel-show', 'json')
|
||||
->addActionContext('populate-repeating-show-instance-form', 'json')
|
||||
->addActionContext('delete-show', 'json')
|
||||
->addActionContext('cancel-current-show', 'json')
|
||||
->addActionContext('get-form', 'json')
|
||||
->addActionContext('upload-to-sound-cloud', 'json')
|
||||
->addActionContext('content-context-menu', 'json')
|
||||
->addActionContext('set-time-scale', 'json')
|
||||
->addActionContext('set-time-interval', 'json')
|
||||
->addActionContext('edit-show-instance', 'json')
|
||||
->addActionContext('edit-repeating-show-instance', 'json')
|
||||
->addActionContext('dj-edit-show', 'json')
|
||||
->addActionContext('calculate-duration', 'json')
|
||||
->addActionContext('get-current-show', 'json')
|
||||
|
@ -90,13 +90,14 @@ class ScheduleController extends Zend_Controller_Action
|
|||
$this->view->headLink()->appendStylesheet($baseUrl.'css/showbuilder.css?'.$CC_CONFIG['airtime_version']);
|
||||
//End Show builder JS/CSS requirements
|
||||
|
||||
$this->createShowFormAction(true);
|
||||
|
||||
Application_Model_Schedule::createNewFormSections($this->view);
|
||||
$user = Application_Model_User::getCurrentUser();
|
||||
if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
|
||||
$this->view->preloadShowForm = true;
|
||||
}
|
||||
|
||||
$this->view->addNewShow = true;
|
||||
$this->view->headScript()->appendScript(
|
||||
"var calendarPref = {};\n".
|
||||
"calendarPref.weekStart = ".Application_Model_Preference::GetWeekStartDay().";\n".
|
||||
|
@ -111,16 +112,17 @@ class ScheduleController extends Zend_Controller_Action
|
|||
|
||||
public function eventFeedAction()
|
||||
{
|
||||
$service_user = new Application_Service_UserService();
|
||||
$currentUser = $service_user->getCurrentUser();
|
||||
|
||||
$start = new DateTime($this->_getParam('start', null));
|
||||
$start->setTimezone(new DateTimeZone("UTC"));
|
||||
$end = new DateTime($this->_getParam('end', null));
|
||||
$end->setTimezone(new DateTimeZone("UTC"));
|
||||
|
||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
$user = new Application_Model_User($userInfo->id);
|
||||
$editable = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
|
||||
$events = &Application_Model_Show::getFullCalendarEvents($start, $end,
|
||||
$currentUser->isAdminOrPM());
|
||||
|
||||
$events = &Application_Model_Show::getFullCalendarEvents($start, $end, $editable);
|
||||
$this->view->events = $events;
|
||||
}
|
||||
|
||||
|
@ -161,22 +163,16 @@ class ScheduleController extends Zend_Controller_Action
|
|||
{
|
||||
$deltaDay = $this->_getParam('day');
|
||||
$deltaMin = $this->_getParam('min');
|
||||
$showInstanceId = $this->_getParam('showInstanceId');
|
||||
|
||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
$user = new Application_Model_User($userInfo->id);
|
||||
|
||||
if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
|
||||
try {
|
||||
$showInstance = new Application_Model_ShowInstance($showInstanceId);
|
||||
} catch (Exception $e) {
|
||||
$this->view->show_error = true;
|
||||
|
||||
return false;
|
||||
}
|
||||
$error = $showInstance->moveShow($deltaDay, $deltaMin);
|
||||
try {
|
||||
$service_calendar = new Application_Service_CalendarService(
|
||||
$this->_getParam('showInstanceId'));
|
||||
} catch (Exception $e) {
|
||||
$this->view->show_error = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
$error = $service_calendar->moveShow($deltaDay, $deltaMin);
|
||||
if (isset($error)) {
|
||||
$this->view->error = $error;
|
||||
}
|
||||
|
@ -207,28 +203,17 @@ class ScheduleController extends Zend_Controller_Action
|
|||
}
|
||||
}
|
||||
|
||||
public function deleteShowAction()
|
||||
public function deleteShowInstanceAction()
|
||||
{
|
||||
$showInstanceId = $this->_getParam('id');
|
||||
$instanceId = $this->_getParam('id');
|
||||
|
||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
$user = new Application_Model_User($userInfo->id);
|
||||
$service_show = new Application_Service_ShowService();
|
||||
$showId = $service_show->deleteShow($instanceId, true);
|
||||
|
||||
if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
|
||||
|
||||
try {
|
||||
$showInstance = new Application_Model_ShowInstance($showInstanceId);
|
||||
} catch (Exception $e) {
|
||||
Logging::info($e->getMessage());
|
||||
$this->view->show_error = true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$showInstance->delete();
|
||||
|
||||
$this->view->show_id = $showInstance->getShowId();
|
||||
if (!$showId) {
|
||||
$this->view->show_error = true;
|
||||
}
|
||||
$this->view->show_id = $showId;
|
||||
}
|
||||
|
||||
public function uploadToSoundCloudAction()
|
||||
|
@ -251,107 +236,11 @@ class ScheduleController extends Zend_Controller_Action
|
|||
|
||||
public function makeContextMenuAction()
|
||||
{
|
||||
$id = $this->_getParam('id');
|
||||
$menu = array();
|
||||
$epochNow = time();
|
||||
$baseUrl = Application_Common_OsPath::getBaseDir();
|
||||
$instanceId = $this->_getParam('instanceId');
|
||||
|
||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
$user = new Application_Model_User($userInfo->id);
|
||||
try {
|
||||
$instance = new Application_Model_ShowInstance($id);
|
||||
} catch (Exception $e) {
|
||||
$this->view->show_error = true;
|
||||
$service_calendar = new Application_Service_CalendarService($instanceId);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
|
||||
$isDJ = $user->isHostOfShow($instance->getShowId());
|
||||
|
||||
$showStartLocalDT = Application_Common_DateHelper::ConvertToLocalDateTime($instance->getShowInstanceStart());
|
||||
$showEndLocalDT = Application_Common_DateHelper::ConvertToLocalDateTime($instance->getShowInstanceEnd());
|
||||
|
||||
if ($instance->isRecorded() && $epochNow > $showEndLocalDT->getTimestamp()) {
|
||||
|
||||
$file = $instance->getRecordedFile();
|
||||
$fileId = $file->getId();
|
||||
|
||||
$menu["view_recorded"] = array("name" => _("View Recorded File Metadata"), "icon" => "overview",
|
||||
"url" => $baseUrl."library/edit-file-md/id/".$fileId);
|
||||
}
|
||||
|
||||
if ($epochNow < $showStartLocalDT->getTimestamp()) {
|
||||
if ( ($isAdminOrPM || $isDJ)
|
||||
&& !$instance->isRecorded()
|
||||
&& !$instance->isRebroadcast()) {
|
||||
|
||||
$menu["schedule"] = array("name"=> _("Add / Remove Content"), "icon" => "add-remove-content",
|
||||
"url" => $baseUrl."showbuilder/builder-dialog/");
|
||||
|
||||
$menu["clear"] = array("name"=> _("Remove All Content"), "icon" => "remove-all-content",
|
||||
"url" => $baseUrl."schedule/clear-show");
|
||||
}
|
||||
}
|
||||
|
||||
if (!$instance->isRecorded()) {
|
||||
|
||||
$menu["content"] = array("name"=> _("Show Content"), "icon" => "overview", "url" => $baseUrl."schedule/show-content-dialog");
|
||||
}
|
||||
|
||||
if ($showEndLocalDT->getTimestamp() <= $epochNow
|
||||
&& $instance->isRecorded()
|
||||
&& Application_Model_Preference::GetUploadToSoundcloudOption()) {
|
||||
|
||||
$file = $instance->getRecordedFile();
|
||||
$fileId = $file->getId();
|
||||
$scid = $instance->getSoundCloudFileId();
|
||||
|
||||
if ($scid > 0) {
|
||||
$url = $file->getSoundCloudLinkToFile();
|
||||
$menu["soundcloud_view"] = array("name" => _("View on Soundcloud"), "icon" => "soundcloud", "url" => $url);
|
||||
}
|
||||
|
||||
$text = is_null($scid) ? _('Upload to SoundCloud') : _('Re-upload to SoundCloud');
|
||||
$menu["soundcloud_upload"] = array("name"=> $text, "icon" => "soundcloud");
|
||||
}
|
||||
|
||||
if ($showStartLocalDT->getTimestamp() <= $epochNow &&
|
||||
$epochNow < $showEndLocalDT->getTimestamp() && $isAdminOrPM) {
|
||||
|
||||
if ($instance->isRecorded()) {
|
||||
$menu["cancel_recorded"] = array("name"=> _("Cancel Current Show"), "icon" => "delete");
|
||||
} else {
|
||||
|
||||
if (!$instance->isRebroadcast()) {
|
||||
$menu["edit"] = array("name"=> _("Edit Show"), "icon" => "edit", "_type"=>"all", "url" => $baseUrl."Schedule/populate-show-form");
|
||||
}
|
||||
|
||||
$menu["cancel"] = array("name"=> _("Cancel Current Show"), "icon" => "delete");
|
||||
}
|
||||
}
|
||||
|
||||
if ($epochNow < $showStartLocalDT->getTimestamp()) {
|
||||
|
||||
if (!$instance->isRebroadcast() && $isAdminOrPM) {
|
||||
$menu["edit"] = array("name"=> _("Edit Show"), "icon" => "edit", "_type"=>"all", "url" => $baseUrl."Schedule/populate-show-form");
|
||||
}
|
||||
|
||||
if ($instance->getShow()->isRepeating() && $isAdminOrPM) {
|
||||
|
||||
//create delete sub menu.
|
||||
$menu["del"] = array("name"=> _("Delete"), "icon" => "delete", "items" => array());
|
||||
|
||||
$menu["del"]["items"]["single"] = array("name"=> _("Delete This Instance"), "icon" => "delete", "url" => $baseUrl."schedule/delete-show");
|
||||
|
||||
$menu["del"]["items"]["following"] = array("name"=> _("Delete This Instance and All Following"), "icon" => "delete", "url" => $baseUrl."schedule/cancel-show");
|
||||
} elseif ($isAdminOrPM) {
|
||||
|
||||
$menu["del"] = array("name"=> _("Delete"), "icon" => "delete", "url" => $baseUrl."schedule/delete-show");
|
||||
}
|
||||
}
|
||||
|
||||
$this->view->items = $menu;
|
||||
$this->view->items = $service_calendar->makeContextMenu();
|
||||
}
|
||||
|
||||
public function clearShowAction()
|
||||
|
@ -416,32 +305,6 @@ class ScheduleController extends Zend_Controller_Action
|
|||
$this->view->show_name = isset($show[0])?$show[0]["name"]:"";
|
||||
}
|
||||
|
||||
public function removeGroupAction()
|
||||
{
|
||||
$showInstanceId = $this->sched_sess->showInstanceId;
|
||||
$group_id = $this->_getParam('groupId');
|
||||
|
||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
$user = new Application_Model_User($userInfo->id);
|
||||
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)) || $user->isHostOfShow($show->getShowId())) {
|
||||
$show->removeGroupFromShow($group_id);
|
||||
}
|
||||
|
||||
$this->view->showContent = $show->getShowContent();
|
||||
$this->view->timeFilled = $show->getTimeScheduled();
|
||||
$this->view->percentFilled = $show->getPercentScheduled();
|
||||
$this->view->chosen = $this->view->render('schedule/scheduled-content.phtml');
|
||||
unset($this->view->showContent);
|
||||
}
|
||||
|
||||
public function showContentDialogAction()
|
||||
{
|
||||
$showInstanceId = $this->_getParam('id');
|
||||
|
@ -484,256 +347,66 @@ class ScheduleController extends Zend_Controller_Action
|
|||
unset($this->view->showContent);
|
||||
}
|
||||
|
||||
// we removed edit show instance option in menu item
|
||||
// this feature is disabled in 2.1 and should be back in 2.2
|
||||
/*public function populateShowInstanceFormAction(){
|
||||
$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();
|
||||
$formLive = new Application_Form_AddShowLiveStream();
|
||||
public function populateRepeatingShowInstanceFormAction()
|
||||
{
|
||||
$showId = $this->_getParam('showId');
|
||||
$instanceId = $this->_getParam('instanceId');
|
||||
$service_showForm = new Application_Service_ShowFormService($showId, $instanceId);
|
||||
|
||||
$formWhat->removeDecorator('DtDdWrapper');
|
||||
$formWho->removeDecorator('DtDdWrapper');
|
||||
$formWhen->removeDecorator('DtDdWrapper');
|
||||
$formRepeats->removeDecorator('DtDdWrapper');
|
||||
$formStyle->removeDecorator('DtDdWrapper');
|
||||
$forms = $this->createShowFormAction();
|
||||
|
||||
$service_showForm->delegateShowInstanceFormPopulation($forms);
|
||||
|
||||
$this->view->what = $formWhat;
|
||||
$this->view->when = $formWhen;
|
||||
$this->view->repeats = $formRepeats;
|
||||
$this->view->who = $formWho;
|
||||
$this->view->style = $formStyle;
|
||||
$this->view->live = $formLive;
|
||||
$this->view->addNewShow = false;
|
||||
|
||||
$showInstanceId = $this->_getParam('id');
|
||||
|
||||
$show_instance = CcShowInstancesQuery::create()->findPK($showInstanceId);
|
||||
$show = new Application_Model_Show($show_instance->getDbShowId());
|
||||
|
||||
$starts_string = $show_instance->getDbStarts();
|
||||
$ends_string = $show_instance->getDbEnds();
|
||||
|
||||
$starts_datetime = new DateTime($starts_string, new DateTimeZone("UTC"));
|
||||
$ends_datetime = new DateTime($ends_string, new DateTimeZone("UTC"));
|
||||
|
||||
$starts_datetime->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
||||
$ends_datetime->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
||||
|
||||
$instance_duration = $starts_datetime->diff($ends_datetime);
|
||||
|
||||
$formWhat->populate(array('add_show_id' => $show->getId(),
|
||||
'add_show_instance_id' => $showInstanceId,
|
||||
'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' => $starts_datetime->format("Y-m-d"),
|
||||
'add_show_start_time' => $starts_datetime->format("H:i"),
|
||||
'add_show_end_date_no_repeat' => $ends_datetime->format("Y-m-d"),
|
||||
'add_show_end_time' => $ends_datetime->format("H:i"),
|
||||
'add_show_duration' => $instance_duration->format("%h")));
|
||||
|
||||
$formWhat->disable();
|
||||
$formWho->disable();
|
||||
$formWhen->disableRepeatCheckbox();
|
||||
$formRepeats->disable();
|
||||
$formStyle->disable();
|
||||
|
||||
//$formRecord->disable();
|
||||
//$formAbsoluteRebroadcast->disable();
|
||||
//$formRebroadcast->disable();
|
||||
|
||||
$this->view->action = "edit-show-instance";
|
||||
$this->view->action = "edit-repeating-show-instance";
|
||||
$this->view->newForm = $this->view->render('schedule/add-show-form.phtml');
|
||||
}*/
|
||||
}
|
||||
|
||||
public function populateShowFormAction()
|
||||
{
|
||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
$user = new Application_Model_User($userInfo->id);
|
||||
$service_user = new Application_Service_UserService();
|
||||
$currentUser = $service_user->getCurrentUser();
|
||||
|
||||
$showInstanceId = $this->_getParam('id');
|
||||
|
||||
$this->view->action = "edit-show";
|
||||
try {
|
||||
$showInstance = new Application_Model_ShowInstance($showInstanceId);
|
||||
} catch (Exception $e) {
|
||||
$this->view->show_error = true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
|
||||
$isDJ = $user->isHostOfShow($showInstance->getShowId());
|
||||
|
||||
if (!($isAdminOrPM || $isDJ)) {
|
||||
return;
|
||||
}
|
||||
$showId = $this->_getParam('showId');
|
||||
$instanceId = $this->_getParam('instanceId');
|
||||
$service_showForm = new Application_Service_ShowFormService($showId, $instanceId);
|
||||
|
||||
$isAdminOrPM = $currentUser->isAdminOrPM();
|
||||
/*$isHostOfShow = $currentUser->isHostOfShow($showId);
|
||||
// in case a user was once a dj and had been assigned to a show
|
||||
// but was then changed to an admin user we need to allow
|
||||
// the user to edit the show as an admin (CC-4925)
|
||||
if ($isDJ && !$isAdminOrPM) {
|
||||
if ($isHostOfShow && !$isAdminOrPM) {
|
||||
$this->view->action = "dj-edit-show";
|
||||
}
|
||||
}*/
|
||||
|
||||
$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();
|
||||
$formLive = new Application_Form_AddShowLiveStream();
|
||||
$forms = $this->createShowFormAction();
|
||||
|
||||
$formWhat->removeDecorator('DtDdWrapper');
|
||||
$formWho->removeDecorator('DtDdWrapper');
|
||||
$formWhen->removeDecorator('DtDdWrapper');
|
||||
$formRepeats->removeDecorator('DtDdWrapper');
|
||||
$formStyle->removeDecorator('DtDdWrapper');
|
||||
|
||||
$this->view->what = $formWhat;
|
||||
$this->view->when = $formWhen;
|
||||
$this->view->repeats = $formRepeats;
|
||||
$this->view->who = $formWho;
|
||||
$this->view->style = $formStyle;
|
||||
$this->view->live = $formLive;
|
||||
$this->view->addNewShow = false;
|
||||
|
||||
$show = new Application_Model_Show($showInstance->getShowId());
|
||||
|
||||
$formWhat->populate(array('add_show_id' => $show->getId(),
|
||||
'add_show_instance_id' => $showInstanceId,
|
||||
'add_show_name' => $show->getName(),
|
||||
'add_show_url' => $show->getUrl(),
|
||||
'add_show_genre' => $show->getGenre(),
|
||||
'add_show_description' => $show->getDescription()));
|
||||
|
||||
$startsDateTime = new DateTime($show->getStartDate()." ".$show->getStartTime(), new DateTimeZone("UTC"));
|
||||
$endsDateTime = new DateTime($show->getEndDate()." ".$show->getEndTime(), new DateTimeZone("UTC"));
|
||||
|
||||
$startsDateTime->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
||||
$endsDateTime->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
||||
|
||||
$formWhen->populate(array('add_show_start_date' => $startsDateTime->format("Y-m-d"),
|
||||
'add_show_start_time' => $startsDateTime->format("H:i"),
|
||||
'add_show_end_date_no_repeat' => $endsDateTime->format("Y-m-d"),
|
||||
'add_show_end_time' => $endsDateTime->format("H:i"),
|
||||
'add_show_duration' => $show->getDuration(true),
|
||||
'add_show_repeats' => $show->isRepeating() ? 1 : 0));
|
||||
|
||||
if ($show->isStartDateTimeInPast()) {
|
||||
// for a non-repeating show, we should never allow user to change the start time.
|
||||
// for the repeating show, we should allow because the form works as repeating template form
|
||||
if (!$showInstance->getShow()->isRepeating()) {
|
||||
$formWhen->disableStartDateAndTime();
|
||||
} else {
|
||||
$nextFutureRepeatShow = $show->getNextFutureRepeatShowTime();
|
||||
$formWhen->getElement('add_show_start_date')->setValue($nextFutureRepeatShow["starts"]->format("Y-m-d"));
|
||||
$formWhen->getElement('add_show_start_time')->setValue($nextFutureRepeatShow["starts"]->format("H:i"));
|
||||
$formWhen->getElement('add_show_end_date_no_repeat')->setValue($nextFutureRepeatShow["ends"]->format("Y-m-d"));
|
||||
$formWhen->getElement('add_show_end_time')->setValue($nextFutureRepeatShow["ends"]->format("H:i"));
|
||||
}
|
||||
}
|
||||
|
||||
//need to get the days of the week in the php timezone (for the front end).
|
||||
$days = array();
|
||||
$showDays = CcShowDaysQuery::create()->filterByDbShowId($showInstance->getShowId())->find();
|
||||
foreach ($showDays as $showDay) {
|
||||
$showStartDay = new DateTime($showDay->getDbFirstShow(), new DateTimeZone($showDay->getDbTimezone()));
|
||||
$showStartDay->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
||||
array_push($days, $showStartDay->format('w'));
|
||||
}
|
||||
|
||||
$displayedEndDate = new DateTime($show->getRepeatingEndDate(), new DateTimeZone($showDays[0]->getDbTimezone()));
|
||||
$displayedEndDate->sub(new DateInterval("P1D"));//end dates are stored non-inclusively.
|
||||
$displayedEndDate->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
||||
|
||||
$formRepeats->populate(array('add_show_repeat_type' => $show->getRepeatType(),
|
||||
'add_show_day_check' => $days,
|
||||
'add_show_end_date' => $displayedEndDate->format("Y-m-d"),
|
||||
'add_show_no_end' => ($show->getRepeatingEndDate() == '')));
|
||||
|
||||
$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()));
|
||||
|
||||
$formLive->populate($show->getLiveStreamInfo());
|
||||
|
||||
$formRecord = new Application_Form_AddShowRR();
|
||||
$formAbsoluteRebroadcast = new Application_Form_AddShowAbsoluteRebroadcastDates();
|
||||
$formRebroadcast = new Application_Form_AddShowRebroadcastDates();
|
||||
|
||||
$formRecord->removeDecorator('DtDdWrapper');
|
||||
$formAbsoluteRebroadcast->removeDecorator('DtDdWrapper');
|
||||
$formRebroadcast->removeDecorator('DtDdWrapper');
|
||||
|
||||
$this->view->rr = $formRecord;
|
||||
$this->view->absoluteRebroadcast = $formAbsoluteRebroadcast;
|
||||
$this->view->rebroadcast = $formRebroadcast;
|
||||
|
||||
$formRecord->populate(array('add_show_record' => $show->isRecorded(),
|
||||
'add_show_rebroadcast' => $show->isRebroadcast()));
|
||||
|
||||
$formRecord->getElement('add_show_record')->setOptions(array('disabled' => true));
|
||||
|
||||
|
||||
|
||||
$rebroadcastsRelative = $show->getRebroadcastsRelative();
|
||||
$rebroadcastFormValues = array();
|
||||
$i = 1;
|
||||
foreach ($rebroadcastsRelative as $rebroadcast) {
|
||||
$rebroadcastFormValues["add_show_rebroadcast_date_$i"] = $rebroadcast['day_offset'];
|
||||
$rebroadcastFormValues["add_show_rebroadcast_time_$i"] = Application_Common_DateHelper::removeSecondsFromTime($rebroadcast['start_time']);
|
||||
$i++;
|
||||
}
|
||||
$formRebroadcast->populate($rebroadcastFormValues);
|
||||
|
||||
$rebroadcastsAbsolute = $show->getRebroadcastsAbsolute();
|
||||
$rebroadcastAbsoluteFormValues = array();
|
||||
$i = 1;
|
||||
foreach ($rebroadcastsAbsolute as $rebroadcast) {
|
||||
$rebroadcastAbsoluteFormValues["add_show_rebroadcast_date_absolute_$i"] = $rebroadcast['start_date'];
|
||||
$rebroadcastAbsoluteFormValues["add_show_rebroadcast_time_absolute_$i"] = $rebroadcast['start_time'];
|
||||
$i++;
|
||||
}
|
||||
$formAbsoluteRebroadcast->populate($rebroadcastAbsoluteFormValues);
|
||||
if (!$isAdminOrPM) {
|
||||
$formRecord->disable();
|
||||
$formAbsoluteRebroadcast->disable();
|
||||
$formRebroadcast->disable();
|
||||
}
|
||||
$service_showForm->delegateShowFormPopulation($forms);
|
||||
|
||||
if (!$isAdminOrPM) {
|
||||
$formWhat->disable();
|
||||
$formWho->disable();
|
||||
$formWhen->disable();
|
||||
$formRepeats->disable();
|
||||
$formStyle->disable();
|
||||
foreach ($forms as $form) {
|
||||
$form->disable();
|
||||
}
|
||||
}
|
||||
|
||||
$this->view->action = "edit-show";
|
||||
$this->view->newForm = $this->view->render('schedule/add-show-form.phtml');
|
||||
$this->view->entries = 5;
|
||||
}
|
||||
|
||||
public function getFormAction()
|
||||
{
|
||||
$user = Application_Model_User::getCurrentUser();
|
||||
$service_user = new Application_Service_UserService();
|
||||
$currentUser = $service_user->getCurrentUser();
|
||||
|
||||
if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
|
||||
Application_Model_Schedule::createNewFormSections($this->view);
|
||||
if ($currentUser->isAdminOrPM()) {
|
||||
$this->createShowFormAction(true);
|
||||
$this->view->form = $this->view->render('schedule/add-show-form.phtml');
|
||||
}
|
||||
}
|
||||
|
||||
public function djEditShowAction()
|
||||
/*public function djEditShowAction()
|
||||
{
|
||||
$js = $this->_getParam('data');
|
||||
$data = array();
|
||||
|
@ -751,30 +424,9 @@ class ScheduleController extends Zend_Controller_Action
|
|||
$show->setCustomPassword($data["custom_password"]);
|
||||
|
||||
$this->view->edit = true;
|
||||
}
|
||||
|
||||
/*public function editShowInstanceAction(){
|
||||
$js = $this->_getParam('data');
|
||||
$data = array();
|
||||
|
||||
//need to convert from serialized jQuery array.
|
||||
foreach ($js as $j) {
|
||||
$data[$j["name"]] = $j["value"];
|
||||
}
|
||||
|
||||
$success = Application_Model_Schedule::updateShowInstance($data, $this);
|
||||
if ($success) {
|
||||
$this->view->addNewShow = true;
|
||||
$this->view->newForm = $this->view->render('schedule/add-show-form.phtml');
|
||||
} else {
|
||||
$this->view->addNewShow = false;
|
||||
$this->view->form = $this->view->render('schedule/add-show-form.phtml');
|
||||
}
|
||||
}*/
|
||||
|
||||
public function editShowAction()
|
||||
{
|
||||
//1) Get add_show_start_date since it might not have been sent
|
||||
public function editRepeatingShowInstanceAction(){
|
||||
$js = $this->_getParam('data');
|
||||
$data = array();
|
||||
|
||||
|
@ -783,6 +435,53 @@ class ScheduleController extends Zend_Controller_Action
|
|||
$data[$j["name"]] = $j["value"];
|
||||
}
|
||||
|
||||
$data['add_show_hosts'] = $this->_getParam('hosts');
|
||||
|
||||
$service_showForm = new Application_Service_ShowFormService(
|
||||
$data["add_show_id"], $data["add_show_instance_id"]);
|
||||
$service_show = new Application_Service_ShowService(null, $data);
|
||||
|
||||
$forms = $this->createShowFormAction();
|
||||
|
||||
list($data, $validateStartDate, $validateStartTime, $originalShowStartDateTime) =
|
||||
$service_showForm->preEditShowValidationCheck($data);
|
||||
|
||||
if ($service_showForm->validateShowForms($forms, $data, $validateStartDate,
|
||||
$originalShowStartDateTime, true, $data["add_show_instance_id"])) {
|
||||
|
||||
$service_show->createShowFromRepeatingInstance($data);
|
||||
|
||||
$this->view->addNewShow = true;
|
||||
$this->view->newForm = $this->view->render('schedule/add-show-form.phtml');
|
||||
} else {
|
||||
if (!$validateStartDate) {
|
||||
$this->view->when->getElement('add_show_start_date')->setOptions(array('disabled' => true));
|
||||
}
|
||||
if (!$validateStartTime) {
|
||||
$this->view->when->getElement('add_show_start_time')->setOptions(array('disabled' => true));
|
||||
}
|
||||
$this->view->rr->getElement('add_show_record')->setOptions(array('disabled' => true));
|
||||
$this->view->addNewShow = false;
|
||||
$this->view->action = "edit-show";
|
||||
$this->view->form = $this->view->render('schedule/add-show-form.phtml');
|
||||
}
|
||||
}
|
||||
|
||||
public function editShowAction()
|
||||
{
|
||||
$js = $this->_getParam('data');
|
||||
$data = array();
|
||||
|
||||
//need to convert from serialized jQuery array.
|
||||
foreach ($js as $j) {
|
||||
$data[$j["name"]] = $j["value"];
|
||||
}
|
||||
|
||||
$service_showForm = new Application_Service_ShowFormService(
|
||||
$data["add_show_id"]);
|
||||
$service_show = new Application_Service_ShowService(null, $data, true);
|
||||
|
||||
//TODO: move this to js
|
||||
$data['add_show_hosts'] = $this->_getParam('hosts');
|
||||
$data['add_show_day_check'] = $this->_getParam('days');
|
||||
|
||||
|
@ -790,43 +489,16 @@ class ScheduleController extends Zend_Controller_Action
|
|||
$data['add_show_day_check'] = null;
|
||||
}
|
||||
|
||||
$show = new Application_Model_Show($data['add_show_id']);
|
||||
$forms = $this->createShowFormAction();
|
||||
|
||||
$validateStartDate = true;
|
||||
$validateStartTime = true;
|
||||
if (!array_key_exists('add_show_start_date', $data)) {
|
||||
//Changing the start date was disabled, since the
|
||||
//array key does not exist. We need to repopulate this entry from the db.
|
||||
//The start date will be returned in UTC time, so lets convert it to local time.
|
||||
$dt = Application_Common_DateHelper::ConvertToLocalDateTime($show->getStartDateAndTime());
|
||||
$data['add_show_start_date'] = $dt->format("Y-m-d");
|
||||
list($data, $validateStartDate, $validateStartTime, $originalShowStartDateTime) =
|
||||
$service_showForm->preEditShowValidationCheck($data);
|
||||
|
||||
if (!array_key_exists('add_show_start_time', $data)) {
|
||||
$data['add_show_start_time'] = $dt->format("H:i");
|
||||
$validateStartTime = false;
|
||||
}
|
||||
$validateStartDate = false;
|
||||
}
|
||||
$data['add_show_record'] = $show->isRecorded();
|
||||
if ($service_showForm->validateShowForms($forms, $data, $validateStartDate,
|
||||
$originalShowStartDateTime, true, $data["add_show_instance_id"])) {
|
||||
|
||||
if ($show->isRepeating()) {
|
||||
$nextFutureRepeatShow = $show->getNextFutureRepeatShowTime();
|
||||
$originalShowStartDateTime = $nextFutureRepeatShow["starts"];
|
||||
} else {
|
||||
$originalShowStartDateTime = Application_Common_DateHelper::ConvertToLocalDateTime(
|
||||
$show->getStartDateAndTime());
|
||||
}
|
||||
$service_show->addUpdateShow($data);
|
||||
|
||||
$success = Application_Model_Schedule::addUpdateShow($data, $this,
|
||||
$validateStartDate, $originalShowStartDateTime, true,
|
||||
$data['add_show_instance_id']);
|
||||
|
||||
if ($success) {
|
||||
$scheduler = new Application_Model_Scheduler();
|
||||
$showInstances = CcShowInstancesQuery::create()->filterByDbShowId($data['add_show_id'])->find();
|
||||
foreach ($showInstances as $si) {
|
||||
$scheduler->removeGaps($si->getDbId());
|
||||
}
|
||||
$this->view->addNewShow = true;
|
||||
$this->view->newForm = $this->view->render('schedule/add-show-form.phtml');
|
||||
} else {
|
||||
|
@ -845,6 +517,9 @@ class ScheduleController extends Zend_Controller_Action
|
|||
|
||||
public function addShowAction()
|
||||
{
|
||||
$service_showForm = new Application_Service_ShowFormService(null);
|
||||
//$service_show = new Application_Service_ShowService();
|
||||
|
||||
$js = $this->_getParam('data');
|
||||
$data = array();
|
||||
|
||||
|
@ -853,6 +528,9 @@ class ScheduleController extends Zend_Controller_Action
|
|||
$data[$j["name"]] = $j["value"];
|
||||
}
|
||||
|
||||
$service_show = new Application_Service_ShowService(null, $data);
|
||||
|
||||
// TODO: move this to js
|
||||
$data['add_show_hosts'] = $this->_getParam('hosts');
|
||||
$data['add_show_day_check'] = $this->_getParam('days');
|
||||
|
||||
|
@ -860,42 +538,60 @@ class ScheduleController extends Zend_Controller_Action
|
|||
$data['add_show_day_check'] = null;
|
||||
}
|
||||
|
||||
$validateStartDate = true;
|
||||
$success = Application_Model_Schedule::addUpdateShow($data, $this,
|
||||
$validateStartDate);
|
||||
$forms = $this->createShowFormAction();
|
||||
|
||||
$this->view->addNewShow = true;
|
||||
|
||||
if ($service_showForm->validateShowForms($forms, $data)) {
|
||||
$service_show->addUpdateShow($data);
|
||||
|
||||
$this->view->newForm = $this->view->render('schedule/add-show-form.phtml');
|
||||
//send new show forms to the user
|
||||
$this->createShowFormAction(true);
|
||||
|
||||
if ($success) {
|
||||
$this->view->addNewShow = true;
|
||||
$this->view->newForm = $this->view->render(
|
||||
'schedule/add-show-form.phtml');
|
||||
Logging::debug("Show creation succeeded");
|
||||
} else {
|
||||
$this->view->addNewShow = true;
|
||||
$this->view->form = $this->view->render(
|
||||
'schedule/add-show-form.phtml');
|
||||
$this->view->form = $this->view->render('schedule/add-show-form.phtml');
|
||||
Logging::debug("Show creation failed");
|
||||
}
|
||||
}
|
||||
|
||||
public function cancelShowAction()
|
||||
public function createShowFormAction($populateDefaults=false)
|
||||
{
|
||||
$user = Application_Model_User::getCurrentUser();
|
||||
$service_showForm = new Application_Service_ShowFormService();
|
||||
|
||||
if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
|
||||
$showInstanceId = $this->_getParam('id');
|
||||
$forms = $service_showForm->createShowForms();
|
||||
|
||||
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->getShowInstanceStart());
|
||||
$this->view->show_id = $showInstance->getShowId();
|
||||
// populate forms with default values
|
||||
if ($populateDefaults) {
|
||||
$service_showForm->populateNewShowForms(
|
||||
$forms["what"], $forms["when"], $forms["repeats"]);
|
||||
}
|
||||
|
||||
$this->view->what = $forms["what"];
|
||||
$this->view->when = $forms["when"];
|
||||
$this->view->repeats = $forms["repeats"];
|
||||
$this->view->live = $forms["live"];
|
||||
$this->view->rr = $forms["record"];
|
||||
$this->view->absoluteRebroadcast = $forms["abs_rebroadcast"];
|
||||
$this->view->rebroadcast = $forms["rebroadcast"];
|
||||
$this->view->who = $forms["who"];
|
||||
$this->view->style = $forms["style"];
|
||||
|
||||
return $forms;
|
||||
}
|
||||
|
||||
public function deleteShowAction()
|
||||
{
|
||||
$instanceId = $this->_getParam('id');
|
||||
|
||||
$service_show = new Application_Service_ShowService();
|
||||
$showId = $service_show->deleteShow($instanceId);
|
||||
|
||||
if (!$showId) {
|
||||
$this->view->show_error = true;
|
||||
}
|
||||
$this->view->show_id = $showId;
|
||||
}
|
||||
|
||||
public function cancelCurrentShowAction()
|
||||
|
@ -962,32 +658,9 @@ class ScheduleController extends Zend_Controller_Action
|
|||
|
||||
public function calculateDurationAction()
|
||||
{
|
||||
$startParam = $this->_getParam('startTime');
|
||||
$endParam = $this->_getParam('endTime');
|
||||
|
||||
try {
|
||||
$startDateTime = new DateTime($startParam);
|
||||
$endDateTime = new DateTime($endParam);
|
||||
|
||||
$UTCStartDateTime = $startDateTime->setTimezone(new DateTimeZone('UTC'));
|
||||
$UTCEndDateTime = $endDateTime->setTimezone(new DateTimeZone('UTC'));
|
||||
|
||||
$duration = $UTCEndDateTime->diff($UTCStartDateTime);
|
||||
|
||||
$day = intval($duration->format('%d'));
|
||||
if ($day > 0) {
|
||||
$hour = intval($duration->format('%h'));
|
||||
$min = intval($duration->format('%i'));
|
||||
$hour += $day * 24;
|
||||
$hour = min($hour, 99);
|
||||
$sign = $duration->format('%r');
|
||||
$result = sprintf('%s%02dh %02dm', $sign, $hour, $min);
|
||||
} else {
|
||||
$result = $duration->format('%r%Hh %Im');
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$result = "Invalid Date";
|
||||
}
|
||||
$service_showForm = new Application_Service_ShowFormService();
|
||||
$result = $service_showForm->calculateDuration($this->_getParam('startTime'),
|
||||
$this->_getParam('endTime'));
|
||||
|
||||
echo Zend_Json::encode($result);
|
||||
exit();
|
||||
|
|
|
@ -40,6 +40,14 @@ class Application_Form_AddShowAbsoluteRebroadcastDates extends Zend_Form_SubForm
|
|||
}
|
||||
}
|
||||
|
||||
public function isValid($formData) {
|
||||
if (parent::isValid($formData)) {
|
||||
return $this->checkReliantFields($formData);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function checkReliantFields($formData)
|
||||
{
|
||||
$noError = true;
|
||||
|
|
|
@ -45,6 +45,14 @@ class Application_Form_AddShowRebroadcastDates extends Zend_Form_SubForm
|
|||
}
|
||||
}
|
||||
|
||||
public function isValid($formData) {
|
||||
if (parent::isValid($formData)) {
|
||||
return $this->checkReliantFields($formData);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function checkReliantFields($formData)
|
||||
{
|
||||
$noError = true;
|
||||
|
|
|
@ -5,6 +5,11 @@ class Application_Form_AddShowRepeats extends Zend_Form_SubForm
|
|||
|
||||
public function init()
|
||||
{
|
||||
|
||||
$linked = new Zend_Form_Element_Checkbox("add_show_linked");
|
||||
$linked->setLabel(_("Link:"));
|
||||
$this->addElement($linked);
|
||||
|
||||
//Add type select
|
||||
$this->addElement('select', 'add_show_repeat_type', array(
|
||||
'required' => true,
|
||||
|
@ -35,6 +40,15 @@ class Application_Form_AddShowRepeats extends Zend_Form_SubForm
|
|||
),
|
||||
));
|
||||
|
||||
$repeatMonthlyType = new Zend_Form_Element_Radio("add_show_monthly_repeat_type");
|
||||
$repeatMonthlyType
|
||||
->setLabel(_("Repeat By:"))
|
||||
->setRequired(true)
|
||||
->setMultiOptions(
|
||||
array(2 => _("day of the month"), 3 => _("day of the week")))
|
||||
->setValue(2);
|
||||
$this->addElement($repeatMonthlyType);
|
||||
|
||||
// Add end date element
|
||||
$this->addElement('text', 'add_show_end_date', array(
|
||||
'label' => _('Date End:'),
|
||||
|
@ -66,6 +80,14 @@ class Application_Form_AddShowRepeats extends Zend_Form_SubForm
|
|||
}
|
||||
}
|
||||
|
||||
public function isValid($formData) {
|
||||
if (parent::isValid($formData)) {
|
||||
return $this->checkReliantFields($formData);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function checkReliantFields($formData)
|
||||
{
|
||||
if (!$formData['add_show_no_end']) {
|
||||
|
|
|
@ -87,6 +87,16 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
|
|||
|
||||
}
|
||||
|
||||
public function isWhenFormValid($formData, $validateStartDate, $originalStartDate,
|
||||
$update, $instanceId) {
|
||||
if (parent::isValid($formData)) {
|
||||
return self::checkReliantFields($formData, $validateStartDate,
|
||||
$originalStartDate, $update, $instanceId);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function checkReliantFields($formData, $validateStartDate, $originalStartDate=null, $update=false, $instanceId=null)
|
||||
{
|
||||
$valid = true;
|
||||
|
@ -285,7 +295,8 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
|
|||
$rebroadcastShowStart->setTimezone(new DateTimeZone('UTC'));
|
||||
$rebroadcastShowEnd = clone $rebroadcastShowStart;
|
||||
$rebroadcastShowEnd->add(new DateInterval($durationToAdd));
|
||||
$overlapping = Application_Model_Schedule::checkOverlappingShows($rebroadcastShowStart, $rebroadcastShowEnd, $update, $instanceId);
|
||||
$overlapping = Application_Model_Schedule::checkOverlappingShows($rebroadcastShowStart,
|
||||
$rebroadcastShowEnd, $update, null, $formData["add_show_id"]);
|
||||
if ($overlapping) {
|
||||
$valid = false;
|
||||
$this->getElement('add_show_duration')->setErrors(array(_('Cannot schedule overlapping shows')));
|
||||
|
|
|
@ -385,6 +385,7 @@ SELECT showt.name AS show_name,
|
|||
showt.color AS show_color,
|
||||
showt.background_color AS show_background_color,
|
||||
showt.id AS show_id,
|
||||
showt.linked AS linked,
|
||||
si.starts AS si_starts,
|
||||
si.ends AS si_ends,
|
||||
si.time_filled AS si_time_filled,
|
||||
|
@ -961,7 +962,7 @@ SQL;
|
|||
Application_Common_Database::prepareAndExecute($sql, array(':file_id'=>$fileId), 'execute');
|
||||
}
|
||||
|
||||
public static function createNewFormSections($p_view)
|
||||
/*public static function createNewFormSections($p_view)
|
||||
{
|
||||
$formWhat = new Application_Form_AddShowWhat();
|
||||
$formWho = new Application_Form_AddShowWho();
|
||||
|
@ -1006,7 +1007,7 @@ SQL;
|
|||
$p_view->absoluteRebroadcast = $formAbsoluteRebroadcast;
|
||||
$p_view->rebroadcast = $formRebroadcast;
|
||||
$p_view->addNewShow = true;
|
||||
}
|
||||
}*/
|
||||
|
||||
/* This function is responsible for handling the case where an individual
|
||||
* show instance in a repeating show was edited (via the context menu in the Calendar).
|
||||
|
@ -1089,7 +1090,7 @@ SQL;
|
|||
* Another clean-up is to move all the form manipulation to the proper form class.....
|
||||
* -Martin
|
||||
*/
|
||||
public static function addUpdateShow($data, $controller, $validateStartDate,
|
||||
/*public static function addUpdateShow($data, $controller, $validateStartDate,
|
||||
$originalStartDate=null, $update=false, $instanceId=null)
|
||||
{
|
||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
|
@ -1141,13 +1142,13 @@ SQL;
|
|||
|
||||
$data["add_show_duration"] = $hValue.":".$mValue;
|
||||
|
||||
$formRecord = new Application_Form_AddShowRR();
|
||||
$formAbsoluteRebroadcast = new Application_Form_AddShowAbsoluteRebroadcastDates();
|
||||
$formRebroadcast = new Application_Form_AddShowRebroadcastDates();
|
||||
$formRecord = new Application_Form_AddShowRR();
|
||||
$formAbsoluteRebroadcast = new Application_Form_AddShowAbsoluteRebroadcastDates();
|
||||
$formRebroadcast = new Application_Form_AddShowRebroadcastDates();
|
||||
|
||||
$formRecord->removeDecorator('DtDdWrapper');
|
||||
$formAbsoluteRebroadcast->removeDecorator('DtDdWrapper');
|
||||
$formRebroadcast->removeDecorator('DtDdWrapper');
|
||||
$formRecord->removeDecorator('DtDdWrapper');
|
||||
$formAbsoluteRebroadcast->removeDecorator('DtDdWrapper');
|
||||
$formRebroadcast->removeDecorator('DtDdWrapper');
|
||||
|
||||
|
||||
$record = $formRecord->isValid($data);
|
||||
|
@ -1157,18 +1158,18 @@ SQL;
|
|||
if ($repeats) {
|
||||
$repeats = $formRepeats->checkReliantFields($data);
|
||||
}
|
||||
$formAbsoluteRebroadcast->reset();
|
||||
//make it valid, results don't matter anyways.
|
||||
$rebroadAb = 1;
|
||||
$formAbsoluteRebroadcast->reset();
|
||||
//make it valid, results don't matter anyways.
|
||||
$rebroadAb = 1;
|
||||
|
||||
if ($data["add_show_rebroadcast"]) {
|
||||
$rebroad = $formRebroadcast->isValid($data);
|
||||
if ($rebroad) {
|
||||
$rebroad = $formRebroadcast->checkReliantFields($data);
|
||||
}
|
||||
} else {
|
||||
$rebroad = 1;
|
||||
if ($data["add_show_rebroadcast"]) {
|
||||
$rebroad = $formRebroadcast->isValid($data);
|
||||
if ($rebroad) {
|
||||
$rebroad = $formRebroadcast->checkReliantFields($data);
|
||||
}
|
||||
} else {
|
||||
$rebroad = 1;
|
||||
}
|
||||
} else {
|
||||
$repeats = 1;
|
||||
$formRebroadcast->reset();
|
||||
|
@ -1221,15 +1222,14 @@ SQL;
|
|||
$controller->view->who = $formWho;
|
||||
$controller->view->style = $formStyle;
|
||||
$controller->view->live = $formLive;
|
||||
|
||||
$controller->view->rr = $formRecord;
|
||||
$controller->view->absoluteRebroadcast = $formAbsoluteRebroadcast;
|
||||
$controller->view->rebroadcast = $formRebroadcast;
|
||||
$controller->view->rr = $formRecord;
|
||||
$controller->view->absoluteRebroadcast = $formAbsoluteRebroadcast;
|
||||
$controller->view->rebroadcast = $formRebroadcast;
|
||||
//$controller->view->addNewShow = !$editShow;
|
||||
//$controller->view->form = $controller->view->render('schedule/add-show-form.phtml');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
public static function checkOverlappingShows($show_start, $show_end,
|
||||
$update=false, $instanceId=null, $showId=null)
|
||||
|
@ -1258,19 +1258,19 @@ WHERE (ends <= :show_end1
|
|||
AND date(starts) >= (date(:show_end3) - INTERVAL '2 days')
|
||||
AND modified_instance = FALSE
|
||||
SQL;
|
||||
if (is_null($showId)) {
|
||||
$sql .= <<<SQL
|
||||
if (is_null($showId)) {
|
||||
$sql .= <<<SQL
|
||||
AND id != :instanceId
|
||||
ORDER BY ends
|
||||
SQL;
|
||||
$params[':instanceId'] = $instanceId;
|
||||
} else {
|
||||
$sql .= <<<SQL
|
||||
$params[':instanceId'] = $instanceId;
|
||||
} else {
|
||||
$sql .= <<<SQL
|
||||
AND show_id != :showId
|
||||
ORDER BY ends
|
||||
SQL;
|
||||
$params[':showId'] = $showId;
|
||||
}
|
||||
$params[':showId'] = $showId;
|
||||
}
|
||||
$rows = Application_Common_Database::prepareAndExecute($sql, $params, 'all');
|
||||
} else {
|
||||
$sql = <<<SQL
|
||||
|
|
|
@ -45,13 +45,40 @@ class Application_Model_Scheduler
|
|||
$this->checkUserPermissions = $value;
|
||||
}
|
||||
|
||||
private function validateItemMove($itemsToMove, $destination)
|
||||
{
|
||||
$destinationInstanceId = $destination["instance"];
|
||||
$destinationCcShowInstance = CcShowInstancesQuery::create()
|
||||
->findPk($destinationInstanceId);
|
||||
$isDestinationLinked = $destinationCcShowInstance->getCcShow()->isLinked();
|
||||
|
||||
foreach ($itemsToMove as $itemToMove) {
|
||||
$sourceInstanceId = $itemToMove["instance"];
|
||||
$ccShowInstance = CcShowInstancesQuery::create()
|
||||
->findPk($sourceInstanceId);
|
||||
|
||||
//does the item being moved belong to a linked show
|
||||
$isSourceLinked = $ccShowInstance->getCcShow()->isLinked();
|
||||
|
||||
if ($isDestinationLinked && !$isSourceLinked) {
|
||||
throw new Exception("Cannot move items into linked shows");
|
||||
} elseif (!$isDestinationLinked && $isSourceLinked) {
|
||||
throw new Exception("Cannot move items out of linked shows");
|
||||
} elseif ($isSourceLinked && $sourceInstanceId != $destinationInstanceId) {
|
||||
throw new Exception(_("Cannot move items out of linked shows"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* make sure any incoming requests for scheduling are ligit.
|
||||
*
|
||||
* @param array $items, an array containing pks of cc_schedule items.
|
||||
*/
|
||||
private function validateRequest($items)
|
||||
private function validateRequest($items, $addAction=false)
|
||||
{
|
||||
//$items is where tracks get inserted (they are schedule locations)
|
||||
|
||||
$nowEpoch = floatval($this->nowDT->format("U.u"));
|
||||
|
||||
for ($i = 0; $i < count($items); $i++) {
|
||||
|
@ -59,9 +86,11 @@ class Application_Model_Scheduler
|
|||
|
||||
//could be added to the beginning of a show, which sends id = 0;
|
||||
if ($id > 0) {
|
||||
//schedule_id of where we are inserting after?
|
||||
$schedInfo[$id] = $items[$i]["instance"];
|
||||
}
|
||||
|
||||
//format is instance_id => timestamp
|
||||
$instanceInfo[$items[$i]["instance"]] = $items[$i]["timestamp"];
|
||||
}
|
||||
|
||||
|
@ -104,7 +133,7 @@ class Application_Model_Scheduler
|
|||
if ($this->checkUserPermissions && $this->user->canSchedule($show->getDbId()) === false) {
|
||||
throw new Exception(sprintf(_("You are not allowed to schedule show %s."), $show->getDbName()));
|
||||
}
|
||||
|
||||
|
||||
if ($instance->getDbRecord()) {
|
||||
throw new Exception(_("You cannot add files to recording shows."));
|
||||
}
|
||||
|
@ -121,6 +150,28 @@ class Application_Model_Scheduler
|
|||
Logging::info("ts {$ts} last sched {$lastSchedTs}");
|
||||
throw new OutDatedScheduleException(sprintf(_("The show %s has been previously updated!"), $show->getDbName()));
|
||||
}
|
||||
|
||||
/*
|
||||
* Does the afterItem belong to a show that is linked AND
|
||||
* currently playing?
|
||||
* If yes, throw an exception
|
||||
*/
|
||||
if ($addAction) {
|
||||
$ccShow = $instance->getCcShow();
|
||||
if ($ccShow->isLinked()) {
|
||||
//get all the linked shows instances and check if
|
||||
//any of them are currently playing
|
||||
$ccShowInstances = $ccShow->getCcShowInstancess();
|
||||
$timeNowUTC = gmdate("Y-m-d H:i:s");
|
||||
foreach ($ccShowInstances as $ccShowInstance) {
|
||||
|
||||
if ($ccShowInstance->getDbStarts() <= $timeNowUTC &&
|
||||
$ccShowInstance->getDbEnds() > $timeNowUTC) {
|
||||
throw new Exception(_("Content in linked shows must be scheduled before or after any one is broadcasted"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -380,135 +431,227 @@ class Application_Model_Scheduler
|
|||
$schedule->save($this->con);
|
||||
}
|
||||
|
||||
/*
|
||||
* @param array $scheduledIds
|
||||
* @param array $fileIds
|
||||
* @param array $playlistIds
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
* @param $scheduleItems
|
||||
* cc_schedule items, where the items get inserted after
|
||||
* @param $filesToInsert
|
||||
* array of schedule item info, what gets inserted into cc_schedule
|
||||
* @param $adjustSched
|
||||
*/
|
||||
private function insertAfter($scheduleItems, $schedFiles, $adjustSched = true, $mediaItems = null)
|
||||
private function insertAfter($scheduleItems, $mediaItems, $filesToInsert=null, $adjustSched=true, $moveAction=false)
|
||||
{
|
||||
try {
|
||||
$affectedShowInstances = array();
|
||||
|
||||
//dont want to recalculate times for moved items.
|
||||
|
||||
//dont want to recalculate times for moved items
|
||||
//only moved items have a sched_id
|
||||
$excludeIds = array();
|
||||
foreach ($schedFiles as $file) {
|
||||
if (isset($file["sched_id"])) {
|
||||
$excludeIds[] = intval($file["sched_id"]);
|
||||
}
|
||||
}
|
||||
|
||||
$startProfile = microtime(true);
|
||||
|
||||
$temp = array();
|
||||
$instance = null;
|
||||
/* Items in shows are ordered by position number. We need to know
|
||||
* the position when adding/moving items in linked shows so they are
|
||||
* added or moved in the correct position
|
||||
*/
|
||||
$pos = 0;
|
||||
|
||||
foreach ($scheduleItems as $schedule) {
|
||||
$id = intval($schedule["id"]);
|
||||
|
||||
// if mediaItmes is passed in, we want to create contents
|
||||
// at the time of insert. This is for dyanmic blocks or
|
||||
// playlist that contains dynamic blocks
|
||||
if ($mediaItems != null) {
|
||||
$schedFiles = array();
|
||||
foreach ($mediaItems as $media) {
|
||||
$schedFiles = array_merge($schedFiles, $this->retrieveMediaFiles($media["id"], $media["type"]));
|
||||
|
||||
/* Find out if the show where the cursor position (where an item will
|
||||
* be inserted) is located is linked or not. If the show is linked,
|
||||
* we need to make sure there isn't another cursor selection in one of it's
|
||||
* linked shows. If there is that will cause a duplication, in the least,
|
||||
* of inserted items
|
||||
*/
|
||||
if ($id != 0) {
|
||||
$ccSchedule = CcScheduleQuery::create()->findPk($schedule["id"]);
|
||||
$ccShowInstance = CcShowInstancesQuery::create()->findPk($ccSchedule->getDbInstanceId());
|
||||
$ccShow = $ccShowInstance->getCcShow();
|
||||
if ($ccShow->isLinked()) {
|
||||
$unique = $ccShow->getDbId() . $ccSchedule->getDbPosition();
|
||||
if (!in_array($unique, $temp)) {
|
||||
$temp[] = $unique;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$ccShowInstance = CcShowInstancesQuery::create()->findPk($schedule["instance"]);
|
||||
$ccShow = $ccShowInstance->getccShow();
|
||||
if ($ccShow->isLinked()) {
|
||||
$unique = $ccShow->getDbId() . "a";
|
||||
if (!in_array($unique, $temp)) {
|
||||
$temp[] = $unique;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($id !== 0) {
|
||||
$schedItem = CcScheduleQuery::create()->findPK($id, $this->con);
|
||||
$instance = $schedItem->getCcShowInstances($this->con);
|
||||
|
||||
$schedItemEndDT = $schedItem->getDbEnds(null);
|
||||
$nextStartDT = $this->findNextStartTime($schedItemEndDT, $instance);
|
||||
}
|
||||
//selected empty row to add after
|
||||
else {
|
||||
/* If the show where the cursor position is located is linked
|
||||
* we need to insert the items for each linked instance belonging
|
||||
* to that show
|
||||
*/
|
||||
$instances = $this->getInstances($schedule["instance"]);
|
||||
foreach($instances as $instance) {
|
||||
if ($id !== 0) {
|
||||
$schedItem = CcScheduleQuery::create()->findPK($id, $this->con);
|
||||
/* We use the selected cursor's position to find the same
|
||||
* positions in every other linked instance
|
||||
*/
|
||||
$pos = $schedItem->getDbPosition();
|
||||
|
||||
$instance = CcShowInstancesQuery::create()->findPK($schedule["instance"], $this->con);
|
||||
$ccSchedule = CcScheduleQuery::create()
|
||||
->filterByDbInstanceId($instance->getDbId())
|
||||
->filterByDbPosition($pos)
|
||||
->findOne();
|
||||
|
||||
$showStartDT = $instance->getDbStarts(null);
|
||||
$nextStartDT = $this->findNextStartTime($showStartDT, $instance);
|
||||
}
|
||||
//$schedItemEndDT = $schedItem->getDbEnds(null);
|
||||
$schedItemEndDT = $ccSchedule->getDbEnds(null);
|
||||
$nextStartDT = $this->findNextStartTime($schedItemEndDT, $instance);
|
||||
|
||||
if (!in_array($instance->getDbId(), $affectedShowInstances)) {
|
||||
$affectedShowInstances[] = $instance->getDbId();
|
||||
}
|
||||
$pos++;
|
||||
}
|
||||
//selected empty row to add after
|
||||
else {
|
||||
$showStartDT = $instance->getDbStarts(null);
|
||||
$nextStartDT = $this->findNextStartTime($showStartDT, $instance);
|
||||
|
||||
if ($adjustSched === true) {
|
||||
|
||||
$pstart = microtime(true);
|
||||
|
||||
$followingSchedItems = CcScheduleQuery::create()
|
||||
->filterByDBStarts($nextStartDT->format("Y-m-d H:i:s.u"), Criteria::GREATER_EQUAL)
|
||||
->filterByDbInstanceId($instance->getDbId())
|
||||
->filterByDbId($excludeIds, Criteria::NOT_IN)
|
||||
->orderByDbStarts()
|
||||
->find($this->con);
|
||||
|
||||
$pend = microtime(true);
|
||||
Logging::debug("finding all following items.");
|
||||
Logging::debug(floatval($pend) - floatval($pstart));
|
||||
}
|
||||
|
||||
foreach ($schedFiles as $file) {
|
||||
$endTimeDT = $this->findEndTime($nextStartDT, $file['cliplength']);
|
||||
|
||||
//item existed previously and is being moved.
|
||||
//need to keep same id for resources if we want REST.
|
||||
if (isset($file['sched_id'])) {
|
||||
$sched = CcScheduleQuery::create()->findPK($file['sched_id'], $this->con);
|
||||
} else {
|
||||
$sched = new CcSchedule();
|
||||
//show is empty so start position counter at 0
|
||||
$pos = 0;
|
||||
}
|
||||
|
||||
// default fades are in seconds
|
||||
// we need to convert to '00:00:00' format
|
||||
$file['fadein'] = Application_Common_DateHelper::secondsToPlaylistTime($file['fadein']);
|
||||
$file['fadeout'] = Application_Common_DateHelper::secondsToPlaylistTime($file['fadeout']);
|
||||
|
||||
$sched->setDbStarts($nextStartDT)
|
||||
->setDbEnds($endTimeDT)
|
||||
->setDbCueIn($file['cuein'])
|
||||
->setDbCueOut($file['cueout'])
|
||||
->setDbFadeIn($file['fadein'])
|
||||
->setDbFadeOut($file['fadeout'])
|
||||
->setDbClipLength($file['cliplength'])
|
||||
->setDbInstanceId($instance->getDbId());
|
||||
|
||||
switch ($file["type"]) {
|
||||
case 0:
|
||||
$sched->setDbFileId($file['id']);
|
||||
break;
|
||||
case 1:
|
||||
$sched->setDbStreamId($file['id']);
|
||||
break;
|
||||
default: break;
|
||||
if (!in_array($instance->getDbId(), $affectedShowInstances)) {
|
||||
$affectedShowInstances[] = $instance->getDbId();
|
||||
}
|
||||
|
||||
$sched->save($this->con);
|
||||
/*
|
||||
* $adjustSched is true if there are schedule items
|
||||
* following the item just inserted, per show instance
|
||||
*/
|
||||
if ($adjustSched === true) {
|
||||
|
||||
$nextStartDT = $endTimeDT;
|
||||
}
|
||||
$pstart = microtime(true);
|
||||
|
||||
if ($adjustSched === true) {
|
||||
$initalStartDT = clone $nextStartDT;
|
||||
|
||||
$pstart = microtime(true);
|
||||
$pend = microtime(true);
|
||||
Logging::debug("finding all following items.");
|
||||
Logging::debug(floatval($pend) - floatval($pstart));
|
||||
}
|
||||
|
||||
//recalculate the start/end times after the inserted items.
|
||||
foreach ($followingSchedItems as $item) {
|
||||
if (is_null($filesToInsert)) {
|
||||
$filesToInsert = array();
|
||||
foreach ($mediaItems as $media) {
|
||||
$filesToInsert = array_merge($filesToInsert, $this->retrieveMediaFiles($media["id"], $media["type"]));
|
||||
}
|
||||
}
|
||||
foreach ($filesToInsert as $file) {
|
||||
//item existed previously and is being moved.
|
||||
//need to keep same id for resources if we want REST.
|
||||
if (isset($file['sched_id'])) {
|
||||
$sched = CcScheduleQuery::create()->findPk($file["sched_id"]);
|
||||
|
||||
$endTimeDT = $this->findEndTime($nextStartDT, $item->getDbClipLength());
|
||||
$excludeIds[] = intval($sched->getDbId());
|
||||
|
||||
$file["cliplength"] = $sched->getDbClipLength();
|
||||
$file["cuein"] = $sched->getDbCueIn();
|
||||
$file["cueout"] = $sched->getDbCueOut();
|
||||
$file["fadein"] = $sched->getDbFadeIn();
|
||||
$file["fadeout"] = $sched->getDbFadeOut();
|
||||
} else {
|
||||
$sched = new CcSchedule();
|
||||
}
|
||||
|
||||
$endTimeDT = $this->findEndTime($nextStartDT, $file['cliplength']);
|
||||
// default fades are in seconds
|
||||
// we need to convert to '00:00:00' format
|
||||
$file['fadein'] = Application_Common_DateHelper::secondsToPlaylistTime($file['fadein']);
|
||||
$file['fadeout'] = Application_Common_DateHelper::secondsToPlaylistTime($file['fadeout']);
|
||||
|
||||
$sched->setDbStarts($nextStartDT)
|
||||
->setDbEnds($endTimeDT)
|
||||
->setDbCueIn($file['cuein'])
|
||||
->setDbCueOut($file['cueout'])
|
||||
->setDbFadeIn($file['fadein'])
|
||||
->setDbFadeOut($file['fadeout'])
|
||||
->setDbClipLength($file['cliplength'])
|
||||
->setDbPosition($pos);
|
||||
//->setDbInstanceId($instance->getDbId());
|
||||
if (!$moveAction) {
|
||||
$sched->setDbInstanceId($instance->getDbId());
|
||||
}
|
||||
|
||||
switch ($file["type"]) {
|
||||
case 0:
|
||||
$sched->setDbFileId($file['id']);
|
||||
break;
|
||||
case 1:
|
||||
$sched->setDbStreamId($file['id']);
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
$sched->save($this->con);
|
||||
|
||||
$item->setDbStarts($nextStartDT);
|
||||
$item->setDbEnds($endTimeDT);
|
||||
$item->save($this->con);
|
||||
$nextStartDT = $endTimeDT;
|
||||
$pos++;
|
||||
|
||||
}//all files have been inserted/moved
|
||||
|
||||
// update is_scheduled flag for each cc_file
|
||||
foreach ($filesToInsert as $file) {
|
||||
$db_file = CcFilesQuery::create()->findPk($file['id'], $this->con);
|
||||
$db_file->setDbIsScheduled(true);
|
||||
$db_file->save($this->con);
|
||||
}
|
||||
/* Reset files to insert so we can get a new set of files. We have
|
||||
* to do this in case we are inserting a dynamic block
|
||||
*/
|
||||
if (!$moveAction) {
|
||||
$filesToInsert = null;
|
||||
}
|
||||
|
||||
$pend = microtime(true);
|
||||
Logging::debug("adjusting all following items.");
|
||||
Logging::debug(floatval($pend) - floatval($pstart));
|
||||
}
|
||||
}
|
||||
/* If we are adjusting start and end times for items
|
||||
* after the insert location, we need to exclude the
|
||||
* schedule item we just inserted because it has correct
|
||||
* start and end times*/
|
||||
$excludeIds[] = $sched->getDbId();
|
||||
|
||||
if ($adjustSched === true) {
|
||||
$followingSchedItems = CcScheduleQuery::create()
|
||||
->filterByDBStarts($initalStartDT->format("Y-m-d H:i:s.u"), Criteria::GREATER_EQUAL)
|
||||
->filterByDbInstanceId($instance->getDbId())
|
||||
->filterByDbId($excludeIds, Criteria::NOT_IN)
|
||||
->orderByDbStarts()
|
||||
->find($this->con);
|
||||
|
||||
$pstart = microtime(true);
|
||||
|
||||
//recalculate the start/end times after the inserted items.
|
||||
foreach ($followingSchedItems as $item) {
|
||||
$endTimeDT = $this->findEndTime($nextStartDT, $item->getDbClipLength());
|
||||
|
||||
$item->setDbStarts($nextStartDT);
|
||||
$item->setDbEnds($endTimeDT);
|
||||
$item->setDbPosition($pos);
|
||||
$item->save($this->con);
|
||||
$nextStartDT = $endTimeDT;
|
||||
$pos++;
|
||||
}
|
||||
|
||||
$pend = microtime(true);
|
||||
Logging::debug("adjusting all following items.");
|
||||
Logging::debug(floatval($pend) - floatval($pstart));
|
||||
}
|
||||
}//for each instance
|
||||
|
||||
}//for each schedule location
|
||||
|
||||
$endProfile = microtime(true);
|
||||
Logging::debug("finished adding scheduled items.");
|
||||
|
@ -525,13 +668,6 @@ class Application_Model_Scheduler
|
|||
$instance->updateScheduleStatus($this->con);
|
||||
}
|
||||
|
||||
// update is_scheduled flag for each cc_file
|
||||
foreach ($schedFiles as $file) {
|
||||
$db_file = CcFilesQuery::create()->findPk($file['id'], $this->con);
|
||||
$db_file->setDbIsScheduled(true);
|
||||
$db_file->save($this->con);
|
||||
}
|
||||
|
||||
$endProfile = microtime(true);
|
||||
Logging::debug("updating show instances status.");
|
||||
Logging::debug(floatval($endProfile) - floatval($startProfile));
|
||||
|
@ -552,46 +688,53 @@ class Application_Model_Scheduler
|
|||
}
|
||||
}
|
||||
|
||||
private function getInstances($instanceId)
|
||||
{
|
||||
$ccShowInstance = CcShowInstancesQuery::create()->findPk($instanceId);
|
||||
$ccShow = $ccShowInstance->getCcShow();
|
||||
if ($ccShow->isLinked()) {
|
||||
return $ccShow->getCcShowInstancess();
|
||||
} else {
|
||||
return array($ccShowInstance);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @param array $scheduleItems
|
||||
* @param array $mediaItems
|
||||
* @param array $scheduleItems (schedule_id and instance_id it belongs to)
|
||||
* @param array $mediaItems (file|block|playlist|webstream)
|
||||
*/
|
||||
public function scheduleAfter($scheduleItems, $mediaItems, $adjustSched = true)
|
||||
{
|
||||
$this->con->beginTransaction();
|
||||
|
||||
$schedFiles = array();
|
||||
|
||||
try {
|
||||
$this->validateRequest($scheduleItems, true);
|
||||
|
||||
$this->validateRequest($scheduleItems);
|
||||
|
||||
$requireDynamicContentCreation = false;
|
||||
|
||||
foreach ($mediaItems as $media) {
|
||||
if ($media['type'] == "playlist") {
|
||||
$pl = new Application_Model_Playlist($media['id']);
|
||||
if ($pl->hasDynamicBlock()) {
|
||||
$requireDynamicContentCreation = true;
|
||||
break;
|
||||
}
|
||||
} else if ($media['type'] == "block") {
|
||||
$bl = new Application_Model_Block($media['id']);
|
||||
if (!$bl->isStatic()) {
|
||||
$requireDynamicContentCreation = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($requireDynamicContentCreation) {
|
||||
$this->insertAfter($scheduleItems, $schedFiles, $adjustSched, $mediaItems);
|
||||
} else {
|
||||
foreach ($mediaItems as $media) {
|
||||
$schedFiles = array_merge($schedFiles, $this->retrieveMediaFiles($media["id"], $media["type"]));
|
||||
}
|
||||
$this->insertAfter($scheduleItems, $schedFiles, $adjustSched);
|
||||
}
|
||||
/*
|
||||
* create array of arrays
|
||||
* array of schedule item info
|
||||
* (sched_id is the cc_schedule id and is set if an item is being
|
||||
* moved because it is already in cc_schedule)
|
||||
* [0] = Array(
|
||||
* id => 1,
|
||||
* cliplength => 00:04:32,
|
||||
* cuein => 00:00:00,
|
||||
* cueout => 00:04:32,
|
||||
* fadein => 00.5,
|
||||
* fadeout => 00.5,
|
||||
* sched_id => ,
|
||||
* type => 0)
|
||||
* [1] = Array(
|
||||
* id => 2,
|
||||
* cliplength => 00:05:07,
|
||||
* cuein => 00:00:00,
|
||||
* cueout => 00:05:07,
|
||||
* fadein => 00.5,
|
||||
* fadeout => 00.5,
|
||||
* sched_id => ,
|
||||
* type => 0)
|
||||
*/
|
||||
$this->insertAfter($scheduleItems, $mediaItems, null, $adjustSched);
|
||||
|
||||
$this->con->commit();
|
||||
|
||||
|
@ -615,6 +758,7 @@ class Application_Model_Scheduler
|
|||
|
||||
try {
|
||||
|
||||
$this->validateItemMove($selectedItems, $afterItems[0]);
|
||||
$this->validateRequest($selectedItems);
|
||||
$this->validateRequest($afterItems);
|
||||
|
||||
|
@ -668,7 +812,7 @@ class Application_Model_Scheduler
|
|||
|
||||
$startProfile = microtime(true);
|
||||
|
||||
$this->insertAfter($afterItems, $movedData, $adjustSched);
|
||||
$this->insertAfter($afterItems, null, $movedData, $adjustSched, true);
|
||||
|
||||
$endProfile = microtime(true);
|
||||
Logging::debug("inserting after removing gaps.");
|
||||
|
@ -692,7 +836,7 @@ class Application_Model_Scheduler
|
|||
}
|
||||
}
|
||||
|
||||
public function removeItems($scheduledItems, $adjustSched = true)
|
||||
public function removeItems($scheduledItems, $adjustSched = true, $cancelShow=false)
|
||||
{
|
||||
$showInstances = array();
|
||||
$this->con->beginTransaction();
|
||||
|
@ -713,6 +857,31 @@ class Application_Model_Scheduler
|
|||
|
||||
$instance = $removedItem->getCcShowInstances($this->con);
|
||||
|
||||
//check if instance is linked and if so get the schedule items
|
||||
//for all linked instances so we can delete them too
|
||||
if (!$cancelShow && $instance->getCcShow()->isLinked()) {
|
||||
//returns all linked instances if linked
|
||||
$ccShowInstances = $this->getInstances($instance->getDbId());
|
||||
$instanceIds = array();
|
||||
foreach ($ccShowInstances as $ccShowInstance) {
|
||||
$instanceIds[] = $ccShowInstance->getDbId();
|
||||
}
|
||||
/*
|
||||
* Find all the schedule items that are in the same position
|
||||
* as the selected item by the user.
|
||||
* The position of each track is the same across each linked instance
|
||||
*/
|
||||
$itemsToDelete = CcScheduleQuery::create()
|
||||
->filterByDbPosition($removedItem->getDbPosition())
|
||||
->filterByDbInstanceId($instanceIds, Criteria::IN)
|
||||
->find();
|
||||
foreach ($itemsToDelete as $item) {
|
||||
if (!$removedItems->contains($item)) {
|
||||
$removedItems->append($item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//check to truncate the currently playing item instead of deleting it.
|
||||
if ($removedItem->isCurrentItem($this->epochNow)) {
|
||||
|
||||
|
@ -816,7 +985,7 @@ class Application_Model_Scheduler
|
|||
$remove[$i]["id"] = $items[$i]->getDbId();
|
||||
}
|
||||
|
||||
$this->removeItems($remove, false);
|
||||
$this->removeItems($remove, false, true);
|
||||
}
|
||||
} else {
|
||||
$rebroadcasts = $instance->getCcShowInstancessRelatedByDbId(null, $this->con);
|
||||
|
|
|
@ -1113,11 +1113,13 @@ SQL;
|
|||
*/
|
||||
public static function create($data)
|
||||
{
|
||||
$startDateTime = new DateTime($data['add_show_start_date']." ".$data['add_show_start_time']);
|
||||
$utcStartDateTime = clone $startDateTime;
|
||||
$utcStartDateTime->setTimezone(new DateTimeZone('UTC'));
|
||||
/*$startDateTime = new DateTime($data['add_show_start_date']." ".$data['add_show_start_time']);*/
|
||||
|
||||
// these are not used
|
||||
/*$utcStartDateTime = clone $startDateTime;
|
||||
$utcStartDateTime->setTimezone(new DateTimeZone('UTC'));*/
|
||||
|
||||
if ($data['add_show_no_end']) {
|
||||
/*if ($data['add_show_no_end']) {
|
||||
$endDate = NULL;
|
||||
} elseif ($data['add_show_repeats']) {
|
||||
$endDateTime = new DateTime($data['add_show_end_date']);
|
||||
|
@ -1129,28 +1131,29 @@ SQL;
|
|||
//$endDateTime->setTimezone(new DateTimeZone('UTC'));
|
||||
$endDateTime->add(new DateInterval("P1D"));
|
||||
$endDate = $endDateTime->format("Y-m-d");
|
||||
}
|
||||
}*/
|
||||
|
||||
//What we are doing here is checking if the show repeats or if
|
||||
//any repeating days have been checked. If not, then by default
|
||||
//the "selected" DOW is the initial day.
|
||||
//DOW in local time.
|
||||
$startDow = date("w", $startDateTime->getTimestamp());
|
||||
/*$startDow = date("w", $startDateTime->getTimestamp());
|
||||
if (!$data['add_show_repeats']) {
|
||||
$data['add_show_day_check'] = array($startDow);
|
||||
} elseif ($data['add_show_repeats'] && $data['add_show_day_check'] == "") {
|
||||
$data['add_show_day_check'] = array($startDow);
|
||||
}
|
||||
}*/
|
||||
|
||||
//find repeat type or set to a non repeating show.
|
||||
$repeatType = ($data['add_show_repeats']) ? $data['add_show_repeat_type'] : -1;
|
||||
/*$repeatType = ($data['add_show_repeats']) ? $data['add_show_repeat_type'] : -1;*/
|
||||
|
||||
if ($data['add_show_id'] == -1) {
|
||||
/*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->setDbName($data['add_show_name']);
|
||||
$ccShow->setDbDescription($data['add_show_description']);
|
||||
$ccShow->setDbUrl($data['add_show_url']);
|
||||
$ccShow->setDbGenre($data['add_show_genre']);
|
||||
|
@ -1160,25 +1163,26 @@ SQL;
|
|||
$ccShow->setDbLiveStreamUsingCustomAuth($data['cb_custom_auth'] == 1);
|
||||
$ccShow->setDbLiveStreamUser($data['custom_username']);
|
||||
$ccShow->setDbLiveStreamPass($data['custom_password']);
|
||||
$ccShow->save();
|
||||
$ccShow->save();*/
|
||||
|
||||
$showId = $ccShow->getDbId();
|
||||
/*$showId = $ccShow->getDbId();*/
|
||||
|
||||
$isRecorded = (isset($data['add_show_record']) && $data['add_show_record']) ? 1 : 0;
|
||||
/*$isRecorded = (isset($data['add_show_record']) && $data['add_show_record']) ? 1 : 0;*/
|
||||
|
||||
if ($data['add_show_id'] != -1) {
|
||||
/*if ($data['add_show_id'] != -1) {
|
||||
$show = new Application_Model_Show($showId);
|
||||
//CC-4150 CULPRIT
|
||||
$show->deletePossiblyInvalidInstances($data, $endDate, $isRecorded, $repeatType);
|
||||
}
|
||||
}*/
|
||||
|
||||
//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) {
|
||||
/*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($startDateTime->format("Y-m-d"));
|
||||
$showDay->setDbLastShow($endDate);
|
||||
|
@ -1215,19 +1219,19 @@ SQL;
|
|||
$showDay->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
//check if we are adding or updating a show, and if updating
|
||||
//erase all the show's future show_rebroadcast information first.
|
||||
if (($data['add_show_id'] != -1) && isset($data['add_show_rebroadcast']) && $data['add_show_rebroadcast']) {
|
||||
/*if (($data['add_show_id'] != -1) && isset($data['add_show_rebroadcast']) && $data['add_show_rebroadcast']) {
|
||||
CcShowRebroadcastQuery::create()
|
||||
->filterByDbShowId($data['add_show_id'])
|
||||
->delete();
|
||||
}
|
||||
}*/
|
||||
//adding rows to cc_show_rebroadcast
|
||||
/* TODO: Document magic constant 10 and define it properly somewhere
|
||||
--RG */
|
||||
if (($isRecorded && $data['add_show_rebroadcast']) && ($repeatType != -1)) {
|
||||
/*if (($isRecorded && $data['add_show_rebroadcast']) && ($repeatType != -1)) {
|
||||
for ($i=1; $i<=10; $i++) {
|
||||
if ($data['add_show_rebroadcast_date_'.$i]) {
|
||||
$showRebroad = new CcShowRebroadcast();
|
||||
|
@ -1264,14 +1268,14 @@ SQL;
|
|||
$showRebroad->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
//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) {
|
||||
/*if ($data['add_show_id'] != -1) {
|
||||
CcShowHostsQuery::create()->filterByDbShow($data['add_show_id'])->delete();
|
||||
}
|
||||
if (is_array($data['add_show_hosts'])) {
|
||||
}*/
|
||||
/*if (is_array($data['add_show_hosts'])) {
|
||||
//add selected hosts to cc_show_hosts table.
|
||||
foreach ($data['add_show_hosts'] as $host) {
|
||||
$showHost = new CcShowHosts();
|
||||
|
@ -1279,9 +1283,9 @@ SQL;
|
|||
$showHost->setDbHost($host);
|
||||
$showHost->save();
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
if ($data['add_show_id'] != -1) {
|
||||
/*if ($data['add_show_id'] != -1) {
|
||||
$con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME);
|
||||
$con->beginTransaction();
|
||||
|
||||
|
@ -1306,12 +1310,12 @@ SQL;
|
|||
Logging::info("Couldn't update schedule status.");
|
||||
Logging::info($e->getMessage());
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
Application_Model_Show::populateShowUntil($showId);
|
||||
Application_Model_RabbitMq::PushSchedule();
|
||||
/*Application_Model_Show::populateShowUntil($showId);
|
||||
Application_Model_RabbitMq::PushSchedule();*/
|
||||
|
||||
return $showId;
|
||||
/*return $showId;*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1321,7 +1325,7 @@ SQL;
|
|||
*
|
||||
* @param int $p_showId
|
||||
*/
|
||||
public static function populateShowUntil($p_showId)
|
||||
/*public static function populateShowUntil($p_showId)
|
||||
{
|
||||
$con = Propel::getConnection();
|
||||
$date = Application_Model_Preference::GetShowsPopulatedUntil();
|
||||
|
@ -1342,7 +1346,7 @@ SQL;
|
|||
foreach ($res as $showDaysRow) {
|
||||
Application_Model_Show::populateShow($showDaysRow, $p_populateUntilDateTime);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
/**
|
||||
* We are going to use cc_show_days as a template, to generate Show Instances. This function
|
||||
|
@ -1355,7 +1359,7 @@ SQL;
|
|||
* @param DateTime $p_populateUntilDateTime
|
||||
* DateTime object in UTC time.
|
||||
*/
|
||||
private static function populateShow($p_showDaysRow, $p_populateUntilDateTime)
|
||||
/*private static function populateShow($p_showDaysRow, $p_populateUntilDateTime)
|
||||
{
|
||||
// TODO : use constants instead of int values here? or maybe php will
|
||||
// get enum types by the time somebody gets around to fix this. -- RG
|
||||
|
@ -1369,7 +1373,7 @@ SQL;
|
|||
Application_Model_Show::populateRepeatingShow($p_showDaysRow, $p_populateUntilDateTime, 'P1M');
|
||||
}
|
||||
Application_Model_RabbitMq::PushSchedule();
|
||||
}
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Creates a single show instance. If the show is recorded, it may have multiple
|
||||
|
@ -1382,7 +1386,7 @@ SQL;
|
|||
*/
|
||||
private static function populateNonRepeatingShow($p_showRow, $p_populateUntilDateTime)
|
||||
{
|
||||
$show_id = $p_showRow["show_id"];
|
||||
/*$show_id = $p_showRow["show_id"];
|
||||
$first_show = $p_showRow["first_show"]; //non-UTC
|
||||
$start_time = $p_showRow["start_time"]; //non-UTC
|
||||
$duration = $p_showRow["duration"];
|
||||
|
@ -1393,41 +1397,42 @@ SQL;
|
|||
//start & end UTC DateTimes for the show.
|
||||
list($utcStartDateTime, $utcEndDateTime) = Application_Model_Show::createUTCStartEndDateTime($start, $duration, $timezone);
|
||||
if ($utcStartDateTime->getTimestamp() < $p_populateUntilDateTime->getTimestamp()) {
|
||||
$currentUtcTimestamp = gmdate("Y-m-d H:i:s");
|
||||
$currentUtcTimestamp = gmdate("Y-m-d H:i:s");*/
|
||||
|
||||
$show = new Application_Model_Show($show_id);
|
||||
/*$show = new Application_Model_Show($show_id);
|
||||
if ($show->hasInstance()) {
|
||||
$ccShowInstance = $show->getInstance();
|
||||
$newInstance = false;
|
||||
} else {
|
||||
}*/ /*else {
|
||||
$ccShowInstance = new CcShowInstances();
|
||||
$newInstance = true;
|
||||
}
|
||||
}*/
|
||||
|
||||
if ($newInstance || $ccShowInstance->getDbStarts() > $currentUtcTimestamp) {
|
||||
/*if ($newInstance || $ccShowInstance->getDbStarts() > $currentUtcTimestamp) {
|
||||
$ccShowInstance->setDbShowId($show_id);
|
||||
$ccShowInstance->setDbStarts($utcStartDateTime);
|
||||
$ccShowInstance->setDbEnds($utcEndDateTime);
|
||||
$ccShowInstance->setDbRecord($record);
|
||||
$ccShowInstance->save();
|
||||
}
|
||||
}*/
|
||||
|
||||
$show_instance_id = $ccShowInstance->getDbId();
|
||||
$showInstance = new Application_Model_ShowInstance($show_instance_id);
|
||||
/* $show_instance_id = $ccShowInstance->getDbId();
|
||||
$showInstance = new Application_Model_ShowInstance($show_instance_id);*/
|
||||
|
||||
if (!$newInstance) {
|
||||
/*if (!$newInstance) {
|
||||
$showInstance->correctScheduleStartTimes();
|
||||
}
|
||||
}*/
|
||||
|
||||
$sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id=:show_id";
|
||||
/*$sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id=:show_id";
|
||||
$rebroadcasts = Application_Common_Database::prepareAndExecute($sql,
|
||||
array( ':show_id' => $show_id ), 'all');
|
||||
array( ':show_id' => $show_id ), 'all');*/
|
||||
|
||||
if ($showInstance->isRecorded()) {
|
||||
/*if ($showInstance->isRecorded()) {
|
||||
//only do this for editing
|
||||
$showInstance->deleteRebroadcasts();
|
||||
self::createRebroadcastInstances($rebroadcasts, $currentUtcTimestamp, $show_id, $show_instance_id, $start, $duration, $timezone);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
/*}*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1444,7 +1449,7 @@ SQL;
|
|||
*/
|
||||
private static function populateRepeatingShow($p_showDaysRow, $p_populateUntilDateTime, $p_interval)
|
||||
{
|
||||
$show_id = $p_showDaysRow["show_id"];
|
||||
/*$show_id = $p_showDaysRow["show_id"];
|
||||
$next_pop_date = $p_showDaysRow["next_pop_date"];
|
||||
$first_show = $p_showDaysRow["first_show"]; //non-UTC
|
||||
$last_show = $p_showDaysRow["last_show"]; //non-UTC
|
||||
|
@ -1464,21 +1469,23 @@ SQL;
|
|||
|
||||
$utcStartDateTime = Application_Common_DateHelper::ConvertToUtcDateTime($start, $timezone);
|
||||
//convert $last_show into a UTC DateTime object, or null if there is no last show.
|
||||
$utcLastShowDateTime = $last_show ? Application_Common_DateHelper::ConvertToUtcDateTime($last_show, $timezone) : null;
|
||||
$utcLastShowDateTime = $last_show ? Application_Common_DateHelper::ConvertToUtcDateTime($last_show, $timezone) : null;*/
|
||||
|
||||
$sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id=:show_id";
|
||||
/*$sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id=:show_id";
|
||||
|
||||
$rebroadcasts = Application_Common_Database::prepareAndExecute( $sql,
|
||||
array( ':show_id' => $show_id ), 'all');
|
||||
|
||||
$show = new Application_Model_Show($show_id);
|
||||
$show = new Application_Model_Show($show_id);*/
|
||||
|
||||
while ($utcStartDateTime->getTimestamp() <= $p_populateUntilDateTime->getTimestamp()
|
||||
&& (is_null($utcLastShowDateTime) || $utcStartDateTime->getTimestamp() < $utcLastShowDateTime->getTimestamp())){
|
||||
/*while ($utcStartDateTime->getTimestamp() <= $p_populateUntilDateTime->getTimestamp()
|
||||
&& (is_null($utcLastShowDateTime) || $utcStartDateTime->getTimestamp() < $utcLastShowDateTime->getTimestamp())){*/
|
||||
|
||||
list($utcStartDateTime, $utcEndDateTime) = self::createUTCStartEndDateTime($start, $duration, $timezone);
|
||||
/*list($utcStartDateTime, $utcEndDateTime) = self::createUTCStartEndDateTime($start, $duration, $timezone);*/
|
||||
|
||||
if ($show->hasInstanceOnDate($utcStartDateTime)) {
|
||||
//determine if we are adding a new show
|
||||
//or editing a show
|
||||
/* if ($show->hasInstanceOnDate($utcStartDateTime)) {
|
||||
$ccShowInstance = $show->getInstanceOnDate($utcStartDateTime);
|
||||
|
||||
if ($ccShowInstance->getDbModifiedInstance()) {
|
||||
|
@ -1491,12 +1498,12 @@ SQL;
|
|||
} else {
|
||||
$ccShowInstance = new CcShowInstances();
|
||||
$newInstance = true;
|
||||
}
|
||||
}*/
|
||||
|
||||
/* When editing the start/end time of a repeating show, we don't want to
|
||||
* change shows that started in the past. So check the start time.
|
||||
*/
|
||||
if ($newInstance || $ccShowInstance->getDbStarts() > $currentUtcTimestamp) {
|
||||
/*if ($newInstance || $ccShowInstance->getDbStarts() > $currentUtcTimestamp) {
|
||||
$ccShowInstance->setDbShowId($show_id);
|
||||
$ccShowInstance->setDbStarts($utcStartDateTime);
|
||||
$ccShowInstance->setDbEnds($utcEndDateTime);
|
||||
|
@ -1506,21 +1513,22 @@ SQL;
|
|||
|
||||
|
||||
$show_instance_id = $ccShowInstance->getDbId();
|
||||
$showInstance = new Application_Model_ShowInstance($show_instance_id);
|
||||
$showInstance = new Application_Model_ShowInstance($show_instance_id);*/
|
||||
|
||||
/* If we are updating a show then make sure that the scheduled content within
|
||||
* the show is updated to the correct time. */
|
||||
if (!$newInstance) {
|
||||
// don't we already do this in deletePossiblyInvalidInstances???
|
||||
/*if (!$newInstance) {
|
||||
$showInstance->correctScheduleStartTimes();
|
||||
}
|
||||
}*/
|
||||
|
||||
$showInstance->deleteRebroadcasts();
|
||||
/*$showInstance->deleteRebroadcasts();
|
||||
self::createRebroadcastInstances($rebroadcasts, $currentUtcTimestamp, $show_id, $show_instance_id, $start, $duration, $timezone);
|
||||
list($start, $utcStartDateTime) = self::advanceRepeatingDate($p_interval, $start, $timezone);
|
||||
list($start, $utcStartDateTime) = self::advanceRepeatingDate($p_interval, $start, $timezone);*/
|
||||
|
||||
}
|
||||
/*}*/
|
||||
|
||||
Application_Model_Show::setNextPop($start, $show_id, $day);
|
||||
/*Application_Model_Show::setNextPop($start, $show_id, $day);*/
|
||||
}
|
||||
|
||||
private static function advanceRepeatingDate($p_interval, $start, $timezone)
|
||||
|
@ -1574,7 +1582,7 @@ SQL;
|
|||
*/
|
||||
private static function createUTCStartEndDateTime($p_start, $p_duration, $p_timezone=null, $p_offset=null)
|
||||
{
|
||||
$timezone = $p_timezone ? $p_timezone : date_default_timezone_get();
|
||||
/*$timezone = $p_timezone ? $p_timezone : date_default_timezone_get();
|
||||
|
||||
$startDateTime = new DateTime($p_start, new DateTimeZone($timezone));
|
||||
if (isset($p_offset)) {
|
||||
|
@ -1588,7 +1596,7 @@ SQL;
|
|||
list($hours, $mins) = array_slice($duration, 0, 2);
|
||||
$endDateTime->add(new DateInterval("PT{$hours}H{$mins}M"));
|
||||
|
||||
return array($startDateTime, $endDateTime);
|
||||
return array($startDateTime, $endDateTime);*/
|
||||
}
|
||||
|
||||
/* Create rebroadcast instances for a created show marked for recording
|
||||
|
@ -1614,7 +1622,7 @@ SQL;
|
|||
{
|
||||
//Y-m-d
|
||||
//use only the date part of the show start time stamp for the offsets to work properly.
|
||||
$date = explode(" ", $p_startTime);
|
||||
/*$date = explode(" ", $p_startTime);
|
||||
$start_date = $date[0];
|
||||
|
||||
foreach ($p_rebroadcasts as $rebroadcast) {
|
||||
|
@ -1636,7 +1644,7 @@ SQL;
|
|||
$newRebroadcastInstance->setDbOriginalShow($p_showInstanceId);
|
||||
$newRebroadcastInstance->save();
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1656,7 +1664,8 @@ SQL;
|
|||
$showsPopUntil = Application_Model_Preference::GetShowsPopulatedUntil();
|
||||
//if application is requesting shows past our previous populated until date, generate shows up until this point.
|
||||
if (is_null($showsPopUntil) || $showsPopUntil->getTimestamp() < $end_timestamp->getTimestamp()) {
|
||||
Application_Model_Show::populateAllShowsInRange($showsPopUntil, $end_timestamp);
|
||||
$service_show = new Application_Service_ShowService();
|
||||
$ccShow = $service_show->delegateInstanceCreation(null, $end_timestamp, true);
|
||||
Application_Model_Preference::SetShowsPopulatedUntil($end_timestamp);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ class Application_Model_ShowBuilder
|
|||
private $contentDT;
|
||||
private $epoch_now;
|
||||
private $currentShow;
|
||||
private $currentShowId;
|
||||
|
||||
private $showInstances = array();
|
||||
|
||||
|
@ -27,6 +28,7 @@ class Application_Model_ShowBuilder
|
|||
"footer" => false,
|
||||
"empty" => false,
|
||||
"allowed" => false,
|
||||
"linked_allowed" => true,
|
||||
"id" => 0,
|
||||
"instance" => "",
|
||||
"starts" => "",
|
||||
|
@ -85,6 +87,18 @@ class Application_Model_ShowBuilder
|
|||
return;
|
||||
}
|
||||
|
||||
if ($this->currentShow) {
|
||||
$this->currentShowId = $p_item["show_id"];
|
||||
}
|
||||
|
||||
/* If any linked show instance is currently playing
|
||||
* we have to disable editing, or else the times
|
||||
* will not make sense for shows scheduled in the future
|
||||
*/
|
||||
if ($p_item["linked"] && $p_item["show_id"] == $this->currentShowId) {
|
||||
$row["linked_allowed"] = false;
|
||||
}
|
||||
|
||||
if ($this->user->canSchedule($p_item["show_id"]) == true) {
|
||||
$row["allowed"] = true;
|
||||
}
|
||||
|
@ -174,7 +188,7 @@ class Application_Model_ShowBuilder
|
|||
private function makeHeaderRow($p_item)
|
||||
{
|
||||
$row = $this->defaultRowArray;
|
||||
$this->isAllowed($p_item, $row);
|
||||
//$this->isAllowed($p_item, $row);
|
||||
$this->getRowTimestamp($p_item, $row);
|
||||
$this->getItemColor($p_item, $row);
|
||||
|
||||
|
@ -217,6 +231,8 @@ class Application_Model_ShowBuilder
|
|||
$this->currentShow = false;
|
||||
}
|
||||
|
||||
$this->isAllowed($p_item, $row);
|
||||
|
||||
$row["header"] = true;
|
||||
$row["starts"] = $showStartDT->format("Y-m-d H:i");
|
||||
$row["startDate"] = $showStartDT->format("Y-m-d");
|
||||
|
|
|
@ -391,7 +391,7 @@ SQL;
|
|||
* @param int $plId
|
||||
* Playlist ID.
|
||||
*/
|
||||
public function addPlaylistToShow($pl_id, $checkUserPerm = true)
|
||||
/*public function addPlaylistToShow($pl_id, $checkUserPerm = true)
|
||||
{
|
||||
$ts = intval($this->_showInstance->getDbLastScheduled("U")) ? : 0;
|
||||
$id = $this->_showInstance->getDbId();
|
||||
|
@ -401,7 +401,7 @@ SQL;
|
|||
array(array("id" => 0, "instance" => $id, "timestamp" => $ts)),
|
||||
array(array("id" => $pl_id, "type" => "playlist"))
|
||||
);
|
||||
}
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Add a media file as the last item in the show.
|
||||
|
@ -427,12 +427,12 @@ SQL;
|
|||
* @param array $plIds
|
||||
* An array of playlist IDs.
|
||||
*/
|
||||
public function scheduleShow($plIds)
|
||||
/*public function scheduleShow($plIds)
|
||||
{
|
||||
foreach ($plIds as $plId) {
|
||||
$this->addPlaylistToShow($plId);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
public function clearShow()
|
||||
{
|
||||
|
|
|
@ -1017,6 +1017,9 @@ SQL;
|
|||
Logging::info("Successfully written identification file for
|
||||
uploaded '$audio_stor'");
|
||||
}
|
||||
//if the uploaded file is not UTF-8 encoded, let's encode it. Assuming source
|
||||
//encoding is ISO-8859-1
|
||||
$audio_stor = mb_detect_encoding($audio_stor, "UTF-8") == "UTF-8" ? $audio_stor : utf8_encode($audio_stor);
|
||||
Logging::info("copyFileToStor: moving file $audio_file to $audio_stor");
|
||||
// Martin K.: changed to rename: Much less load + quicker since this is
|
||||
// an atomic operation
|
||||
|
|
|
@ -15,4 +15,171 @@
|
|||
*/
|
||||
class CcShow extends BaseCcShow {
|
||||
|
||||
public function getCcShowDays(){
|
||||
return CcShowDaysQuery::create()->filterByDbShowId($this->getDbId())->find();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an array of CcShowDays objects which contain a foreign key that references this object.
|
||||
*
|
||||
* If the $criteria is not null, it is used to always fetch the results from the database.
|
||||
* Otherwise the results are fetched from the database the first time, then cached.
|
||||
* Next time the same method is called without $criteria, the cached collection is returned.
|
||||
* If this CcShow is new, it will return
|
||||
* an empty collection or the current collection; the criteria is ignored on a new object.
|
||||
*
|
||||
* @param Criteria $criteria optional Criteria object to narrow the query
|
||||
* @param PropelPDO $con optional connection object
|
||||
* @return PropelCollection|array CcShowDays[] List of CcShowDays objects
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getFirstCcShowDay($criteria = null, PropelPDO $con = null)
|
||||
{
|
||||
if(null === $this->collCcShowDayss || null !== $criteria) {
|
||||
if ($this->isNew() && null === $this->collCcShowDayss) {
|
||||
// return empty collection
|
||||
$this->initCcShowDayss();
|
||||
} else {
|
||||
$collCcShowDayss = CcShowDaysQuery::create(null, $criteria)
|
||||
->filterByCcShow($this)
|
||||
->orderByDbFirstShow()
|
||||
->limit(1)
|
||||
->find($con);
|
||||
if (null !== $criteria) {
|
||||
return $collCcShowDayss;
|
||||
}
|
||||
$this->collCcShowDayss = $collCcShowDayss;
|
||||
}
|
||||
}
|
||||
return $this->collCcShowDayss[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an array of CcShowInstances objects which contain a foreign key that references this object.
|
||||
*
|
||||
* If the $criteria is not null, it is used to always fetch the results from the database.
|
||||
* Otherwise the results are fetched from the database the first time, then cached.
|
||||
* Next time the same method is called without $criteria, the cached collection is returned.
|
||||
* If this CcShow is new, it will return
|
||||
* an empty collection or the current collection; the criteria is ignored on a new object.
|
||||
*
|
||||
* @param Criteria $criteria optional Criteria object to narrow the query
|
||||
* @param PropelPDO $con optional connection object
|
||||
* @return PropelCollection|array CcShowInstances[] List of CcShowInstances objects
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getFutureCcShowInstancess($criteria = null, PropelPDO $con = null)
|
||||
{
|
||||
if(null === $this->collCcShowInstancess || null !== $criteria) {
|
||||
if ($this->isNew() && null === $this->collCcShowInstancess) {
|
||||
// return empty collection
|
||||
$this->initCcShowInstancess();
|
||||
} else {
|
||||
$collCcShowInstancess = CcShowInstancesQuery::create(null, $criteria)
|
||||
->filterByCcShow($this)
|
||||
->filterByDbStarts(gmdate("Y-m-d H:i:s"), Criteria::GREATER_THAN)
|
||||
->filterByDbModifiedInstance(false)
|
||||
->find($con);
|
||||
if (null !== $criteria) {
|
||||
return $collCcShowInstancess;
|
||||
}
|
||||
$this->collCcShowInstancess = $collCcShowInstancess;
|
||||
}
|
||||
}
|
||||
return $this->collCcShowInstancess;
|
||||
}
|
||||
|
||||
public function isRecorded()
|
||||
{
|
||||
$ccShowInstances = CcShowInstancesQuery::create()
|
||||
->filterByDbShowId($this->getDbId())
|
||||
->filterByDbRecord(1)
|
||||
->filterByDbModifiedInstance(false)
|
||||
->findOne();
|
||||
|
||||
return (!is_null($ccShowInstances));
|
||||
}
|
||||
|
||||
public function isRebroadcast()
|
||||
{
|
||||
$ccShowInstances = CcShowInstancesQuery::create()
|
||||
->filterByDbShowId($this->getDbId())
|
||||
->filterByDbRebroadcast(1)
|
||||
->filterByDbModifiedInstance(false)
|
||||
->findOne();
|
||||
|
||||
return (!is_null($ccShowInstances));
|
||||
}
|
||||
|
||||
public function getRebroadcastsRelative()
|
||||
{
|
||||
return CcShowRebroadcastQuery::create()
|
||||
->filterByDbShowId($this->getDbId())
|
||||
->orderByDbDayOffset()
|
||||
->find();
|
||||
}
|
||||
|
||||
public function getRebroadcastsAbsolute()
|
||||
{
|
||||
return CcShowInstancesQuery::create()
|
||||
->filterByDbShowId($this->getDbId())
|
||||
->filterByDbRebroadcast(1)
|
||||
->filterByDbModifiedInstance(false)
|
||||
->orderByDbStarts()
|
||||
->find();
|
||||
}
|
||||
|
||||
public function isLinked()
|
||||
{
|
||||
return $this->getDbLinked();
|
||||
}
|
||||
|
||||
public function isLinkable()
|
||||
{
|
||||
return $this->getDbIsLinkable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an array of CcShowInstances objects which contain a foreign key that references this object.
|
||||
*
|
||||
* If the $criteria is not null, it is used to always fetch the results from the database.
|
||||
* Otherwise the results are fetched from the database the first time, then cached.
|
||||
* Next time the same method is called without $criteria, the cached collection is returned.
|
||||
* If this CcShow is new, it will return
|
||||
* an empty collection or the current collection; the criteria is ignored on a new object.
|
||||
*
|
||||
* @param Criteria $criteria optional Criteria object to narrow the query
|
||||
* @param PropelPDO $con optional connection object
|
||||
* @return PropelCollection|array CcShowInstances[] List of CcShowInstances objects
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getCcShowInstancess($criteria = null, PropelPDO $con = null)
|
||||
{
|
||||
if(null === $this->collCcShowInstancess || null !== $criteria) {
|
||||
if ($this->isNew() && null === $this->collCcShowInstancess) {
|
||||
// return empty collection
|
||||
$this->initCcShowInstancess();
|
||||
} else {
|
||||
$collCcShowInstancess = CcShowInstancesQuery::create(null, $criteria)
|
||||
->filterByCcShow($this)
|
||||
->filterByDbModifiedInstance(false)
|
||||
->filterByDbStarts(gmdate("Y-m-d H:i:s"), criteria::GREATER_THAN)
|
||||
->orderByDbId()
|
||||
->find($con);
|
||||
if (null !== $criteria) {
|
||||
return $collCcShowInstancess;
|
||||
}
|
||||
$this->collCcShowInstancess = $collCcShowInstancess;
|
||||
}
|
||||
}
|
||||
return $this->collCcShowInstancess;
|
||||
}
|
||||
|
||||
public function getInstanceIds() {
|
||||
$instanceIds = array();
|
||||
foreach ($this->getCcShowInstancess() as $ccShowInstance) {
|
||||
$instanceIds[] = $ccShowInstance->getDbId();
|
||||
}
|
||||
return $instanceIds;
|
||||
}
|
||||
} // CcShow
|
||||
|
|
|
@ -15,4 +15,54 @@
|
|||
*/
|
||||
class CcShowDays extends BaseCcShowDays {
|
||||
|
||||
public function isRepeating()
|
||||
{
|
||||
return $this->getDbRepeatType() != -1;
|
||||
}
|
||||
|
||||
public function getUTCStartDateAndTime()
|
||||
{
|
||||
$dt = new DateTime(
|
||||
"{$this->getDbFirstShow()} {$this->getDbStartTime()}",
|
||||
new DateTimeZone($this->getDbTimezone())
|
||||
);
|
||||
$dt->setTimezone(new DateTimeZone("UTC"));
|
||||
|
||||
return $dt;
|
||||
}
|
||||
|
||||
public function getLocalStartDateAndTime()
|
||||
{
|
||||
$dt = new DateTime(
|
||||
"{$this->getDbFirstShow()} {$this->getDbStartTime()}",
|
||||
new DateTimeZone($this->getDbTimezone())
|
||||
);
|
||||
|
||||
return $dt;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
* @param DateTime $startDateTime first show in user's local time
|
||||
*/
|
||||
public function getLocalEndDateAndTime($showStart)
|
||||
{
|
||||
$startDateTime = clone $showStart;
|
||||
$duration = explode(":", $this->getDbDuration());
|
||||
|
||||
return $startDateTime->add(new DateInterval('PT'.$duration[0].'H'.$duration[1].'M'));
|
||||
}
|
||||
|
||||
public function isShowStartInPast()
|
||||
{
|
||||
return $this->getUTCStartDateAndTime()->format("Y-m-d H:i:s") < gmdate("Y-m-d H:i:s");
|
||||
}
|
||||
|
||||
public function formatDuration()
|
||||
{
|
||||
$info = explode(':',$this->getDbDuration());
|
||||
|
||||
return str_pad(intval($info[0]),2,'0',STR_PAD_LEFT).'h '.str_pad(intval($info[1]),2,'0',STR_PAD_LEFT).'m';
|
||||
}
|
||||
} // CcShowDays
|
||||
|
|
|
@ -175,4 +175,20 @@ class CcShowInstances extends BaseCcShowInstances {
|
|||
return true;
|
||||
}
|
||||
|
||||
public function isRecorded()
|
||||
{
|
||||
return $this->getDbRecord() == 1 ? true : false;
|
||||
}
|
||||
|
||||
public function isRebroadcast()
|
||||
{
|
||||
return $this->getDbRebroadcast() == 1 ? true : false;
|
||||
}
|
||||
|
||||
public function getLocalStartDateTime()
|
||||
{
|
||||
$startDT = $this->getDbStarts(null);
|
||||
return $startDT->setTimezone(new DateTimeZone(Application_Model_Preference::GetTimezone()));
|
||||
}
|
||||
|
||||
} // CcShowInstances
|
||||
|
|
|
@ -15,4 +15,16 @@
|
|||
*/
|
||||
class CcSubjs extends BaseCcSubjs {
|
||||
|
||||
public function isAdminOrPM()
|
||||
{
|
||||
return $this->type === UTYPE_ADMIN || $this->type === UTYPE_PROGRAM_MANAGER;
|
||||
}
|
||||
|
||||
public function isHostOfShow($showId)
|
||||
{
|
||||
return CcShowHostsQuery::create()
|
||||
->filterByDbShow($showId)
|
||||
->filterByDbHost($this->getDbId())
|
||||
->count() > 0;
|
||||
}
|
||||
} // CcSubjs
|
||||
|
|
|
@ -52,6 +52,7 @@ class CcScheduleTableMap extends TableMap {
|
|||
$this->addForeignKey('INSTANCE_ID', 'DbInstanceId', 'INTEGER', 'cc_show_instances', 'ID', true, null, null);
|
||||
$this->addColumn('PLAYOUT_STATUS', 'DbPlayoutStatus', 'SMALLINT', true, null, 1);
|
||||
$this->addColumn('BROADCASTED', 'DbBroadcasted', 'SMALLINT', true, null, 0);
|
||||
$this->addColumn('POSITION', 'DbPosition', 'INTEGER', true, null, 0);
|
||||
// validators
|
||||
} // initialize()
|
||||
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This class defines the structure of the 'cc_show_stamp' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* This map class is used by Propel to do runtime db structure discovery.
|
||||
* For example, the createSelectSql() method checks the type of a given column used in an
|
||||
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
|
||||
* (i.e. if it's a text column type).
|
||||
*
|
||||
* @package propel.generator.airtime.map
|
||||
*/
|
||||
class CcShowStampTableMap extends TableMap {
|
||||
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'airtime.map.CcShowStampTableMap';
|
||||
|
||||
/**
|
||||
* Initialize the table attributes, columns and validators
|
||||
* Relations are not initialized by this method since they are lazy loaded
|
||||
*
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function initialize()
|
||||
{
|
||||
// attributes
|
||||
$this->setName('cc_show_stamp');
|
||||
$this->setPhpName('CcShowStamp');
|
||||
$this->setClassname('CcShowStamp');
|
||||
$this->setPackage('airtime');
|
||||
$this->setUseIdGenerator(true);
|
||||
$this->setPrimaryKeyMethodInfo('cc_show_stamp_id_seq');
|
||||
// columns
|
||||
$this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null);
|
||||
$this->addForeignKey('SHOW_ID', 'DbShowId', 'INTEGER', 'cc_show', 'ID', true, null, null);
|
||||
$this->addForeignKey('INSTANCE_ID', 'DbInstanceId', 'INTEGER', 'cc_show_instances', 'ID', false, null, null);
|
||||
$this->addForeignKey('FILE_ID', 'DbFileId', 'INTEGER', 'cc_files', 'ID', false, null, null);
|
||||
$this->addForeignKey('STREAM_ID', 'DbStreamId', 'INTEGER', 'cc_webstream', 'ID', false, null, null);
|
||||
$this->addForeignKey('BLOCK_ID', 'DbBlockId', 'INTEGER', 'cc_block', 'ID', false, null, null);
|
||||
$this->addForeignKey('PLAYLIST_ID', 'DbPlaylistId', 'INTEGER', 'cc_playlist', 'ID', false, null, null);
|
||||
$this->addColumn('POSITION', 'DbPosition', 'INTEGER', true, null, null);
|
||||
$this->addColumn('CLIP_LENGTH', 'DbClipLength', 'VARCHAR', false, null, '00:00:00');
|
||||
$this->addColumn('CUE_IN', 'DbCueIn', 'VARCHAR', false, null, '00:00:00');
|
||||
$this->addColumn('CUE_OUT', 'DbCueOut', 'VARCHAR', false, null, '00:00:00');
|
||||
$this->addColumn('FADE_IN', 'DbFadeIn', 'VARCHAR', false, null, '00:00:00');
|
||||
$this->addColumn('FADE_OUT', 'DbFadeOut', 'VARCHAR', false, null, '00:00:00');
|
||||
// validators
|
||||
} // initialize()
|
||||
|
||||
/**
|
||||
* Build the RelationMap objects for this table relationships
|
||||
*/
|
||||
public function buildRelations()
|
||||
{
|
||||
$this->addRelation('CcShow', 'CcShow', RelationMap::MANY_TO_ONE, array('show_id' => 'id', ), 'CASCADE', null);
|
||||
$this->addRelation('CcShowInstances', 'CcShowInstances', RelationMap::MANY_TO_ONE, array('instance_id' => 'id', ), 'CASCADE', null);
|
||||
$this->addRelation('CcFiles', 'CcFiles', RelationMap::MANY_TO_ONE, array('file_id' => 'id', ), 'CASCADE', null);
|
||||
$this->addRelation('CcWebstream', 'CcWebstream', RelationMap::MANY_TO_ONE, array('stream_id' => 'id', ), 'CASCADE', null);
|
||||
$this->addRelation('CcBlock', 'CcBlock', RelationMap::MANY_TO_ONE, array('block_id' => 'id', ), 'CASCADE', null);
|
||||
$this->addRelation('CcPlaylist', 'CcPlaylist', RelationMap::MANY_TO_ONE, array('playlist_id' => 'id', ), 'CASCADE', null);
|
||||
} // buildRelations()
|
||||
|
||||
} // CcShowStampTableMap
|
|
@ -49,6 +49,8 @@ class CcShowTableMap extends TableMap {
|
|||
$this->addColumn('LIVE_STREAM_USING_CUSTOM_AUTH', 'DbLiveStreamUsingCustomAuth', 'BOOLEAN', false, null, false);
|
||||
$this->addColumn('LIVE_STREAM_USER', 'DbLiveStreamUser', 'VARCHAR', false, 255, null);
|
||||
$this->addColumn('LIVE_STREAM_PASS', 'DbLiveStreamPass', 'VARCHAR', false, 255, null);
|
||||
$this->addColumn('LINKED', 'DbLinked', 'BOOLEAN', true, null, false);
|
||||
$this->addColumn('IS_LINKABLE', 'DbIsLinkable', 'BOOLEAN', true, null, true);
|
||||
// validators
|
||||
} // initialize()
|
||||
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This class defines the structure of the 'cc_stamp_contents' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* This map class is used by Propel to do runtime db structure discovery.
|
||||
* For example, the createSelectSql() method checks the type of a given column used in an
|
||||
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
|
||||
* (i.e. if it's a text column type).
|
||||
*
|
||||
* @package propel.generator.airtime.map
|
||||
*/
|
||||
class CcStampContentsTableMap extends TableMap {
|
||||
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'airtime.map.CcStampContentsTableMap';
|
||||
|
||||
/**
|
||||
* Initialize the table attributes, columns and validators
|
||||
* Relations are not initialized by this method since they are lazy loaded
|
||||
*
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function initialize()
|
||||
{
|
||||
// attributes
|
||||
$this->setName('cc_stamp_contents');
|
||||
$this->setPhpName('CcStampContents');
|
||||
$this->setClassname('CcStampContents');
|
||||
$this->setPackage('airtime');
|
||||
$this->setUseIdGenerator(true);
|
||||
$this->setPrimaryKeyMethodInfo('cc_stamp_contents_id_seq');
|
||||
// columns
|
||||
$this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null);
|
||||
$this->addForeignKey('STAMP_ID', 'DbStampId', 'INTEGER', 'cc_stamp', 'ID', true, null, null);
|
||||
$this->addForeignKey('FILE_ID', 'DbFileId', 'INTEGER', 'cc_files', 'ID', false, null, null);
|
||||
$this->addForeignKey('STREAM_ID', 'DbStreamId', 'INTEGER', 'cc_webstream', 'ID', false, null, null);
|
||||
$this->addForeignKey('BLOCK_ID', 'DbBlockId', 'INTEGER', 'cc_block', 'ID', false, null, null);
|
||||
$this->addForeignKey('PLAYLIST_ID', 'DbPlaylistId', 'INTEGER', 'cc_playlist', 'ID', false, null, null);
|
||||
$this->addColumn('POSITION', 'DbPosition', 'INTEGER', false, null, null);
|
||||
$this->addColumn('CLIP_LENGTH', 'DbClipLength', 'VARCHAR', false, null, '00:00:00');
|
||||
$this->addColumn('CUE_IN', 'DbCueIn', 'VARCHAR', false, null, '00:00:00');
|
||||
$this->addColumn('CUE_OUT', 'DbCueOut', 'VARCHAR', false, null, '00:00:00');
|
||||
$this->addColumn('FADE_IN', 'DbFadeIn', 'VARCHAR', false, null, '00:00:00');
|
||||
$this->addColumn('FADE_OUT', 'DbFadeOut', 'VARCHAR', false, null, '00:00:00');
|
||||
// validators
|
||||
} // initialize()
|
||||
|
||||
/**
|
||||
* Build the RelationMap objects for this table relationships
|
||||
*/
|
||||
public function buildRelations()
|
||||
{
|
||||
$this->addRelation('CcStamp', 'CcStamp', RelationMap::MANY_TO_ONE, array('stamp_id' => 'id', ), 'CASCADE', null);
|
||||
$this->addRelation('CcFiles', 'CcFiles', RelationMap::MANY_TO_ONE, array('file_id' => 'id', ), 'CASCADE', null);
|
||||
$this->addRelation('CcWebstream', 'CcWebstream', RelationMap::MANY_TO_ONE, array('stream_id' => 'id', ), 'CASCADE', null);
|
||||
$this->addRelation('CcBlock', 'CcBlock', RelationMap::MANY_TO_ONE, array('block_id' => 'id', ), 'CASCADE', null);
|
||||
$this->addRelation('CcPlaylist', 'CcPlaylist', RelationMap::MANY_TO_ONE, array('playlist_id' => 'id', ), 'CASCADE', null);
|
||||
} // buildRelations()
|
||||
|
||||
} // CcStampContentsTableMap
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This class defines the structure of the 'cc_stamp' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* This map class is used by Propel to do runtime db structure discovery.
|
||||
* For example, the createSelectSql() method checks the type of a given column used in an
|
||||
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
|
||||
* (i.e. if it's a text column type).
|
||||
*
|
||||
* @package propel.generator.airtime.map
|
||||
*/
|
||||
class CcStampTableMap extends TableMap {
|
||||
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'airtime.map.CcStampTableMap';
|
||||
|
||||
/**
|
||||
* Initialize the table attributes, columns and validators
|
||||
* Relations are not initialized by this method since they are lazy loaded
|
||||
*
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function initialize()
|
||||
{
|
||||
// attributes
|
||||
$this->setName('cc_stamp');
|
||||
$this->setPhpName('CcStamp');
|
||||
$this->setClassname('CcStamp');
|
||||
$this->setPackage('airtime');
|
||||
$this->setUseIdGenerator(true);
|
||||
$this->setPrimaryKeyMethodInfo('cc_stamp_id_seq');
|
||||
// columns
|
||||
$this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null);
|
||||
$this->addForeignKey('SHOW_ID', 'DbShowId', 'INTEGER', 'cc_show', 'ID', true, null, null);
|
||||
$this->addForeignKey('INSTANCE_ID', 'DbInstanceId', 'INTEGER', 'cc_show_instances', 'ID', false, null, null);
|
||||
$this->addColumn('LINKED', 'DbLinked', 'BOOLEAN', true, null, null);
|
||||
// validators
|
||||
} // initialize()
|
||||
|
||||
/**
|
||||
* Build the RelationMap objects for this table relationships
|
||||
*/
|
||||
public function buildRelations()
|
||||
{
|
||||
$this->addRelation('CcShow', 'CcShow', RelationMap::MANY_TO_ONE, array('show_id' => 'id', ), 'CASCADE', null);
|
||||
$this->addRelation('CcShowInstances', 'CcShowInstances', RelationMap::MANY_TO_ONE, array('instance_id' => 'id', ), 'CASCADE', null);
|
||||
$this->addRelation('CcStampContents', 'CcStampContents', RelationMap::ONE_TO_MANY, array('id' => 'stamp_id', ), 'CASCADE', null);
|
||||
} // buildRelations()
|
||||
|
||||
} // CcStampTableMap
|
|
@ -114,6 +114,13 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent
|
|||
*/
|
||||
protected $broadcasted;
|
||||
|
||||
/**
|
||||
* The value for the position field.
|
||||
* Note: this column has a database default value of: 0
|
||||
* @var int
|
||||
*/
|
||||
protected $position;
|
||||
|
||||
/**
|
||||
* @var CcShowInstances
|
||||
*/
|
||||
|
@ -162,6 +169,7 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent
|
|||
$this->media_item_played = false;
|
||||
$this->playout_status = 1;
|
||||
$this->broadcasted = 0;
|
||||
$this->position = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -406,6 +414,16 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent
|
|||
return $this->broadcasted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [position] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getDbPosition()
|
||||
{
|
||||
return $this->position;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of [id] column.
|
||||
*
|
||||
|
@ -816,6 +834,26 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent
|
|||
return $this;
|
||||
} // setDbBroadcasted()
|
||||
|
||||
/**
|
||||
* Set the value of [position] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return CcSchedule The current object (for fluent API support)
|
||||
*/
|
||||
public function setDbPosition($v)
|
||||
{
|
||||
if ($v !== null) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->position !== $v || $this->isNew()) {
|
||||
$this->position = $v;
|
||||
$this->modifiedColumns[] = CcSchedulePeer::POSITION;
|
||||
}
|
||||
|
||||
return $this;
|
||||
} // setDbPosition()
|
||||
|
||||
/**
|
||||
* Indicates whether the columns in this object are only set to default values.
|
||||
*
|
||||
|
@ -850,6 +888,10 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent
|
|||
return false;
|
||||
}
|
||||
|
||||
if ($this->position !== 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// otherwise, everything was equal, so return TRUE
|
||||
return true;
|
||||
} // hasOnlyDefaultValues()
|
||||
|
@ -886,6 +928,7 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent
|
|||
$this->instance_id = ($row[$startcol + 11] !== null) ? (int) $row[$startcol + 11] : null;
|
||||
$this->playout_status = ($row[$startcol + 12] !== null) ? (int) $row[$startcol + 12] : null;
|
||||
$this->broadcasted = ($row[$startcol + 13] !== null) ? (int) $row[$startcol + 13] : null;
|
||||
$this->position = ($row[$startcol + 14] !== null) ? (int) $row[$startcol + 14] : null;
|
||||
$this->resetModified();
|
||||
|
||||
$this->setNew(false);
|
||||
|
@ -894,7 +937,7 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent
|
|||
$this->ensureConsistency();
|
||||
}
|
||||
|
||||
return $startcol + 14; // 14 = CcSchedulePeer::NUM_COLUMNS - CcSchedulePeer::NUM_LAZY_LOAD_COLUMNS).
|
||||
return $startcol + 15; // 15 = CcSchedulePeer::NUM_COLUMNS - CcSchedulePeer::NUM_LAZY_LOAD_COLUMNS).
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating CcSchedule object", $e);
|
||||
|
@ -1315,6 +1358,9 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent
|
|||
case 13:
|
||||
return $this->getDbBroadcasted();
|
||||
break;
|
||||
case 14:
|
||||
return $this->getDbPosition();
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
break;
|
||||
|
@ -1353,6 +1399,7 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent
|
|||
$keys[11] => $this->getDbInstanceId(),
|
||||
$keys[12] => $this->getDbPlayoutStatus(),
|
||||
$keys[13] => $this->getDbBroadcasted(),
|
||||
$keys[14] => $this->getDbPosition(),
|
||||
);
|
||||
if ($includeForeignObjects) {
|
||||
if (null !== $this->aCcShowInstances) {
|
||||
|
@ -1437,6 +1484,9 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent
|
|||
case 13:
|
||||
$this->setDbBroadcasted($value);
|
||||
break;
|
||||
case 14:
|
||||
$this->setDbPosition($value);
|
||||
break;
|
||||
} // switch()
|
||||
}
|
||||
|
||||
|
@ -1475,6 +1525,7 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent
|
|||
if (array_key_exists($keys[11], $arr)) $this->setDbInstanceId($arr[$keys[11]]);
|
||||
if (array_key_exists($keys[12], $arr)) $this->setDbPlayoutStatus($arr[$keys[12]]);
|
||||
if (array_key_exists($keys[13], $arr)) $this->setDbBroadcasted($arr[$keys[13]]);
|
||||
if (array_key_exists($keys[14], $arr)) $this->setDbPosition($arr[$keys[14]]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1500,6 +1551,7 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent
|
|||
if ($this->isColumnModified(CcSchedulePeer::INSTANCE_ID)) $criteria->add(CcSchedulePeer::INSTANCE_ID, $this->instance_id);
|
||||
if ($this->isColumnModified(CcSchedulePeer::PLAYOUT_STATUS)) $criteria->add(CcSchedulePeer::PLAYOUT_STATUS, $this->playout_status);
|
||||
if ($this->isColumnModified(CcSchedulePeer::BROADCASTED)) $criteria->add(CcSchedulePeer::BROADCASTED, $this->broadcasted);
|
||||
if ($this->isColumnModified(CcSchedulePeer::POSITION)) $criteria->add(CcSchedulePeer::POSITION, $this->position);
|
||||
|
||||
return $criteria;
|
||||
}
|
||||
|
@ -1574,6 +1626,7 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent
|
|||
$copyObj->setDbInstanceId($this->instance_id);
|
||||
$copyObj->setDbPlayoutStatus($this->playout_status);
|
||||
$copyObj->setDbBroadcasted($this->broadcasted);
|
||||
$copyObj->setDbPosition($this->position);
|
||||
|
||||
if ($deepCopy) {
|
||||
// important: temporarily setNew(false) because this affects the behavior of
|
||||
|
@ -1906,6 +1959,7 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent
|
|||
$this->instance_id = null;
|
||||
$this->playout_status = null;
|
||||
$this->broadcasted = null;
|
||||
$this->position = null;
|
||||
$this->alreadyInSave = false;
|
||||
$this->alreadyInValidation = false;
|
||||
$this->clearAllReferences();
|
||||
|
|
|
@ -26,7 +26,7 @@ abstract class BaseCcSchedulePeer {
|
|||
const TM_CLASS = 'CcScheduleTableMap';
|
||||
|
||||
/** The total number of columns. */
|
||||
const NUM_COLUMNS = 14;
|
||||
const NUM_COLUMNS = 15;
|
||||
|
||||
/** The number of lazy-loaded columns. */
|
||||
const NUM_LAZY_LOAD_COLUMNS = 0;
|
||||
|
@ -73,6 +73,9 @@ abstract class BaseCcSchedulePeer {
|
|||
/** the column name for the BROADCASTED field */
|
||||
const BROADCASTED = 'cc_schedule.BROADCASTED';
|
||||
|
||||
/** the column name for the POSITION field */
|
||||
const POSITION = 'cc_schedule.POSITION';
|
||||
|
||||
/**
|
||||
* An identiy map to hold any loaded instances of CcSchedule objects.
|
||||
* This must be public so that other peer classes can access this when hydrating from JOIN
|
||||
|
@ -89,12 +92,12 @@ abstract class BaseCcSchedulePeer {
|
|||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||
*/
|
||||
private static $fieldNames = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('DbId', 'DbStarts', 'DbEnds', 'DbFileId', 'DbStreamId', 'DbClipLength', 'DbFadeIn', 'DbFadeOut', 'DbCueIn', 'DbCueOut', 'DbMediaItemPlayed', 'DbInstanceId', 'DbPlayoutStatus', 'DbBroadcasted', ),
|
||||
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbStarts', 'dbEnds', 'dbFileId', 'dbStreamId', 'dbClipLength', 'dbFadeIn', 'dbFadeOut', 'dbCueIn', 'dbCueOut', 'dbMediaItemPlayed', 'dbInstanceId', 'dbPlayoutStatus', 'dbBroadcasted', ),
|
||||
BasePeer::TYPE_COLNAME => array (self::ID, self::STARTS, self::ENDS, self::FILE_ID, self::STREAM_ID, self::CLIP_LENGTH, self::FADE_IN, self::FADE_OUT, self::CUE_IN, self::CUE_OUT, self::MEDIA_ITEM_PLAYED, self::INSTANCE_ID, self::PLAYOUT_STATUS, self::BROADCASTED, ),
|
||||
BasePeer::TYPE_RAW_COLNAME => array ('ID', 'STARTS', 'ENDS', 'FILE_ID', 'STREAM_ID', 'CLIP_LENGTH', 'FADE_IN', 'FADE_OUT', 'CUE_IN', 'CUE_OUT', 'MEDIA_ITEM_PLAYED', 'INSTANCE_ID', 'PLAYOUT_STATUS', 'BROADCASTED', ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id', 'starts', 'ends', 'file_id', 'stream_id', 'clip_length', 'fade_in', 'fade_out', 'cue_in', 'cue_out', 'media_item_played', 'instance_id', 'playout_status', 'broadcasted', ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, )
|
||||
BasePeer::TYPE_PHPNAME => array ('DbId', 'DbStarts', 'DbEnds', 'DbFileId', 'DbStreamId', 'DbClipLength', 'DbFadeIn', 'DbFadeOut', 'DbCueIn', 'DbCueOut', 'DbMediaItemPlayed', 'DbInstanceId', 'DbPlayoutStatus', 'DbBroadcasted', 'DbPosition', ),
|
||||
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbStarts', 'dbEnds', 'dbFileId', 'dbStreamId', 'dbClipLength', 'dbFadeIn', 'dbFadeOut', 'dbCueIn', 'dbCueOut', 'dbMediaItemPlayed', 'dbInstanceId', 'dbPlayoutStatus', 'dbBroadcasted', 'dbPosition', ),
|
||||
BasePeer::TYPE_COLNAME => array (self::ID, self::STARTS, self::ENDS, self::FILE_ID, self::STREAM_ID, self::CLIP_LENGTH, self::FADE_IN, self::FADE_OUT, self::CUE_IN, self::CUE_OUT, self::MEDIA_ITEM_PLAYED, self::INSTANCE_ID, self::PLAYOUT_STATUS, self::BROADCASTED, self::POSITION, ),
|
||||
BasePeer::TYPE_RAW_COLNAME => array ('ID', 'STARTS', 'ENDS', 'FILE_ID', 'STREAM_ID', 'CLIP_LENGTH', 'FADE_IN', 'FADE_OUT', 'CUE_IN', 'CUE_OUT', 'MEDIA_ITEM_PLAYED', 'INSTANCE_ID', 'PLAYOUT_STATUS', 'BROADCASTED', 'POSITION', ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id', 'starts', 'ends', 'file_id', 'stream_id', 'clip_length', 'fade_in', 'fade_out', 'cue_in', 'cue_out', 'media_item_played', 'instance_id', 'playout_status', 'broadcasted', 'position', ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, )
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -104,12 +107,12 @@ abstract class BaseCcSchedulePeer {
|
|||
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
private static $fieldKeys = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbStarts' => 1, 'DbEnds' => 2, 'DbFileId' => 3, 'DbStreamId' => 4, 'DbClipLength' => 5, 'DbFadeIn' => 6, 'DbFadeOut' => 7, 'DbCueIn' => 8, 'DbCueOut' => 9, 'DbMediaItemPlayed' => 10, 'DbInstanceId' => 11, 'DbPlayoutStatus' => 12, 'DbBroadcasted' => 13, ),
|
||||
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbStarts' => 1, 'dbEnds' => 2, 'dbFileId' => 3, 'dbStreamId' => 4, 'dbClipLength' => 5, 'dbFadeIn' => 6, 'dbFadeOut' => 7, 'dbCueIn' => 8, 'dbCueOut' => 9, 'dbMediaItemPlayed' => 10, 'dbInstanceId' => 11, 'dbPlayoutStatus' => 12, 'dbBroadcasted' => 13, ),
|
||||
BasePeer::TYPE_COLNAME => array (self::ID => 0, self::STARTS => 1, self::ENDS => 2, self::FILE_ID => 3, self::STREAM_ID => 4, self::CLIP_LENGTH => 5, self::FADE_IN => 6, self::FADE_OUT => 7, self::CUE_IN => 8, self::CUE_OUT => 9, self::MEDIA_ITEM_PLAYED => 10, self::INSTANCE_ID => 11, self::PLAYOUT_STATUS => 12, self::BROADCASTED => 13, ),
|
||||
BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'STARTS' => 1, 'ENDS' => 2, 'FILE_ID' => 3, 'STREAM_ID' => 4, 'CLIP_LENGTH' => 5, 'FADE_IN' => 6, 'FADE_OUT' => 7, 'CUE_IN' => 8, 'CUE_OUT' => 9, 'MEDIA_ITEM_PLAYED' => 10, 'INSTANCE_ID' => 11, 'PLAYOUT_STATUS' => 12, 'BROADCASTED' => 13, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'starts' => 1, 'ends' => 2, 'file_id' => 3, 'stream_id' => 4, 'clip_length' => 5, 'fade_in' => 6, 'fade_out' => 7, 'cue_in' => 8, 'cue_out' => 9, 'media_item_played' => 10, 'instance_id' => 11, 'playout_status' => 12, 'broadcasted' => 13, ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, )
|
||||
BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbStarts' => 1, 'DbEnds' => 2, 'DbFileId' => 3, 'DbStreamId' => 4, 'DbClipLength' => 5, 'DbFadeIn' => 6, 'DbFadeOut' => 7, 'DbCueIn' => 8, 'DbCueOut' => 9, 'DbMediaItemPlayed' => 10, 'DbInstanceId' => 11, 'DbPlayoutStatus' => 12, 'DbBroadcasted' => 13, 'DbPosition' => 14, ),
|
||||
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbStarts' => 1, 'dbEnds' => 2, 'dbFileId' => 3, 'dbStreamId' => 4, 'dbClipLength' => 5, 'dbFadeIn' => 6, 'dbFadeOut' => 7, 'dbCueIn' => 8, 'dbCueOut' => 9, 'dbMediaItemPlayed' => 10, 'dbInstanceId' => 11, 'dbPlayoutStatus' => 12, 'dbBroadcasted' => 13, 'dbPosition' => 14, ),
|
||||
BasePeer::TYPE_COLNAME => array (self::ID => 0, self::STARTS => 1, self::ENDS => 2, self::FILE_ID => 3, self::STREAM_ID => 4, self::CLIP_LENGTH => 5, self::FADE_IN => 6, self::FADE_OUT => 7, self::CUE_IN => 8, self::CUE_OUT => 9, self::MEDIA_ITEM_PLAYED => 10, self::INSTANCE_ID => 11, self::PLAYOUT_STATUS => 12, self::BROADCASTED => 13, self::POSITION => 14, ),
|
||||
BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'STARTS' => 1, 'ENDS' => 2, 'FILE_ID' => 3, 'STREAM_ID' => 4, 'CLIP_LENGTH' => 5, 'FADE_IN' => 6, 'FADE_OUT' => 7, 'CUE_IN' => 8, 'CUE_OUT' => 9, 'MEDIA_ITEM_PLAYED' => 10, 'INSTANCE_ID' => 11, 'PLAYOUT_STATUS' => 12, 'BROADCASTED' => 13, 'POSITION' => 14, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'starts' => 1, 'ends' => 2, 'file_id' => 3, 'stream_id' => 4, 'clip_length' => 5, 'fade_in' => 6, 'fade_out' => 7, 'cue_in' => 8, 'cue_out' => 9, 'media_item_played' => 10, 'instance_id' => 11, 'playout_status' => 12, 'broadcasted' => 13, 'position' => 14, ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, )
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -195,6 +198,7 @@ abstract class BaseCcSchedulePeer {
|
|||
$criteria->addSelectColumn(CcSchedulePeer::INSTANCE_ID);
|
||||
$criteria->addSelectColumn(CcSchedulePeer::PLAYOUT_STATUS);
|
||||
$criteria->addSelectColumn(CcSchedulePeer::BROADCASTED);
|
||||
$criteria->addSelectColumn(CcSchedulePeer::POSITION);
|
||||
} else {
|
||||
$criteria->addSelectColumn($alias . '.ID');
|
||||
$criteria->addSelectColumn($alias . '.STARTS');
|
||||
|
@ -210,6 +214,7 @@ abstract class BaseCcSchedulePeer {
|
|||
$criteria->addSelectColumn($alias . '.INSTANCE_ID');
|
||||
$criteria->addSelectColumn($alias . '.PLAYOUT_STATUS');
|
||||
$criteria->addSelectColumn($alias . '.BROADCASTED');
|
||||
$criteria->addSelectColumn($alias . '.POSITION');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
* @method CcScheduleQuery orderByDbInstanceId($order = Criteria::ASC) Order by the instance_id column
|
||||
* @method CcScheduleQuery orderByDbPlayoutStatus($order = Criteria::ASC) Order by the playout_status column
|
||||
* @method CcScheduleQuery orderByDbBroadcasted($order = Criteria::ASC) Order by the broadcasted column
|
||||
* @method CcScheduleQuery orderByDbPosition($order = Criteria::ASC) Order by the position column
|
||||
*
|
||||
* @method CcScheduleQuery groupByDbId() Group by the id column
|
||||
* @method CcScheduleQuery groupByDbStarts() Group by the starts column
|
||||
|
@ -35,6 +36,7 @@
|
|||
* @method CcScheduleQuery groupByDbInstanceId() Group by the instance_id column
|
||||
* @method CcScheduleQuery groupByDbPlayoutStatus() Group by the playout_status column
|
||||
* @method CcScheduleQuery groupByDbBroadcasted() Group by the broadcasted column
|
||||
* @method CcScheduleQuery groupByDbPosition() Group by the position column
|
||||
*
|
||||
* @method CcScheduleQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
|
||||
* @method CcScheduleQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
|
||||
|
@ -73,6 +75,7 @@
|
|||
* @method CcSchedule findOneByDbInstanceId(int $instance_id) Return the first CcSchedule filtered by the instance_id column
|
||||
* @method CcSchedule findOneByDbPlayoutStatus(int $playout_status) Return the first CcSchedule filtered by the playout_status column
|
||||
* @method CcSchedule findOneByDbBroadcasted(int $broadcasted) Return the first CcSchedule filtered by the broadcasted column
|
||||
* @method CcSchedule findOneByDbPosition(int $position) Return the first CcSchedule filtered by the position column
|
||||
*
|
||||
* @method array findByDbId(int $id) Return CcSchedule objects filtered by the id column
|
||||
* @method array findByDbStarts(string $starts) Return CcSchedule objects filtered by the starts column
|
||||
|
@ -88,6 +91,7 @@
|
|||
* @method array findByDbInstanceId(int $instance_id) Return CcSchedule objects filtered by the instance_id column
|
||||
* @method array findByDbPlayoutStatus(int $playout_status) Return CcSchedule objects filtered by the playout_status column
|
||||
* @method array findByDbBroadcasted(int $broadcasted) Return CcSchedule objects filtered by the broadcasted column
|
||||
* @method array findByDbPosition(int $position) Return CcSchedule objects filtered by the position column
|
||||
*
|
||||
* @package propel.generator.airtime.om
|
||||
*/
|
||||
|
@ -576,6 +580,37 @@ abstract class BaseCcScheduleQuery extends ModelCriteria
|
|||
return $this->addUsingAlias(CcSchedulePeer::BROADCASTED, $dbBroadcasted, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the position column
|
||||
*
|
||||
* @param int|array $dbPosition The value to use as filter.
|
||||
* Accepts an associative array('min' => $minValue, 'max' => $maxValue)
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return CcScheduleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByDbPosition($dbPosition = null, $comparison = null)
|
||||
{
|
||||
if (is_array($dbPosition)) {
|
||||
$useMinMax = false;
|
||||
if (isset($dbPosition['min'])) {
|
||||
$this->addUsingAlias(CcSchedulePeer::POSITION, $dbPosition['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($dbPosition['max'])) {
|
||||
$this->addUsingAlias(CcSchedulePeer::POSITION, $dbPosition['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
return $this->addUsingAlias(CcSchedulePeer::POSITION, $dbPosition, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related CcShowInstances object
|
||||
*
|
||||
|
|
|
@ -95,6 +95,20 @@ abstract class BaseCcShow extends BaseObject implements Persistent
|
|||
*/
|
||||
protected $live_stream_pass;
|
||||
|
||||
/**
|
||||
* The value for the linked field.
|
||||
* Note: this column has a database default value of: false
|
||||
* @var boolean
|
||||
*/
|
||||
protected $linked;
|
||||
|
||||
/**
|
||||
* The value for the is_linkable field.
|
||||
* Note: this column has a database default value of: true
|
||||
* @var boolean
|
||||
*/
|
||||
protected $is_linkable;
|
||||
|
||||
/**
|
||||
* @var array CcShowInstances[] Collection to store aggregation of CcShowInstances objects.
|
||||
*/
|
||||
|
@ -142,6 +156,8 @@ abstract class BaseCcShow extends BaseObject implements Persistent
|
|||
$this->genre = '';
|
||||
$this->live_stream_using_airtime_auth = false;
|
||||
$this->live_stream_using_custom_auth = false;
|
||||
$this->linked = false;
|
||||
$this->is_linkable = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -264,6 +280,26 @@ abstract class BaseCcShow extends BaseObject implements Persistent
|
|||
return $this->live_stream_pass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [linked] column value.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getDbLinked()
|
||||
{
|
||||
return $this->linked;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [is_linkable] column value.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getDbIsLinkable()
|
||||
{
|
||||
return $this->is_linkable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of [id] column.
|
||||
*
|
||||
|
@ -484,6 +520,46 @@ abstract class BaseCcShow extends BaseObject implements Persistent
|
|||
return $this;
|
||||
} // setDbLiveStreamPass()
|
||||
|
||||
/**
|
||||
* Set the value of [linked] column.
|
||||
*
|
||||
* @param boolean $v new value
|
||||
* @return CcShow The current object (for fluent API support)
|
||||
*/
|
||||
public function setDbLinked($v)
|
||||
{
|
||||
if ($v !== null) {
|
||||
$v = (boolean) $v;
|
||||
}
|
||||
|
||||
if ($this->linked !== $v || $this->isNew()) {
|
||||
$this->linked = $v;
|
||||
$this->modifiedColumns[] = CcShowPeer::LINKED;
|
||||
}
|
||||
|
||||
return $this;
|
||||
} // setDbLinked()
|
||||
|
||||
/**
|
||||
* Set the value of [is_linkable] column.
|
||||
*
|
||||
* @param boolean $v new value
|
||||
* @return CcShow The current object (for fluent API support)
|
||||
*/
|
||||
public function setDbIsLinkable($v)
|
||||
{
|
||||
if ($v !== null) {
|
||||
$v = (boolean) $v;
|
||||
}
|
||||
|
||||
if ($this->is_linkable !== $v || $this->isNew()) {
|
||||
$this->is_linkable = $v;
|
||||
$this->modifiedColumns[] = CcShowPeer::IS_LINKABLE;
|
||||
}
|
||||
|
||||
return $this;
|
||||
} // setDbIsLinkable()
|
||||
|
||||
/**
|
||||
* Indicates whether the columns in this object are only set to default values.
|
||||
*
|
||||
|
@ -514,6 +590,14 @@ abstract class BaseCcShow extends BaseObject implements Persistent
|
|||
return false;
|
||||
}
|
||||
|
||||
if ($this->linked !== false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->is_linkable !== true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// otherwise, everything was equal, so return TRUE
|
||||
return true;
|
||||
} // hasOnlyDefaultValues()
|
||||
|
@ -547,6 +631,8 @@ abstract class BaseCcShow extends BaseObject implements Persistent
|
|||
$this->live_stream_using_custom_auth = ($row[$startcol + 8] !== null) ? (boolean) $row[$startcol + 8] : null;
|
||||
$this->live_stream_user = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null;
|
||||
$this->live_stream_pass = ($row[$startcol + 10] !== null) ? (string) $row[$startcol + 10] : null;
|
||||
$this->linked = ($row[$startcol + 11] !== null) ? (boolean) $row[$startcol + 11] : null;
|
||||
$this->is_linkable = ($row[$startcol + 12] !== null) ? (boolean) $row[$startcol + 12] : null;
|
||||
$this->resetModified();
|
||||
|
||||
$this->setNew(false);
|
||||
|
@ -555,7 +641,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent
|
|||
$this->ensureConsistency();
|
||||
}
|
||||
|
||||
return $startcol + 11; // 11 = CcShowPeer::NUM_COLUMNS - CcShowPeer::NUM_LAZY_LOAD_COLUMNS).
|
||||
return $startcol + 13; // 13 = CcShowPeer::NUM_COLUMNS - CcShowPeer::NUM_LAZY_LOAD_COLUMNS).
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating CcShow object", $e);
|
||||
|
@ -959,6 +1045,12 @@ abstract class BaseCcShow extends BaseObject implements Persistent
|
|||
case 10:
|
||||
return $this->getDbLiveStreamPass();
|
||||
break;
|
||||
case 11:
|
||||
return $this->getDbLinked();
|
||||
break;
|
||||
case 12:
|
||||
return $this->getDbIsLinkable();
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
break;
|
||||
|
@ -993,6 +1085,8 @@ abstract class BaseCcShow extends BaseObject implements Persistent
|
|||
$keys[8] => $this->getDbLiveStreamUsingCustomAuth(),
|
||||
$keys[9] => $this->getDbLiveStreamUser(),
|
||||
$keys[10] => $this->getDbLiveStreamPass(),
|
||||
$keys[11] => $this->getDbLinked(),
|
||||
$keys[12] => $this->getDbIsLinkable(),
|
||||
);
|
||||
return $result;
|
||||
}
|
||||
|
@ -1057,6 +1151,12 @@ abstract class BaseCcShow extends BaseObject implements Persistent
|
|||
case 10:
|
||||
$this->setDbLiveStreamPass($value);
|
||||
break;
|
||||
case 11:
|
||||
$this->setDbLinked($value);
|
||||
break;
|
||||
case 12:
|
||||
$this->setDbIsLinkable($value);
|
||||
break;
|
||||
} // switch()
|
||||
}
|
||||
|
||||
|
@ -1092,6 +1192,8 @@ abstract class BaseCcShow extends BaseObject implements Persistent
|
|||
if (array_key_exists($keys[8], $arr)) $this->setDbLiveStreamUsingCustomAuth($arr[$keys[8]]);
|
||||
if (array_key_exists($keys[9], $arr)) $this->setDbLiveStreamUser($arr[$keys[9]]);
|
||||
if (array_key_exists($keys[10], $arr)) $this->setDbLiveStreamPass($arr[$keys[10]]);
|
||||
if (array_key_exists($keys[11], $arr)) $this->setDbLinked($arr[$keys[11]]);
|
||||
if (array_key_exists($keys[12], $arr)) $this->setDbIsLinkable($arr[$keys[12]]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1114,6 +1216,8 @@ abstract class BaseCcShow extends BaseObject implements Persistent
|
|||
if ($this->isColumnModified(CcShowPeer::LIVE_STREAM_USING_CUSTOM_AUTH)) $criteria->add(CcShowPeer::LIVE_STREAM_USING_CUSTOM_AUTH, $this->live_stream_using_custom_auth);
|
||||
if ($this->isColumnModified(CcShowPeer::LIVE_STREAM_USER)) $criteria->add(CcShowPeer::LIVE_STREAM_USER, $this->live_stream_user);
|
||||
if ($this->isColumnModified(CcShowPeer::LIVE_STREAM_PASS)) $criteria->add(CcShowPeer::LIVE_STREAM_PASS, $this->live_stream_pass);
|
||||
if ($this->isColumnModified(CcShowPeer::LINKED)) $criteria->add(CcShowPeer::LINKED, $this->linked);
|
||||
if ($this->isColumnModified(CcShowPeer::IS_LINKABLE)) $criteria->add(CcShowPeer::IS_LINKABLE, $this->is_linkable);
|
||||
|
||||
return $criteria;
|
||||
}
|
||||
|
@ -1185,6 +1289,8 @@ abstract class BaseCcShow extends BaseObject implements Persistent
|
|||
$copyObj->setDbLiveStreamUsingCustomAuth($this->live_stream_using_custom_auth);
|
||||
$copyObj->setDbLiveStreamUser($this->live_stream_user);
|
||||
$copyObj->setDbLiveStreamPass($this->live_stream_pass);
|
||||
$copyObj->setDbLinked($this->linked);
|
||||
$copyObj->setDbIsLinkable($this->is_linkable);
|
||||
|
||||
if ($deepCopy) {
|
||||
// important: temporarily setNew(false) because this affects the behavior of
|
||||
|
@ -1787,6 +1893,8 @@ abstract class BaseCcShow extends BaseObject implements Persistent
|
|||
$this->live_stream_using_custom_auth = null;
|
||||
$this->live_stream_user = null;
|
||||
$this->live_stream_pass = null;
|
||||
$this->linked = null;
|
||||
$this->is_linkable = null;
|
||||
$this->alreadyInSave = false;
|
||||
$this->alreadyInValidation = false;
|
||||
$this->clearAllReferences();
|
||||
|
|
|
@ -26,7 +26,7 @@ abstract class BaseCcShowPeer {
|
|||
const TM_CLASS = 'CcShowTableMap';
|
||||
|
||||
/** The total number of columns. */
|
||||
const NUM_COLUMNS = 11;
|
||||
const NUM_COLUMNS = 13;
|
||||
|
||||
/** The number of lazy-loaded columns. */
|
||||
const NUM_LAZY_LOAD_COLUMNS = 0;
|
||||
|
@ -64,6 +64,12 @@ abstract class BaseCcShowPeer {
|
|||
/** the column name for the LIVE_STREAM_PASS field */
|
||||
const LIVE_STREAM_PASS = 'cc_show.LIVE_STREAM_PASS';
|
||||
|
||||
/** the column name for the LINKED field */
|
||||
const LINKED = 'cc_show.LINKED';
|
||||
|
||||
/** the column name for the IS_LINKABLE field */
|
||||
const IS_LINKABLE = 'cc_show.IS_LINKABLE';
|
||||
|
||||
/**
|
||||
* An identiy map to hold any loaded instances of CcShow objects.
|
||||
* This must be public so that other peer classes can access this when hydrating from JOIN
|
||||
|
@ -80,12 +86,12 @@ abstract class BaseCcShowPeer {
|
|||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||
*/
|
||||
private static $fieldNames = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('DbId', 'DbName', 'DbUrl', 'DbGenre', 'DbDescription', 'DbColor', 'DbBackgroundColor', 'DbLiveStreamUsingAirtimeAuth', 'DbLiveStreamUsingCustomAuth', 'DbLiveStreamUser', 'DbLiveStreamPass', ),
|
||||
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbUrl', 'dbGenre', 'dbDescription', 'dbColor', 'dbBackgroundColor', 'dbLiveStreamUsingAirtimeAuth', 'dbLiveStreamUsingCustomAuth', 'dbLiveStreamUser', 'dbLiveStreamPass', ),
|
||||
BasePeer::TYPE_COLNAME => array (self::ID, self::NAME, self::URL, self::GENRE, self::DESCRIPTION, self::COLOR, self::BACKGROUND_COLOR, self::LIVE_STREAM_USING_AIRTIME_AUTH, self::LIVE_STREAM_USING_CUSTOM_AUTH, self::LIVE_STREAM_USER, self::LIVE_STREAM_PASS, ),
|
||||
BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'URL', 'GENRE', 'DESCRIPTION', 'COLOR', 'BACKGROUND_COLOR', 'LIVE_STREAM_USING_AIRTIME_AUTH', 'LIVE_STREAM_USING_CUSTOM_AUTH', 'LIVE_STREAM_USER', 'LIVE_STREAM_PASS', ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'url', 'genre', 'description', 'color', 'background_color', 'live_stream_using_airtime_auth', 'live_stream_using_custom_auth', 'live_stream_user', 'live_stream_pass', ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, )
|
||||
BasePeer::TYPE_PHPNAME => array ('DbId', 'DbName', 'DbUrl', 'DbGenre', 'DbDescription', 'DbColor', 'DbBackgroundColor', 'DbLiveStreamUsingAirtimeAuth', 'DbLiveStreamUsingCustomAuth', 'DbLiveStreamUser', 'DbLiveStreamPass', 'DbLinked', 'DbIsLinkable', ),
|
||||
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbUrl', 'dbGenre', 'dbDescription', 'dbColor', 'dbBackgroundColor', 'dbLiveStreamUsingAirtimeAuth', 'dbLiveStreamUsingCustomAuth', 'dbLiveStreamUser', 'dbLiveStreamPass', 'dbLinked', 'dbIsLinkable', ),
|
||||
BasePeer::TYPE_COLNAME => array (self::ID, self::NAME, self::URL, self::GENRE, self::DESCRIPTION, self::COLOR, self::BACKGROUND_COLOR, self::LIVE_STREAM_USING_AIRTIME_AUTH, self::LIVE_STREAM_USING_CUSTOM_AUTH, self::LIVE_STREAM_USER, self::LIVE_STREAM_PASS, self::LINKED, self::IS_LINKABLE, ),
|
||||
BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'URL', 'GENRE', 'DESCRIPTION', 'COLOR', 'BACKGROUND_COLOR', 'LIVE_STREAM_USING_AIRTIME_AUTH', 'LIVE_STREAM_USING_CUSTOM_AUTH', 'LIVE_STREAM_USER', 'LIVE_STREAM_PASS', 'LINKED', 'IS_LINKABLE', ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'url', 'genre', 'description', 'color', 'background_color', 'live_stream_using_airtime_auth', 'live_stream_using_custom_auth', 'live_stream_user', 'live_stream_pass', 'linked', 'is_linkable', ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, )
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -95,12 +101,12 @@ abstract class BaseCcShowPeer {
|
|||
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
private static $fieldKeys = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbName' => 1, 'DbUrl' => 2, 'DbGenre' => 3, 'DbDescription' => 4, 'DbColor' => 5, 'DbBackgroundColor' => 6, 'DbLiveStreamUsingAirtimeAuth' => 7, 'DbLiveStreamUsingCustomAuth' => 8, 'DbLiveStreamUser' => 9, 'DbLiveStreamPass' => 10, ),
|
||||
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbUrl' => 2, 'dbGenre' => 3, 'dbDescription' => 4, 'dbColor' => 5, 'dbBackgroundColor' => 6, 'dbLiveStreamUsingAirtimeAuth' => 7, 'dbLiveStreamUsingCustomAuth' => 8, 'dbLiveStreamUser' => 9, 'dbLiveStreamPass' => 10, ),
|
||||
BasePeer::TYPE_COLNAME => array (self::ID => 0, self::NAME => 1, self::URL => 2, self::GENRE => 3, self::DESCRIPTION => 4, self::COLOR => 5, self::BACKGROUND_COLOR => 6, self::LIVE_STREAM_USING_AIRTIME_AUTH => 7, self::LIVE_STREAM_USING_CUSTOM_AUTH => 8, self::LIVE_STREAM_USER => 9, self::LIVE_STREAM_PASS => 10, ),
|
||||
BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'URL' => 2, 'GENRE' => 3, 'DESCRIPTION' => 4, 'COLOR' => 5, 'BACKGROUND_COLOR' => 6, 'LIVE_STREAM_USING_AIRTIME_AUTH' => 7, 'LIVE_STREAM_USING_CUSTOM_AUTH' => 8, 'LIVE_STREAM_USER' => 9, 'LIVE_STREAM_PASS' => 10, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'url' => 2, 'genre' => 3, 'description' => 4, 'color' => 5, 'background_color' => 6, 'live_stream_using_airtime_auth' => 7, 'live_stream_using_custom_auth' => 8, 'live_stream_user' => 9, 'live_stream_pass' => 10, ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, )
|
||||
BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbName' => 1, 'DbUrl' => 2, 'DbGenre' => 3, 'DbDescription' => 4, 'DbColor' => 5, 'DbBackgroundColor' => 6, 'DbLiveStreamUsingAirtimeAuth' => 7, 'DbLiveStreamUsingCustomAuth' => 8, 'DbLiveStreamUser' => 9, 'DbLiveStreamPass' => 10, 'DbLinked' => 11, 'DbIsLinkable' => 12, ),
|
||||
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbUrl' => 2, 'dbGenre' => 3, 'dbDescription' => 4, 'dbColor' => 5, 'dbBackgroundColor' => 6, 'dbLiveStreamUsingAirtimeAuth' => 7, 'dbLiveStreamUsingCustomAuth' => 8, 'dbLiveStreamUser' => 9, 'dbLiveStreamPass' => 10, 'dbLinked' => 11, 'dbIsLinkable' => 12, ),
|
||||
BasePeer::TYPE_COLNAME => array (self::ID => 0, self::NAME => 1, self::URL => 2, self::GENRE => 3, self::DESCRIPTION => 4, self::COLOR => 5, self::BACKGROUND_COLOR => 6, self::LIVE_STREAM_USING_AIRTIME_AUTH => 7, self::LIVE_STREAM_USING_CUSTOM_AUTH => 8, self::LIVE_STREAM_USER => 9, self::LIVE_STREAM_PASS => 10, self::LINKED => 11, self::IS_LINKABLE => 12, ),
|
||||
BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'URL' => 2, 'GENRE' => 3, 'DESCRIPTION' => 4, 'COLOR' => 5, 'BACKGROUND_COLOR' => 6, 'LIVE_STREAM_USING_AIRTIME_AUTH' => 7, 'LIVE_STREAM_USING_CUSTOM_AUTH' => 8, 'LIVE_STREAM_USER' => 9, 'LIVE_STREAM_PASS' => 10, 'LINKED' => 11, 'IS_LINKABLE' => 12, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'url' => 2, 'genre' => 3, 'description' => 4, 'color' => 5, 'background_color' => 6, 'live_stream_using_airtime_auth' => 7, 'live_stream_using_custom_auth' => 8, 'live_stream_user' => 9, 'live_stream_pass' => 10, 'linked' => 11, 'is_linkable' => 12, ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, )
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -183,6 +189,8 @@ abstract class BaseCcShowPeer {
|
|||
$criteria->addSelectColumn(CcShowPeer::LIVE_STREAM_USING_CUSTOM_AUTH);
|
||||
$criteria->addSelectColumn(CcShowPeer::LIVE_STREAM_USER);
|
||||
$criteria->addSelectColumn(CcShowPeer::LIVE_STREAM_PASS);
|
||||
$criteria->addSelectColumn(CcShowPeer::LINKED);
|
||||
$criteria->addSelectColumn(CcShowPeer::IS_LINKABLE);
|
||||
} else {
|
||||
$criteria->addSelectColumn($alias . '.ID');
|
||||
$criteria->addSelectColumn($alias . '.NAME');
|
||||
|
@ -195,6 +203,8 @@ abstract class BaseCcShowPeer {
|
|||
$criteria->addSelectColumn($alias . '.LIVE_STREAM_USING_CUSTOM_AUTH');
|
||||
$criteria->addSelectColumn($alias . '.LIVE_STREAM_USER');
|
||||
$criteria->addSelectColumn($alias . '.LIVE_STREAM_PASS');
|
||||
$criteria->addSelectColumn($alias . '.LINKED');
|
||||
$criteria->addSelectColumn($alias . '.IS_LINKABLE');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
* @method CcShowQuery orderByDbLiveStreamUsingCustomAuth($order = Criteria::ASC) Order by the live_stream_using_custom_auth column
|
||||
* @method CcShowQuery orderByDbLiveStreamUser($order = Criteria::ASC) Order by the live_stream_user column
|
||||
* @method CcShowQuery orderByDbLiveStreamPass($order = Criteria::ASC) Order by the live_stream_pass column
|
||||
* @method CcShowQuery orderByDbLinked($order = Criteria::ASC) Order by the linked column
|
||||
* @method CcShowQuery orderByDbIsLinkable($order = Criteria::ASC) Order by the is_linkable column
|
||||
*
|
||||
* @method CcShowQuery groupByDbId() Group by the id column
|
||||
* @method CcShowQuery groupByDbName() Group by the name column
|
||||
|
@ -29,6 +31,8 @@
|
|||
* @method CcShowQuery groupByDbLiveStreamUsingCustomAuth() Group by the live_stream_using_custom_auth column
|
||||
* @method CcShowQuery groupByDbLiveStreamUser() Group by the live_stream_user column
|
||||
* @method CcShowQuery groupByDbLiveStreamPass() Group by the live_stream_pass column
|
||||
* @method CcShowQuery groupByDbLinked() Group by the linked column
|
||||
* @method CcShowQuery groupByDbIsLinkable() Group by the is_linkable column
|
||||
*
|
||||
* @method CcShowQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
|
||||
* @method CcShowQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
|
||||
|
@ -64,6 +68,8 @@
|
|||
* @method CcShow findOneByDbLiveStreamUsingCustomAuth(boolean $live_stream_using_custom_auth) Return the first CcShow filtered by the live_stream_using_custom_auth column
|
||||
* @method CcShow findOneByDbLiveStreamUser(string $live_stream_user) Return the first CcShow filtered by the live_stream_user column
|
||||
* @method CcShow findOneByDbLiveStreamPass(string $live_stream_pass) Return the first CcShow filtered by the live_stream_pass column
|
||||
* @method CcShow findOneByDbLinked(boolean $linked) Return the first CcShow filtered by the linked column
|
||||
* @method CcShow findOneByDbIsLinkable(boolean $is_linkable) Return the first CcShow filtered by the is_linkable column
|
||||
*
|
||||
* @method array findByDbId(int $id) Return CcShow objects filtered by the id column
|
||||
* @method array findByDbName(string $name) Return CcShow objects filtered by the name column
|
||||
|
@ -76,6 +82,8 @@
|
|||
* @method array findByDbLiveStreamUsingCustomAuth(boolean $live_stream_using_custom_auth) Return CcShow objects filtered by the live_stream_using_custom_auth column
|
||||
* @method array findByDbLiveStreamUser(string $live_stream_user) Return CcShow objects filtered by the live_stream_user column
|
||||
* @method array findByDbLiveStreamPass(string $live_stream_pass) Return CcShow objects filtered by the live_stream_pass column
|
||||
* @method array findByDbLinked(boolean $linked) Return CcShow objects filtered by the linked column
|
||||
* @method array findByDbIsLinkable(boolean $is_linkable) Return CcShow objects filtered by the is_linkable column
|
||||
*
|
||||
* @package propel.generator.airtime.om
|
||||
*/
|
||||
|
@ -412,6 +420,40 @@ abstract class BaseCcShowQuery extends ModelCriteria
|
|||
return $this->addUsingAlias(CcShowPeer::LIVE_STREAM_PASS, $dbLiveStreamPass, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the linked column
|
||||
*
|
||||
* @param boolean|string $dbLinked The value to use as filter.
|
||||
* Accepts strings ('false', 'off', '-', 'no', 'n', and '0' are false, the rest is true)
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return CcShowQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByDbLinked($dbLinked = null, $comparison = null)
|
||||
{
|
||||
if (is_string($dbLinked)) {
|
||||
$linked = in_array(strtolower($dbLinked), array('false', 'off', '-', 'no', 'n', '0')) ? false : true;
|
||||
}
|
||||
return $this->addUsingAlias(CcShowPeer::LINKED, $dbLinked, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the is_linkable column
|
||||
*
|
||||
* @param boolean|string $dbIsLinkable The value to use as filter.
|
||||
* Accepts strings ('false', 'off', '-', 'no', 'n', and '0' are false, the rest is true)
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return CcShowQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByDbIsLinkable($dbIsLinkable = null, $comparison = null)
|
||||
{
|
||||
if (is_string($dbIsLinkable)) {
|
||||
$is_linkable = in_array(strtolower($dbIsLinkable), array('false', 'off', '-', 'no', 'n', '0')) ? false : true;
|
||||
}
|
||||
return $this->addUsingAlias(CcShowPeer::IS_LINKABLE, $dbIsLinkable, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related CcShowInstances object
|
||||
*
|
||||
|
|
|
@ -0,0 +1,326 @@
|
|||
<?php
|
||||
|
||||
class Application_Service_CalendarService
|
||||
{
|
||||
private $currentUser;
|
||||
private $ccShowInstance;
|
||||
private $ccShow;
|
||||
|
||||
public function __construct($instanceId = null)
|
||||
{
|
||||
if (!is_null($instanceId)) {
|
||||
$this->ccShowInstance = CcShowInstancesQuery::create()->findPk($instanceId);
|
||||
if (is_null($this->ccShowInstance)) {
|
||||
throw new Exception("Instance does not exist");
|
||||
}
|
||||
$this->ccShow = $this->ccShowInstance->getCcShow();
|
||||
}
|
||||
|
||||
$service_user = new Application_Service_UserService();
|
||||
$this->currentUser = $service_user->getCurrentUser();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
*/
|
||||
public function makeContextMenu()
|
||||
{
|
||||
$menu = array();
|
||||
$now = time();
|
||||
$baseUrl = Application_Common_OsPath::getBaseDir();
|
||||
$isAdminOrPM = $this->currentUser->isAdminOrPM();
|
||||
$isHostOfShow = $this->currentUser->isHostOfShow($this->ccShow->getDbId());
|
||||
|
||||
//DateTime objects in UTC
|
||||
$startDT = $this->ccShowInstance->getDbStarts(null);
|
||||
$endDT = $this->ccShowInstance->getDbEnds(null);
|
||||
|
||||
//timestamps
|
||||
$start = $startDT->getTimestamp();
|
||||
$end = $endDT->getTimestamp();
|
||||
|
||||
//show has ended
|
||||
if ($now > $end) {
|
||||
if ($this->ccShowInstance->isRecorded()) {
|
||||
|
||||
$ccFile = $this->ccShowInstance->getCcFiles();
|
||||
|
||||
$menu["view_recorded"] = array(
|
||||
"name" => _("View Recorded File Metadata"),
|
||||
"icon" => "overview",
|
||||
"url" => $baseUrl."library/edit-file-md/id/".$ccFile->getDbId());
|
||||
|
||||
//recorded show can be uploaded to soundcloud
|
||||
if (Application_Model_Preference::GetUploadToSoundcloudOption()) {
|
||||
$scid = $ccFile->getDbSoundcloudId();
|
||||
|
||||
if ($scid > 0) {
|
||||
$menu["soundcloud_view"] = array(
|
||||
"name" => _("View on Soundcloud"),
|
||||
"icon" => "soundcloud",
|
||||
"url" => $ccFile->getDbSoundcloudLinkToFile());
|
||||
}
|
||||
|
||||
$text = is_null($scid) ? _('Upload to SoundCloud') : _('Re-upload to SoundCloud');
|
||||
$menu["soundcloud_upload"] = array(
|
||||
"name"=> $text,
|
||||
"icon" => "soundcloud");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//Show content can be modified from the calendar if:
|
||||
// the show has not started,
|
||||
// the user is admin or hosting the show,
|
||||
// the show is not recorded or rebroadcasted
|
||||
if ($now < $start && ($isAdminOrPM || $isHostOfShow) &&
|
||||
!$this->ccShowInstance->isRecorded() && !$this->ccShowInstance->isRebroadcast()) {
|
||||
|
||||
$menu["schedule"] = array(
|
||||
"name"=> _("Add / Remove Content"),
|
||||
"icon" => "add-remove-content",
|
||||
"url" => $baseUrl."showbuilder/builder-dialog/");
|
||||
|
||||
$menu["clear"] = array(
|
||||
"name"=> _("Remove All Content"),
|
||||
"icon" => "remove-all-content",
|
||||
"url" => $baseUrl."schedule/clear-show");
|
||||
}
|
||||
|
||||
//"Show Content" should be a menu item at all times except when
|
||||
//the show is recorded
|
||||
if (!$this->ccShowInstance->isRecorded()) {
|
||||
|
||||
$menu["content"] = array(
|
||||
"name"=> _("Show Content"),
|
||||
"icon" => "overview",
|
||||
"url" => $baseUrl."schedule/show-content-dialog");
|
||||
}
|
||||
|
||||
//show is currently playing and user is admin
|
||||
if ($start <= $now && $now < $end && $isAdminOrPM) {
|
||||
|
||||
if ($this->ccShowInstance->isRecorded()) {
|
||||
$menu["cancel_recorded"] = array(
|
||||
"name"=> _("Cancel Current Show"),
|
||||
"icon" => "delete");
|
||||
} else {
|
||||
$menu["cancel"] = array(
|
||||
"name"=> _("Cancel Current Show"),
|
||||
"icon" => "delete");
|
||||
}
|
||||
}
|
||||
|
||||
$isRepeating = $this->ccShow->getFirstCcShowDay()->isRepeating();
|
||||
if (!$this->ccShowInstance->isRebroadcast()) {
|
||||
if ($isRepeating) {
|
||||
$menu["edit"] = array(
|
||||
"name" => _("Edit"),
|
||||
"icon" => "edit",
|
||||
"items" => array());
|
||||
|
||||
$menu["edit"]["items"]["all"] = array(
|
||||
"name" => _("Edit Show"),
|
||||
"icon" => "edit",
|
||||
"url" => $baseUrl."Schedule/populate-show-form");
|
||||
|
||||
$menu["edit"]["items"]["instance"] = array(
|
||||
"name" => _("Edit This Instance"),
|
||||
"icon" => "edit",
|
||||
"url" => $baseUrl."Schedule/populate-repeating-show-instance-form");
|
||||
} else {
|
||||
$menu["edit"] = array(
|
||||
"name"=> _("Edit Show"),
|
||||
"icon" => "edit",
|
||||
"_type"=>"all",
|
||||
"url" => $baseUrl."Schedule/populate-show-form");
|
||||
}
|
||||
}
|
||||
|
||||
//show hasn't started yet and user is admin
|
||||
if ($now < $start && $isAdminOrPM) {
|
||||
//show is repeating so give user the option to delete all
|
||||
//repeating instances or just the one
|
||||
if ($isRepeating) {
|
||||
$menu["del"] = array(
|
||||
"name"=> _("Delete"),
|
||||
"icon" => "delete",
|
||||
"items" => array());
|
||||
|
||||
$menu["del"]["items"]["single"] = array(
|
||||
"name"=> _("Delete This Instance"),
|
||||
"icon" => "delete",
|
||||
"url" => $baseUrl."schedule/delete-show-instance");
|
||||
|
||||
$menu["del"]["items"]["following"] = array(
|
||||
"name"=> _("Delete This Instance and All Following"),
|
||||
"icon" => "delete",
|
||||
"url" => $baseUrl."schedule/delete-show");
|
||||
} else {
|
||||
$menu["del"] = array(
|
||||
"name"=> _("Delete"),
|
||||
"icon" => "delete",
|
||||
"url" => $baseUrl."schedule/delete-show");
|
||||
}
|
||||
}
|
||||
}
|
||||
return $menu;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
* @param DateTime $dateTime object to add deltas to
|
||||
* @param int $deltaDay delta days show moved
|
||||
* @param int $deltaMin delta minutes show moved
|
||||
*/
|
||||
public static function addDeltas($dateTime, $deltaDay, $deltaMin)
|
||||
{
|
||||
$newDateTime = clone $dateTime;
|
||||
|
||||
$days = abs($deltaDay);
|
||||
$mins = abs($deltaMin);
|
||||
|
||||
$dayInterval = new DateInterval("P{$days}D");
|
||||
$minInterval = new DateInterval("PT{$mins}M");
|
||||
|
||||
if ($deltaDay > 0) {
|
||||
$newDateTime->add($dayInterval);
|
||||
} elseif ($deltaDay < 0) {
|
||||
$newDateTime->sub($dayInterval);
|
||||
}
|
||||
|
||||
if ($deltaMin > 0) {
|
||||
$newDateTime->add($minInterval);
|
||||
} elseif ($deltaMin < 0) {
|
||||
$newDateTime->sub($minInterval);
|
||||
}
|
||||
|
||||
return $newDateTime;
|
||||
}
|
||||
|
||||
private function validateShowMove($deltaDay, $deltaMin)
|
||||
{
|
||||
if (!$this->currentUser->isAdminOrPM()) {
|
||||
throw new Exception(_("Permission denied"));
|
||||
}
|
||||
|
||||
if ($this->ccShow->getFirstCcShowDay()->isRepeating()) {
|
||||
throw new Exception(_("Can't drag and drop repeating shows"));
|
||||
}
|
||||
|
||||
$today_timestamp = time();
|
||||
|
||||
$startsDateTime = new DateTime($this->ccShowInstance->getDbStarts(), new DateTimeZone("UTC"));
|
||||
$endsDateTime = new DateTime($this->ccShowInstance->getDbEnds(), new DateTimeZone("UTC"));
|
||||
|
||||
if ($today_timestamp > $startsDateTime->getTimestamp()) {
|
||||
throw new Exception(_("Can't move a past show"));
|
||||
}
|
||||
|
||||
//the user is moving the show on the calendar from the perspective of local time.
|
||||
//incase a show is moved across a time change border offsets should be added to the localtime
|
||||
//stamp and then converted back to UTC to avoid show time changes!
|
||||
$localTimezone = Application_Model_Preference::GetTimezone();
|
||||
$startsDateTime->setTimezone(new DateTimeZone($localTimezone));
|
||||
$endsDateTime->setTimezone(new DateTimeZone($localTimezone));
|
||||
|
||||
$newStartsDateTime = self::addDeltas($startsDateTime, $deltaDay, $deltaMin);
|
||||
$newEndsDateTime = self::addDeltas($endsDateTime, $deltaDay, $deltaMin);
|
||||
|
||||
//convert our new starts/ends to UTC.
|
||||
$newStartsDateTime->setTimezone(new DateTimeZone("UTC"));
|
||||
$newEndsDateTime->setTimezone(new DateTimeZone("UTC"));
|
||||
|
||||
if ($today_timestamp > $newStartsDateTime->getTimestamp()) {
|
||||
throw new Exception(_("Can't move show into past"));
|
||||
}
|
||||
|
||||
//check if show is overlapping
|
||||
$overlapping = Application_Model_Schedule::checkOverlappingShows(
|
||||
$newStartsDateTime, $newEndsDateTime, true, $this->ccShowInstance->getDbId());
|
||||
if ($overlapping) {
|
||||
throw new Exception(_("Cannot schedule overlapping shows"));
|
||||
}
|
||||
|
||||
if ($this->ccShow->isRecorded()) {
|
||||
//rebroadcasts should start at max 1 hour after a recorded show has ended.
|
||||
$minRebroadcastStart = self::addDeltas($newEndsDateTime, 0, 60);
|
||||
//check if we are moving a recorded show less than 1 hour before any of its own rebroadcasts.
|
||||
$rebroadcasts = CcShowInstancesQuery::create()
|
||||
->filterByDbOriginalShow($this->_instanceId)
|
||||
->filterByDbStarts($minRebroadcastStart->format('Y-m-d H:i:s'), Criteria::LESS_THAN)
|
||||
->find();
|
||||
|
||||
if (count($rebroadcasts) > 0) {
|
||||
throw new Exception(_("Can't move a recorded show less than 1 hour before its rebroadcasts."));
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->ccShow->isRebroadcast()) {
|
||||
$recordedShow = CcShowInstancesQuery::create()->findPk(
|
||||
$this->ccShowInstance->getDbOriginalShow());
|
||||
if (is_null($recordedShow)) {
|
||||
$this->ccShowInstance->delete();
|
||||
throw new Exception(_("Show was deleted because recorded show does not exist!"));
|
||||
}
|
||||
|
||||
$recordEndDateTime = new DateTime($recordedShow->getDbEnds(), new DateTimeZone("UTC"));
|
||||
$newRecordEndDateTime = self::addDeltas($recordEndDateTime, 0, 60);
|
||||
|
||||
if ($newStartsDateTime->getTimestamp() < $newRecordEndDateTime->getTimestamp()) {
|
||||
throw new Exception(_("Must wait 1 hour to rebroadcast."));
|
||||
}
|
||||
}
|
||||
return array($newStartsDateTime, $newEndsDateTime);
|
||||
}
|
||||
|
||||
public function moveShow($deltaDay, $deltaMin)
|
||||
{
|
||||
try {
|
||||
$con = Propel::getConnection();
|
||||
$con->beginTransaction();
|
||||
|
||||
list($newStartsDateTime, $newEndsDateTime) = $this->validateShowMove(
|
||||
$deltaDay, $deltaMin);
|
||||
|
||||
$this->ccShowInstance
|
||||
->setDbStarts($newStartsDateTime)
|
||||
->setDbEnds($newEndsDateTime)
|
||||
->save();
|
||||
|
||||
if (!$this->ccShowInstance->getCcShow()->isRebroadcast()) {
|
||||
//we can get the first show day because we know the show is
|
||||
//not repeating, and therefore will only have one show day entry
|
||||
$ccShowDay = $this->ccShow->getFirstCcShowDay();
|
||||
$ccShowDay
|
||||
->setDbFirstShow($newStartsDateTime)
|
||||
->setDbLastShow($newEndsDateTime)
|
||||
->save();
|
||||
}
|
||||
|
||||
Application_Service_SchedulerService::updateScheduleStartTime(
|
||||
array($this->ccShowInstance->getDbId()), null, $newStartsDateTime);
|
||||
|
||||
$con->commit();
|
||||
Application_Model_RabbitMq::PushSchedule();
|
||||
} catch (Exception $e) {
|
||||
$con->rollback();
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
public function resizeShow($deltaDay, $deltaMin)
|
||||
{
|
||||
try {
|
||||
$con = Propel::getConnection();
|
||||
$con->beginTransaction();
|
||||
|
||||
$con->commit();
|
||||
Application_Model_RabbitMq::PushSchedule();
|
||||
} catch (Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,207 @@
|
|||
<?php
|
||||
class Application_Service_SchedulerService
|
||||
{
|
||||
private $con;
|
||||
private $fileInfo = array(
|
||||
"id" => "",
|
||||
"cliplength" => "",
|
||||
"cuein" => "00:00:00",
|
||||
"cueout" => "00:00:00",
|
||||
"fadein" => "00:00:00",
|
||||
"fadeout" => "00:00:00",
|
||||
"sched_id" => null,
|
||||
"type" => 0 //default type of '0' to represent files. type '1' represents a webstream
|
||||
);
|
||||
|
||||
private $epochNow;
|
||||
private $nowDT;
|
||||
private $currentUser;
|
||||
private $checkUserPermissions = true;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME);
|
||||
|
||||
//subtracting one because sometimes when we cancel a track, we set its end time
|
||||
//to epochNow and then send the new schedule to pypo. Sometimes the currently cancelled
|
||||
//track can still be included in the new schedule because it may have a few ms left to play.
|
||||
//subtracting 1 second from epochNow resolves this issue.
|
||||
$this->epochNow = microtime(true)-1;
|
||||
$this->nowDT = DateTime::createFromFormat("U.u", $this->epochNow, new DateTimeZone("UTC"));
|
||||
|
||||
if ($this->nowDT === false) {
|
||||
// DateTime::createFromFormat does not support millisecond string formatting in PHP 5.3.2 (Ubuntu 10.04).
|
||||
// In PHP 5.3.3 (Ubuntu 10.10), this has been fixed.
|
||||
$this->nowDT = DateTime::createFromFormat("U", time(), new DateTimeZone("UTC"));
|
||||
}
|
||||
|
||||
$user_service = new Application_Service_UserService();
|
||||
$this->currentUser = $user_service->getCurrentUser();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
* @param array $instanceIds
|
||||
*/
|
||||
public static function updateScheduleStartTime($instanceIds, $diff=null, $newStart=null)
|
||||
{
|
||||
$con = Propel::getConnection();
|
||||
if (count($instanceIds) > 0) {
|
||||
$showIdList = implode(",", $instanceIds);
|
||||
|
||||
if (is_null($diff)) {
|
||||
$ccSchedule = CcScheduleQuery::create()
|
||||
->filterByDbInstanceId($instanceIds, Criteria::IN)
|
||||
->orderByDbStarts()
|
||||
->limit(1)
|
||||
->findOne();
|
||||
|
||||
if (!is_null($ccSchedule)) {
|
||||
$scheduleStartsEpoch = strtotime($ccSchedule->getDbStarts());
|
||||
$showStartsEpoch = strtotime($newStart->format("Y-m-d H:i:s"));
|
||||
|
||||
$diff = $showStartsEpoch - $scheduleStartsEpoch;
|
||||
}
|
||||
}
|
||||
|
||||
$ccSchedules = CcScheduleQuery::create()
|
||||
->filterByDbInstanceId($instanceIds, Criteria::IN)
|
||||
->find();
|
||||
foreach ($ccSchedules as $ccSchedule) {
|
||||
$interval = new DateInterval("PT".$diff."S");
|
||||
$start = new DateTime($ccSchedule->getDbStarts());
|
||||
$newStart = $start->add($interval);
|
||||
$end = new DateTime($ccSchedule->getDbEnds());
|
||||
$newEnd = $end->add($interval);
|
||||
$ccSchedule
|
||||
->setDbStarts($newStart->format("Y-m-d H:i:s"))
|
||||
->setDbEnds($newEnd->format("Y-m-d H:i:s"))
|
||||
->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Removes any time gaps in shows
|
||||
*
|
||||
* @param array $schedIds schedule ids to exclude
|
||||
*/
|
||||
public function removeGaps($showId, $schedIds=null)
|
||||
{
|
||||
$ccShowInstances = CcShowInstancesQuery::create()->filterByDbShowId($showId)->find();
|
||||
|
||||
foreach ($ccShowInstances as $instance) {
|
||||
Logging::info("Removing gaps from show instance #".$instance->getDbId());
|
||||
//DateTime object
|
||||
$itemStart = $instance->getDbStarts(null);
|
||||
|
||||
$ccScheduleItems = CcScheduleQuery::create()
|
||||
->filterByDbInstanceId($instance->getDbId())
|
||||
->filterByDbId($schedIds, Criteria::NOT_IN)
|
||||
->orderByDbStarts()
|
||||
->find();
|
||||
|
||||
foreach ($ccScheduleItems as $ccSchedule) {
|
||||
//DateTime object
|
||||
$itemEnd = $this->findEndTime($itemStart, $ccSchedule->getDbClipLength());
|
||||
|
||||
$ccSchedule->setDbStarts($itemStart)
|
||||
->setDbEnds($itemEnd);
|
||||
|
||||
$itemStart = $itemEnd;
|
||||
}
|
||||
$ccScheduleItems->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
* @param DateTime $instanceStart
|
||||
* @param string $clipLength
|
||||
*/
|
||||
private static function findEndTime($instanceStart, $clipLength)
|
||||
{
|
||||
$startEpoch = $instanceStart->format("U.u");
|
||||
$durationSeconds = Application_Common_DateHelper::playlistTimeToSeconds($clipLength);
|
||||
|
||||
//add two float numbers to 6 subsecond precision
|
||||
//DateTime::createFromFormat("U.u") will have a problem if there is no decimal in the resulting number.
|
||||
$endEpoch = bcadd($startEpoch , (string) $durationSeconds, 6);
|
||||
|
||||
$dt = DateTime::createFromFormat("U.u", $endEpoch, new DateTimeZone("UTC"));
|
||||
|
||||
if ($dt === false) {
|
||||
//PHP 5.3.2 problem
|
||||
$dt = DateTime::createFromFormat("U", intval($endEpoch), new DateTimeZone("UTC"));
|
||||
}
|
||||
|
||||
return $dt;
|
||||
}
|
||||
|
||||
public static function fillLinkedShows($ccShow)
|
||||
{
|
||||
if ($ccShow->isLinked()) {
|
||||
/* First check if any linked instances have content
|
||||
* If all instances are empty then we don't need to fill
|
||||
* any other instances with content
|
||||
*/
|
||||
$instanceIds = $ccShow->getInstanceIds();
|
||||
$ccSchedules = CcScheduleQuery::create()
|
||||
->filterByDbInstanceId($instanceIds, Criteria::IN)
|
||||
->find();
|
||||
if (!$ccSchedules->isEmpty()) {
|
||||
/* Find the show contents of just one of the instances. It doesn't
|
||||
* matter which instance we use since all the content is the same
|
||||
*/
|
||||
$ccSchedule = $ccSchedules->getFirst();
|
||||
$showStamp = CcScheduleQuery::create()
|
||||
->filterByDbInstanceId($ccSchedule->getDbInstanceId())
|
||||
->orderByDbStarts()
|
||||
->find();
|
||||
|
||||
//get time_filled so we can update cc_show_instances
|
||||
$timeFilled = $ccSchedule->getCcShowInstances()->getDbTimeFilled();
|
||||
|
||||
//need to find out which linked instances are empty
|
||||
foreach ($ccShow->getCcShowInstancess() as $ccShowInstance) {
|
||||
$ccSchedules = CcScheduleQuery::create()
|
||||
->filterByDbInstanceId($ccShowInstance->getDbId())
|
||||
->find();
|
||||
if ($ccSchedules->isEmpty()) {
|
||||
$nextStartDT = $ccShowInstance->getDbStarts(null);
|
||||
|
||||
foreach ($showStamp as $item) {
|
||||
$endTimeDT = self::findEndTime($nextStartDT, $item->getDbClipLength());
|
||||
|
||||
$ccSchedule = new CcSchedule();
|
||||
$ccSchedule
|
||||
->setDbStarts($nextStartDT)
|
||||
->setDbEnds($endTimeDT)
|
||||
->setDbFileId($item->getDbFileId())
|
||||
->setDbStreamId($item->getDbStreamId())
|
||||
->setDbClipLength($item->getDbClipLength())
|
||||
->setDbFadeIn($item->getDbFadeIn())
|
||||
->setDbFadeOut($item->getDbFadeOut())
|
||||
->setDbCuein($item->getDbCueIn())
|
||||
->setDbCueOut($item->getDbCueOut())
|
||||
->setDbInstanceId($ccShowInstance->getDbId())
|
||||
->setDbPosition($item->getDbPosition())
|
||||
->save();
|
||||
|
||||
$nextStartDT = $endTimeDT;
|
||||
} //foreach show item
|
||||
|
||||
//update time_filled in cc_show_instances
|
||||
$ccShowInstance
|
||||
->setDbTimeFilled($timeFilled)
|
||||
->setDbLastScheduled(gmdate("Y-m-d H:i:s"))
|
||||
->save();
|
||||
}
|
||||
} //foreach linked instance
|
||||
} //if at least one linked instance has content
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,449 @@
|
|||
<?php
|
||||
class Application_Service_ShowFormService
|
||||
{
|
||||
private $ccShow;
|
||||
private $instanceId;
|
||||
|
||||
public function __construct($showId = null, $instanceId = null)
|
||||
{
|
||||
if (!is_null($showId)) {
|
||||
$this->ccShow = CcShowQuery::create()->findPk($showId);
|
||||
}
|
||||
$this->instanceId = $instanceId;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array of show forms
|
||||
*/
|
||||
public function createShowForms()
|
||||
{
|
||||
$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();
|
||||
$formLive = new Application_Form_AddShowLiveStream();
|
||||
$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');
|
||||
$formLive->removeDecorator('DtDdWrapper');
|
||||
$formRecord->removeDecorator('DtDdWrapper');
|
||||
$formAbsoluteRebroadcast->removeDecorator('DtDdWrapper');
|
||||
$formRebroadcast->removeDecorator('DtDdWrapper');
|
||||
|
||||
$forms = array();
|
||||
$forms["what"] = $formWhat;
|
||||
$forms["who"] = $formWho;
|
||||
$forms["when"] = $formWhen;
|
||||
$forms["repeats"] = $formRepeats;
|
||||
$forms["style"] = $formStyle;
|
||||
$forms["live"] = $formLive;
|
||||
$forms["record"] = $formRecord;
|
||||
$forms["abs_rebroadcast"] = $formAbsoluteRebroadcast;
|
||||
$forms["rebroadcast"] = $formRebroadcast;
|
||||
|
||||
return $forms;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Popluates the what, when, and repeat forms
|
||||
* with default values
|
||||
*/
|
||||
public function populateNewShowForms($formWhat, $formWhen, $formRepeats)
|
||||
{
|
||||
$formWhat->populate(
|
||||
array('add_show_id' => '-1',
|
||||
'add_show_instance_id' => '-1'));
|
||||
|
||||
$formWhen->populate(
|
||||
array('add_show_start_date' => date("Y-m-d"),
|
||||
'add_show_start_time' => '00:00',
|
||||
'add_show_end_date_no_repeate' => date("Y-m-d"),
|
||||
'add_show_end_time' => '01:00',
|
||||
'add_show_duration' => '01h 00m'));
|
||||
|
||||
$formRepeats->populate(array('add_show_end_date' => date("Y-m-d")));
|
||||
}
|
||||
|
||||
public function delegateShowInstanceFormPopulation($forms)
|
||||
{
|
||||
$this->populateFormWhat($forms["what"]);
|
||||
$this->populateInstanceFormWhen($forms["when"]);
|
||||
$this->populateFormWho($forms["who"]);
|
||||
$this->populateFormLive($forms["live"]);
|
||||
$this->populateFormStyle($forms["style"]);
|
||||
|
||||
//no need to populate these forms since the user won't
|
||||
//be able to see them
|
||||
$forms["repeats"]->disable();
|
||||
$forms["record"]->disable();
|
||||
$forms["rebroadcast"]->disable();
|
||||
$forms["abs_rebroadcast"]->disable();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Delegates populating each show form with the appropriate
|
||||
* data of the current show being edited
|
||||
*
|
||||
* @param $forms
|
||||
*/
|
||||
public function delegateShowFormPopulation($forms)
|
||||
{
|
||||
$this->populateFormWhat($forms["what"]);
|
||||
$this->populateFormWhen($forms["when"]);
|
||||
$this->populateFormRepeats($forms["repeats"]);
|
||||
$this->populateFormWho($forms["who"]);
|
||||
$this->populateFormStyle($forms["style"]);
|
||||
$this->populateFormLive($forms["live"]);
|
||||
$this->populateFormRecord($forms["record"]);
|
||||
$this->populateFormRebroadcastRelative($forms["rebroadcast"]);
|
||||
$this->populateFormRebroadcastAbsolute($forms["abs_rebroadcast"]);
|
||||
}
|
||||
|
||||
private function populateFormWhat($form)
|
||||
{
|
||||
$form->populate(
|
||||
array(
|
||||
'add_show_instance_id' => $this->instanceId,
|
||||
'add_show_id' => $this->ccShow->getDbId(),
|
||||
'add_show_name' => $this->ccShow->getDbName(),
|
||||
'add_show_url' => $this->ccShow->getDbUrl(),
|
||||
'add_show_genre' => $this->ccShow->getDbGenre(),
|
||||
'add_show_description' => $this->ccShow->getDbDescription()));
|
||||
}
|
||||
|
||||
private function populateFormWhen($form)
|
||||
{
|
||||
$ccShowDay = $this->ccShow->getFirstCcShowDay();
|
||||
|
||||
$showStart = $ccShowDay->getLocalStartDateAndTime();
|
||||
$showEnd = $ccShowDay->getLocalEndDateAndTime($showStart);
|
||||
|
||||
//check if the first show is in the past
|
||||
if ($ccShowDay->isShowStartInPast()) {
|
||||
//for a non-repeating show, we should never allow user to change the start time.
|
||||
//for a repeating show, we should allow because the form works as repeating template form
|
||||
if (!$ccShowDay->isRepeating()) {
|
||||
$form->disableStartDateAndTime();
|
||||
} else {
|
||||
list($showStart, $showEnd) = $this->getNextFutureRepeatShowTime();
|
||||
}
|
||||
}
|
||||
|
||||
$form->populate(
|
||||
array(
|
||||
'add_show_start_date' => $showStart->format("Y-m-d"),
|
||||
'add_show_start_time' => $showStart->format("H:i"),
|
||||
'add_show_end_date_no_repeat' => $showEnd->format("Y-m-d"),
|
||||
'add_show_end_time' => $showEnd->format("H:i"),
|
||||
'add_show_duration' => $ccShowDay->formatDuration(true),
|
||||
'add_show_repeats' => $ccShowDay->isRepeating() ? 1 : 0));
|
||||
}
|
||||
|
||||
private function populateInstanceFormWhen($form)
|
||||
{
|
||||
$ccShowInstance = CcShowInstancesQuery::create()->findPk($this->instanceId);
|
||||
|
||||
$timezone = new DateTimeZone(Application_Model_Preference::GetTimezone());
|
||||
//DateTime object in UTC
|
||||
$showStart = $ccShowInstance->getDbStarts(null);
|
||||
$showStart->setTimezone($timezone);
|
||||
|
||||
$showEnd = $ccShowInstance->getDbEnds(null);
|
||||
$showEnd->setTimezone($timezone);
|
||||
|
||||
//if the show has started, do not allow editing on the start time
|
||||
if ($showStart->getTimestamp() <= time()) {
|
||||
$form->disableStartDateAndTime();
|
||||
}
|
||||
|
||||
$form->populate(
|
||||
array(
|
||||
'add_show_start_date' => $showStart->format("Y-m-d"),
|
||||
'add_show_start_time' => $showStart->format("H:i"),
|
||||
'add_show_end_date_no_repeat' => $showEnd->format("Y-m-d"),
|
||||
'add_show_end_time' => $showEnd->format("H:i"),
|
||||
'add_show_duration' => $this->calculateDuration(
|
||||
$showStart->format("Y-m-d H:i:s"), $showEnd->format("Y-m-d H:i:s")),
|
||||
'add_show_repeats' => 0));
|
||||
|
||||
$form->getElement('add_show_repeats')->setOptions(array("disabled" => true));
|
||||
}
|
||||
|
||||
private function populateFormRepeats($form)
|
||||
{
|
||||
$ccShowDays = $this->ccShow->getCcShowDays();
|
||||
|
||||
$days = array();
|
||||
foreach ($ccShowDays as $ccShowDay) {
|
||||
$showStart = $ccShowDay->getLocalStartDateAndTime();
|
||||
array_push($days, $showStart->format("w"));
|
||||
}
|
||||
|
||||
$service_show = new Application_Service_ShowService($this->ccShow->getDbId());
|
||||
$repeatEndDate = new DateTime($service_show->getRepeatingEndDate(), new DateTimeZone(
|
||||
$ccShowDays[0]->getDbTimezone()));
|
||||
//end dates are stored non-inclusively so we need to
|
||||
//subtract one day
|
||||
$repeatEndDate->sub(new DateInterval("P1D"));
|
||||
|
||||
//default monthly repeat type
|
||||
$monthlyRepeatType = 2;
|
||||
$repeatType = $ccShowDays[0]->getDbRepeatType();
|
||||
if ($repeatType == REPEAT_MONTHLY_WEEKLY) {
|
||||
$monthlyRepeatType = $repeatType;
|
||||
//a repeat type of 2 means the show is repeating monthly
|
||||
$repeatType = 2;
|
||||
} elseif ($repeatType == REPEAT_MONTHLY_MONTHLY) {
|
||||
$monthlyRepeatType = $repeatType;
|
||||
}
|
||||
|
||||
$form->populate(
|
||||
array(
|
||||
'add_show_linked' => $this->ccShow->getDbLinked(),
|
||||
'add_show_repeat_type' => $repeatType,
|
||||
'add_show_day_check' => $days,
|
||||
'add_show_end_date' => $repeatEndDate->format("Y-m-d"),
|
||||
'add_show_no_end' => (!$service_show->getRepeatingEndDate()),
|
||||
'add_show_monthly_repeat_type' => $monthlyRepeatType));
|
||||
|
||||
if (!$this->ccShow->isLinkable()) {
|
||||
$form->getElement('add_show_linked')->setOptions(array('disabled' => true));
|
||||
}
|
||||
}
|
||||
|
||||
private function populateFormWho($form)
|
||||
{
|
||||
$ccShowHosts = $this->ccShow->getCcShowHostss();
|
||||
|
||||
$hosts = array();
|
||||
foreach ($ccShowHosts as $ccShowHost) {
|
||||
array_push($hosts, $ccShowHost->getDbHost());
|
||||
}
|
||||
|
||||
$form->populate(array('add_show_hosts' => $hosts));
|
||||
}
|
||||
|
||||
private function populateFormStyle($form)
|
||||
{
|
||||
$form->populate(
|
||||
array(
|
||||
'add_show_background_color' => $this->ccShow->getDbBackgroundColor(),
|
||||
'add_show_color' => $this->ccShow->getDbColor()));
|
||||
}
|
||||
|
||||
private function populateFormLive($form)
|
||||
{
|
||||
$form->populate(
|
||||
array(
|
||||
"cb_airtime_auth" => $this->ccShow->getDbLiveStreamUsingAirtimeAuth(),
|
||||
"cb_custom_auth" => $this->ccShow->getDbLiveStreamUsingCustomAuth(),
|
||||
"custom_username" => $this->ccShow->getDbLiveStreamUser(),
|
||||
"custom_password" => $this->ccShow->getDbLiveStreamPass()));
|
||||
}
|
||||
|
||||
private function populateFormRecord($form)
|
||||
{
|
||||
$form->populate(
|
||||
array(
|
||||
'add_show_record' => $this->ccShow->isRecorded(),
|
||||
'add_show_rebroadcast' => $this->ccShow->isRebroadcast()));
|
||||
|
||||
$form->getElement('add_show_record')->setOptions(array('disabled' => true));
|
||||
}
|
||||
|
||||
private function populateFormRebroadcastRelative($form)
|
||||
{
|
||||
$relativeRebroadcasts = $this->ccShow->getRebroadcastsRelative();
|
||||
|
||||
$formValues = array();
|
||||
$i = 1;
|
||||
foreach ($relativeRebroadcasts as $rr) {
|
||||
$formValues["add_show_rebroadcast_date_$i"] = $rr->getDbDayOffset();
|
||||
$formValues["add_show_rebroadcast_time_$i"] = Application_Common_DateHelper::removeSecondsFromTime(
|
||||
$rr->getDbStartTime());
|
||||
$i++;
|
||||
}
|
||||
|
||||
$form->populate($formValues);
|
||||
}
|
||||
|
||||
private function populateFormRebroadcastAbsolute($form)
|
||||
{
|
||||
$absolutRebroadcasts = $this->ccShow->getRebroadcastsAbsolute();
|
||||
|
||||
$formValues = array();
|
||||
$i = 1;
|
||||
foreach ($absolutRebroadcasts as $ar) {
|
||||
//convert dates to user's local time
|
||||
$start = new DateTime($ar->getDbStarts(), new DateTimeZone("UTC"));
|
||||
$start->setTimezone(new DateTimeZone(Application_Model_Preference::GetTimezone()));
|
||||
$formValues["add_show_rebroadcast_date_absolute_$i"] = $start->format("Y-m-d");
|
||||
$formValues["add_show_rebroadcast_time_absolute_$i"] = $start->format("H:i");
|
||||
$i++;
|
||||
}
|
||||
|
||||
$form->populate($formValues);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Before we send the form data in for validation, there
|
||||
* are a few fields we may need to adjust first
|
||||
* @param $formData
|
||||
*/
|
||||
public function preEditShowValidationCheck($formData)
|
||||
{
|
||||
$validateStartDate = true;
|
||||
$validateStartTime = true;
|
||||
|
||||
//CcShowDays object of the show currently being edited
|
||||
$currentShowDay = $this->ccShow->getFirstCcShowDay();
|
||||
|
||||
//DateTime object
|
||||
$dt = $currentShowDay->getLocalStartDateAndTime();
|
||||
|
||||
if (!array_key_exists('add_show_start_date', $formData)) {
|
||||
//Changing the start date was disabled, since the
|
||||
//array key does not exist. We need to repopulate this entry from the db.
|
||||
$formData['add_show_start_date'] = $dt->format("Y-m-d");
|
||||
|
||||
if (!array_key_exists('add_show_start_time', $formData)) {
|
||||
$formData['add_show_start_time'] = $dt->format("H:i");
|
||||
$validateStartTime = false;
|
||||
}
|
||||
$validateStartDate = false;
|
||||
}
|
||||
$formData['add_show_record'] = $currentShowDay->getDbRecord();
|
||||
|
||||
//if the show is repeating, set the start date to the next
|
||||
//repeating instance in the future
|
||||
if ($currentShowDay->isRepeating()) {
|
||||
list($originalShowStartDateTime,) = $this->getNextFutureRepeatShowTime();
|
||||
} else {
|
||||
$originalShowStartDateTime = $dt;
|
||||
}
|
||||
|
||||
return array($formData, $validateStartDate, $validateStartTime, $originalShowStartDateTime);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Returns 2 DateTime objects, in the user's local time,
|
||||
* of the next future repeat show instance start and end time
|
||||
*/
|
||||
public function getNextFutureRepeatShowTime()
|
||||
{
|
||||
$ccShowInstance = CcShowInstancesQuery::create()
|
||||
->filterByDbShowId($this->ccShow->getDbId())
|
||||
->filterByDbModifiedInstance(false)
|
||||
->filterByDbEnds(gmdate("Y-m-d H:i:s"), Criteria::GREATER_THAN)
|
||||
->orderByDbStarts()
|
||||
->limit(1)
|
||||
->findOne();
|
||||
|
||||
$starts = new DateTime($ccShowInstance->getDbStarts(), new DateTimeZone("UTC"));
|
||||
$ends = new DateTime($ccShowInstance->getDbEnds(), new DateTimeZone("UTC"));
|
||||
$userTimezone = Application_Model_Preference::GetTimezone();
|
||||
|
||||
$starts->setTimezone(new DateTimeZone($userTimezone));
|
||||
$ends->setTimezone(new DateTimeZone($userTimezone));
|
||||
|
||||
return array($starts, $ends);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Validates show forms
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function validateShowForms($forms, $formData, $validateStartDate = true,
|
||||
$originalStartDate=null, $editShow=false, $instanceId=null)
|
||||
{
|
||||
$what = $forms["what"]->isValid($formData);
|
||||
$live = $forms["live"]->isValid($formData);
|
||||
$record = $forms["record"]->isValid($formData);
|
||||
$who = $forms["who"]->isValid($formData);
|
||||
$style = $forms["style"]->isValid($formData);
|
||||
$when = $forms["when"]->isWhenFormValid($formData, $validateStartDate,
|
||||
$originalStartDate, $editShow, $instanceId);
|
||||
|
||||
$repeats = true;
|
||||
if ($formData["add_show_repeats"]) {
|
||||
$repeats = $forms["repeats"]->isValid($formData);
|
||||
|
||||
/*
|
||||
* Make the absolute rebroadcast form valid since
|
||||
* it does not get used if the show is repeating
|
||||
*/
|
||||
$forms["abs_rebroadcast"]->reset();
|
||||
$absRebroadcast = true;
|
||||
|
||||
$rebroadcast = true;
|
||||
if ($formData["add_show_rebroadcast"]) {
|
||||
$formData["add_show_duration"] = Application_Service_ShowService::formatShowDuration(
|
||||
$formData["add_show_duration"]);
|
||||
$rebroadcast = $forms["rebroadcast"]->isValid($formData);
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* Make the rebroadcast form valid since it does
|
||||
* not get used if the show is not repeating.
|
||||
* Instead, we use the absolute rebroadcast form
|
||||
*/
|
||||
$forms["rebroadcast"]->reset();
|
||||
$rebroadcast = true;
|
||||
|
||||
$absRebroadcast = true;
|
||||
if ($formData["add_show_rebroadcast"]) {
|
||||
$formData["add_show_duration"] = Application_Service_ShowService::formatShowDuration(
|
||||
$formData["add_show_duration"]);
|
||||
$absRebroadcast = $forms["abs_rebroadcast"]->isValid($formData);
|
||||
}
|
||||
}
|
||||
|
||||
if ($what && $live && $record && $who && $style && $when &&
|
||||
$repeats && $absRebroadcast && $rebroadcast) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function calculateDuration($start, $end)
|
||||
{
|
||||
try {
|
||||
$startDateTime = new DateTime($start);
|
||||
$endDateTime = new DateTime($end);
|
||||
|
||||
$UTCStartDateTime = $startDateTime->setTimezone(new DateTimeZone('UTC'));
|
||||
$UTCEndDateTime = $endDateTime->setTimezone(new DateTimeZone('UTC'));
|
||||
|
||||
$duration = $UTCEndDateTime->diff($UTCStartDateTime);
|
||||
|
||||
$day = intval($duration->format('%d'));
|
||||
if ($day > 0) {
|
||||
$hour = intval($duration->format('%h'));
|
||||
$min = intval($duration->format('%i'));
|
||||
$hour += $day * 24;
|
||||
$hour = min($hour, 99);
|
||||
$sign = $duration->format('%r');
|
||||
return sprintf('%s%02dh %02dm', $sign, $hour, $min);
|
||||
} else {
|
||||
return $duration->format('%Hh %Im');
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return "Invalid Date";
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
/*define('UTYPE_HOST' , 'H');
|
||||
define('UTYPE_ADMIN' , 'A');
|
||||
define('UTYPE_GUEST' , 'G');
|
||||
define('UTYPE_PROGRAM_MANAGER' , 'P');*/
|
||||
|
||||
class Application_Service_UserService
|
||||
{
|
||||
private $currentUser;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
if (!is_null($userInfo->id)) {
|
||||
$this->currentUser = CcSubjsQuery::create()->findPK($userInfo->id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Returns a CcSubjs object
|
||||
*/
|
||||
public function getCurrentUser()
|
||||
{
|
||||
if (is_null($this->currentUser)) {
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
return $this->currentUser;
|
||||
}
|
||||
|
||||
}
|
|
@ -132,6 +132,10 @@
|
|||
<column name="live_stream_using_custom_auth" phpName="DbLiveStreamUsingCustomAuth" type="BOOLEAN" required="false" defaultValue="false"/>
|
||||
<column name="live_stream_user" phpName="DbLiveStreamUser" type="VARCHAR" size="255" required="false"/>
|
||||
<column name="live_stream_pass" phpName="DbLiveStreamPass" type="VARCHAR" size="255" required="false"/>
|
||||
<column name="linked" phpName="DbLinked" type="BOOLEAN" required="true" defaultValue="false" />
|
||||
<column name="is_linkable" phpName="DbIsLinkable" type="BOOLEAN" required="true" defaultValue="true" />
|
||||
<!-- A show is_linkable if it has never been linked before. Once a show becomes unlinked
|
||||
it can not be linked again -->
|
||||
</table>
|
||||
<table name="cc_show_instances" phpName="CcShowInstances">
|
||||
<column name="id" phpName="DbId" type="INTEGER" primaryKey="true" autoIncrement="true" required="true"/>
|
||||
|
@ -322,6 +326,11 @@
|
|||
<column name="instance_id" phpName="DbInstanceId" type="INTEGER" required="true"/>
|
||||
<column name="playout_status" phpName="DbPlayoutStatus" type="SMALLINT" required="true" defaultValue="1"/>
|
||||
<column name="broadcasted" phpName="DbBroadcasted" type="SMALLINT" required="true" defaultValue="0"/>
|
||||
<!-- Broadcasted is set to 1 when show and master source are not on.
|
||||
We need to know this for logging playout history. (It only gets logged when
|
||||
broadcasted = 1)
|
||||
-->
|
||||
<column name="position" phpName="DbPosition" type="INTEGER" required="true" default="0" />
|
||||
<!-- This foreign key is still useful even though it may seem we don't ever delete cc_show_instances anymore.
|
||||
We will do delete them in some cases (when editing a show and changing the repeating days of the week
|
||||
for example. \
|
||||
|
|
|
@ -11,7 +11,7 @@ INSERT INTO cc_live_log("state", "start_time") VALUES('S', now() at time zone 'U
|
|||
-- end of added in 2.1
|
||||
|
||||
-- added in 2.0.0
|
||||
INSERT INTO cc_pref("keystr", "valstr") VALUES('stream_type', 'ogg, mp3');
|
||||
INSERT INTO cc_pref("keystr", "valstr") VALUES('stream_type', 'ogg, mp3, opus, aac');
|
||||
INSERT INTO cc_pref("keystr", "valstr") VALUES('stream_bitrate', '24, 32, 48, 64, 96, 128, 160, 192, 224, 256, 320');
|
||||
INSERT INTO cc_pref("keystr", "valstr") VALUES('num_of_streams', '3');
|
||||
INSERT INTO cc_pref("keystr", "valstr") VALUES('max_bitrate', '320');
|
||||
|
|
|
@ -156,6 +156,8 @@ CREATE TABLE "cc_show"
|
|||
"live_stream_using_custom_auth" BOOLEAN default 'f',
|
||||
"live_stream_user" VARCHAR(255),
|
||||
"live_stream_pass" VARCHAR(255),
|
||||
"linked" BOOLEAN default 'f' NOT NULL,
|
||||
"is_linkable" BOOLEAN default 't' NOT NULL,
|
||||
PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
|
@ -426,6 +428,7 @@ CREATE TABLE "cc_schedule"
|
|||
"instance_id" INTEGER NOT NULL,
|
||||
"playout_status" INT2 default 1 NOT NULL,
|
||||
"broadcasted" INT2 default 0 NOT NULL,
|
||||
"position" INTEGER default 0 NOT NULL,
|
||||
PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
|
|
|
@ -214,13 +214,28 @@ function setAddShowEvents() {
|
|||
});
|
||||
|
||||
form.find("#add_show_repeat_type").change(function(){
|
||||
if($(this).val() == 2) {
|
||||
toggleRepeatDays();
|
||||
toggleMonthlyRepeatType();
|
||||
});
|
||||
toggleMonthlyRepeatType();
|
||||
toggleRepeatDays();
|
||||
function toggleRepeatDays() {
|
||||
if(form.find("#add_show_repeat_type").val() >= 2) {
|
||||
form.find("#add_show_day_check-label, #add_show_day_check-element").hide();
|
||||
//form.find("#add_show_monthly_repeat_type-label, #add_show_monthly_repeat_type-element").show();
|
||||
}
|
||||
else {
|
||||
form.find("#add_show_day_check-label, #add_show_day_check-element").show();
|
||||
//form.find("#add_show_monthly_repeat_type-label, #add_show_monthly_repeat_type-element").hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
function toggleMonthlyRepeatType() {
|
||||
if (form.find("#add_show_repeat_type").val() == 2) {
|
||||
form.find("#add_show_monthly_repeat_type-label, #add_show_monthly_repeat_type-element").show();
|
||||
} else {
|
||||
form.find("#add_show_monthly_repeat_type-label, #add_show_monthly_repeat_type-element").hide();
|
||||
}
|
||||
}
|
||||
|
||||
form.find("#add_show_day_check-label").addClass("block-display");
|
||||
form.find("#add_show_day_check-element").addClass("block-display clearfix");
|
||||
|
|
|
@ -379,7 +379,7 @@ $(document).ready(function() {
|
|||
|
||||
//edit a single instance
|
||||
callback = function() {
|
||||
$.get(edit.instance.url, {format: "json", id: data.id, type: "instance"}, function(json){
|
||||
$.get(edit.instance.url, {format: "json", showId: data.showId, instanceId: data.id, type: "instance"}, function(json){
|
||||
beginEditShow(json);
|
||||
});
|
||||
};
|
||||
|
@ -387,14 +387,14 @@ $(document).ready(function() {
|
|||
|
||||
//edit this instance and all
|
||||
callback = function() {
|
||||
$.get(edit.all.url, {format: "json", id: data.id, type: "all"}, function(json){
|
||||
$.get(edit.all.url, {format: "json", showId: data.showId, instanceId: data.id, type: "all"}, function(json){
|
||||
beginEditShow(json);
|
||||
});
|
||||
};
|
||||
edit.all.callback = callback;
|
||||
}else{
|
||||
callback = function() {
|
||||
$.get(oItems.edit.url, {format: "json", id: data.id, type: oItems.edit._type}, function(json){
|
||||
$.get(oItems.edit.url, {format: "json", showId: data.showId, instanceId: data.id, type: oItems.edit._type}, function(json){
|
||||
beginEditShow(json);
|
||||
});
|
||||
};
|
||||
|
@ -497,11 +497,11 @@ $(document).ready(function() {
|
|||
|
||||
items = oItems;
|
||||
}
|
||||
|
||||
|
||||
$.ajax({
|
||||
url: baseUrl+"schedule/make-context-menu",
|
||||
type: "GET",
|
||||
data: {id : data.id, format: "json"},
|
||||
data: {instanceId : data.id, showId: data.showId, format: "json"},
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json){
|
||||
|
|
|
@ -172,7 +172,6 @@ var AIRTIME = (function(AIRTIME){
|
|||
};
|
||||
|
||||
mod.checkToolBarIcons = function() {
|
||||
|
||||
AIRTIME.library.checkAddButton();
|
||||
mod.checkSelectButton();
|
||||
mod.checkTrimButton();
|
||||
|
@ -299,7 +298,6 @@ var AIRTIME = (function(AIRTIME){
|
|||
};
|
||||
|
||||
mod.fnAdd = function(aMediaIds, aSchedIds) {
|
||||
|
||||
mod.disableUI();
|
||||
|
||||
$.post(baseUrl+"showbuilder/schedule-add",
|
||||
|
@ -646,7 +644,7 @@ var AIRTIME = (function(AIRTIME){
|
|||
|
||||
//save some info for reordering purposes.
|
||||
$nRow.data({"aData": aData});
|
||||
|
||||
|
||||
if (aData.scheduled === 1) {
|
||||
$nRow.addClass(NOW_PLAYING_CLASS);
|
||||
}
|
||||
|
@ -657,7 +655,7 @@ var AIRTIME = (function(AIRTIME){
|
|||
$nRow.addClass("sb-future");
|
||||
}
|
||||
|
||||
if (aData.allowed !== true) {
|
||||
if (aData.allowed !== true || aData.linked_allowed === false) {
|
||||
$nRow.addClass("sb-not-allowed");
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
#!/bin/bash -e
|
||||
apt-get install -y --force-yes lsb-release sudo
|
||||
dist=`lsb_release -is`
|
||||
code=`lsb_release -cs`
|
||||
cpu=`getconf LONG_BIT`
|
||||
cpuvalue=
|
||||
|
||||
if [ "$dist" = "Ubuntu" ]; then
|
||||
set +e
|
||||
grep -E "deb http://ca.archive.ubuntu.com/ubuntu/ $code multiverse" /etc/apt/sources.list
|
||||
returncode=$?
|
||||
set -e
|
||||
if [ "$returncode" -ne "0" ]; then
|
||||
echo "deb http://ca.archive.ubuntu.com/ubuntu/ $code multiverse" >> /etc/apt/sources.list
|
||||
echo "deb http://ca.archive.ubuntu.com/ubuntu/ $code universe" >> /etc/apt/sources.list
|
||||
fi
|
||||
fi
|
||||
|
||||
#enable squeeze backports to get lame packages
|
||||
if [ "$dist" = "Debian" -a "$code" = "squeeze" ]; then
|
||||
set +e
|
||||
grep -E "deb http://backports.debian.org/debian-backports squeeze-backports main" /etc/apt/sources.list
|
||||
returncode=$?
|
||||
set -e
|
||||
if [ "$returncode" -ne "0" ]; then
|
||||
echo "deb http://backports.debian.org/debian-backports squeeze-backports main" >> /etc/apt/sources.list
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "System is $cpu bit..."
|
||||
if [ "$cpu" = "64" ]; then
|
||||
cpuvalue="amd64"
|
||||
else
|
||||
cpuvalue="i386"
|
||||
fi
|
||||
|
||||
apt-get update
|
||||
apt-get -o Dpkg::Options::="--force-confold" upgrade
|
||||
apt-get install wget
|
||||
wget http://apt.sourcefabric.org/misc/libopus_1.0.1/libopus-dbg_1.0.1~$code~sfo-1_$cpuvalue.deb
|
||||
wget http://apt.sourcefabric.org/misc/libopus_1.0.1/libopus-dev_1.0.1~$code~sfo-1_$cpuvalue.deb
|
||||
wget http://apt.sourcefabric.org/misc/libopus_1.0.1/libopus0_1.0.1~$code~sfo-1_$cpuvalue.deb
|
||||
|
||||
apt-get -y --force-yes install git-core ocaml-findlib libao-ocaml-dev \
|
||||
libportaudio-ocaml-dev libmad-ocaml-dev libtaglib-ocaml-dev libalsa-ocaml-dev \
|
||||
libvorbis-ocaml-dev libladspa-ocaml-dev libxmlplaylist-ocaml-dev libflac-dev \
|
||||
libxml-dom-perl libxml-dom-xpath-perl patch autoconf libmp3lame-dev \
|
||||
libcamomile-ocaml-dev libcamlimages-ocaml-dev libtool libpulse-dev camlidl \
|
||||
libfaad-dev libpcre-ocaml-dev
|
||||
|
||||
dpkg -i libopus-dbg_1.0.1~$code~sfo-1_$cpuvalue.deb libopus-dev_1.0.1~$code~sfo-1_$cpuvalue.deb libopus0_1.0.1~$code~sfo-1_$cpuvalue.deb
|
||||
rm -rf liquidsoap-full
|
||||
git clone https://github.com/savonet/liquidsoap-full
|
||||
chmod -R 777 liquidsoap-full
|
||||
cd liquidsoap-full
|
||||
sudo -u tmp make init
|
||||
sudo -u tmp make update
|
||||
|
||||
sudo -u tmp cp PACKAGES.minimal PACKAGES
|
||||
|
||||
sed -i "s/#ocaml-portaudio/ocaml-portaudio/g" PACKAGES
|
||||
sed -i "s/#ocaml-alsa/ocaml-alsa/g" PACKAGES
|
||||
sed -i "s/#ocaml-pulseaudio/ocaml-pulseaudio/g" PACKAGES
|
||||
sed -i "s/#ocaml-faad/ocaml-faad/g" PACKAGES
|
||||
sed -i "s/#ocaml-opus/ocaml-opus/g" PACKAGES
|
||||
#sed -i "s/#ocaml-shine/ocaml-shine/g" PACKAGES
|
||||
|
||||
sudo -u tmp ./bootstrap
|
||||
sudo -u tmp ./configure
|
||||
sudo -u tmp make
|
||||
cp /liquidsoap-full/liquidsoap/src/liquidsoap /
|
|
@ -0,0 +1,170 @@
|
|||
#!/bin/bash
|
||||
|
||||
exec 2>&1
|
||||
|
||||
ROOT_UID="0"
|
||||
|
||||
#Check if run as root
|
||||
if [ "$UID" -ne "$ROOT_UID" ] ; then
|
||||
echo "You must have 'sudo' right to do that!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -rf ./liquidsoap_compile_logs
|
||||
mkdir -p ./liquidsoap_compile_logs
|
||||
|
||||
showhelp () {
|
||||
echo "Usage: run.sh [options] [parameters]
|
||||
-c all|ubuntu_lucid_32 Compile liquidsoap on all platforms or specified platform.
|
||||
-b all|ubuntu_lucid_32 Build shroot environments for all platforms or specified platform.
|
||||
-u username Local username will be used as sudo user of chroot env. Must be assigned before -b options"
|
||||
exit 0
|
||||
}
|
||||
|
||||
build_env () {
|
||||
if [ $sudo_user = "-1" ];then
|
||||
echo "Please use -u to assign sudo username before build environments."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "build_env $1"
|
||||
#exec > >(tee ./liquidsoap_compile_logs/build_env_$1.log)
|
||||
os=`echo $1 | awk '/(debian)/'`
|
||||
cpu=`echo $1 | awk '/(64)/'`
|
||||
dist=`echo $1 | awk -F "_" '{print $2}'`
|
||||
|
||||
rm -f /etc/schroot/chroot.d/$1.conf
|
||||
if cat /etc/passwd | awk -F:'{print $1}' | grep "tmp" >/dev/null 2>&1;then
|
||||
echo "User tmp exists."
|
||||
else
|
||||
useradd tmp
|
||||
echo "User tmp is created."
|
||||
fi
|
||||
|
||||
apt-get update
|
||||
apt-get --force-yes -y install debootstrap dchroot
|
||||
echo [$1] > /etc/schroot/chroot.d/$1.conf
|
||||
echo description=$1 >> /etc/schroot/chroot.d/$1.conf
|
||||
echo directory=/srv/chroot/$1 >> /etc/schroot/chroot.d/$1.conf
|
||||
echo type=directory >> /etc/schroot/chroot.d/$1.conf
|
||||
echo users=$sudo_user,tmp >> /etc/schroot/chroot.d/$1.conf
|
||||
echo root-users=$sudo_user >> /etc/schroot/chroot.d/$1.conf
|
||||
rm -rf /srv/chroot/$1
|
||||
mkdir -p /srv/chroot/$1
|
||||
|
||||
#cp liquidsoap_compile.sh /srv/chroot/$1/
|
||||
if [ "$os" = "" ];then
|
||||
if [ "$cpu" = "" ];then
|
||||
echo "debootstrap --variant=buildd --arch=i386 $dist /srv/chroot/$1 http://archive.ubuntu.com/ubuntu/"
|
||||
debootstrap --variant=buildd --arch=i386 $dist /srv/chroot/$1 http://archive.ubuntu.com/ubuntu/
|
||||
else
|
||||
echo "debootstrap --variant=buildd --arch=amd64 $dist /srv/chroot/$1 http://archive.ubuntu.com/ubuntu/"
|
||||
debootstrap --variant=buildd --arch=amd64 $dist /srv/chroot/$1 http://archive.ubuntu.com/ubuntu/
|
||||
fi
|
||||
else
|
||||
if [ "$cpu" = "" ];then
|
||||
echo "debootstrap --variant=buildd --arch=i386 $dist /srv/chroot/$1 http://ftp.debian.com/debian/"
|
||||
debootstrap --variant=buildd --arch=i386 $dist /srv/chroot/$1 http://ftp.debian.com/debian/
|
||||
else
|
||||
echo "debootstrap --variant=buildd --arch=amd64 $dist /srv/chroot/$1 http://ftp.debian.com/debian/"
|
||||
debootstrap --variant=buildd --arch=amd64 $dist /srv/chroot/$1 http://ftp.debian.com/debian/
|
||||
fi
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
compile_liq () {
|
||||
echo "complie_liq $1"
|
||||
#exec > >(tee ./liquidsoap_compile_logs/compile_liq_$1.log)
|
||||
binfilename=`echo $1 | sed -e 's/ubuntu/liquidsoap/g' -e 's/debian/liquidsoap/g' -e 's/32/i386/g' -e 's/64/amd64/g'`
|
||||
rm -f /srv/chroot/$1/liquidsoap_compile.sh
|
||||
rm -f /srv/chroot/$1/liquidsoap
|
||||
cp liquidsoap_compile.sh /srv/chroot/$1/
|
||||
schroot -c $1 -u root -d / -- /liquidsoap_compile.sh
|
||||
cp /srv/chroot/$1/liquidsoap ./$binfilename
|
||||
if [ $? -ne 0 ];then
|
||||
echo "$binfilename is generated successfully"
|
||||
else
|
||||
mv ./liquidsoap_compile_logs/compile_liq_$1.log ./liquidsoap_compile_logs/fail_to_compile_liq_$1.log
|
||||
fi
|
||||
}
|
||||
|
||||
os_versions=("ubuntu_lucid_32" "ubuntu_lucid_64" "ubuntu_oneiric_32" "ubuntu_oneiric_64" "ubuntu_precise_32" "ubuntu_precise_64" "ubuntu_quantal_32" "ubuntu_quantal_64" "debian_squeeze_32" "debian_squeeze_64" "debian_wheezy_32" "debian_wheezy_64")
|
||||
|
||||
num=${#os_versions[@]}
|
||||
flag=
|
||||
os=
|
||||
sudo_user="-1"
|
||||
|
||||
if [ x$1 = x ];then
|
||||
showhelp
|
||||
fi
|
||||
|
||||
while getopts b:c:u: arg
|
||||
do
|
||||
case $arg in
|
||||
b)
|
||||
if [ "$OPTARG" = "all" ];then
|
||||
echo "Building all platforms on server..."
|
||||
for i in $(seq 0 $(($num -1)))
|
||||
do
|
||||
build_env ${os_versions[$i]} | tee ./liquidsoap_compile_logs/build_env_${os_versions[$i]}.log
|
||||
done
|
||||
else
|
||||
flag=1
|
||||
for i in $(seq 0 $(($num -1)));
|
||||
do
|
||||
if [ "$OPTARG" = ${os_versions[$i]} ];then
|
||||
echo "Building platform: $OPTARG ..."
|
||||
build_env ${os_versions[$i]} | tee ./liquidsoap_compile_logs/build_env_${os_versions[$i]}.log
|
||||
flag=0
|
||||
fi
|
||||
done
|
||||
if [ $flag = 1 ];then
|
||||
echo "Unsupported Platform from:"
|
||||
for j in "${os_versions[@]}"
|
||||
do
|
||||
echo $j
|
||||
done
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
c)
|
||||
if [ "$OPTARG" = "all" ];then
|
||||
echo "Compiling liquidsoap for all platforms on server..."
|
||||
for i in $(seq 0 $(($num -1)))
|
||||
do
|
||||
compile_liq ${os_versions[$i]} | tee ./liquidsoap_compile_logs/compile_liq_${os_versions[$i]}.log
|
||||
done
|
||||
|
||||
else
|
||||
flag=1
|
||||
for i in $(seq 0 $(($num -1)));
|
||||
do
|
||||
if [ "$OPTARG" = ${os_versions[$i]} ];then
|
||||
echo "Compiling liquidsoap for platform: $OPTARG ..."
|
||||
compile_liq ${os_versions[$i]} | tee ./liquidsoap_compile_logs/compile_liq_${os_versions[$i]}.log
|
||||
flag=0
|
||||
fi
|
||||
done
|
||||
if [ $flag = 1 ];then
|
||||
echo "Unsupported Platform from:"
|
||||
for k in "${os_versions[@]}"
|
||||
do
|
||||
echo $k
|
||||
done
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
u)
|
||||
sudo_user="$OPTARG"
|
||||
echo "sudo_user is set as $sudo_user."
|
||||
;;
|
||||
?)
|
||||
showhelp
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
|
@ -82,10 +82,11 @@ else
|
|||
apt-get -y --force-yes install coreutils
|
||||
fi
|
||||
|
||||
#Install Sourcefabric's custom Liquidsoap debian package
|
||||
#Install packages back-ported by Sourcefabric
|
||||
apt-get -y --force-yes install sourcefabric-keyring
|
||||
apt-get -y --force-yes install liquidsoap
|
||||
apt-get -y --force-yes install silan
|
||||
apt-get -y --force-yes install libopus0
|
||||
|
||||
if [ "$server" = "nginx" ]; then
|
||||
apt-get -y --force-yes install nginx php5-fpm
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
<?php
|
||||
|
||||
define('AIRTIME_VERSION', '2.3.1');
|
||||
define('AIRTIME_VERSION', '2.4.0');
|
||||
|
|
|
@ -80,4 +80,8 @@ if (strcmp($version, "2.3.1") < 0) {
|
|||
passthru("php --php-ini $SCRIPTPATH/../airtime-php.ini $SCRIPTPATH/../upgrades/airtime-2.3.1/airtime-upgrade.php");
|
||||
pause();
|
||||
}
|
||||
if (strcmp($version, "2.4.0") < 0) {
|
||||
passthru("php --php-ini $SCRIPTPATH/../airtime-php.ini $SCRIPTPATH/../upgrades/airtime-2.4.0/airtime-upgrade.php");
|
||||
pause();
|
||||
}
|
||||
echo "******************************* Upgrade Complete *******************************".PHP_EOL;
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
DELETE FROM cc_pref WHERE keystr = 'system_version';
|
||||
INSERT INTO cc_pref (keystr, valstr) VALUES ('system_version', '2.4.0');
|
||||
|
||||
DELETE FROM cc_pref WHERE keystr = 'stream_type';
|
||||
INSERT INTO cc_pref (keystr, valstr) VALUES ('stream_type', 'ogg, mp3, opus, aac');
|
|
@ -16,7 +16,7 @@ import base64
|
|||
import traceback
|
||||
from configobj import ConfigObj
|
||||
|
||||
AIRTIME_VERSION = "2.3.1"
|
||||
AIRTIME_VERSION = "2.4.0"
|
||||
|
||||
|
||||
# TODO : Place these functions in some common module. Right now, media
|
||||
|
@ -127,22 +127,31 @@ class ApiRequest(object):
|
|||
self.__req = None
|
||||
if logger is None: self.logger = logging
|
||||
else: self.logger = logger
|
||||
|
||||
def __call__(self,_post_data=None, **kwargs):
|
||||
final_url = self.url.params(**kwargs).url()
|
||||
if _post_data is not None: _post_data = urllib.urlencode(_post_data)
|
||||
self.logger.debug(final_url)
|
||||
try:
|
||||
req = urllib2.Request(final_url, _post_data)
|
||||
response = urllib2.urlopen(req).read()
|
||||
f = urllib2.urlopen(req)
|
||||
content_type = f.info().getheader('Content-Type')
|
||||
response = f.read()
|
||||
except Exception, e:
|
||||
self.logger.error('Exception: %s', e)
|
||||
self.logger.error("traceback: %s", traceback.format_exc())
|
||||
raise
|
||||
# Ghetto hack for now because we don't the content type we are getting
|
||||
# (Pointless to look at mime since it's not being set correctly always)
|
||||
|
||||
try:
|
||||
return json.loads(response)
|
||||
if content_type == 'application/json':
|
||||
data = json.loads(response)
|
||||
self.logger.debug(data)
|
||||
return data
|
||||
else:
|
||||
raise InvalidContentType()
|
||||
except Exception:
|
||||
self.logger.error(response)
|
||||
self.logger.error("traceback: %s", traceback.format_exc())
|
||||
raise
|
||||
|
||||
def req(self, *args, **kwargs):
|
||||
|
@ -508,3 +517,7 @@ class AirtimeApiClient(object):
|
|||
except Exception, e:
|
||||
#TODO
|
||||
self.logger.error(str(e))
|
||||
|
||||
|
||||
class InvalidContentType(Exception):
|
||||
pass
|
||||
|
|
|
@ -148,7 +148,8 @@ class MetadataElement(Loggable):
|
|||
if self.__max_length != -1:
|
||||
r = truncate_to_length(r, self.__max_length)
|
||||
if self.__max_value != -1:
|
||||
r = truncate_to_value(r, self.__max_value)
|
||||
try: r = truncate_to_value(r, self.__max_value)
|
||||
except ValueError, e: r = ''
|
||||
return r
|
||||
|
||||
def normalize_mutagen(path):
|
||||
|
|
|
@ -245,7 +245,7 @@ if __name__ == '__main__':
|
|||
pf.daemon = True
|
||||
pf.start()
|
||||
|
||||
pp = PypoPush(pypoPush_q, telnet_lock, pypo_liquidsoap)
|
||||
pp = PypoPush(pypoPush_q, telnet_lock, pypo_liquidsoap, config)
|
||||
pp.daemon = True
|
||||
pp.start()
|
||||
|
||||
|
|
|
@ -281,7 +281,7 @@ class PypoFetch(Thread):
|
|||
|
||||
line = line.strip()
|
||||
|
||||
if not len(line) or line[0] == "#"
|
||||
if not len(line) or line[0] == "#":
|
||||
continue
|
||||
|
||||
try:
|
||||
|
|
|
@ -57,8 +57,7 @@ class PypoPush(Thread):
|
|||
self.queue_id = 0
|
||||
|
||||
self.future_scheduled_queue = Queue()
|
||||
self.pypo_liquidsoap = PypoLiquidsoap(self.logger, telnet_lock,\
|
||||
config['ls_host'], config['ls_port'])
|
||||
self.pypo_liquidsoap = pypo_liquidsoap
|
||||
|
||||
self.plq = PypoLiqQueue(self.future_scheduled_queue, \
|
||||
self.pypo_liquidsoap, \
|
||||
|
|
|
@ -2,9 +2,9 @@ import telnetlib
|
|||
|
||||
def create_liquidsoap_annotation(media):
|
||||
# We need liq_start_next value in the annotate. That is the value that controls overlap duration of crossfade.
|
||||
return 'annotate:media_id="%s",liq_start_next="0",liq_fade_in="%s",' + \
|
||||
return ('annotate:media_id="%s",liq_start_next="0",liq_fade_in="%s",' + \
|
||||
'liq_fade_out="%s",liq_cue_in="%s",liq_cue_out="%s",' + \
|
||||
'schedule_table_id="%s",replay_gain="%s dB":%s' % \
|
||||
'schedule_table_id="%s",replay_gain="%s dB":%s') % \
|
||||
(media['id'],
|
||||
float(media['fade_in']) / 1000,
|
||||
float(media['fade_out']) / 1000,
|
||||
|
|
Loading…
Reference in New Issue