Merge branch 'devel' of dev.sourcefabric.org:airtime into devel

This commit is contained in:
Paul Baranowski 2012-02-23 15:24:40 -05:00
commit e99b23434e
39 changed files with 1608 additions and 1564 deletions

View file

@ -25,7 +25,8 @@ $ccAcl->add(new Zend_Acl_Resource('library'))
->add(new Zend_Acl_Resource('preference'))
->add(new Zend_Acl_Resource('recorder'))
->add(new Zend_Acl_Resource('showbuilder'))
->add(new Zend_Acl_Resource('auth'));
->add(new Zend_Acl_Resource('auth'))
->add(new Zend_Acl_Resource('usersettings'));
/** Creating permissions */
$ccAcl->allow('G', 'index')
@ -34,11 +35,10 @@ $ccAcl->allow('G', 'index')
->allow('G', 'nowplaying')
->allow('G', 'api')
->allow('G', 'auth')
//->allow('G', 'plupload', array('upload-recorded'))
->allow('G', 'recorder')
->allow('G', 'schedule')
->allow('G', 'dashboard')
//->allow('H', 'plupload', array('plupload', 'upload', 'index'))
->allow('H', 'usersettings')
->allow('H', 'plupload')
->allow('H', 'library')
->allow('H', 'search')

View file

@ -24,7 +24,6 @@ class ApiController extends Zend_Controller_Action
->addActionContext('status', 'json')
->addActionContext('register-component', 'json')
->addActionContext('update-liquidsoap-status', 'json')
->addActionContext('library-init', 'json')
->addActionContext('live-chat', 'json')
->addActionContext('update-file-system-mount', 'json')
->addActionContext('handle-watched-dir-missing', 'json')
@ -64,7 +63,7 @@ class ApiController extends Zend_Controller_Action
$jsonStr = json_encode(array("version"=>Application_Model_Preference::GetAirtimeVersion()));
echo $jsonStr;
}
/**
* Sets up and send init values used in the Calendar.
* This is only being used by schedule.js at the moment.
@ -72,16 +71,16 @@ 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.';
return;
}
$this->view->calendarInit = array(
"timestamp" => time(),
"timezoneOffset" => date("Z"),
"timestamp" => time(),
"timezoneOffset" => date("Z"),
"timeScale" => Application_Model_Preference::GetCalendarTimeScale(),
"timeInterval" => Application_Model_Preference::GetCalendarTimeInterval(),
"weekStartDay" => Application_Model_Preference::GetWeekStartDay()
@ -178,9 +177,9 @@ class ApiController extends Zend_Controller_Action
* Retrieve the currently playing show as well as upcoming shows.
* Number of shows returned and the time interval in which to
* get the next shows can be configured as GET parameters.
*
*
* TODO: in the future, make interval length a parameter instead of hardcode to 48
*
*
* Possible parameters:
* type - Can have values of "endofday" or "interval". If set to "endofday",
* the function will retrieve shows from now to end of day.
@ -199,19 +198,19 @@ class ApiController extends Zend_Controller_Action
$date = new Application_Model_DateHelper;
$utcTimeNow = $date->getUtcTimestamp();
$utcTimeEnd = ""; // if empty, GetNextShows will use interval instead of end of day
$request = $this->getRequest();
$type = $request->getParam('type');
if($type == "endofday") {
// make GetNextShows use end of day
$utcTimeEnd = Application_Model_DateHelper::GetDayEndTimestampInUtc();
}
$limit = $request->getParam('limit');
if($limit == "" || !is_numeric($limit)) {
$limit = "5";
}
$result = array("env"=>APPLICATION_ENV,
"schedulerTime"=>gmdate("Y-m-d H:i:s"),
"currentShow"=>Application_Model_Show::GetCurrentShow($utcTimeNow),
@ -219,7 +218,7 @@ class ApiController extends Zend_Controller_Action
"timezone"=> date("T"),
"timezoneOffset"=> date("Z"),
"AIRTIME_API_VERSION"=>AIRTIME_API_VERSION); //used by caller to determine if the airtime they are running or widgets in use is out of date.
//Convert from UTC to localtime for user.
Application_Model_Show::ConvertToLocalTimeZone($result["currentShow"], array("starts", "ends", "start_timestamp", "end_timestamp"));
Application_Model_Show::ConvertToLocalTimeZone($result["nextShow"], array("starts", "ends", "start_timestamp", "end_timestamp"));
@ -233,7 +232,7 @@ class ApiController extends Zend_Controller_Action
exit;
}
}
public function weekInfoAction()
{
if (Application_Model_Preference::GetAllow3rdPartyApi()){
@ -244,7 +243,7 @@ class ApiController extends Zend_Controller_Action
$date = new Application_Model_DateHelper;
$dayStart = $date->getWeekStartDate();
$utcDayStart = Application_Model_DateHelper::ConvertToUtcDateTimeString($dayStart);
$dow = array("sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday");
$result = array();
@ -252,9 +251,9 @@ class ApiController extends Zend_Controller_Action
$utcDayEnd = Application_Model_DateHelper::GetDayEndTimestamp($utcDayStart);
$shows = Application_Model_Show::GetNextShows($utcDayStart, "0", $utcDayEnd);
$utcDayStart = $utcDayEnd;
Application_Model_Show::ConvertToLocalTimeZone($shows, array("starts", "ends", "start_timestamp", "end_timestamp"));
$result[$dow[$i]] = $shows;
}
$result['AIRTIME_API_VERSION'] = AIRTIME_API_VERSION; //used by caller to determine if the airtime they are running or widgets in use is out of date.
@ -373,8 +372,8 @@ class ApiController extends Zend_Controller_Action
$now = new DateTime($today_timestamp);
$end_timestamp = $now->add(new DateInterval("PT2H"));
$end_timestamp = $end_timestamp->format("Y-m-d H:i:s");
$this->view->shows = Application_Model_Show::getShows(Application_Model_DateHelper::ConvertToUtcDateTime($today_timestamp, date_default_timezone_get()),
$this->view->shows = Application_Model_Show::getShows(Application_Model_DateHelper::ConvertToUtcDateTime($today_timestamp, date_default_timezone_get()),
Application_Model_DateHelper::ConvertToUtcDateTime($end_timestamp, date_default_timezone_get()),
$excludeInstance=NULL, $onlyRecord=TRUE);
@ -405,7 +404,7 @@ class ApiController extends Zend_Controller_Action
$upload_dir = ini_get("upload_tmp_dir");
$tempFilePath = Application_Model_StoredFile::uploadFile($upload_dir);
$tempFileName = basename($tempFilePath);
$fileName = isset($_REQUEST["name"]) ? $_REQUEST["name"] : '';
$result = Application_Model_StoredFile::copyFileToStor($upload_dir, $fileName, $tempFileName);
if (isset($result)){
@ -456,19 +455,19 @@ class ApiController extends Zend_Controller_Action
}
if (isset($show_name)) {
$show_name = str_replace(" ", "-", $show_name);
//2011-12-09-19-28-00-ofirrr-256kbps
$filename = $file->getName();
//replace the showname in the filepath incase it has been edited since the show started recording
//(some old bug)
$filename_parts = explode("-", $filename);
$new_name = array_slice($filename_parts, 0, 6);
$new_name[] = $show_name;
$new_name[] = $filename_parts[count($filename_parts)-1];
$tmpTitle = implode("-", $new_name);
}
else {
@ -533,7 +532,7 @@ class ApiController extends Zend_Controller_Action
}
$this->view->stor = Application_Model_MusicDir::getStorDir()->getDirectory();
$watchedDirs = Application_Model_MusicDir::getWatchedDirs();
$watchedDirsPath = array();
foreach($watchedDirs as $wd){
@ -573,7 +572,7 @@ class ApiController extends Zend_Controller_Action
$filepath = str_replace("//", "/", $filepath);
$file = Application_Model_StoredFile::RecallByFilepath($filepath);
if (is_null($file)) {
$file = Application_Model_StoredFile::Insert($md);
}
@ -737,10 +736,10 @@ class ApiController extends Zend_Controller_Action
$this->view->msg = Application_Model_MusicDir::setStorDir($path);
}
public function getStreamSettingAction() {
global $CC_CONFIG;
$request = $this->getRequest();
$api_key = $request->getParam('api_key');
if (!in_array($api_key, $CC_CONFIG["apiKey"]))
@ -752,10 +751,10 @@ class ApiController extends Zend_Controller_Action
$this->view->msg = Application_Model_StreamSetting::getStreamSetting();
}
public function statusAction() {
global $CC_CONFIG;
$request = $this->getRequest();
$api_key = $request->getParam('api_key');
$getDiskInfo = $request->getParam('diskinfo') == "true";
@ -767,7 +766,7 @@ class ApiController extends Zend_Controller_Action
exit;
}
*/
$status = array(
"platform"=>Application_Model_Systemstatus::GetPlatformInfo(),
"airtime_version"=>Application_Model_Preference::GetAirtimeVersion(),
@ -779,11 +778,11 @@ class ApiController extends Zend_Controller_Action
"media_monitor"=>Application_Model_Systemstatus::GetMediaMonitorStatus()
)
);
if ($getDiskInfo){
$status["partitions"] = Application_Model_Systemstatus::GetDiskInfo();
}
$this->view->status = $status;
}
@ -796,40 +795,21 @@ class ApiController extends Zend_Controller_Action
Application_Model_ServiceRegister::Register($component, $remoteAddr);
}
public function updateLiquidsoapStatusAction(){
$request = $this->getRequest();
$msg = $request->getParam('msg');
$stream_id = $request->getParam('stream_id');
$boot_time = $request->getParam('boot_time');
Application_Model_StreamSetting::setLiquidsoapError($stream_id, $msg, $boot_time);
}
/**
* Sets up and send init values used in the Library.
* This is being used by library.js
*/
public function libraryInitAction(){
$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.';
return;
}
$this->view->libraryInit = array(
"numEntries"=>Application_Model_Preference::GetLibraryNumEntries()
);
}
// handles addition/deletion of mount point which watched dirs reside
public function updateFileSystemMountAction(){
global $CC_CONFIG;
$request = $this->getRequest();
$api_key = $request->getParam('api_key');
if (!in_array($api_key, $CC_CONFIG["apiKey"]))
@ -842,16 +822,16 @@ class ApiController extends Zend_Controller_Action
$params = $request->getParams();
$added_list = empty($params['added_dir'])?array():explode(',',$params['added_dir']);
$removed_list = empty($params['removed_dir'])?array():explode(',',$params['removed_dir']);
// get all watched dirs
$watched_dirs = Application_Model_MusicDir::getWatchedDirs(null,null);
foreach( $added_list as $ad){
foreach( $watched_dirs as $dir ){
$dirPath = $dir->getDirectory();
$ad .= '/';
// if mount path itself was watched
if($dirPath == $ad){
Application_Model_MusicDir::addWatchedDir($dirPath, false);
@ -884,7 +864,7 @@ class ApiController extends Zend_Controller_Action
// is new mount point within the watched dir?
// pyinotify doesn't notify anyhing in this case, so we walk through all files within
// this watched dir in DB and mark them deleted.
// In case of h) of use cases, due to pyinotify behaviour of noticing mounted dir, we need to
// In case of h) of use cases, due to pyinotify behaviour of noticing mounted dir, we need to
// compare agaisnt all files in cc_files table
else if(substr($rd, 0, strlen($dirPath)) === $dirPath ){
$watchDir = Application_Model_MusicDir::getDirByPath($rd);
@ -903,13 +883,13 @@ class ApiController extends Zend_Controller_Action
}
}
}
}
// handles case where watched dir is missing
public function handleWatchedDirMissingAction(){
global $CC_CONFIG;
$request = $this->getRequest();
$api_key = $request->getParam('api_key');
if (!in_array($api_key, $CC_CONFIG["apiKey"]))
@ -918,7 +898,7 @@ class ApiController extends Zend_Controller_Action
print 'You are not allowed to access this resource.';
exit;
}
$dir = base64_decode($request->getParam('dir'));
Application_Model_MusicDir::removeWatchedDir($dir, false);
}

View file

@ -47,7 +47,7 @@ class LibraryController extends Zend_Controller_Action
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.pluginAPI.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.fnSetFilteringDelay.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColVis.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColReorderResize.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColReorder.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.FixedColumns.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.TableTools.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
@ -282,14 +282,4 @@ class LibraryController extends Zend_Controller_Action
$this->view->error_msg = $file->getSoundCloudErrorMsg();
}
}
/**
* Stores the number of entries user chose to show in the Library
* to the pref db
*/
public function setNumEntriesAction() {
$request = $this->getRequest();
$numEntries = $request->getParam('numEntries');
Application_Model_Preference::SetLibraryNumEntries($numEntries);
}
}

View file

@ -15,25 +15,25 @@ class NowplayingController extends Zend_Controller_Action
public function indexAction()
{
global $CC_CONFIG;
$request = $this->getRequest();
$baseUrl = $request->getBaseUrl();
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/js/jquery.dataTables.min.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/js/jquery.dataTables.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
//nowplayingdatagrid.js requires this variable, so that datePicker widget can be offset to server time instead of client time
$this->view->headScript()->appendScript("var timezoneOffset = ".date("Z")."; //in seconds");
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/nowplaying/nowplayingdatagrid.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/nowplaying/nowview.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$refer_sses = new Zend_Session_Namespace('referrer');
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new Application_Model_User($userInfo->id);
if ($request->isPost()) {
$form = new Application_Form_RegisterAirtime();
$values = $request->getPost();
if ($values["Publicise"] != 1 && $form->isValid($values)){
Application_Model_Preference::SetSupportFeedback($values["SupportFeedback"]);
@ -49,10 +49,10 @@ class NowplayingController extends Zend_Controller_Action
Application_Model_Preference::SetEmail($values["Email"]);
Application_Model_Preference::SetStationWebSite($values["StationWebSite"]);
Application_Model_Preference::SetPublicise($values["Publicise"]);
$form->Logo->receive();
$imagePath = $form->Logo->getFileName();
Application_Model_Preference::SetStationCountry($values["Country"]);
Application_Model_Preference::SetStationCity($values["City"]);
Application_Model_Preference::SetStationDescription($values["Description"]);
@ -75,10 +75,10 @@ class NowplayingController extends Zend_Controller_Action
//popup if previous page was login
if($refer_sses->referrer == 'login' && Application_Model_Nowplaying::ShouldShowPopUp()
&& !Application_Model_Preference::GetSupportFeedback() && $user->isAdmin()){
$form = new Application_Form_RegisterAirtime();
$logo = Application_Model_Preference::GetStationLogo();
if($logo){
$this->view->logoImg = $logo;
@ -94,7 +94,7 @@ class NowplayingController extends Zend_Controller_Action
$viewType = $this->_request->getParam('view');
$dateString = $this->_request->getParam('date');
$this->view->entries = Application_Model_Nowplaying::GetDataGridData($viewType, $dateString);
}
/*
public function livestreamAction()
@ -107,16 +107,16 @@ class NowplayingController extends Zend_Controller_Action
public function dayViewAction()
{
global $CC_CONFIG;
$request = $this->getRequest();
$baseUrl = $request->getBaseUrl();
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/js/jquery.dataTables.min.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
//nowplayingdatagrid.js requires this variable, so that datePicker widget can be offset to server time instead of client time
$this->view->headScript()->appendScript("var timezoneOffset = ".date("Z")."; //in seconds");
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/nowplaying/nowplayingdatagrid.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/nowplaying/dayview.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
}
@ -127,7 +127,7 @@ class NowplayingController extends Zend_Controller_Action
Application_Model_Preference::SetRemindMeDate();
die();
}
public function donotshowregistrationpopupAction()
{
// unset session

View file

@ -30,6 +30,12 @@ class PlaylistController extends Zend_Controller_Action
if (isset($this->pl_sess->id)) {
$pl = new Application_Model_Playlist($this->pl_sess->id);
$modified = $this->_getParam('modified', null);
if ($pl->getLastModified("U") !== $modified) {
$this->createFullResponse($pl);
throw new PlaylistOutDatedException("You are viewing an older version of {$pl->getName()}");
}
}
return $pl;
}
@ -51,6 +57,7 @@ class PlaylistController extends Zend_Controller_Action
$this->view->name = $pl->getName();
$this->view->length = $pl->getLength();
$this->view->description = $pl->getDescription();
$this->view->modified = $pl->getLastModified("U");
unset($this->view->pl);
}
@ -68,10 +75,33 @@ class PlaylistController extends Zend_Controller_Action
}
}
private function playlistOutdated($pl, $e)
{
$this->view->error = $e->getMessage();
}
private function playlistNotFound()
{
$this->view->error = "Playlist not found";
Logging::log("Playlist not found");
$this->changePlaylist(null);
$this->createFullResponse(null);
}
private function playlistUnknownError($e)
{
$this->view->error = "Something went wrong.";
Logging::log("{$e->getFile()}");
Logging::log("{$e->getLine()}");
Logging::log("{$e->getMessage()}");
}
public function indexAction()
{
global $CC_CONFIG;
$request = $this->getRequest();
$baseUrl = $request->getBaseUrl();
@ -81,18 +111,16 @@ class PlaylistController extends Zend_Controller_Action
$this->_helper->viewRenderer->setResponseSegment('spl');
try {
$pl = $this->getPlaylist();
if (isset($pl)) {
$this->view->pl = $pl;
if (isset($this->pl_sess->id)) {
$pl = new Application_Model_Playlist($this->pl_sess->id);
$this->view->pl = $pl;
}
}
catch (PlaylistNotFoundException $e) {
Logging::log("Playlist not found");
$this->changePlaylist(null);
$this->playlistNotFound();
}
catch (Exception $e) {
Logging::log("{$e->getMessage()}");
$this->playlistUnknownError($e);
}
}
@ -119,20 +147,15 @@ class PlaylistController extends Zend_Controller_Action
}
try {
$pl = $this->getPlaylist();
$pl = new Application_Model_Playlist($id);
$this->createFullResponse($pl);
}
catch (PlaylistNotFoundException $e) {
Logging::log("Playlist {$id} not found");
$this->changePlaylist(null);
$this->playlistNotFound();
}
catch (Exception $e) {
Logging::log("{$e->getFile()}");
Logging::log("{$e->getLine()}");
Logging::log("{$e->getMessage()}");
$this->changePlaylist(null);
$this->playlistUnknownError($e);
}
$this->createFullResponse($pl);
}
public function deleteAction()
@ -150,23 +173,18 @@ class PlaylistController extends Zend_Controller_Action
}
else {
Logging::log("Not deleting currently active playlist");
$pl = new Application_Model_Playlist($this->pl_sess->id);
}
Application_Model_Playlist::DeletePlaylists($ids);
$pl = $this->getPlaylist();
$this->createFullResponse($pl);
}
catch(PlaylistNotFoundException $e) {
Logging::log("Playlist not found");
$this->changePlaylist(null);
$pl = null;
catch (PlaylistNotFoundException $e) {
$this->playlistNotFound();
}
catch(Exception $e) {
Logging::log("{$e->getFile()}");
Logging::log("{$e->getLine()}");
Logging::log("{$e->getMessage()}");
catch (Exception $e) {
$this->playlistUnknownError($e);
}
$this->createFullResponse($pl);
}
public function addItemsAction()
@ -176,24 +194,20 @@ class PlaylistController extends Zend_Controller_Action
$afterItem = $this->_getParam('afterItem', null);
$addType = $this->_getParam('type', 'after');
Logging::log("type is ".$addType);
try {
$pl = $this->getPlaylist();
$pl->addAudioClips($ids, $afterItem, $addType);
$this->createUpdateResponse($pl);
}
catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($pl, $e);
}
catch (PlaylistNotFoundException $e) {
Logging::log("Playlist not found");
$this->changePlaylist(null);
$this->createFullResponse(null);
$this->playlistNotFound();
}
catch (Exception $e) {
Logging::log("{$e->getFile()}");
Logging::log("{$e->getLine()}");
Logging::log("{$e->getMessage()}");
$this->playlistUnknownError($e);
}
$this->createUpdateResponse($pl);
}
public function moveItemsAction()
@ -201,46 +215,44 @@ class PlaylistController extends Zend_Controller_Action
$ids = $this->_getParam('ids');
$ids = (!is_array($ids)) ? array($ids) : $ids;
$afterItem = $this->_getParam('afterItem', null);
$modified = $this->_getParam('modified');
try {
$pl = $this->getPlaylist();
$pl->moveAudioClips($ids, $afterItem);
$this->createUpdateResponse($pl);
}
catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($pl, $e);
}
catch (PlaylistNotFoundException $e) {
Logging::log("Playlist not found");
$this->changePlaylist(null);
$this->createFullResponse(null);
$this->playlistNotFound();
}
catch (Exception $e) {
Logging::log("{$e->getFile()}");
Logging::log("{$e->getLine()}");
Logging::log("{$e->getMessage()}");
$this->playlistUnknownError($e);
}
$this->createUpdateResponse($pl);
}
public function deleteItemsAction()
{
$ids = $this->_getParam('ids');
$ids = (!is_array($ids)) ? array($ids) : $ids;
$modified = $this->_getParam('modified');
try {
$pl = $this->getPlaylist();
$pl->delAudioClips($ids);
$this->createUpdateResponse($pl);
}
catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($pl, $e);
}
catch (PlaylistNotFoundException $e) {
Logging::log("Playlist not found");
$this->changePlaylist(null);
$this->createFullResponse(null);
$this->playlistNotFound();
}
catch (Exception $e) {
Logging::log("{$e->getFile()}");
Logging::log("{$e->getLine()}");
Logging::log("{$e->getMessage()}");
$this->playlistUnknownError($e);
}
$this->createUpdateResponse($pl);
}
public function setCueAction()
@ -253,21 +265,22 @@ class PlaylistController extends Zend_Controller_Action
$pl = $this->getPlaylist();
$response = $pl->changeClipLength($id, $cueIn, $cueOut);
$this->view->response = $response;
if(!isset($response["error"])) {
if (!isset($response["error"])) {
$this->view->response = $response;
$this->createUpdateResponse($pl);
}
else {
$this->view->cue_error = $response["error"];
}
}
catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($pl, $e);
}
catch (PlaylistNotFoundException $e) {
Logging::log("Playlist not found");
$this->changePlaylist(null);
$this->createFullResponse(null);
$this->playlistNotFound();
}
catch (Exception $e) {
Logging::log("{$e->getFile()}");
Logging::log("{$e->getLine()}");
Logging::log("{$e->getMessage()}");
$this->playlistUnknownError($e);
}
}
@ -281,21 +294,22 @@ class PlaylistController extends Zend_Controller_Action
$pl = $this->getPlaylist();
$response = $pl->changeFadeInfo($id, $fadeIn, $fadeOut);
$this->view->response = $response;
if (!isset($response["error"])) {
$this->createUpdateResponse($pl);
$this->view->response = $response;
}
else {
$this->view->fade_error = $response["error"];
}
}
catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($pl, $e);
}
catch (PlaylistNotFoundException $e) {
Logging::log("Playlist not found");
$this->changePlaylist(null);
$this->createFullResponse(null);
$this->playlistNotFound();
}
catch (Exception $e) {
Logging::log("{$e->getFile()}");
Logging::log("{$e->getLine()}");
Logging::log("{$e->getMessage()}");
$this->playlistUnknownError($e);
}
}
@ -309,15 +323,14 @@ class PlaylistController extends Zend_Controller_Action
$fades = $pl->getFadeInfo($pl->getSize()-1);
$this->view->fadeOut = $fades[1];
}
catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($pl, $e);
}
catch (PlaylistNotFoundException $e) {
Logging::log("Playlist not found");
$this->changePlaylist(null);
$this->createFullResponse(null);
$this->playlistNotFound();
}
catch (Exception $e) {
Logging::log("{$e->getFile()}");
Logging::log("{$e->getLine()}");
Logging::log("{$e->getMessage()}");
$this->playlistUnknownError($e);
}
}
@ -335,15 +348,14 @@ class PlaylistController extends Zend_Controller_Action
$pl = $this->getPlaylist();
$pl->setPlaylistfades($fadeIn, $fadeOut);
}
catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($pl, $e);
}
catch (PlaylistNotFoundException $e) {
Logging::log("Playlist not found");
$this->changePlaylist(null);
$this->createFullResponse(null);
$this->playlistNotFound();
}
catch (Exception $e) {
Logging::log("{$e->getFile()}");
Logging::log("{$e->getLine()}");
Logging::log("{$e->getMessage()}");
$this->playlistUnknownError($e);
}
}
@ -351,33 +363,42 @@ class PlaylistController extends Zend_Controller_Action
{
$name = $this->_getParam('name', 'Unknown Playlist');
$pl = $this->getPlaylist();
if($pl === false){
$this->view->playlist_error = true;
return false;
try {
$pl = $this->getPlaylist();
$pl->setName($name);
$this->view->playlistName = $name;
$this->view->modified = $pl->getLastModified("U");
}
catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($pl, $e);
}
catch (PlaylistNotFoundException $e) {
$this->playlistNotFound();
}
catch (Exception $e) {
$this->playlistUnknownError($e);
}
$pl->setName($name);
$this->view->playlistName = $name;
}
public function setPlaylistDescriptionAction()
{
$description = $this->_getParam('description', false);
$pl = $this->getPlaylist();
if($pl === false){
$this->view->playlist_error = true;
return false;
}
$description = $this->_getParam('description', "");
if($description != false) {
try {
$pl = $this->getPlaylist();
$pl->setDescription($description);
$this->view->description = $pl->getDescription();
$this->view->modified = $pl->getLastModified("U");
}
else {
$description = $pl->getDescription();
catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($pl, $e);
}
catch (PlaylistNotFoundException $e) {
$this->playlistNotFound();
}
catch (Exception $e) {
$this->playlistUnknownError($e);
}
$this->view->playlistDescription = $description;
}
}

View file

@ -20,7 +20,7 @@ class PreferenceController extends Zend_Controller_Action
public function indexAction()
{
global $CC_CONFIG;
$request = $this->getRequest();
$baseUrl = $request->getBaseUrl();
@ -59,7 +59,7 @@ class PreferenceController extends Zend_Controller_Action
public function supportSettingAction()
{
global $CC_CONFIG;
$request = $this->getRequest();
$baseUrl = $request->getBaseUrl();
@ -119,7 +119,7 @@ class PreferenceController extends Zend_Controller_Action
public function directoryConfigAction()
{
global $CC_CONFIG;
if(Application_Model_Preference::GetPlanLevel() == 'disabled'){
$request = $this->getRequest();
$baseUrl = $request->getBaseUrl();
@ -136,7 +136,7 @@ class PreferenceController extends Zend_Controller_Action
public function streamSettingAction()
{
global $CC_CONFIG;
$request = $this->getRequest();
$baseUrl = $request->getBaseUrl();
@ -206,10 +206,10 @@ class PreferenceController extends Zend_Controller_Action
$values['output_sound_device'] = $form->getValue('output_sound_device');
}
$values['icecast_vorbis_metadata'] = $form->getValue('icecast_vorbis_metadata');
$values['output_sound_device_type'] = $form->getValue('output_sound_device_type');
$values['streamFormat'] = $form->getValue('streamFormat');
$values['streamFormat'] = $form->getValue('streamFormat');
}
if(!$error){

View file

@ -15,12 +15,9 @@ class ScheduleController extends Zend_Controller_Action
->addActionContext('move-show', 'json')
->addActionContext('resize-show', 'json')
->addActionContext('delete-show', 'json')
->addActionContext('schedule-show', 'json')
->addActionContext('schedule-show-dialog', 'json')
->addActionContext('show-content-dialog', 'json')
->addActionContext('clear-show', 'json')
->addActionContext('get-current-playlist', 'json')
->addActionContext('find-playlists', 'json')
->addActionContext('remove-group', 'json')
->addActionContext('edit-show', 'json')
->addActionContext('add-show', 'json')
@ -43,8 +40,6 @@ class ScheduleController extends Zend_Controller_Action
$baseUrl = $request->getBaseUrl();
$this->view->headScript()->appendFile($baseUrl.'/js/contextmenu/jquery.contextMenu.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/js/jquery.dataTables.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.pluginAPI.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
//full-calendar-functions.js requires this variable, so that datePicker widget can be offset to server time instead of client time
$this->view->headScript()->appendScript("var timezoneOffset = ".date("Z")."; //in seconds");
@ -264,37 +259,6 @@ class ScheduleController extends Zend_Controller_Action
$this->view->items = $menu;
}
public function scheduleShowAction()
{
$showInstanceId = $this->sched_sess->showInstanceId;
$search = $this->_getParam('search', null);
$plId = $this->_getParam('plId');
if($search == "") {
$search = null;
}
$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, UTYPE_HOST),$show->getShowId())) {
$show->scheduleShow(array($plId));
}
$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 clearShowAction()
{
$showInstanceId = $this->_getParam('id');
@ -336,27 +300,6 @@ class ScheduleController extends Zend_Controller_Action
$this->view->entries = $range;
}
public function findPlaylistsAction()
{
$post = $this->getRequest()->getPost();
try{
$show = new Application_Model_ShowInstance($this->sched_sess->showInstanceId);
}catch(Exception $e){
$this->view->show_error = true;
return false;
}
$playlists = $show->searchPlaylistsForShow($post);
foreach( $playlists['aaData'] as &$data){
// calling two functions to format time to 1 decimal place
$sec = Application_Model_Playlist::playlistTimeToSeconds($data['length']);
$data['length'] = Application_Model_Playlist::secondsToPlaylistTime($sec);
}
//for datatables
die(json_encode($playlists));
}
public function removeGroupAction()
{
$showInstanceId = $this->sched_sess->showInstanceId;
@ -383,44 +326,6 @@ class ScheduleController extends Zend_Controller_Action
unset($this->view->showContent);
}
public function scheduleShowDialogAction()
{
$showInstanceId = $this->_getParam('id');
$this->sched_sess->showInstanceId = $showInstanceId;
try{
$show = new Application_Model_ShowInstance($showInstanceId);
}catch(Exception $e){
$this->view->show_error = true;
return false;
}
$start_timestamp = $show->getShowInstanceStart();
$end_timestamp = $show->getShowInstanceEnd();
$dateInfo_s = getDate(strtotime(Application_Model_DateHelper::ConvertToLocalDateTimeString($start_timestamp)));
$dateInfo_e = getDate(strtotime(Application_Model_DateHelper::ConvertToLocalDateTimeString($end_timestamp)));
$this->view->showContent = $show->getShowContent();
$this->view->timeFilled = $show->getTimeScheduled();
$this->view->showName = $show->getName();
$this->view->showLength = $show->getShowLength();
$this->view->percentFilled = $show->getPercentScheduled();
$this->view->s_wday = $dateInfo_s['weekday'];
$this->view->s_month = $dateInfo_s['month'];
$this->view->s_day = $dateInfo_s['mday'];
$this->view->e_wday = $dateInfo_e['weekday'];
$this->view->e_month = $dateInfo_e['month'];
$this->view->e_day = $dateInfo_e['mday'];
$this->view->startTime = sprintf("%02d:%02d", $dateInfo_s['hours'], $dateInfo_s['minutes']);
$this->view->endTime = sprintf("%02d:%02d", $dateInfo_e['hours'], $dateInfo_e['minutes']);
$this->view->chosen = $this->view->render('schedule/scheduled-content.phtml');
$this->view->dialog = $this->view->render('schedule/schedule-show-dialog.phtml');
unset($this->view->showContent);
}
public function showContentDialogAction()
{
$showInstanceId = $this->_getParam('id');

View file

@ -83,8 +83,8 @@ class ShowbuilderController extends Zend_Controller_Action
public function scheduleAddAction() {
$request = $this->getRequest();
$mediaItems = $request->getParam("mediaIds", null);
$scheduledIds = $request->getParam("schedIds", null);
$mediaItems = $request->getParam("mediaIds", array());
$scheduledIds = $request->getParam("schedIds", array());
try {
$scheduler = new Application_Model_Scheduler();
@ -102,14 +102,12 @@ class ShowbuilderController extends Zend_Controller_Action
Logging::log("{$e->getFile()}");
Logging::log("{$e->getLine()}");
}
$this->view->data = $json;
}
public function scheduleRemoveAction()
{
$request = $this->getRequest();
$items = $request->getParam("items", null);
$items = $request->getParam("items", array());
try {
$scheduler = new Application_Model_Scheduler();
@ -151,8 +149,6 @@ class ShowbuilderController extends Zend_Controller_Action
Logging::log("{$e->getFile()}");
Logging::log("{$e->getLine()}");
}
$this->view->data = $json;
}
public function scheduleReorderAction() {

View file

@ -0,0 +1,49 @@
<?php
class UsersettingsController extends Zend_Controller_Action
{
public function init()
{
/* Initialize action controller here */
$ajaxContext = $this->_helper->getHelper('AjaxContext');
$ajaxContext->addActionContext('get-library-datatable', 'json')
->addActionContext('set-library-datatable', 'json')
->addActionContext('get-timeline-datatable', 'json')
->addActionContext('set-timeline-datatable', 'json')
->initContext();
}
public function setLibraryDatatableAction() {
$request = $this->getRequest();
$settings = $request->getParam("settings");
$data = serialize($settings);
Application_Model_Preference::SetValue("library_datatable", $data, true);
}
public function getLibraryDatatableAction() {
$data = Application_Model_Preference::GetValue("library_datatable", true);
if ($data != "") {
$this->view->settings = unserialize($data);
}
}
public function setTimelineDatatableAction() {
$request = $this->getRequest();
$settings = $request->getParam("settings");
$data = serialize($settings);
Application_Model_Preference::SetValue("timeline_datatable", $data, true);
}
public function getTimelineDatatableAction() {
$data = Application_Model_Preference::GetValue("timeline_datatable", true);
if ($data != "") {
$this->view->settings = unserialize($data);
}
}
}

View file

@ -22,7 +22,7 @@
<div class="wrapper">
<!--Set to z-index 254 to make it lower than the top-panel and the ZFDebug info bar, but higher than the side-playlist-->
<div id="library_content" class="tabs ui-widget ui-widget-content block-shadow alpha-block padded" style="z-index:254"><?php echo $this->layout()->library ?></div>
<div id="library_content" class="ui-widget ui-widget-content block-shadow alpha-block padded" style="z-index:254"><?php echo $this->layout()->library ?></div>
<div id="side_playlist" class="ui-widget ui-widget-content block-shadow omega-block"><?php echo $this->layout()->spl ?></div>
</div>
</body>

View file

@ -89,7 +89,7 @@ class Application_Model_Playlist {
public function setName($p_newname)
{
$this->pl->setDbName($p_newname);
$this->pl->setDbMtime(new DateTime("now"), new DateTimeZone("UTC"));
$this->pl->setDbMtime(new DateTime("now", new DateTimeZone("UTC")));
$this->pl->save($this->con);
}
@ -106,7 +106,7 @@ class Application_Model_Playlist {
public function setDescription($p_description)
{
$this->pl->setDbDescription($p_description);
$this->pl->setDbMtime(new DateTime("now"), new DateTimeZone("UTC"));
$this->pl->setDbMtime(new DateTime("now", new DateTimeZone("UTC")));
$this->pl->save($this->con);
}
@ -123,7 +123,7 @@ class Application_Model_Playlist {
public function setCreator($p_id) {
$this->pl->setDbCreatorId($p_id);
$this->pl->setDbMtime(new DateTime("now"), new DateTimeZone("UTC"));
$this->pl->setDbMtime(new DateTime("now", new DateTimeZone("UTC")));
$this->pl->save($this->con);
}
@ -218,13 +218,18 @@ class Application_Model_Playlist {
{
$file = CcFilesQuery::create()->findPK($p_item, $this->con);
$entry = $this->plItem;
$entry["id"] = $file->getDbId();
$entry["pos"] = $pos;
$entry["cliplength"] = $file->getDbLength();
$entry["cueout"] = $file->getDbLength();
if (isset($file) && $file->getDbFileExists()) {
$entry = $this->plItem;
$entry["id"] = $file->getDbId();
$entry["pos"] = $pos;
$entry["cliplength"] = $file->getDbLength();
$entry["cueout"] = $file->getDbLength();
return $entry;
return $entry;
}
else {
throw new Exception("trying to add a file that does not exist.");
}
}
/*
@ -300,7 +305,7 @@ class Application_Model_Playlist {
$pos = $pos + 1;
}
$this->pl->setDbMtime(new DateTime("now"), new DateTimeZone("UTC"));
$this->pl->setDbMtime(new DateTime("now", new DateTimeZone("UTC")));
$this->pl->save($this->con);
$this->con->commit();
@ -383,7 +388,7 @@ class Application_Model_Playlist {
$this->pl = CcPlaylistQuery::create()->findPK($this->id);
$this->pl->setDbMtime(new DateTime("now"), new DateTimeZone("UTC"));
$this->pl->setDbMtime(new DateTime("now", new DateTimeZone("UTC")));
$this->pl->save($this->con);
}
@ -415,7 +420,7 @@ class Application_Model_Playlist {
$contents[$i]->save($this->con);
}
$this->pl->setDbMtime(new DateTime("now"), new DateTimeZone("UTC"));
$this->pl->setDbMtime(new DateTime("now", new DateTimeZone("UTC")));
$this->pl->save($this->con);
$this->con->commit();
@ -462,47 +467,52 @@ class Application_Model_Playlist {
$fadeIn = $fadeIn?'00:00:'.$fadeIn:$fadeIn;
$fadeOut = $fadeOut?'00:00:'.$fadeOut:$fadeOut;
$this->con->beginTransaction();
$errArray= array();
$con = Propel::getConnection(CcPlaylistPeer::DATABASE_NAME);
$row = CcPlaylistcontentsQuery::create()->findPK($id);
if (is_null($row)) {
$errArray["error"]="Playlist item does not exist.";
return $errArray;
}
$clipLength = $row->getDbCliplength();
if(!is_null($fadeIn)) {
$sql = "SELECT INTERVAL '{$fadeIn}' > INTERVAL '{$clipLength}'";
$r = $con->query($sql);
if($r->fetchColumn(0)) {
//"Fade In can't be larger than overall playlength.";
$fadeIn = $clipLength;
}
$row->setDbFadein($fadeIn);
}
if(!is_null($fadeOut)){
$sql = "SELECT INTERVAL '{$fadeOut}' > INTERVAL '{$clipLength}'";
$r = $con->query($sql);
if($r->fetchColumn(0)) {
//Fade Out can't be larger than overall playlength.";
$fadeOut = $clipLength;
}
$row->setDbFadeout($fadeOut);
}
try {
$row->save();
$row = CcPlaylistcontentsQuery::create()->findPK($id);
if (is_null($row)) {
throw new Exception("Playlist item does not exist.");
}
$clipLength = $row->getDbCliplength();
if (!is_null($fadeIn)) {
$sql = "SELECT INTERVAL '{$fadeIn}' > INTERVAL '{$clipLength}'";
$r = $this->con->query($sql);
if ($r->fetchColumn(0)) {
//"Fade In can't be larger than overall playlength.";
$fadeIn = $clipLength;
}
$row->setDbFadein($fadeIn);
}
if (!is_null($fadeOut)){
$sql = "SELECT INTERVAL '{$fadeOut}' > INTERVAL '{$clipLength}'";
$r = $this->con->query($sql);
if ($r->fetchColumn(0)) {
//Fade Out can't be larger than overall playlength.";
$fadeOut = $clipLength;
}
$row->setDbFadeout($fadeOut);
}
$row->save($this->con);
$this->pl->setDbMtime(new DateTime("now", new DateTimeZone("UTC")));
$this->pl->save($this->con);
$this->con->commit();
}
catch (Exception $e) {
Logging::log($e->getMessage());
$this->con->rollback();
throw $e;
}
return array("fadeIn"=>$fadeIn, "fadeOut"=>$fadeOut);
return array("fadeIn"=> $fadeIn, "fadeOut"=> $fadeOut);
}
public function setPlaylistfades($fadein, $fadeout) {
@ -512,7 +522,7 @@ class Application_Model_Playlist {
$row = CcPlaylistcontentsQuery::create()
->filterByDbPlaylistId($this->id)
->filterByDbPosition(0)
->findOne();
->findOne($this->con);
$this->changeFadeInfo($row->getDbId(), $fadein, null);
}
@ -521,7 +531,7 @@ class Application_Model_Playlist {
$row = CcPlaylistcontentsQuery::create()
->filterByDbPlaylistId($this->id)
->filterByDbPosition($this->getSize()-1)
->findOne();
->findOne($this->con);
$this->changeFadeInfo($row->getDbId(), null, $fadeout);
}
@ -540,126 +550,135 @@ class Application_Model_Playlist {
*/
public function changeClipLength($id, $cueIn, $cueOut)
{
$this->con->beginTransaction();
$errArray= array();
$con = Propel::getConnection(CcPlaylistPeer::DATABASE_NAME);
if (is_null($cueIn) && is_null($cueOut)) {
$errArray["error"]="Cue in and cue out are null.";
return $errArray;
}
$row = CcPlaylistcontentsQuery::create()
->joinWith(CcFilesPeer::OM_CLASS)
->filterByPrimaryKey($id)
->findOne();
if (is_null($row)) {
$errArray["error"]="Playlist item does not exist!.";
return $errArray;
}
$oldCueIn = $row->getDBCuein();
$oldCueOut = $row->getDbCueout();
$fadeIn = $row->getDbFadein();
$fadeOut = $row->getDbFadeout();
$file = $row->getCcFiles();
$origLength = $file->getDbLength();
if(!is_null($cueIn) && !is_null($cueOut)){
if($cueOut === ""){
$cueOut = $origLength;
}
$sql = "SELECT INTERVAL '{$cueIn}' > INTERVAL '{$cueOut}'";
$r = $con->query($sql);
if($r->fetchColumn(0)) {
$errArray["error"]= "Can't set cue in to be larger than cue out.";
try {
if (is_null($cueIn) && is_null($cueOut)) {
$errArray["error"] = "Cue in and cue out are null.";
return $errArray;
}
$sql = "SELECT INTERVAL '{$cueOut}' > INTERVAL '{$origLength}'";
$r = $con->query($sql);
if($r->fetchColumn(0)){
$errArray["error"] = "Can't set cue out to be greater than file length.";
return $errArray;
$row = CcPlaylistcontentsQuery::create()
->joinWith(CcFilesPeer::OM_CLASS)
->filterByPrimaryKey($id)
->findOne($this->con);
if (is_null($row)) {
throw new Exception("Playlist item does not exist.");
}
$sql = "SELECT INTERVAL '{$cueOut}' - INTERVAL '{$cueIn}'";
$r = $con->query($sql);
$cliplength = $r->fetchColumn(0);
$oldCueIn = $row->getDBCuein();
$oldCueOut = $row->getDbCueout();
$fadeIn = $row->getDbFadein();
$fadeOut = $row->getDbFadeout();
$row->setDbCuein($cueIn);
$row->setDbCueout($cueOut);
$row->setDBCliplength($cliplength);
$file = $row->getCcFiles($this->con);
$origLength = $file->getDbLength();
}
else if(!is_null($cueIn)) {
if (!is_null($cueIn) && !is_null($cueOut)){
$sql = "SELECT INTERVAL '{$cueIn}' > INTERVAL '{$oldCueOut}'";
$r = $con->query($sql);
if($r->fetchColumn(0)) {
$errArray["error"] = "Can't set cue in to be larger than cue out.";
return $errArray;
if ($cueOut === ""){
$cueOut = $origLength;
}
$sql = "SELECT INTERVAL '{$cueIn}' > INTERVAL '{$cueOut}'";
$r = $this->con->query($sql);
if ($r->fetchColumn(0)) {
$errArray["error"] = "Can't set cue in to be larger than cue out.";
return $errArray;
}
$sql = "SELECT INTERVAL '{$cueOut}' > INTERVAL '{$origLength}'";
$r = $this->con->query($sql);
if ($r->fetchColumn(0)){
$errArray["error"] = "Can't set cue out to be greater than file length.";
return $errArray;
}
$sql = "SELECT INTERVAL '{$cueOut}' - INTERVAL '{$cueIn}'";
$r = $this->con->query($sql);
$cliplength = $r->fetchColumn(0);
$row->setDbCuein($cueIn);
$row->setDbCueout($cueOut);
$row->setDBCliplength($cliplength);
}
else if (!is_null($cueIn)) {
$sql = "SELECT INTERVAL '{$cueIn}' > INTERVAL '{$oldCueOut}'";
$r = $this->con->query($sql);
if ($r->fetchColumn(0)) {
$errArray["error"] = "Can't set cue in to be larger than cue out.";
return $errArray;
}
$sql = "SELECT INTERVAL '{$oldCueOut}' - INTERVAL '{$cueIn}'";
$r = $this->con->query($sql);
$cliplength = $r->fetchColumn(0);
$row->setDbCuein($cueIn);
$row->setDBCliplength($cliplength);
}
else if (!is_null($cueOut)) {
if ($cueOut === ""){
$cueOut = $origLength;
}
$sql = "SELECT INTERVAL '{$cueOut}' < INTERVAL '{$oldCueIn}'";
$r = $this->con->query($sql);
if ($r->fetchColumn(0)) {
$errArray["error"] = "Can't set cue out to be smaller than cue in.";
return $errArray;
}
$sql = "SELECT INTERVAL '{$cueOut}' > INTERVAL '{$origLength}'";
$r = $this->con->query($sql);
if ($r->fetchColumn(0)){
$errArray["error"] = "Can't set cue out to be greater than file length.";
return $errArray;
}
$sql = "SELECT INTERVAL '{$cueOut}' - INTERVAL '{$oldCueIn}'";
$r = $this->con->query($sql);
$cliplength = $r->fetchColumn(0);
$row->setDbCueout($cueOut);
$row->setDBCliplength($cliplength);
}
$sql = "SELECT INTERVAL '{$oldCueOut}' - INTERVAL '{$cueIn}'";
$r = $con->query($sql);
$cliplength = $r->fetchColumn(0);
$cliplength = $row->getDbCliplength();
$row->setDbCuein($cueIn);
$row->setDBCliplength($cliplength);
}
else if(!is_null($cueOut)) {
if($cueOut === ""){
$cueOut = $origLength;
$sql = "SELECT INTERVAL '{$fadeIn}' > INTERVAL '{$cliplength}'";
$r = $this->con->query($sql);
if ($r->fetchColumn(0)){
$fadeIn = $cliplength;
$row->setDbFadein($fadeIn);
}
$sql = "SELECT INTERVAL '{$cueOut}' < INTERVAL '{$oldCueIn}'";
$r = $con->query($sql);
if($r->fetchColumn(0)) {
$errArray["error"] ="Can't set cue out to be smaller than cue in.";
return $errArray;
$sql = "SELECT INTERVAL '{$fadeOut}' > INTERVAL '{$cliplength}'";
$r = $this->con->query($sql);
if ($r->fetchColumn(0)){
$fadeOut = $cliplength;
$row->setDbFadein($fadeOut);
}
$sql = "SELECT INTERVAL '{$cueOut}' > INTERVAL '{$origLength}'";
$r = $con->query($sql);
if($r->fetchColumn(0)){
$errArray["error"] ="Can't set cue out to be greater than file length.";
return $errArray;
}
$row->save($this->con);
$this->pl->setDbMtime(new DateTime("now", new DateTimeZone("UTC")));
$this->pl->save($this->con);
$sql = "SELECT INTERVAL '{$cueOut}' - INTERVAL '{$oldCueIn}'";
$r = $con->query($sql);
$cliplength = $r->fetchColumn(0);
$row->setDbCueout($cueOut);
$row->setDBCliplength($cliplength);
$this->con->commit();
}
catch (Exception $e) {
$this->con->rollback();
throw $e;
}
$cliplength = $row->getDbCliplength();
$sql = "SELECT INTERVAL '{$fadeIn}' > INTERVAL '{$cliplength}'";
$r = $con->query($sql);
if($r->fetchColumn(0)){
$fadeIn = $cliplength;
$row->setDbFadein($fadeIn);
}
$sql = "SELECT INTERVAL '{$fadeOut}' > INTERVAL '{$cliplength}'";
$r = $con->query($sql);
if($r->fetchColumn(0)){
$fadeOut = $cliplength;
$row->setDbFadein($fadeOut);
}
$row->save();
return array("cliplength"=>$cliplength, "cueIn"=>$cueIn, "cueOut"=>$cueOut, "length"=>$this->getLength(),
"fadeIn"=>$fadeIn, "fadeOut"=>$fadeOut);
return array("cliplength"=> $cliplength, "cueIn"=> $cueIn, "cueOut"=> $cueOut, "length"=> $this->getLength(),
"fadeIn"=> $fadeIn, "fadeOut"=> $fadeOut);
}
public function getAllPLMetaData()

View file

@ -1396,7 +1396,7 @@ class Application_Model_Show {
Application_Model_Preference::SetShowsPopulatedUntil($end_timestamp);
}
$sql = "SELECT starts, ends, record, rebroadcast, instance_id, show_id, name,
$sql = "SELECT starts, ends, record, rebroadcast, instance_id, show_id, name,
color, background_color, file_id, cc_show_instances.id AS instance_id
FROM cc_show_instances
LEFT JOIN cc_show ON cc_show.id = cc_show_instances.show_id
@ -1538,7 +1538,7 @@ class Application_Model_Show {
$event["end"] = $endDateTime->format("Y-m-d H:i:s");
$event["endUnix"] = $endDateTime->format("U");
$event["allDay"] = false;
$event["description"] = $show["description"];
//$event["description"] = $show["description"];
$event["showId"] = intval($show["show_id"]);
$event["record"] = intval($show["record"]);
$event["rebroadcast"] = intval($show["rebroadcast"]);

View file

@ -9,12 +9,13 @@ class Application_Model_ShowBuilder {
private $opts;
private $contentDT;
private $epoch_now;
private $defaultRowArray = array(
"header" => false,
"footer" => false,
"empty" => false,
"checkbox" => false,
"allowed" => false,
"id" => 0,
"instance" => "",
"starts" => "",
@ -37,6 +38,7 @@ class Application_Model_ShowBuilder {
$this->timezone = date_default_timezone_get();
$this->user = Application_Model_User::GetCurrentUser();
$this->opts = $p_opts;
$this->epoch_now = time();
}
/*
@ -89,6 +91,7 @@ class Application_Model_ShowBuilder {
private function makeFooterRow($p_item) {
$row = $this->defaultRowArray;
$this->isAllowed($p_item, $row);
$row["footer"] = true;
$showEndDT = new DateTime($p_item["si_ends"], new DateTimeZone("UTC"));
@ -101,6 +104,16 @@ class Application_Model_ShowBuilder {
return $row;
}
private function isAllowed($p_item, &$row) {
$showStartDT = new DateTime($p_item["si_starts"], new DateTimeZone("UTC"));
//can only schedule the show if it hasn't started and you are allowed.
if ($this->epoch_now < $showStartDT->format('U') && $this->user->canSchedule($p_item["show_id"]) == true) {
$row["allowed"] = true;
}
}
private function getRowTimestamp($p_item, &$row) {
if (is_null($p_item["si_last_scheduled"])) {
@ -116,7 +129,9 @@ class Application_Model_ShowBuilder {
private function makeHeaderRow($p_item) {
$row = $this->defaultRowArray;
$this->getRowTimestamp($p_item, &$row);
$this->isAllowed($p_item, $row);
Logging::log("making header for show id ".$p_item["show_id"]);
$this->getRowTimestamp($p_item, $row);
$showStartDT = new DateTime($p_item["si_starts"], new DateTimeZone("UTC"));
$showStartDT->setTimezone(new DateTimeZone($this->timezone));
@ -137,15 +152,9 @@ class Application_Model_ShowBuilder {
private function makeScheduledItemRow($p_item) {
$row = $this->defaultRowArray;
$epoch_now = time();
$showStartDT = new DateTime($p_item["si_starts"], new DateTimeZone("UTC"));
$this->getRowTimestamp($p_item, &$row);
//can only schedule the show if it hasn't started and you are allowed.
if ($epoch_now < $showStartDT->format('U') && $this->user->canSchedule($p_item["show_id"]) == true) {
$row["checkbox"] = true;
}
$this->isAllowed($p_item, $row);
$this->getRowTimestamp($p_item, $row);
if (isset($p_item["sched_starts"])) {
@ -172,6 +181,8 @@ class Application_Model_ShowBuilder {
$row["empty"] = true;
$row["id"] = 0 ;
$row["instance"] = intval($p_item["si_id"]);
//return null;
}
return $row;
@ -219,7 +230,11 @@ class Application_Model_ShowBuilder {
}
//make a normal data row.
$display_items[] = $this->makeScheduledItemRow($item);
$row = $this->makeScheduledItemRow($item);
//don't display the empty rows.
if (isset($row)) {
$display_items[] = $row;
}
}
//make the last footer if there were any scheduled items.

View file

@ -556,7 +556,7 @@ class Application_Model_StoredFile {
*
* @return string $runtime
*/
private static function formatDuration($dt){
private static function formatDuration($dt) {
$hours = $dt->format("H");
$min = $dt->format("i");
@ -569,7 +569,7 @@ class Application_Model_StoredFile {
$hours = $p_interval->format("%h");
$mins = $p_interval->format("%i");
if( $hours == 0) {
if ( $hours == 0) {
$runtime = $p_interval->format("%i:%S");
}
else {
@ -579,55 +579,61 @@ class Application_Model_StoredFile {
return $runtime;
}
public static function searchFilesForPlaylistBuilder($datatables)
{
public static function searchFilesForPlaylistBuilder($datatables) {
global $CC_CONFIG;
$displayData = array("track_title", "artist_name", "album_title", "genre", "length", "year", "utime", "mtime", "ftype", "track_number");
$displayColumns = array("id", "track_title", "artist_name", "album_title", "genre", "length",
"year", "utime", "mtime", "ftype", "track_number", "mood", "bpm", "composer", "info_url",
"bit_rate", "sample_rate", "isrc_number", "encoded_by", "label", "copyright", "mime", "language"
);
$plSelect = "SELECT ";
$fileSelect = "SELECT ";
foreach ($displayData as $key) {
$plSelect = array();
$fileSelect = array();
foreach ($displayColumns as $key) {
if ($key === "track_title") {
$plSelect .= "name AS ".$key.", ";
$fileSelect .= $key.", ";
if ($key === "id") {
$plSelect[] = "PL.id AS ".$key;
$fileSelect[] = $key;
} else if ($key === "track_title") {
$plSelect[] = "name AS ".$key;
$fileSelect[] = $key;
} else if ($key === "ftype") {
$plSelect .= "'playlist' AS ".$key.", ";
$fileSelect .= $key.", ";
$plSelect[] = "'playlist' AS ".$key;
$fileSelect[] = $key;
} else if ($key === "artist_name") {
$plSelect .= "login AS ".$key.", ";
$fileSelect .= $key.", ";
$plSelect[] = "login AS ".$key;
$fileSelect[] = $key;
} else if ($key === "length") {
$plSelect .= $key.", ";
$fileSelect .= $key."::interval, ";
$plSelect[] = $key;
$fileSelect[] = $key."::interval";
} else if ($key === "year") {
$plSelect .= "CAST(utime AS varchar) AS ".$key.", ";
$fileSelect .= $key.", ";
$plSelect[] = "CAST(utime AS varchar) AS ".$key;
$fileSelect[] = $key;
} else if ($key === "utime") {
$plSelect .= $key.", ";
$fileSelect .= $key.", ";
$plSelect[] = $key;
$fileSelect[] = $key;
} else if ($key === "mtime") {
$plSelect .= $key.", ";
$fileSelect .= $key.", ";
} else if ($key === "track_number") {
$plSelect .= "NULL AS ".$key.", ";
$fileSelect .= $key.", ";
$plSelect[] = $key;
$fileSelect[] = $key;
} else {
$plSelect .= "NULL AS ".$key.", ";
$fileSelect .= $key.", ";
$plSelect[] = "NULL AS ".$key;
$fileSelect[] = $key;
}
}
$fromTable = " ((".$plSelect."PL.id
FROM cc_playlist AS PL LEFT JOIN cc_subjs AS sub ON (sub.id = PL.creator_id))
$plSelect = "SELECT ". join(",", $plSelect);
$fileSelect = "SELECT ". join(",", $fileSelect);
$fromTable = " (({$plSelect} FROM cc_playlist AS PL
LEFT JOIN cc_subjs AS sub ON (sub.id = PL.creator_id))
UNION
(".$fileSelect."id FROM ".$CC_CONFIG["filesTable"]." AS FILES WHERE file_exists = 'TRUE')) AS RESULTS";
$results = Application_Model_StoredFile::searchFiles($fromTable, $datatables);
({$fileSelect} FROM ".$CC_CONFIG["filesTable"]." AS FILES WHERE file_exists = 'TRUE')) AS RESULTS";
foreach($results['aaData'] as &$row){
$results = Application_Model_StoredFile::searchFiles($displayColumns, $fromTable, $datatables);
foreach ($results['aaData'] as &$row) {
$row['id'] = intval($row['id']);
@ -649,7 +655,7 @@ class Application_Model_StoredFile {
//TODO url like this to work on both playlist/showbuilder screens.
//datatable stuff really needs to be pulled out and generalized within the project
//access to zend view methods to access url helpers is needed.
if($type == "au") {
if ($type == "au") {
$row['image'] = '<img src="/css/images/icon_audioclip.png">';
}
else {
@ -660,55 +666,45 @@ class Application_Model_StoredFile {
return $results;
}
public static function searchPlaylistsForSchedule($datatables)
{
$fromTable = "cc_playlist AS pl LEFT JOIN cc_playlisttimes AS plt USING(id) LEFT JOIN cc_subjs AS sub ON pl.editedby = sub.id";
//$datatables["optWhere"][] = "INTERVAL '{$time_remaining}' > INTERVAL '00:00:00'";
$datatables["optWhere"][] = "plt.length > INTERVAL '00:00:00'";
return Application_Model_StoredFile::searchFiles($fromTable, $datatables);
}
public static function searchFiles($fromTable, $data)
public static function searchFiles($displayColumns, $fromTable, $data)
{
global $CC_CONFIG, $CC_DBC;
$con = Propel::getConnection(CcFilesPeer::DATABASE_NAME);
$where = array();
$columnsDisplayed = explode(",", $data["sColumns"]);
/*
$columnsDisplayed = array();
for ($i = 0; $i < $data["iColumns"]; $i++) {
if (in_array($data["mDataProp_".$i], $displayColumns)) {
$columnsDisplayed[] = $data["mDataProp_".$i];
}
}
*/
if($data["sSearch"] !== "")
if ($data["sSearch"] !== "") {
$searchTerms = explode(" ", $data["sSearch"]);
}
$selectorCount = "SELECT COUNT(*)";
foreach( $columnsDisplayed as $key=>$col){
if($col == ''){
unset($columnsDisplayed[$key]);
}
}
//$selectorRows = "SELECT " . join(',', $columnsDisplayed );
$selectorRows = "SELECT * ";
//$selectorRows = "SELECT ". join(",", $displayColumns);
$selectorRows = "SELECT *";
$sql = $selectorCount." FROM ".$fromTable;
$totalRows = $CC_DBC->getOne($sql);
$sqlTotalRows = $sql;
// Where clause
if(isset($data["optWhere"])) {
$where[] = join(" AND ", $data["optWhere"]);
}
if(isset($searchTerms)) {
if (isset($searchTerms)) {
$searchCols = array();
for($i=0; $i<$data["iColumns"]; $i++) {
if($data["bSearchable_".$i] == "true") {
$searchCols[] = $columnsDisplayed[$i];
for ($i = 0; $i < $data["iColumns"]; $i++) {
if ($data["bSearchable_".$i] == "true") {
$searchCols[] = $data["mDataProp_{$i}"];
}
}
$outerCond = array();
foreach($searchTerms as $term) {
foreach ($searchTerms as $term) {
$innerCond = array();
foreach($searchCols as $col) {
foreach ($searchCols as $col) {
$escapedTerm = pg_escape_string($term);
$innerCond[] = "{$col}::text ILIKE '%{$escapedTerm}%'";
}
@ -720,31 +716,47 @@ class Application_Model_StoredFile {
// Order By clause
$orderby = array();
for($i=0; $i<$data["iSortingCols"]; $i++){
$orderby[] = $columnsDisplayed[$data["iSortCol_".$i]]." ".$data["sSortDir_".$i];
for ($i = 0; $i < $data["iSortingCols"]; $i++){
$num = $data["iSortCol_".$i];
$orderby[] = $data["mDataProp_{$num}"]." ".$data["sSortDir_".$i];
}
$orderby[] = "id";
$orderby = join("," , $orderby);
// End Order By clause
if(isset($where)) {
if (count($where) > 0) {
$where = join(" AND ", $where);
$sql = $selectorCount." FROM ".$fromTable." WHERE ".$where;
$totalDisplayRows = $CC_DBC->getOne($sql);
$sqlTotalDisplayRows = $sql;
$sql = $selectorRows." FROM ".$fromTable." WHERE ".$where." ORDER BY ".$orderby." OFFSET ".$data["iDisplayStart"]." LIMIT ".$data["iDisplayLength"];
}
else {
$sql = $selectorRows." FROM ".$fromTable." ORDER BY ".$orderby." OFFSET ".$data["iDisplayStart"]." LIMIT ".$data["iDisplayLength"];
}
try {
$r = $con->query($sqlTotalRows);
$totalRows = $r->fetchColumn(0);
if (isset($sqlTotalDisplayRows)) {
$r = $con->query($sqlTotalDisplayRows);
$totalDisplayRows = $r->fetchColumn(0);
}
else {
$totalDisplayRows = $totalRows;
}
$r = $con->query($sql);
$r->setFetchMode(PDO::FETCH_ASSOC);
$results = $r->fetchAll();
}
catch (Exception $e) {
Logging::log($e->getMessage());
}
//display sql executed in airtime log for testing
//Logging::log($sql);
$results = $CC_DBC->getAll($sql);
if(!isset($totalDisplayRows)) {
$totalDisplayRows = $totalRows;
}
Logging::log($sql);
return array("sEcho" => intval($data["sEcho"]), "iTotalDisplayRecords" => $totalDisplayRows, "iTotalRecords" => $totalRows, "aaData" => $results);
}

View file

@ -37,15 +37,16 @@ class Application_Model_User {
public function canSchedule($p_showId) {
$type = $this->getType();
$result = false;
if ( $type === UTYPE_ADMIN ||
$type === UTYPE_PROGRAM_MANAGER ||
CcShowHostsQuery::create()->filterByDbShow($p_showId)->filterByDbHost($this->getId())->count() > 0 )
{
return true;
$result = true;
}
return false;
return $result;
}
public function isUserType($type, $showId=''){
@ -240,6 +241,7 @@ class Application_Model_User {
public static function getUsersDataTablesInfo($datatables_post) {
$displayColumns = array("id", "login", "first_name", "last_name", "type");
$fromTable = "cc_subjs";
// get current user
@ -250,7 +252,7 @@ class Application_Model_User {
$username = $auth->getIdentity()->login;
}
$res = Application_Model_StoredFile::searchFiles($fromTable, $datatables_post);
$res = Application_Model_StoredFile::searchFiles($displayColumns, $fromTable, $datatables_post);
// mark record which is for the current user
foreach($res['aaData'] as &$record){

View file

@ -1,7 +1,3 @@
<ul>
<li><a href="#simpleSearch">Search</a></li>
</ul>
<div id="simpleSearch">
<div id="import_status" style="visibility:hidden">File import in progress...</div>
<table id="library_display" cellpadding="0" cellspacing="0" class="datatable"></table>
</div>
<div id="import_status" style="display:none">File import in progress...</div>
<table id="library_display" cellpadding="0" cellspacing="0" class="datatable"></table>

View file

@ -1,11 +0,0 @@
<li id="sp_<?php echo $this->id ?>" class="ui-widget-content">
<span><?php echo $this->name ?></span>
<span><?php echo $this->length ?></span>
<div>
<span>Creator: <?php echo $this->creator ?></span>
<?php if($this->state === "edited") : ?>
<span>Editing: <?php echo $this->login ?></span>
<?php endif ?>
</div>
<div><?php echo $this->description ?></div>
</li>

View file

@ -1,8 +0,0 @@
<?php
if(count($this->playlists) > 0) {
echo $this->partialLoop('schedule/find-playlists-partial.phtml', $this->playlists);
}
else {
echo "No Playlists Fit Duration";
}
?>

View file

@ -1,8 +0,0 @@
<?php
if(count($this->playlists) > 0) {
echo $this->partialLoop('schedule/find-playlists-partial.phtml', $this->playlists);
}
else {
echo "No Playlists Fit Duration";
}
?>

View file

@ -1,34 +0,0 @@
<div id="schedule_playlist_dialog">
<h2 id="scheduled_playlist_name">
<?php echo $this->showName; ?>: <span><?php echo $this->s_wday." ".$this->s_month." ".$this->s_day." ".$this->startTime.
" - ".$this->e_wday." ".$this->e_month." ".$this->e_day." ".$this->endTime; ?></span>
</h2>
<div class="clearfix">
<div class="wrapp-one">
<table id="schedule_playlists" cellpadding="0" cellspacing="0" class="datatable">
<thead>
<tr>
<th>Id</th>
<th>Description</th>
<th>Title</th>
<th>Creator</th>
<th>Length</th>
<th>Editing</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
<div class="wrapp-two">
<div><h4>Items In This Show:</h4></div>
<ul id="schedule_playlist_chosen"></ul>
<div id="show_time_info">
<span id="show_time_filled" class="time"><?php echo $this->timeFilled; ?></span>
<div id="show_progressbar"></div>
<span id="show_length" class="time"><?php echo $this->showLength; ?></span>
</div>
<div id="show_time_warning" style="display:none"></div>
</div>
</div>
</div>

View file

@ -1,26 +0,0 @@
<?php if(count($this->showContent) > 0) : ?>
<?php foreach($this->showContent as $pl) : ?>
<li id="g_<?php echo $pl["pl_group"] ?>" >
<h3 class="ui-accordion-header ui-state-default ui-corner-all">
<span class="ui-icon ui-icon-triangle-1-e"></span>
<span class="ui-icon ui-icon-close"></span>
<div class="sh_pl_name"><?php echo $pl["pl_name"] ?></div>
<div class="sh_pl_creator"><?php echo $pl["pl_creator"] ?></div>
<div class="sh_pl_time"><?php echo $pl["pl_length"] ?></div>
</h3>
<div class="group_list ui-widget-content ui-corner-bottom" style="display:none">
<div class="sched_description"><?php echo $pl["pl_description"] ?></div>
<?php foreach($pl["pl_content"] as $file) : ?>
<div>
<span class="sh_file_name"><?php echo $file["f_name"] ?></span>
<span><?php echo $file["f_length"] ?></span>
</div>
<div class="sh_file_artist"><?php echo $file["f_artist"] ?></div>
<?php endforeach; ?>
</div>
</li>
<?php endforeach; ?>
<?php else : ?>
<li>Nothing Scheduled</li>
<?php endif; ?>