Merge branch 'cc-84-smart-playlist' of dev.sourcefabric.org:airtime into cc-84-smart-playlist

This commit is contained in:
denise 2012-07-11 11:50:52 -04:00
commit fe75ba0e93
71 changed files with 2122 additions and 2072 deletions

View File

@ -83,7 +83,7 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
$view->headScript()->appendFile($baseUrl.'/js/airtime/common/common.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$user = Application_Model_User::GetCurrentUser();
$user = Application_Model_User::getCurrentUser();
if (!is_null($user)){
$userType = $user->getType();
} else {

View File

@ -74,7 +74,7 @@ class ApiController extends Zend_Controller_Action
* This is only being used by schedule.js at the moment.
*/
public function calendarInitAction(){
$this->view->layout()->disableLayout();
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
if(is_null(Zend_Auth::getInstance()->getStorage()->read())) {
@ -83,12 +83,12 @@ class ApiController extends Zend_Controller_Action
return;
}
$this->view->calendarInit = array(
"timestamp" => time(),
"timezoneOffset" => date("Z"),
"timeScale" => Application_Model_Preference::GetCalendarTimeScale(),
"timeInterval" => Application_Model_Preference::GetCalendarTimeInterval(),
"weekStartDay" => Application_Model_Preference::GetWeekStartDay()
$this->view->calendarInit = array(
"timestamp" => time(),
"timezoneOffset" => date("Z"),
"timeScale" => Application_Model_Preference::GetCalendarTimeScale(),
"timeInterval" => Application_Model_Preference::GetCalendarTimeInterval(),
"weekStartDay" => Application_Model_Preference::GetWeekStartDay()
);
}
@ -116,24 +116,24 @@ class ApiController extends Zend_Controller_Action
Logging::log("401 Unauthorized");
return;
}
$fileID = $this->_getParam("file");
$file_id = substr($fileID, 0, strpos($fileID, "."));
if (ctype_alnum($file_id) && strlen($file_id) == 32)
{
$media = Application_Model_StoredFile::RecallByGunid($file_id);
if ( $media != null )
{
$filepath = $media->getFilePath();
if(is_file($filepath)){
$full_path = $media->getPropelOrm()->getDbFilepath();
$file_base_name = strrchr($full_path, '/');
/* If $full_path does not contain a '/', strrchr will return false,
* in which case we can use $full_path as the base name.
*/
*/
if (!$file_base_name) {
$file_base_name = $full_path;
} else {
@ -270,32 +270,32 @@ class ApiController extends Zend_Controller_Action
$date = new Application_Common_DateHelper;
$utcTimeNow = $date->getUtcTimestamp();
$utcTimeEnd = ""; // if empty, GetNextShows will use interval instead of end of day
$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
// make getNextShows use end of day
$utcTimeEnd = Application_Common_DateHelper::GetDayEndTimestampInUtc();
$result = array("env"=>APPLICATION_ENV,
"schedulerTime"=>gmdate("Y-m-d H:i:s"),
"nextShow"=>Application_Model_Show::GetNextShows($utcTimeNow, 5, $utcTimeEnd));
Application_Model_Show::ConvertToLocalTimeZone($result["nextShow"], array("starts", "ends", "start_timestamp", "end_timestamp"));
"nextShow"=>Application_Model_Show::getNextShows($utcTimeNow, 5, $utcTimeEnd));
Application_Model_Show::convertToLocalTimeZone($result["nextShow"], array("starts", "ends", "start_timestamp", "end_timestamp"));
}else{
$limit = $request->getParam('limit');
if($limit == "" || !is_numeric($limit)) {
$limit = "5";
}
$result = Application_Model_Schedule::GetPlayOrderRange();
//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"));
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"));
}
$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.
//echo json_encode($result);
@ -324,14 +324,14 @@ class ApiController extends Zend_Controller_Action
$result = array();
for ($i=0; $i<7; $i++){
$utcDayEnd = Application_Common_DateHelper::GetDayEndTimestamp($utcDayStart);
$shows = Application_Model_Show::GetNextShows($utcDayStart, "0", $utcDayEnd);
$shows = Application_Model_Show::getNextShows($utcDayStart, "0", $utcDayEnd);
$utcDayStart = $utcDayEnd;
Application_Model_Show::ConvertToLocalTimeZone($shows, array("starts", "ends", "start_timestamp", "end_timestamp"));
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.
$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.
header("Content-type: text/javascript");
echo $_GET['callback'].'('.json_encode($result).')';
} else {
@ -413,7 +413,7 @@ class ApiController extends Zend_Controller_Action
$this->view->server_timezone = Application_Model_Preference::GetTimezone();
$rows = Application_Model_Show::GetCurrentShow($today_timestamp);
Application_Model_Show::ConvertToLocalTimeZone($rows, array("starts", "ends", "start_timestamp", "end_timestamp"));
Application_Model_Show::convertToLocalTimeZone($rows, array("starts", "ends", "start_timestamp", "end_timestamp"));
if (count($rows) > 0){
$this->view->is_recording = ($rows[0]['record'] == 1);
@ -466,8 +466,8 @@ class ApiController extends Zend_Controller_Action
$this->view->showinstanceid = $show_instance_id;
$showCanceled = false;
$file = Application_Model_StoredFile::Recall($file_id);
$showCanceled = false;
$file = Application_Model_StoredFile::Recall($file_id);
//$show_instance = $this->_getParam('show_instance');
$show_name = null;
@ -508,7 +508,7 @@ class ApiController extends Zend_Controller_Action
$tmpTitle = $file->getName();
}
//$file->setMetadataValue('MDATA_KEY_TITLE', $tmpTitle);
//$file->setMetadataValue('MDATA_KEY_TITLE', $tmpTitle);
$file->setMetadataValue('MDATA_KEY_CREATOR', "Airtime Show Recorder");
$file->setMetadataValue('MDATA_KEY_TRACKNUMBER', $show_instance_id);
@ -627,7 +627,7 @@ class ApiController extends Zend_Controller_Action
$filepath = $md['MDATA_KEY_FILEPATH'];
//$filepath = str_replace("\\", "", $filepath);
$file = Application_Model_StoredFile::RecallByFilepath($filepath);
if (is_null($file)) {
$this->view->error = "File doesn't exist in Airtime.";
return;
@ -770,7 +770,7 @@ class ApiController extends Zend_Controller_Action
$request = $this->getRequest();
$api_key = $request->getParam('api_key');
$getDiskInfo = $request->getParam('diskinfo') == "true";
if (!in_array($api_key, $CC_CONFIG["apiKey"]) &&
is_null(Zend_Auth::getInstance()->getStorage()->read()))
{
@ -823,7 +823,7 @@ class ApiController extends Zend_Controller_Action
$msg = $request->getParam('msg');
$sourcename = $request->getParam('sourcename');
$status = $request->getParam('status');
// on source disconnection sent msg to pypo to turn off the switch
// Added AutoTransition option
if($status == "false" && Application_Model_Preference::GetAutoTransition()){
@ -977,7 +977,7 @@ class ApiController extends Zend_Controller_Action
$username = $request->getParam('username');
$password = $request->getParam('password');
$djtype = $request->getParam('djtype');
if (!in_array($api_key, $CC_CONFIG["apiKey"]) &&
is_null(Zend_Auth::getInstance()->getStorage()->read()))
{

View File

@ -20,14 +20,14 @@ class AudiopreviewController extends Zend_Controller_Action
public function audioPreviewAction()
{
global $CC_CONFIG;
$audioFileID = $this->_getParam('audioFileID');
$audioFileArtist = $this->_getParam('audioFileArtist');
$audioFileTitle = $this->_getParam('audioFileTitle');
$request = $this->getRequest();
$baseUrl = $request->getBaseUrl();
$baseDir = dirname($_SERVER['SCRIPT_FILENAME']);
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/audiopreview/preview_jplayer.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
@ -55,13 +55,13 @@ class AudiopreviewController extends Zend_Controller_Action
public function playlistPreviewAction()
{
global $CC_CONFIG;
$playlistIndex = $this->_getParam('playlistIndex');
$playlistID = $this->_getParam('playlistID');
$request = $this->getRequest();
$baseUrl = $request->getBaseUrl();
$baseDir = dirname($_SERVER['SCRIPT_FILENAME']);
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/audiopreview/preview_jplayer.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
@ -88,18 +88,18 @@ class AudiopreviewController extends Zend_Controller_Action
// disable the view and the layout
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$playlistID = $this->_getParam('playlistID');
if (!isset($playlistID)){
return;
}
$pl = new Application_Model_Playlist($playlistID);
$result = Array();
foreach ( $pl->getContents(true) as $track ){
$elementMap = array( 'element_title' => isset($track['CcFiles']['track_title'])?$track['CcFiles']['track_title']:"",
'element_artist' => isset($track['CcFiles']['artist_name'])?$track['CcFiles']['artist_name']:"",
'element_id' => isset($track['id'])?$track['id']:"",
@ -115,7 +115,7 @@ class AudiopreviewController extends Zend_Controller_Action
}
$result[] = $elementMap;
}
$this->_helper->json($result);
}
@ -126,13 +126,13 @@ class AudiopreviewController extends Zend_Controller_Action
public function showPreviewAction()
{
global $CC_CONFIG;
$showID = $this->_getParam('showID');
$showIndex = $this->_getParam('showIndex');
$request = $this->getRequest();
$baseUrl = $request->getBaseUrl();
$baseDir = dirname($_SERVER['SCRIPT_FILENAME']);
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/audiopreview/preview_jplayer.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
@ -146,13 +146,13 @@ class AudiopreviewController extends Zend_Controller_Action
} else {
$this->view->logo = "$baseUrl/css/images/airtime_logo_jp.png";
}
$this->view->showID = $showID;
$this->view->showIndex = $showIndex;
$this->_helper->viewRenderer->setRender('audio-preview');
}
/**
*Function will load and return the contents of the requested show.
*/
@ -161,25 +161,25 @@ class AudiopreviewController extends Zend_Controller_Action
// disable the view and the layout
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$showID = $this->_getParam('showID');
if (!isset($showID)){
return;
}
$showInstance = new Application_Model_ShowInstance($showID);
$result = array();
$position = 0;
foreach ($showInstance->getShowListContent() as $track){
$elementMap = array(
$elementMap = array(
'element_title' => isset($track['track_title']) ? $track['track_title'] : "",
'element_artist' => isset($track['artist_name']) ? $track['artist_name'] : "",
'element_position' => $position,
'element_id' => ++$position,
);
$fileExtension = pathinfo($track['filepath'], PATHINFO_EXTENSION);
if (strtolower($fileExtension) === 'mp3'){
$elementMap['element_mp3'] = $track['gunid'].'.'.$fileExtension;

View File

@ -15,20 +15,20 @@ class DashboardController extends Zend_Controller_Action
{
// action body
}
public function disconnectSourceAction(){
$request = $this->getRequest();
$sourcename = $request->getParam('sourcename');
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new Application_Model_User($userInfo->id);
$show = Application_Model_Show::GetCurrentShow();
$show_id = isset($show['id'])?$show['id']:0;
$source_connected = Application_Model_Preference::GetSourceStatus($sourcename);
if($user->canSchedule($show_id) && $source_connected){
$data = array("sourcename"=>$sourcename);
Application_Model_RabbitMq::SendMessageToPypo("disconnect_source", $data);
@ -40,40 +40,40 @@ class DashboardController extends Zend_Controller_Action
}
}
}
public function switchSourceAction(){
$request = $this->getRequest();
$sourcename = $this->_getParam('sourcename');
$current_status = $this->_getParam('status');
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new Application_Model_User($userInfo->id);
$show = Application_Model_Show::GetCurrentShow();
$show_id = isset($show[0]['id'])?$show[0]['id']:0;
$source_connected = Application_Model_Preference::GetSourceStatus($sourcename);
if($user->canSchedule($show_id) && ($source_connected || $sourcename == 'scheduled_play' || $current_status == "on")){
$change_status_to = "on";
if(strtolower($current_status) == "on"){
$change_status_to = "off";
}
$data = array("sourcename"=>$sourcename, "status"=>$change_status_to);
Application_Model_RabbitMq::SendMessageToPypo("switch_source", $data);
if(strtolower($current_status) == "on"){
Application_Model_Preference::SetSourceSwitchStatus($sourcename, "off");
$this->view->status = "OFF";
//Log table updates
Application_Model_LiveLog::SetEndTime($sourcename == 'scheduled_play'?'S':'L',
new DateTime("now", new DateTimeZone('UTC')));
}else{
Application_Model_Preference::SetSourceSwitchStatus($sourcename, "on");
$this->view->status = "ON";
//Log table updates
Application_Model_LiveLog::SetNewLogTime($sourcename == 'scheduled_play'?'S':'L',
new DateTime("now", new DateTimeZone('UTC')));
@ -91,18 +91,18 @@ class DashboardController extends Zend_Controller_Action
}
}
}
public function switchOffSource(){
}
public function streamPlayerAction()
{
global $CC_CONFIG;
$request = $this->getRequest();
$baseUrl = $request->getBaseUrl();
$this->view->headLink()->appendStylesheet($baseUrl.'/js/jplayer/skin/jplayer.blue.monday.css?'.$CC_CONFIG['airtime_version']);
$this->_helper->layout->setLayout('bare');

View File

@ -6,12 +6,12 @@ class ErrorController extends Zend_Controller_Action
public function errorAction()
{
$errors = $this->_getParam('error_handler');
switch ($errors->type) {
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
// 404 error -- controller or action not found
$this->getResponse()->setHttpResponseCode(404);
$this->view->message = 'Page not found';
@ -22,17 +22,17 @@ class ErrorController extends Zend_Controller_Action
$this->view->message = 'Application error';
break;
}
// Log exception, if logger available
if ($log = $this->getLog()) {
$log->crit($this->view->message, $errors->exception);
}
// conditionally display exceptions
if ($this->getInvokeArg('displayExceptions') == true) {
$this->view->exception = $errors->exception;
}
$this->view->request = $errors->request;
}

View File

@ -5,7 +5,7 @@ class IndexController extends Zend_Controller_Action
public function init()
{
}
public function indexAction()
@ -14,7 +14,7 @@ class IndexController extends Zend_Controller_Action
}
public function mainAction()
{
{
$this->_helper->layout->setLayout('layout');
}

View File

@ -39,10 +39,10 @@ class LibraryController extends Zend_Controller_Action
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new Application_Model_User($userInfo->id);
//Open a jPlayer window and play the audio clip.
$menu["play"] = array("name"=> "Preview", "icon" => "play");
$isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
if ($type === "audioclip") {
@ -76,7 +76,7 @@ class LibraryController extends Zend_Controller_Action
}
}
//SOUNDCLOUD MENU OPTIONS
if ($type === "audioclip" && Application_Model_Preference::GetUploadToSoundcloudOption()) {
@ -87,7 +87,7 @@ class LibraryController extends Zend_Controller_Action
$menu["soundcloud"] = array("name" => "Soundcloud", "icon" => "soundcloud", "items" => array());
$scid = $file->getSoundCloudId();
if ($scid > 0){
$url = $file->getSoundCloudLinkToFile();
$menu["soundcloud"]["items"]["view"] = array("name" => "View on Soundcloud", "icon" => "soundcloud", "url" => $url);
@ -102,7 +102,7 @@ class LibraryController extends Zend_Controller_Action
$menu["soundcloud"]["items"]["upload"] = array("name" => $text, "icon" => "soundcloud", "url" => "/library/upload-file-soundcloud/id/{$id}");
}
$this->view->items = $menu;
}
@ -111,7 +111,7 @@ class LibraryController extends Zend_Controller_Action
//array containing id and type of media to delete.
$mediaItems = $this->_getParam('media', null);
$user = Application_Model_User::GetCurrentUser();
$user = Application_Model_User::getCurrentUser();
$isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
$files = array();
@ -204,12 +204,12 @@ class LibraryController extends Zend_Controller_Action
public function editFileMdAction()
{
$user = Application_Model_User::GetCurrentUser();
$user = Application_Model_User::getCurrentUser();
$isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
if(!$isAdminOrPM){
return;
}
$request = $this->getRequest();
$form = new Application_Form_EditAudioMD();
@ -247,14 +247,14 @@ class LibraryController extends Zend_Controller_Action
$file = Application_Model_StoredFile::Recall($id);
$this->view->type = $type;
$md = $file->getMetadata();
foreach ($md as $key => $value) {
if ($key == 'MDATA_KEY_DIRECTORY') {
$musicDir = Application_Model_MusicDir::getDirByPK($value);
$md['MDATA_KEY_FILEPATH'] = Application_Common_OsPath::join($musicDir->getDirectory(), $md['MDATA_KEY_FILEPATH']);
}
}
$formatter = new SamplerateFormatter($md["MDATA_KEY_SAMPLERATE"]);
$md["MDATA_KEY_SAMPLERATE"] = $formatter->format();

View File

@ -11,23 +11,23 @@ class LoginController extends Zend_Controller_Action
public function indexAction()
{
global $CC_CONFIG;
if (Zend_Auth::getInstance()->hasIdentity())
{
$this->_redirect('Showbuilder');
}
//uses separate layout without a navigation.
$this->_helper->layout->setLayout('login');
$error = false;
$request = $this->getRequest();
$baseUrl = $request->getBaseUrl();
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/login/login.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$form = new Application_Form_Login();
$message = "Please enter your user name and password";
if($request->isPost())
@ -50,24 +50,24 @@ class LoginController extends Zend_Controller_Action
//pass to the adapter the submitted username and password
$authAdapter->setIdentity($username)
->setCredential($password);
$auth = Zend_Auth::getInstance();
$result = $auth->authenticate($authAdapter);
if($result->isValid())
{
//all info about this user from the login table omit only the password
$userInfo = $authAdapter->getResultRowObject(null, 'password');
//the default storage is a session with namespace Zend_Auth
$authStorage = $auth->getStorage();
$authStorage->write($userInfo);
Application_Model_LoginAttempts::resetAttempts($_SERVER['REMOTE_ADDR']);
Application_Model_Subjects::resetLoginAttempts($username);
$tempSess = new Zend_Session_Namespace("referrer");
$tempSess->referrer = 'login';
$this->_redirect('Showbuilder');
}
else
@ -81,7 +81,7 @@ class LoginController extends Zend_Controller_Action
}
}
}
$this->view->message = $message;
$this->view->error = $error;
$this->view->form = $form;
@ -97,15 +97,15 @@ class LoginController extends Zend_Controller_Action
Zend_Auth::getInstance()->clearIdentity();
$this->_redirect('showbuilder/index');
}
public function passwordRestoreAction()
{
global $CC_CONFIG;
$request = $this->getRequest();
$baseUrl = $request->getBaseUrl();
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/login/password-restore.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
if (!Application_Model_Preference::GetEnableSystemEmail()) {
$this->_redirect('login');
}

View File

@ -135,7 +135,7 @@ class PlaylistController extends Zend_Controller_Action
$this->view->headLink()->appendStylesheet($baseUrl.'/css/jquery.contextMenu.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'/css/datatables/css/ColVis.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'/css/datatables/css/ColReorder.css?'.$CC_CONFIG['airtime_version']);
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/spl.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/playlist/smart_playlistbuilder.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headLink()->appendStylesheet($baseUrl.'/css/playlist_builder.css?'.$CC_CONFIG['airtime_version']);
@ -162,14 +162,14 @@ class PlaylistController extends Zend_Controller_Action
public function newAction()
{
$pl_sess = $this->pl_sess;
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$pl = new Application_Model_Playlist();
$pl->setName("Untitled Playlist");
$pl->setPLMetaData('dc:creator', $userInfo->id);
$pl->setPLMetaData('dc:creator', $userInfo->id);
$this->changePlaylist($pl->getId());
$this->createFullResponse($pl);
$this->changePlaylist($pl->getId());
$this->createFullResponse($pl);
}
public function editAction()
@ -179,21 +179,20 @@ class PlaylistController extends Zend_Controller_Action
//$form = new Application_Form_SmartPlaylistCriteria();
if (!is_null($id)) {
$this->changePlaylist($id);
}
if (!is_null($id)) {
$this->changePlaylist($id);
}
try {
try {
$pl = new Application_Model_Playlist($id);
$this->createFullResponse($pl);
//$this->view->form = $form;
}
catch (PlaylistNotFoundException $e) {
$this->playlistNotFound();
}
catch (Exception $e) {
$this->playlistUnknownError($e);
}
}
catch (PlaylistNotFoundException $e) {
$this->playlistNotFound();
}
catch (Exception $e) {
$this->playlistUnknownError($e);
}
}
public function deleteAction()
@ -224,13 +223,13 @@ class PlaylistController extends Zend_Controller_Action
$this->playlistUnknownError($e);
}
}
public function addItemsAction()
{
$ids = $this->_getParam('ids', array());
$ids = (!is_array($ids)) ? array($ids) : $ids;
$afterItem = $this->_getParam('afterItem', null);
$addType = $this->_getParam('type', 'after');
$afterItem = $this->_getParam('afterItem', null);
$addType = $this->_getParam('type', 'after');
try {
$pl = $this->getPlaylist();
@ -295,9 +294,9 @@ class PlaylistController extends Zend_Controller_Action
public function setCueAction()
{
$id = $this->_getParam('id');
$cueIn = $this->_getParam('cueIn', null);
$cueOut = $this->_getParam('cueOut', null);
$id = $this->_getParam('id');
$cueIn = $this->_getParam('cueIn', null);
$cueOut = $this->_getParam('cueOut', null);
try {
$pl = $this->getPlaylist();
@ -324,9 +323,9 @@ class PlaylistController extends Zend_Controller_Action
public function setFadeAction()
{
$id = $this->_getParam('id');
$fadeIn = $this->_getParam('fadeIn', null);
$fadeOut = $this->_getParam('fadeOut', null);
$id = $this->_getParam('id');
$fadeIn = $this->_getParam('fadeIn', null);
$fadeOut = $this->_getParam('fadeOut', null);
try {
$pl = $this->getPlaylist();
@ -379,8 +378,8 @@ class PlaylistController extends Zend_Controller_Action
**/
public function setPlaylistFadesAction()
{
$fadeIn = $this->_getParam('fadeIn', null);
$fadeOut = $this->_getParam('fadeOut', null);
$fadeIn = $this->_getParam('fadeIn', null);
$fadeOut = $this->_getParam('fadeOut', null);
try {
$pl = $this->getPlaylist();

View File

@ -2,19 +2,19 @@
class PlayoutHistoryController extends Zend_Controller_Action
{
public function init()
{
$ajaxContext = $this->_helper->getHelper('AjaxContext');
$ajaxContext
->addActionContext('playout-history-feed', 'json')
->initContext();
}
public function indexAction()
{
global $CC_CONFIG;
$request = $this->getRequest();
public function init()
{
$ajaxContext = $this->_helper->getHelper('AjaxContext');
$ajaxContext
->addActionContext('playout-history-feed', 'json')
->initContext();
}
public function indexAction()
{
global $CC_CONFIG;
$request = $this->getRequest();
$baseUrl = $request->getBaseUrl();
//default time is the last 24 hours.
@ -36,49 +36,49 @@ class PlayoutHistoryController extends Zend_Controller_Action
));
$this->view->date_form = $form;
$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');
$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/TableTools/js/ZeroClipboard.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/TableTools/js/TableTools.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$offset = date("Z") * -1;
$this->view->headScript()->appendScript("var serverTimezoneOffset = {$offset}; //in seconds");
$this->view->headScript()->appendFile($baseUrl.'/js/timepicker/jquery.ui.timepicker.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/utilities/utilities.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/playouthistory/historytable.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headLink()->appendStylesheet($baseUrl.'/js/datatables/plugin/TableTools/css/TableTools.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'/css/jquery.ui.timepicker.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'/css/playouthistory.css?'.$CC_CONFIG['airtime_version']);
}
public function playoutHistoryFeedAction()
{
$request = $this->getRequest();
$current_time = time();
$params = $request->getParams();
$starts_epoch = $request->getParam("start", $current_time - (60*60*24));
$ends_epoch = $request->getParam("end", $current_time);
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC"));
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
Logging::log("history starts {$startsDT->format("Y-m-d H:i:s")}");
Logging::log("history ends {$endsDT->format("Y-m-d H:i:s")}");
$history = new Application_Model_PlayoutHistory($startsDT, $endsDT, $params);
$r = $history->getItems();
$this->view->sEcho = $r["sEcho"];
$this->view->iTotalDisplayRecords = $r["iTotalDisplayRecords"];
$this->view->iTotalRecords = $r["iTotalRecords"];
$this->view->history = $r["history"];
}
$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');
$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/TableTools/js/ZeroClipboard.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/TableTools/js/TableTools.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$offset = date("Z") * -1;
$this->view->headScript()->appendScript("var serverTimezoneOffset = {$offset}; //in seconds");
$this->view->headScript()->appendFile($baseUrl.'/js/timepicker/jquery.ui.timepicker.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/utilities/utilities.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/playouthistory/historytable.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headLink()->appendStylesheet($baseUrl.'/js/datatables/plugin/TableTools/css/TableTools.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'/css/jquery.ui.timepicker.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'/css/playouthistory.css?'.$CC_CONFIG['airtime_version']);
}
public function playoutHistoryFeedAction()
{
$request = $this->getRequest();
$current_time = time();
$params = $request->getParams();
$starts_epoch = $request->getParam("start", $current_time - (60*60*24));
$ends_epoch = $request->getParam("end", $current_time);
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC"));
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
Logging::log("history starts {$startsDT->format("Y-m-d H:i:s")}");
Logging::log("history ends {$endsDT->format("Y-m-d H:i:s")}");
$history = new Application_Model_PlayoutHistory($startsDT, $endsDT, $params);
$r = $history->getItems();
$this->view->sEcho = $r["sEcho"];
$this->view->iTotalDisplayRecords = $r["iTotalDisplayRecords"];
$this->view->iTotalRecords = $r["iTotalRecords"];
$this->view->history = $r["history"];
}
}

View File

@ -14,7 +14,7 @@ class PluploadController extends Zend_Controller_Action
public function indexAction()
{
global $CC_CONFIG;
$request = $this->getRequest();
$baseUrl = $request->getBaseUrl();
@ -33,7 +33,7 @@ class PluploadController extends Zend_Controller_Action
die('{"jsonrpc" : "2.0", "tempfilepath" : "'.$tempFileName.'" }');
}
public function copyfileAction(){
$upload_dir = ini_get("upload_tmp_dir") . DIRECTORY_SEPARATOR . "plupload";
$filename = $this->_getParam('name');

View File

@ -21,9 +21,9 @@ class PreferenceController extends Zend_Controller_Action
public function indexAction()
{
global $CC_CONFIG;
$isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true;
$request = $this->getRequest();
$baseUrl = $request->getBaseUrl();
@ -41,7 +41,7 @@ class PreferenceController extends Zend_Controller_Action
Application_Model_Preference::SetAllow3rdPartyApi($values["preferences_general"]["thirdPartyApi"]);
Application_Model_Preference::SetTimezone($values["preferences_general"]["timezone"]);
Application_Model_Preference::SetWeekStartDay($values["preferences_general"]["weekStartDay"]);
if (!$isSaas) {
Application_Model_Preference::SetEnableSystemEmail($values["preferences_email_server"]["enableSystemEmail"]);
Application_Model_Preference::SetSystemEmail($values["preferences_email_server"]["systemEmail"]);
@ -153,7 +153,7 @@ class PreferenceController extends Zend_Controller_Action
$baseUrl = $request->getBaseUrl();
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/preferences/streamsetting.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true;
// get current settings
@ -189,7 +189,7 @@ class PreferenceController extends Zend_Controller_Action
$form->setSetting($setting);
$form->startFrom();
$live_stream_subform = new Application_Form_LiveStreamingPreferences();
$form->addSubForm($live_stream_subform, "live_stream_subform");
@ -207,7 +207,7 @@ class PreferenceController extends Zend_Controller_Action
$error = false;
$values = $post_data;
if($form->isValid($post_data)){
if (!$isSaas) {
$values['output_sound_device'] = $form->getValue('output_sound_device');
@ -218,7 +218,7 @@ class PreferenceController extends Zend_Controller_Action
$values['streamFormat'] = $form->getValue('streamFormat');
Application_Model_StreamSetting::setStreamSetting($values);
// this goes into cc_pref table
Application_Model_Preference::SetStreamLabelFormat($values['streamFormat']);
Application_Model_Preference::SetLiveSteamMasterUsername($values["master_username"]);
@ -226,7 +226,7 @@ class PreferenceController extends Zend_Controller_Action
Application_Model_Preference::SetDefaultTransitionFade($values["transition_fade"]);
Application_Model_Preference::SetAutoTransition($values["auto_transition"]);
Application_Model_Preference::SetAutoSwitch($values["auto_switch"]);
if (!$isSaas) {
if (!Application_Model_Preference::GetMasterDjConnectionUrlOverride()) {
$master_connection_url = "http://".$_SERVER['SERVER_NAME'].":".$values["master_harbor_input_port"]."/".$values["master_harbor_input_mount_point"];
@ -238,9 +238,9 @@ class PreferenceController extends Zend_Controller_Action
}
} else {
Application_Model_Preference::SetMasterDJSourceConnectionURL($values["master_dj_connection_url"]);
}
if (!Application_Model_Preference::GetLiveDjConnectionUrlOverride()) {
}
if (!Application_Model_Preference::GetLiveDjConnectionUrlOverride()) {
$live_connection_url = "http://".$_SERVER['SERVER_NAME'].":".$values["dj_harbor_input_port"]."/".$values["dj_harbor_input_mount_point"];
if (empty($values["dj_harbor_input_port"]) || empty($values["dj_harbor_input_mount_point"])) {
Application_Model_Preference::SetLiveDJSourceConnectionURL('N/A');
@ -252,32 +252,32 @@ class PreferenceController extends Zend_Controller_Action
else {
Application_Model_Preference::SetLiveDJSourceConnectionURL($values["live_dj_connection_url"]);
}
// extra info that goes into cc_stream_setting
Application_Model_StreamSetting::SetMasterLiveSteamPort($values["master_harbor_input_port"]);
Application_Model_StreamSetting::SetMasterLiveSteamMountPoint($values["master_harbor_input_mount_point"]);
Application_Model_StreamSetting::SetDJLiveSteamPort($values["dj_harbor_input_port"]);
Application_Model_StreamSetting::SetDJLiveSteamMountPoint($values["dj_harbor_input_mount_point"]);
Application_Model_StreamSetting::setMasterLiveStreamPort($values["master_harbor_input_port"]);
Application_Model_StreamSetting::setMasterLiveStreamMountPoint($values["master_harbor_input_mount_point"]);
Application_Model_StreamSetting::setDjLiveStreamPort($values["dj_harbor_input_port"]);
Application_Model_StreamSetting::setDjLiveStreamMountPoint($values["dj_harbor_input_mount_point"]);
}
// store stream update timestamp
Application_Model_Preference::SetStreamUpdateTimestamp();
$data = array();
$info = Application_Model_StreamSetting::getStreamSetting();
$data['setting'] = $info;
for($i=1;$i<=$num_of_stream;$i++){
Application_Model_StreamSetting::setLiquidsoapError($i, "waiting");
}
Application_Model_RabbitMq::SendMessageToPypo("update_stream_setting", $data);
$this->view->statusMsg = "<div class='success'>Stream Setting Updated.</div>";
}
}
$live_stream_subform->updateVariables();
$this->view->confirm_pypo_restart_text = "If you change the username or password values for an enabled stream the playout engine will be rebooted and your listeners will hear silence for 5-10 seconds. Changing the following fields will NOT cause a reboot: Stream Label (Global Settings), and Switch Transition Fade(s), Master Username, and Master Password (Input Stream Settings). If Airtime is recording, and if the change causes a playout engine restart, the recording will be interrupted.";
$this->view->num_stream = $num_of_stream;
$this->view->enable_stream_conf = Application_Model_Preference::GetEnableStreamConf();
$this->view->form = $form;
@ -351,7 +351,7 @@ class PreferenceController extends Zend_Controller_Action
$this->view->subform = $watched_dirs_form->render();
}
public function rescanWatchDirectoryAction()
{
$dir = Application_Model_MusicDir::getDirByPath($this->getRequest()->getParam("dir"));
@ -395,13 +395,13 @@ class PreferenceController extends Zend_Controller_Action
}
die(json_encode($out));
}
public function setSourceConnectionUrlAction(){
$request = $this->getRequest();
$type = $request->getParam("type", null);
$url = urldecode($request->getParam("url", null));
$override = $request->getParam("override", false);
if($type == 'masterdj'){
Application_Model_Preference::SetMasterDJSourceConnectionURL($url);
Application_Model_Preference::SetMasterDjConnectionUrlOverride($override);
@ -409,7 +409,7 @@ class PreferenceController extends Zend_Controller_Action
Application_Model_Preference::SetLiveDJSourceConnectionURL($url);
Application_Model_Preference::SetLiveDjConnectionUrlOverride($override);
}
die();
}
}

View File

@ -10,16 +10,16 @@ class ScheduleController extends Zend_Controller_Action
$ajaxContext = $this->_helper->getHelper('AjaxContext');
$ajaxContext->addActionContext('event-feed', 'json')
->addActionContext('make-context-menu', 'json')
->addActionContext('add-show-dialog', 'json')
->addActionContext('add-show', 'json')
->addActionContext('edit-show', 'json')
->addActionContext('move-show', 'json')
->addActionContext('resize-show', 'json')
->addActionContext('delete-show', 'json')
->addActionContext('add-show-dialog', 'json')
->addActionContext('add-show', 'json')
->addActionContext('edit-show', 'json')
->addActionContext('move-show', 'json')
->addActionContext('resize-show', 'json')
->addActionContext('delete-show', 'json')
->addActionContext('show-content-dialog', 'json')
->addActionContext('clear-show', 'json')
->addActionContext('clear-show', 'json')
->addActionContext('get-current-playlist', 'json')
->addActionContext('remove-group', 'json')
->addActionContext('remove-group', 'json')
->addActionContext('populate-show-form', 'json')
->addActionContext('populate-show-instance-form', 'json')
->addActionContext('cancel-show', 'json')
@ -35,7 +35,7 @@ class ScheduleController extends Zend_Controller_Action
->addActionContext('get-current-show', 'json')
->initContext();
$this->sched_sess = new Zend_Session_Namespace("schedule");
$this->sched_sess = new Zend_Session_Namespace("schedule");
}
public function indexAction()
@ -90,12 +90,12 @@ class ScheduleController extends Zend_Controller_Action
Application_Model_Schedule::createNewFormSections($this->view);
$user = Application_Model_User::GetCurrentUser();
$user = Application_Model_User::getCurrentUser();
if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))){
$this->view->preloadShowForm = true;
}
$this->view->headScript()->appendScript("var weekStart = ".Application_Model_Preference::GetWeekStartDay().";");
}
@ -106,7 +106,7 @@ class ScheduleController extends Zend_Controller_Action
$end = new DateTime($this->_getParam('end', null));
$end->setTimezone(new DateTimeZone("UTC"));
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new Application_Model_User($userInfo->id);
if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
$editable = true;
@ -115,9 +115,9 @@ class ScheduleController extends Zend_Controller_Action
$editable = false;
}
$this->view->events = Application_Model_Show::getFullCalendarEvents($start, $end, $editable);
$this->view->events = Application_Model_Show::getFullCalendarEvents($start, $end, $editable);
}
public function getCurrentShowAction() {
$currentShow = Application_Model_Show::GetCurrentShow();
if (!empty($currentShow)) {
@ -155,8 +155,8 @@ class ScheduleController extends Zend_Controller_Action
public function resizeShowAction()
{
$deltaDay = $this->_getParam('day');
$deltaMin = $this->_getParam('min');
$showId = $this->_getParam('showId');
$deltaMin = $this->_getParam('min');
$showId = $this->_getParam('showId');
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new Application_Model_User($userInfo->id);
@ -168,34 +168,34 @@ class ScheduleController extends Zend_Controller_Action
$this->view->show_error = true;
return false;
}
$error = $show->resizeShow($deltaDay, $deltaMin);
$error = $show->resizeShow($deltaDay, $deltaMin);
}
if (isset($error)) {
$this->view->error = $error;
}
if (isset($error)) {
$this->view->error = $error;
}
}
public function deleteShowAction()
{
$showInstanceId = $this->_getParam('id');
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new Application_Model_User($userInfo->id);
$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);
$showInstance = new Application_Model_ShowInstance($showInstanceId);
}
catch(Exception $e){
$this->view->show_error = true;
return false;
}
$showInstance->delete();
$showInstance->delete();
$this->view->show_id = $showInstance->getShowId();
$this->view->show_id = $showInstance->getShowId();
}
}
@ -231,24 +231,24 @@ class ScheduleController extends Zend_Controller_Action
$this->view->show_error = true;
return false;
}
$isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
$isDJ = $user->isHost($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" => "/library/edit-file-md/id/".$fileId);
}
if ($epochNow < $showStartLocalDT->getTimestamp()) {
if ( ($isAdminOrPM || $isDJ)
if ( ($isAdminOrPM || $isDJ)
&& !$instance->isRecorded()
&& !$instance->isRebroadcast()) {
@ -268,18 +268,18 @@ class ScheduleController extends Zend_Controller_Action
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");
$menu["soundcloud_upload"] = array("name"=> $text, "icon" => "soundcloud");
}
if ($showStartLocalDT->getTimestamp() <= $epochNow &&
@ -287,7 +287,7 @@ class ScheduleController extends Zend_Controller_Action
if ($instance->isRecorded()) {
$menu["cancel_recorded"] = array("name"=> "Cancel Current Show", "icon" => "delete");
}
}
else {
if (!$instance->isRebroadcast()) {
@ -357,28 +357,28 @@ class ScheduleController extends Zend_Controller_Action
$range["next"]["ends"] = Application_Common_DateHelper::ConvertToLocalDateTimeString($range["next"]["ends"]);
}
Application_Model_Show::ConvertToLocalTimeZone($range["currentShow"], array("starts", "ends", "start_timestamp", "end_timestamp"));
Application_Model_Show::ConvertToLocalTimeZone($range["nextShow"], array("starts", "ends", "start_timestamp", "end_timestamp"));
Application_Model_Show::convertToLocalTimeZone($range["currentShow"], array("starts", "ends", "start_timestamp", "end_timestamp"));
Application_Model_Show::convertToLocalTimeZone($range["nextShow"], array("starts", "ends", "start_timestamp", "end_timestamp"));
$source_status = array();
$switch_status = array();
$live_dj = Application_Model_Preference::GetSourceStatus("live_dj");
$master_dj = Application_Model_Preference::GetSourceStatus("master_dj");
$scheduled_play_switch = Application_Model_Preference::GetSourceSwitchStatus("scheduled_play");
$live_dj_switch = Application_Model_Preference::GetSourceSwitchStatus("live_dj");
$master_dj_switch = Application_Model_Preference::GetSourceSwitchStatus("master_dj");
//might not be the correct place to implement this but for now let's just do it here
$source_status['live_dj_source'] = $live_dj;
$source_status['master_dj_source'] = $master_dj;
$this->view->source_status = $source_status;
$switch_status['live_dj_source'] = $live_dj_switch;
$switch_status['master_dj_source'] = $master_dj_switch;
$switch_status['scheduled_play'] = $scheduled_play_switch;
$this->view->switch_status = $switch_status;
$this->view->entries = $range;
$this->view->show_name = isset($show[0])?$show[0]["name"]:"";
}
@ -387,9 +387,9 @@ class ScheduleController extends Zend_Controller_Action
{
$showInstanceId = $this->sched_sess->showInstanceId;
$group_id = $this->_getParam('groupId');
$search = $this->_getParam('search', null);
$search = $this->_getParam('search', null);
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new Application_Model_User($userInfo->id);
try{
$show = new Application_Model_ShowInstance($showInstanceId);
@ -399,14 +399,14 @@ class ScheduleController extends Zend_Controller_Action
}
if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER, UTYPE_HOST),$show->getShowId())) {
$show->removeGroupFromShow($group_id);
$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);
$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()
@ -451,53 +451,53 @@ class ScheduleController extends Zend_Controller_Action
// 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();
$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();
$formWhat->removeDecorator('DtDdWrapper');
$formWho->removeDecorator('DtDdWrapper');
$formWhen->removeDecorator('DtDdWrapper');
$formRepeats->removeDecorator('DtDdWrapper');
$formStyle->removeDecorator('DtDdWrapper');
$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->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);
$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()));
'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_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();
@ -505,13 +505,13 @@ class ScheduleController extends Zend_Controller_Action
$formWhen->disableRepeatCheckbox();
$formRepeats->disable();
$formStyle->disable();
//$formRecord->disable();
//$formAbsoluteRebroadcast->disable();
//$formRebroadcast->disable();
$this->view->action = "edit-show-instance";
$this->view->newForm = $this->view->render('schedule/add-show-form.phtml');
}*/
@ -527,7 +527,7 @@ class ScheduleController extends Zend_Controller_Action
// $type is used to determine if this edit is for the specific instance or for all
// repeating shows. It's value is either "instance","rebroadcast", or "all"
$type = $this->_getParam('type');
$this->view->action = "edit-show";
try{
$showInstance = new Application_Model_ShowInstance($showInstanceId);
@ -535,37 +535,37 @@ class ScheduleController extends Zend_Controller_Action
$this->view->show_error = true;
return false;
}
$isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
$isDJ = $user->isHost($showInstance->getShowId());
if(!($isAdminOrPM || $isDJ)) {
return;
}
if($isDJ){
$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();
$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();
$formWhat->removeDecorator('DtDdWrapper');
$formWho->removeDecorator('DtDdWrapper');
$formWhen->removeDecorator('DtDdWrapper');
$formRepeats->removeDecorator('DtDdWrapper');
$formStyle->removeDecorator('DtDdWrapper');
$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->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());
@ -585,8 +585,8 @@ class ScheduleController extends Zend_Controller_Action
$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_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));
@ -626,7 +626,7 @@ class ScheduleController extends Zend_Controller_Action
$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());
if(!$isSaas){
@ -674,7 +674,7 @@ class ScheduleController extends Zend_Controller_Action
$formRebroadcast->disable();
}
}
if(!$isAdminOrPM){
$formWhat->disable();
$formWho->disable();
@ -688,15 +688,15 @@ class ScheduleController extends Zend_Controller_Action
}
public function getFormAction() {
$user = Application_Model_User::GetCurrentUser();
$user = Application_Model_User::getCurrentUser();
if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))){
Application_Model_Schedule::createNewFormSections($this->view);
$this->view->form = $this->view->render('schedule/add-show-form.phtml');
}
}
public function djEditShowAction(){
$js = $this->_getParam('data');
$data = array();
@ -705,17 +705,17 @@ class ScheduleController extends Zend_Controller_Action
foreach($js as $j){
$data[$j["name"]] = $j["value"];
}
//update cc_show
$show = new Application_Model_Show($data["add_show_id"]);
$show->setAirtimeAuthFlag($data["cb_airtime_auth"]);
$show->setCustomAuthFlag($data["cb_custom_auth"]);
$show->setCustomUsername($data["custom_username"]);
$show->setCustomPassword($data["custom_password"]);
$this->view->edit = true;
}
/*public function editShowInstanceAction(){
$js = $this->_getParam('data');
$data = array();
@ -724,7 +724,7 @@ class ScheduleController extends Zend_Controller_Action
foreach($js as $j){
$data[$j["name"]] = $j["value"];
}
$success = Application_Model_Schedule::updateShowInstance($data, $this);
if ($success){
$this->view->addNewShow = true;
@ -734,9 +734,9 @@ class ScheduleController extends Zend_Controller_Action
$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
$js = $this->_getParam('data');
$data = array();
@ -752,9 +752,9 @@ class ScheduleController extends Zend_Controller_Action
if($data['add_show_day_check'] == "") {
$data['add_show_day_check'] = null;
}
$show = new Application_Model_Show($data['add_show_id']);
$validateStartDate = true;
$validateStartTime = true;
if (!array_key_exists('add_show_start_date', $data)){
@ -763,7 +763,7 @@ class ScheduleController extends Zend_Controller_Action
//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");
if (!array_key_exists('add_show_start_time', $data)){
$data['add_show_start_time'] = $dt->format("H:i");
$validateStartTime = false;
@ -771,10 +771,10 @@ class ScheduleController extends Zend_Controller_Action
$validateStartDate = false;
}
$data['add_show_record'] = $show->isRecorded();
$origianlShowStartDateTime = Application_Common_DateHelper::ConvertToLocalDateTime($show->getStartDateAndTime());
$success = Application_Model_Schedule::addUpdateShow($data, $this, $validateStartDate, $origianlShowStartDateTime, true, $data['add_show_instance_id']);
if ($success){
$this->view->addNewShow = true;
$this->view->newForm = $this->view->render('schedule/add-show-form.phtml');
@ -791,7 +791,7 @@ class ScheduleController extends Zend_Controller_Action
$this->view->form = $this->view->render('schedule/add-show-form.phtml');
}
}
public function addShowAction(){
$js = $this->_getParam('data');
$data = array();
@ -807,10 +807,10 @@ class ScheduleController extends Zend_Controller_Action
if($data['add_show_day_check'] == "") {
$data['add_show_day_check'] = null;
}
$validateStartDate = true;
$success = Application_Model_Schedule::addUpdateShow($data, $this, $validateStartDate);
if ($success){
$this->view->addNewShow = true;
$this->view->newForm = $this->view->render('schedule/add-show-form.phtml');
@ -822,14 +822,14 @@ class ScheduleController extends Zend_Controller_Action
public function cancelShowAction()
{
$user = Application_Model_User::GetCurrentUser();
$user = Application_Model_User::getCurrentUser();
if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
$showInstanceId = $this->_getParam('id');
$showInstanceId = $this->_getParam('id');
try {
try {
$showInstance = new Application_Model_ShowInstance($showInstanceId);
} catch(Exception $e) {
} catch(Exception $e) {
$this->view->show_error = true;
return false;
}
@ -842,11 +842,11 @@ class ScheduleController extends Zend_Controller_Action
public function cancelCurrentShowAction()
{
$user = Application_Model_User::GetCurrentUser();
$user = Application_Model_User::getCurrentUser();
if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
$id = $this->_getParam('id');
try {
$scheduler = new Application_Model_Scheduler();
$scheduler->cancelShow($id);
@ -864,9 +864,9 @@ class ScheduleController extends Zend_Controller_Action
}
public function contentContextMenuAction(){
global $CC_CONFIG;
global $CC_CONFIG;
$id = $this->_getParam('id');
$id = $this->_getParam('id');
$params = '/format/json/id/#id#/';
@ -881,7 +881,7 @@ class ScheduleController extends Zend_Controller_Action
$baseUrl = $this->getRequest()->getBaseUrl();
$url = $file->getRelativeFileUrl($baseUrl).'/download/true';
$menu[] = array('action' => array('type' => 'gourl', 'url' => $url),
'title' => 'Download');
'title' => 'Download');
//returns format jjmenu is looking for.
die(json_encode($menu));
@ -892,7 +892,7 @@ class ScheduleController extends Zend_Controller_Action
* This is only being used by schedule.js at the moment.
*/
public function setTimeScaleAction() {
Application_Model_Preference::SetCalendarTimeScale($this->_getParam('timeScale'));
Application_Model_Preference::SetCalendarTimeScale($this->_getParam('timeScale'));
}
/**
@ -900,24 +900,24 @@ class ScheduleController extends Zend_Controller_Action
* This is only being used by schedule.js at the moment.
*/
public function setTimeIntervalAction() {
Application_Model_Preference::SetCalendarTimeInterval($this->_getParam('timeInterval'));
Application_Model_Preference::SetCalendarTimeInterval($this->_getParam('timeInterval'));
}
public function calculateDurationAction() {
global $CC_CONFIG;
$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'));
@ -932,7 +932,7 @@ class ScheduleController extends Zend_Controller_Action
}catch (Exception $e){
$result = "Invalid Date";
}
echo Zend_Json::encode($result);
exit();
}

View File

@ -17,17 +17,17 @@ class ShowbuilderController extends Zend_Controller_Action
}
public function indexAction() {
global $CC_CONFIG;
$request = $this->getRequest();
$baseUrl = $request->getBaseUrl();
$user = Application_Model_User::GetCurrentUser();
$user = Application_Model_User::getCurrentUser();
$userType = $user->getType();
$this->view->headScript()->appendScript("localStorage.setItem( 'user-type', '$userType' );");
$data = Application_Model_Preference::GetValue("library_datatable", true);
$data = Application_Model_Preference::getValue("library_datatable", true);
if ($data != "") {
$libraryTable = json_encode(unserialize($data));
$this->view->headScript()->appendScript("localStorage.setItem( 'datatables-library', JSON.stringify($libraryTable) );");
@ -35,8 +35,8 @@ class ShowbuilderController extends Zend_Controller_Action
else {
$this->view->headScript()->appendScript("localStorage.setItem( 'datatables-library', '' );");
}
$data = Application_Model_Preference::GetValue("timeline_datatable", true);
$data = Application_Model_Preference::getValue("timeline_datatable", true);
if ($data != "") {
$timelineTable = json_encode(unserialize($data));
$this->view->headScript()->appendScript("localStorage.setItem( 'datatables-timeline', JSON.stringify($timelineTable) );");
@ -44,7 +44,7 @@ class ShowbuilderController extends Zend_Controller_Action
else {
$this->view->headScript()->appendScript("localStorage.setItem( 'datatables-timeline', '' );");
}
$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');
@ -52,7 +52,7 @@ class ShowbuilderController extends Zend_Controller_Action
$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.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/blockui/jquery.blockUI.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/utilities/utilities.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
@ -62,89 +62,89 @@ class ShowbuilderController extends Zend_Controller_Action
$this->view->headLink()->appendStylesheet($baseUrl.'/css/jquery.contextMenu.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'/css/datatables/css/ColVis.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'/css/datatables/css/ColReorder.css?'.$CC_CONFIG['airtime_version']);
$this->view->headScript()->appendFile($this->view->baseUrl('/js/airtime/library/events/library_showbuilder.js?'.$CC_CONFIG['airtime_version']),'text/javascript');
$refer_sses = new Zend_Session_Namespace('referrer');
if ($request->isPost()) {
$form = new Application_Form_RegisterAirtime();
$form = new Application_Form_RegisterAirtime();
$values = $request->getPost();
if ($values["Publicise"] != 1 && $form->isValid($values)) {
Application_Model_Preference::SetSupportFeedback($values["SupportFeedback"]);
if (isset($values["Privacy"])) {
Application_Model_Preference::SetPrivacyPolicyCheck($values["Privacy"]);
}
// unset session
Zend_Session::namespaceUnset('referrer');
}
else if ($values["Publicise"] == '1' && $form->isValid($values)) {
Application_Model_Preference::SetHeadTitle($values["stnName"], $this->view);
Application_Model_Preference::SetPhone($values["Phone"]);
Application_Model_Preference::SetEmail($values["Email"]);
Application_Model_Preference::SetStationWebSite($values["StationWebSite"]);
Application_Model_Preference::SetPublicise($values["Publicise"]);
$values = $request->getPost();
if ($values["Publicise"] != 1 && $form->isValid($values)) {
Application_Model_Preference::SetSupportFeedback($values["SupportFeedback"]);
if (isset($values["Privacy"])) {
Application_Model_Preference::SetPrivacyPolicyCheck($values["Privacy"]);
}
// unset session
Zend_Session::namespaceUnset('referrer');
}
else if ($values["Publicise"] == '1' && $form->isValid($values)) {
Application_Model_Preference::SetHeadTitle($values["stnName"], $this->view);
Application_Model_Preference::SetPhone($values["Phone"]);
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();
$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"]);
Application_Model_Preference::SetStationLogo($imagePath);
Application_Model_Preference::SetSupportFeedback($values["SupportFeedback"]);
if (isset($values["Privacy"])){
Application_Model_Preference::SetPrivacyPolicyCheck($values["Privacy"]);
}
// unset session
Zend_Session::namespaceUnset('referrer');
}
else {
$logo = Application_Model_Preference::GetStationLogo();
if ($logo) {
$this->view->logoImg = $logo;
}
$this->view->dialog = $form;
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/nowplaying/register.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
}
Application_Model_Preference::SetStationCountry($values["Country"]);
Application_Model_Preference::SetStationCity($values["City"]);
Application_Model_Preference::SetStationDescription($values["Description"]);
Application_Model_Preference::SetStationLogo($imagePath);
Application_Model_Preference::SetSupportFeedback($values["SupportFeedback"]);
if (isset($values["Privacy"])){
Application_Model_Preference::SetPrivacyPolicyCheck($values["Privacy"]);
}
// unset session
Zend_Session::namespaceUnset('referrer');
}
else {
$logo = Application_Model_Preference::GetStationLogo();
if ($logo) {
$this->view->logoImg = $logo;
}
$this->view->dialog = $form;
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/nowplaying/register.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
}
}
//popup if previous page was login
if ($refer_sses->referrer == 'login' && Application_Model_Preference::ShouldShowPopUp()
&& !Application_Model_Preference::GetSupportFeedback() && $user->isAdmin()){
//popup if previous page was login
if ($refer_sses->referrer == 'login' && Application_Model_Preference::ShouldShowPopUp()
&& !Application_Model_Preference::GetSupportFeedback() && $user->isAdmin()){
$form = new Application_Form_RegisterAirtime();
$form = new Application_Form_RegisterAirtime();
$logo = Application_Model_Preference::GetStationLogo();
if ($logo) {
$this->view->logoImg = $logo;
}
$this->view->dialog = $form;
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/nowplaying/register.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
}
//determine whether to remove/hide/display the library.
$showLib = false;
if (!$user->isGuest()) {
$disableLib = false;
$data = Application_Model_Preference::GetValue("nowplaying_screen", true);
$logo = Application_Model_Preference::GetStationLogo();
if ($logo) {
$this->view->logoImg = $logo;
}
$this->view->dialog = $form;
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/nowplaying/register.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
}
//determine whether to remove/hide/display the library.
$showLib = false;
if (!$user->isGuest()) {
$disableLib = false;
$data = Application_Model_Preference::getValue("nowplaying_screen", true);
if ($data != "") {
$settings = unserialize($data);
if ($settings["library"] == "true") {
$showLib = true;
}
}
}
else {
$disableLib = true;
}
$this->view->disableLib = $disableLib;
$this->view->showLib = $showLib;
}
else {
$disableLib = true;
}
$this->view->disableLib = $disableLib;
$this->view->showLib = $showLib;
//populate date range form for show builder.
$now = time();
$from = $request->getParam("from", $now);
@ -174,7 +174,7 @@ class ShowbuilderController extends Zend_Controller_Action
$this->view->headLink()->appendStylesheet($baseUrl.'/css/jquery.ui.timepicker.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'/css/showbuilder.css?'.$CC_CONFIG['airtime_version']);
}
public function contextMenuAction()
{
$id = $this->_getParam('id');
@ -184,7 +184,7 @@ class ShowbuilderController extends Zend_Controller_Action
$baseUrl = $request->getBaseUrl();
$menu = array();
$user = Application_Model_User::GetCurrentUser();
$user = Application_Model_User::getCurrentUser();
$item = CcScheduleQuery::create()->findPK($id);
$instance = $item->getCcShowInstances();
@ -263,7 +263,7 @@ class ShowbuilderController extends Zend_Controller_Action
public function builderFeedAction() {
$start = microtime(true);
$request = $this->getRequest();
$current_time = time();
@ -284,7 +284,7 @@ class ShowbuilderController extends Zend_Controller_Action
$this->view->schedule = $data["schedule"];
$this->view->instances = $data["showInstances"];
$this->view->timestamp = $current_time;
$end = microtime(true);
Logging::debug("getting builder feed info took:");

View File

@ -5,10 +5,10 @@ class SystemstatusController extends Zend_Controller_Action
public function init()
{
global $CC_CONFIG;
$request = $this->getRequest();
$baseUrl = $request->getBaseUrl();
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/status/status.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
}
@ -22,7 +22,7 @@ class SystemstatusController extends Zend_Controller_Action
);
$partitions = Application_Model_Systemstatus::GetDiskInfo();
$this->view->status = new StdClass;
$this->view->status->services = $services;
$this->view->status->partitions = $partitions;

View File

@ -20,24 +20,24 @@ class UserController extends Zend_Controller_Action
public function addUserAction()
{
global $CC_CONFIG;
$request = $this->getRequest();
$baseUrl = $request->getBaseUrl();
$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');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/user/user.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/user/user.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headLink()->appendStylesheet($baseUrl.'/css/users.css?'.$CC_CONFIG['airtime_version']);
$form = new Application_Form_AddUser();
$this->view->successMessage = "";
if ($request->isPost()) {
if ($form->isValid($request->getPost())) {
$formdata = $form->getValues();
if ($form->isValid($request->getPost())) {
$formdata = $form->getValues();
if(isset($CC_CONFIG['demo']) && $CC_CONFIG['demo'] == 1 && $formdata['login'] == 'admin' && $formdata['user_id'] != 0){
$this->view->successMessage = "<div class='errors'>Specific action is not allowed in demo version!</div>";
}
@ -54,7 +54,7 @@ class UserController extends Zend_Controller_Action
$user->setSkype($formdata['skype']);
$user->setJabber($formdata['jabber']);
$user->save();
$form->reset();
if (strlen($formdata['user_id']) == 0){
@ -65,7 +65,7 @@ class UserController extends Zend_Controller_Action
}
}
}
$this->view->form = $form;
}
@ -80,7 +80,7 @@ class UserController extends Zend_Controller_Action
{
$post = $this->getRequest()->getPost();
$users = Application_Model_User::getUsersDataTablesInfo($post);
die(json_encode($users));
}
@ -102,7 +102,7 @@ class UserController extends Zend_Controller_Action
$user = new Application_Model_User($delId);
$this->view->entries = $user->delete();
}
}

View File

@ -16,19 +16,19 @@ class UsersettingsController extends Zend_Controller_Action
->addActionContext('donotshowregistrationpopup', 'json')
->initContext();
}
public function setNowPlayingScreenSettingsAction() {
$request = $this->getRequest();
$settings = $request->getParam("settings");
$data = serialize($settings);
Application_Model_Preference::SetValue("nowplaying_screen", $data, true);
Application_Model_Preference::setValue("nowplaying_screen", $data, true);
}
public function getNowPlayingScreenSettingsAction() {
$data = Application_Model_Preference::GetValue("nowplaying_screen", true);
$data = Application_Model_Preference::getValue("nowplaying_screen", true);
if ($data != "") {
$this->view->settings = unserialize($data);
}
@ -40,12 +40,12 @@ class UsersettingsController extends Zend_Controller_Action
$settings = $request->getParam("settings");
$data = serialize($settings);
Application_Model_Preference::SetValue("library_datatable", $data, true);
Application_Model_Preference::setValue("library_datatable", $data, true);
}
public function getLibraryDatatableAction() {
$data = Application_Model_Preference::GetValue("library_datatable", true);
$data = Application_Model_Preference::getValue("library_datatable", true);
if ($data != "") {
$this->view->settings = unserialize($data);
}
@ -54,34 +54,34 @@ class UsersettingsController extends Zend_Controller_Action
public function setTimelineDatatableAction() {
$start = microtime(true);
$request = $this->getRequest();
$settings = $request->getParam("settings");
$data = serialize($settings);
Application_Model_Preference::SetValue("timeline_datatable", $data, true);
Application_Model_Preference::setValue("timeline_datatable", $data, true);
$end = microtime(true);
Logging::debug("saving timeline datatables info took:");
Logging::debug(floatval($end) - floatval($start));
}
public function getTimelineDatatableAction() {
$start = microtime(true);
$data = Application_Model_Preference::GetValue("timeline_datatable", true);
$data = Application_Model_Preference::getValue("timeline_datatable", true);
if ($data != "") {
$this->view->settings = unserialize($data);
}
$end = microtime(true);
Logging::debug("getting timeline datatables info took:");
Logging::debug(floatval($end) - floatval($start));
}
public function remindmeAction()
{
// unset session

View File

@ -26,8 +26,8 @@ class Zend_Controller_Plugin_Acl extends Zend_Controller_Plugin_Abstract
**/
public function __construct(Zend_Acl $aclData, $roleName = 'G')
{
$this->_errorPage = array('module' => 'default',
'controller' => 'error',
$this->_errorPage = array('module' => 'default',
'controller' => 'error',
'action' => 'denied');
$this->_roleName = $roleName;
@ -62,17 +62,17 @@ class Zend_Controller_Plugin_Acl extends Zend_Controller_Plugin_Abstract
* Returns the ACL role used
*
* @return string
* @author
* @author
**/
public function getRoleName()
{
return $this->_roleName;
}
public function setRoleName($type)
{
$this->_roleName = $type;
}
public function setRoleName($type)
{
$this->_roleName = $type;
}
/**
* Sets the error page
@ -84,7 +84,7 @@ class Zend_Controller_Plugin_Acl extends Zend_Controller_Plugin_Abstract
**/
public function setErrorPage($action, $controller = 'error', $module = null)
{
$this->_errorPage = array('module' => $module,
$this->_errorPage = array('module' => $module,
'controller' => $controller,
'action' => $action);
}
@ -108,58 +108,58 @@ class Zend_Controller_Plugin_Acl extends Zend_Controller_Plugin_Abstract
**/
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$controller = strtolower($request->getControllerName());
if (in_array($controller, array("api", "auth"))){
$this->setRoleName("G");
}
$controller = strtolower($request->getControllerName());
if (in_array($controller, array("api", "auth"))){
$this->setRoleName("G");
}
else if (!Zend_Auth::getInstance()->hasIdentity()){
if ($controller !== 'login') {
if ($controller !== 'login') {
if ($request->isXmlHttpRequest()) {
if ($request->isXmlHttpRequest()) {
$url = 'http://'.$request->getHttpHost().'/login';
$json = Zend_Json::encode(array('auth' => false, 'url' => $url));
// Prepare response
$this->getResponse()
->setHttpResponseCode(401)
->setBody($json)
->sendResponse();
$url = 'http://'.$request->getHttpHost().'/login';
$json = Zend_Json::encode(array('auth' => false, 'url' => $url));
// Prepare response
$this->getResponse()
->setHttpResponseCode(401)
->setBody($json)
->sendResponse();
//redirectAndExit() cleans up, sends the headers and stops the script
Zend_Controller_Action_HelperBroker::getStaticHelper('redirector')->redirectAndExit();
}
else {
$r = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
$r->gotoSimpleAndExit('index', 'login', $request->getModuleName());
}
}
}
else {
//redirectAndExit() cleans up, sends the headers and stops the script
Zend_Controller_Action_HelperBroker::getStaticHelper('redirector')->redirectAndExit();
}
else {
$r = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
$r->gotoSimpleAndExit('index', 'login', $request->getModuleName());
}
}
}
else {
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$this->setRoleName($userInfo->type);
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$this->setRoleName($userInfo->type);
Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl($this->_acl);
Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole($this->_roleName);
$resourceName = '';
Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole($this->_roleName);
if ($request->getModuleName() != 'default') {
$resourceName .= strtolower($request->getModuleName()) . ':';
}
$resourceName = '';
$resourceName .= $controller;
if ($request->getModuleName() != 'default') {
$resourceName .= strtolower($request->getModuleName()) . ':';
}
/** Check if the controller/action can be accessed by the current user */
if (!$this->getAcl()->isAllowed($this->_roleName, $resourceName, $request->getActionName())) {
/** Redirect to access denied page */
$this->denyAccess();
}
}
$resourceName .= $controller;
/** Check if the controller/action can be accessed by the current user */
if (!$this->getAcl()->isAllowed($this->_roleName, $resourceName, $request->getActionName())) {
/** Redirect to access denied page */
$this->denyAccess();
}
}
}
/**

View File

@ -29,7 +29,7 @@ class Application_Form_AddShowAbsoluteRebroadcastDates extends Zend_Form_SubForm
$this->addElement($text);
}
}
public function disable(){
$elements = $this->getElements();
foreach ($elements as $element)

View File

@ -11,13 +11,13 @@ class Application_Form_AddShowLiveStream extends Zend_Form_SubForm
->setRequired(false)
->setDecorators(array('ViewHelper'));
$this->addElement($cb_airtime_auth);
$cb_custom_auth = new Zend_Form_Element_Checkbox("cb_custom_auth");
$cb_custom_auth ->setLabel("Use Custom Authentication:")
->setRequired(false)
->setDecorators(array('ViewHelper'));
$this->addElement($cb_custom_auth);
//custom username
$custom_username = new Zend_Form_Element_Text('custom_username');
$custom_username->setAttrib('class', 'input_text')
@ -29,7 +29,7 @@ class Application_Form_AddShowLiveStream extends Zend_Form_SubForm
new ConditionalNotEmpty(array("cb_custom_auth"=>"1"))))
->setDecorators(array('ViewHelper'));
$this->addElement($custom_username);
//custom password
$custom_password = new Zend_Form_Element_Password('custom_password');
$custom_password->setAttrib('class', 'input_text')
@ -42,20 +42,20 @@ class Application_Form_AddShowLiveStream extends Zend_Form_SubForm
new ConditionalNotEmpty(array("cb_custom_auth"=>"1"))))
->setDecorators(array('ViewHelper'));
$this->addElement($custom_password);
$connection_url = Application_Model_Preference::GetLiveDJSourceConnectionURL();
if(trim($connection_url) == ""){
$connection_url = "N/A";
}
$this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/add-show-live-stream.phtml', "connection_url"=>$connection_url))
));
}
public function isValid($data){
$isValid = parent::isValid($data);
if($data['cb_custom_auth'] == 1){
if(trim($data['custom_username']) == ''){
$element = $this->getElement("custom_username");

View File

@ -6,16 +6,16 @@ class Application_Form_AddShowRR extends Zend_Form_SubForm
public function init()
{
// Add record element
$this->addElement('checkbox', 'add_show_record', array(
$this->addElement('checkbox', 'add_show_record', array(
'label' => 'Record from Line In?',
'required' => false,
));
));
// Add record element
$this->addElement('checkbox', 'add_show_rebroadcast', array(
$this->addElement('checkbox', 'add_show_rebroadcast', array(
'label' => 'Rebroadcast?',
'required' => false,
));
));
}
public function disable(){

View File

@ -34,7 +34,7 @@ class Application_Form_AddShowRebroadcastDates extends Zend_Form_SubForm
$this->addElement($text);
}
}
public function disable(){
$elements = $this->getElements();
foreach ($elements as $element)

View File

@ -6,56 +6,56 @@ class Application_Form_AddShowRepeats extends Zend_Form_SubForm
public function init()
{
//Add type select
$this->addElement('select', 'add_show_repeat_type', array(
$this->addElement('select', 'add_show_repeat_type', array(
'required' => true,
'label' => 'Repeat Type:',
'class' => ' input_select',
'multiOptions' => array(
"0" => "weekly",
"0" => "weekly",
"1" => "bi-weekly",
"2" => "monthly"
),
));
// Add days checkboxes
$this->addElement(
$this->addElement(
'multiCheckbox',
'add_show_day_check',
array(
'label' => 'Select Days:',
'label' => 'Select Days:',
'required' => false,
'multiOptions' => array(
"0" => "Sun",
"1" => "Mon",
"2" => "Tue",
"3" => "Wed",
"4" => "Thu",
"5" => "Fri",
"6" => "Sat",
"0" => "Sun",
"1" => "Mon",
"2" => "Tue",
"3" => "Wed",
"4" => "Thu",
"5" => "Fri",
"6" => "Sat",
),
));
// Add end date element
// Add end date element
$this->addElement('text', 'add_show_end_date', array(
'label' => 'Date End:',
'class' => 'input_text',
'value' => date("Y-m-d"),
'required' => false,
'filters' => array('StringTrim'),
'validators' => array(
'NotEmpty',
array('date', false, array('YYYY-MM-DD'))
)
'validators' => array(
'NotEmpty',
array('date', false, array('YYYY-MM-DD'))
)
));
// Add no end element
$this->addElement('checkbox', 'add_show_no_end', array(
// Add no end element
$this->addElement('checkbox', 'add_show_no_end', array(
'label' => 'No End?',
'required' => false,
'checked' => true,
));
));
}
public function disable(){
$elements = $this->getElements();
foreach ($elements as $element)
@ -69,10 +69,10 @@ class Application_Form_AddShowRepeats extends Zend_Form_SubForm
public function checkReliantFields($formData) {
if (!$formData['add_show_no_end']){
if (!$formData['add_show_no_end']){
$start_timestamp = $formData['add_show_start_date'];
$end_timestamp = $formData['add_show_end_date'];
$start_epoch = strtotime($start_timestamp);
$end_epoch = strtotime($end_timestamp);

View File

@ -18,14 +18,14 @@ class Application_Form_AddShowStyle extends Zend_Form_SubForm
'viewScript' => 'form/add-show-style.phtml',
'class' => 'big'
))));
$bg->setValidators(array(
'Hex',
array('stringLength', false, array(6, 6))
));
// Add show color input
// Add show color input
$this->addElement('text', 'add_show_color', array(
'label' => 'Text Colour:',
'class' => 'input_text',
@ -38,7 +38,7 @@ class Application_Form_AddShowStyle extends Zend_Form_SubForm
'viewScript' => 'form/add-show-style.phtml',
'class' => 'big'
))));
$c->setValidators(array(
'Hex',
array('stringLength', false, array(6, 6))

View File

@ -4,22 +4,22 @@ class Application_Form_AddShowWhat extends Zend_Form_SubForm
{
public function init()
{
// retrieves the length limit for each char field
// and store to assoc array
$maxLens = Application_Model_Show::GetMaxLengths();
// retrieves the length limit for each char field
// and store to assoc array
$maxLens = Application_Model_Show::getMaxLengths();
// Hidden element to indicate whether the show is new or
// whether we are updating an existing show.
$this->addElement('hidden', 'add_show_id', array(
'decorators' => array('ViewHelper')
));
// Hidden element to indicate the instance id of the show
// being edited.
$this->addElement('hidden', 'add_show_instance_id', array(
'decorators' => array('ViewHelper')
));
// Add name element
$this->addElement('text', 'add_show_name', array(
'label' => 'Name:',
@ -27,8 +27,8 @@ class Application_Form_AddShowWhat extends Zend_Form_SubForm
'required' => true,
'filters' => array('StringTrim'),
'validators' => array('NotEmpty'),
'value' => 'Untitled Show',
'validators' => array(array('StringLength', false, array(0, $maxLens['name'])))
'value' => 'Untitled Show',
'validators' => array(array('StringLength', false, array(0, $maxLens['name'])))
));
// Add URL element
@ -46,16 +46,16 @@ class Application_Form_AddShowWhat extends Zend_Form_SubForm
'class' => 'input_text',
'required' => false,
'filters' => array('StringTrim'),
'validators' => array(array('StringLength', false, array(0, $maxLens['genre'])))
'validators' => array(array('StringLength', false, array(0, $maxLens['genre'])))
));
// Add the description element
// Add the description element
$this->addElement('textarea', 'add_show_description', array(
'label' => 'Description:',
'required' => false,
'class' => 'input_text_area',
'validators' => array(array('StringLength', false, array(0, $maxLens['description'])))
));
'validators' => array(array('StringLength', false, array(0, $maxLens['description'])))
));
$descText = $this->getElement('add_show_description');
@ -65,7 +65,7 @@ class Application_Form_AddShowWhat extends Zend_Form_SubForm
))));
}
public function disable(){
$elements = $this->getElements();
foreach ($elements as $element)

View File

@ -8,7 +8,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
$this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/add-show-when.phtml'))
));
// Add start date element
$startDate = new Zend_Form_Element_Text('add_show_start_date');
$startDate->class = 'input_text';
@ -22,7 +22,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
->setDecorators(array('ViewHelper'));
$startDate->setAttrib('alt', 'date');
$this->addElement($startDate);
// Add start time element
$startTime = new Zend_Form_Element_Text('add_show_start_time');
$startTime->class = 'input_text';
@ -50,7 +50,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
->setDecorators(array('ViewHelper'));
$endDate->setAttrib('alt', 'date');
$this->addElement($endDate);
// Add end time element
$endTime = new Zend_Form_Element_Text('add_show_end_time');
$endTime->class = 'input_text';
@ -64,7 +64,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
->setDecorators(array('ViewHelper'));
$endTime->setAttrib('alt', 'time');
$this->addElement($endTime);
// Add duration element
$this->addElement('text', 'add_show_duration', array(
'label' => 'Duration:',
@ -85,10 +85,13 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
public function checkReliantFields($formData, $validateStartDate, $originalStartDate=null, $update=false, $instanceId=null) {
$valid = true;
$hours;
$minutes;
$start_time = $formData['add_show_start_date']." ".$formData['add_show_start_time'];
$end_time = $formData['add_show_end_date_no_repeat']." ".$formData['add_show_end_time'];
//DateTime stores $start_time in the current timezone
$nowDateTime = new DateTime();
$showStartDateTime = new DateTime($start_time);
@ -109,15 +112,15 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
}
}
}
// if end time is in the past, return error
if($showEndDateTime->getTimestamp() < $nowDateTime->getTimestamp()) {
$this->getElement('add_show_end_time')->setErrors(array('End date/time cannot be in the past'));
$valid = false;
}
$pattern = '/([0-9][0-9])h ([0-9][0-9])m/';
if (preg_match($pattern, $formData['add_show_duration'], $matches) && count($matches) == 3) {
$hours = $matches[1];
$minutes = $matches[2];
@ -147,17 +150,119 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
$show_start->setTimezone(new DateTimeZone('UTC'));
$show_end = new DateTime($end_time);
$show_end->setTimezone(new DateTimeZone('UTC'));
$overlapping = Application_Model_Schedule::checkOverlappingShows($show_start, $show_end, $update, $instanceId);
if ($overlapping) {
$this->getElement('add_show_duration')->setErrors(array('Cannot schedule overlapping shows'));
$valid = false;
if ($formData["add_show_repeats"]) {
//get repeating show end date
if ($formData["add_show_no_end"]) {
$date = Application_Model_Preference::GetShowsPopulatedUntil();
if (is_null($date)) {
$populateUntilDateTime = new DateTime("now", new DateTimeZone('UTC'));
Application_Model_Preference::SetShowsPopulatedUntil($populateUntilDateTime);
} else {
$populateUntilDateTime = clone $date;
}
} elseif (!$formData["add_show_no_end"]) {
$popUntil = $formData["add_show_end_date"]." ".$formData["add_show_end_time"];
$populateUntilDateTime = new DateTime($popUntil, new DateTimeZone('UTC'));
}
//get repeat interval
if ($formData["add_show_repeat_type"] == 0) {
$interval = 'P7D';
} elseif ($formData["add_show_repeat_type"] == 1) {
$interval = 'P14D';
} elseif ($formData["add_show_repeat_type"] == 2) {
$interval = 'P1M';
}
/* Check first show
* Continue if the first show does not overlap
*/
$overlapping = Application_Model_Schedule::checkOverlappingShows($show_start, $show_end, $update, $instanceId);
/* Check if repeats overlap with previously scheduled shows
* Do this for each show day
*/
if (!$overlapping) {
$startDow = date("w", $show_start->getTimestamp());
foreach($formData["add_show_day_check"] as $day) {
$repeatShowStart = clone $show_start;
$repeatShowEnd = clone $show_end;
$daysAdd=0;
if ($startDow !== $day){
if ($startDow > $day)
$daysAdd = 6 - $startDow + 1 + $day;
else
$daysAdd = $day - $startDow;
$repeatShowStart->add(new DateInterval("P".$daysAdd."D"));
$repeatShowEnd->add(new DateInterval("P".$daysAdd."D"));
}
while ($repeatShowStart->getTimestamp() < $populateUntilDateTime->getTimestamp()) {
$overlapping = Application_Model_Schedule::checkOverlappingShows($repeatShowStart, $repeatShowEnd, $update, $instanceId);
if ($overlapping) {
$valid = false;
$this->getElement('add_show_duration')->setErrors(array('Cannot schedule overlapping shows'));
break 1;
} else {
$repeatShowStart->add(new DateInterval($interval));
$repeatShowEnd->add(new DateInterval($interval));
}
}
}
} else {
$valid = false;
$this->getElement('add_show_duration')->setErrors(array('Cannot schedule overlapping shows'));
}
} elseif ($formData["add_show_rebroadcast"]) {
/* Check first show
* Continue if the first show does not overlap
*/
$overlapping = Application_Model_Schedule::checkOverlappingShows($show_start, $show_end, $update, $instanceId);
if (!$overlapping) {
for ($i = 1; $i <= 10; $i++) {
$hours = ltrim($hours, '0');
if ($minutes != "00") {
$minutes = ltrim($minutes, '0');
$durationToAdd = "PT".$hours."H".$minutes."I";
} else {
$minutes = "0";
$durationToAdd = "PT".$hours."H";
}
$abs_rebroadcast_start = $formData["add_show_rebroadcast_date_absolute_".$i]." ".
$formData["add_show_rebroadcast_time_absolute_".$i];
$rebroadcastShowStart = new DateTime($abs_rebroadcast_start);
$rebroadcastShowStart->setTimezone(new DateTimeZone('UTC'));
$rebroadcastShowEnd = clone $rebroadcastShowStart;
$rebroadcastShowEnd->add(new DateInterval($durationToAdd));
$overlapping = Application_Model_Schedule::checkOverlappingShows($rebroadcastShowStart, $rebroadcastShowEnd, $update, $instanceId);
if ($overlapping) {
$valid = false;
$this->getElement('add_show_duration')->setErrors(array('Cannot schedule overlapping shows'));
break;
}
}
} else {
$valid = false;
$this->getElement('add_show_duration')->setErrors(array('Cannot schedule overlapping shows'));
}
} else {
$overlapping = Application_Model_Schedule::checkOverlappingShows($show_start, $show_end, $update, $instanceId);
if ($overlapping) {
$this->getElement('add_show_duration')->setErrors(array('Cannot schedule overlapping shows'));
$valid = false;
}
}
}
return $valid;
}
public function disable(){
$elements = $this->getElements();
foreach ($elements as $element)
@ -168,7 +273,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
}
}
}
public function disableRepeatCheckbox(){
$element = $this->getElement('add_show_repeats');
if ($element->getType() != 'Zend_Form_Element_Hidden')
@ -176,7 +281,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
$element->setAttrib('disabled','disabled');
}
}
public function disableStartDateAndTime(){
$elements = array($this->getElement('add_show_start_date'), $this->getElement('add_show_start_time'));
foreach ($elements as $element)

View File

@ -10,21 +10,21 @@ class Application_Form_AddShowWho extends Zend_Form_SubForm
'label' => 'Search Users:',
'class' => 'input_text ui-autocomplete-input',
'required' => false
));
));
$options = array();
$hosts = Application_Model_User::getHosts();
$options = array();
$hosts = Application_Model_User::getHosts();
foreach ($hosts as $host) {
$options[$host['index']] = $host['label'];
}
foreach ($hosts as $host) {
$options[$host['index']] = $host['label'];
}
//Add hosts selection
$hosts = new Zend_Form_Element_MultiCheckbox('add_show_hosts');
$hosts->setLabel('DJs:')
->setMultiOptions($options);
//Add hosts selection
$hosts = new Zend_Form_Element_MultiCheckbox('add_show_hosts');
$hosts->setLabel('DJs:')
->setMultiOptions($options);
$this->addElement($hosts);
$this->addElement($hosts);
}
public function disable(){

View File

@ -10,11 +10,11 @@ class Application_Form_AddUser extends Zend_Form
'../application/validate',
'validate');
* */
$hidden = new Zend_Form_Element_Hidden('user_id');
$hidden->setDecorators(array('ViewHelper'));
$this->addElement($hidden);
$login = new Zend_Form_Element_Text('login');
$login->setLabel('Username:');
$login->setAttrib('class', 'input_text');
@ -22,7 +22,7 @@ class Application_Form_AddUser extends Zend_Form
$login->addFilter('StringTrim');
//$login->addValidator('UserNameValidate');
$this->addElement($login);
$password = new Zend_Form_Element_Password('password');
$password->setLabel('Password:');
$password->setAttrib('class', 'input_text');
@ -30,21 +30,21 @@ class Application_Form_AddUser extends Zend_Form
$password->addFilter('StringTrim');
$password->addValidator('NotEmpty');
$this->addElement($password);
$firstName = new Zend_Form_Element_Text('first_name');
$firstName->setLabel('Firstname:');
$firstName->setAttrib('class', 'input_text');
$firstName->addFilter('StringTrim');
$firstName->addValidator('NotEmpty');
$this->addElement($firstName);
$lastName = new Zend_Form_Element_Text('last_name');
$lastName->setLabel('Lastname:');
$lastName->setAttrib('class', 'input_text');
$lastName->addFilter('StringTrim');
$lastName->addValidator('NotEmpty');
$this->addElement($lastName);
$email = new Zend_Form_Element_Text('email');
$email->setLabel('Email:');
$email->setAttrib('class', 'input_text');
@ -52,7 +52,7 @@ class Application_Form_AddUser extends Zend_Form
$email->setRequired(true);
$email->addValidator('EmailAddress');
$this->addElement($email);
$cellPhone = new Zend_Form_Element_Text('cell_phone');
$cellPhone->setLabel('Mobile Phone:');
$cellPhone->setAttrib('class', 'input_text');
@ -79,30 +79,30 @@ class Application_Form_AddUser extends Zend_Form
$select->setMultiOptions(array(
"G" => "Guest",
"H" => "DJ",
"P" => "Program Manager",
"P" => "Program Manager",
"A" => "Admin"
));
$select->setRequired(true);
$this->addElement($select);
$submit = new Zend_Form_Element_Submit('submit');
$submit->setAttrib('class', 'ui-button ui-state-default right-floated');
$submit->setIgnore(true);
$submit->setLabel('Save');
$this->addElement($submit);
}
public function validateLogin($data){
if (strlen($data['user_id']) == 0){
$count = CcSubjsQuery::create()->filterByDbLogin($data['login'])->count();
if ($count != 0){
$this->getElement('login')->setErrors(array("Login name is not unique."));
return false;
}
}
return true;
}
}

View File

@ -7,21 +7,21 @@ class Application_Form_EditAudioMD extends Zend_Form
// Set the method for the display form to POST
$this->setMethod('post');
// Add title field
// Add title field
$this->addElement('text', 'track_title', array(
'label' => 'Title:',
'class' => 'input_text',
'filters' => array('StringTrim'),
));
// Add artist field
// Add artist field
$this->addElement('text', 'artist_name', array(
'label' => 'Creator:',
'class' => 'input_text',
'filters' => array('StringTrim'),
));
// Add album field
// Add album field
$this->addElement('text', 'album_title', array(
'label' => 'Album:',
'class' => 'input_text',
@ -37,39 +37,39 @@ class Application_Form_EditAudioMD extends Zend_Form
'required' => true
));
// Add genre field
// Add genre field
$this->addElement('text', 'genre', array(
'label' => 'Genre:',
'class' => 'input_text',
'filters' => array('StringTrim')
));
// Add year field
// Add year field
$this->addElement('text', 'year', array(
'label' => 'Year:',
'class' => 'input_text',
'filters' => array('StringTrim'),
'validators' => array(
array('date', false, array('YYYY-MM-DD')),
array('date', false, array('YYYY-MM-DD')),
array('date', false, array('YYYY-MM')),
array('date', false, array('YYYY'))
)
array('date', false, array('YYYY'))
)
));
// Add label field
// Add label field
$this->addElement('text', 'label', array(
'label' => 'Label:',
'class' => 'input_text',
'filters' => array('StringTrim')
));
// Add composer field
// Add composer field
$this->addElement('text', 'composer', array(
'label' => 'Composer:',
'class' => 'input_text',
'filters' => array('StringTrim')
));
// Add conductor field
$this->addElement('text', 'conductor', array(
'label' => 'Conductor:',
@ -77,7 +77,7 @@ class Application_Form_EditAudioMD extends Zend_Form
'filters' => array('StringTrim')
));
// Add mood field
// Add mood field
$this->addElement('text', 'mood', array(
'label' => 'Mood:',
'class' => 'input_text',
@ -122,7 +122,7 @@ class Application_Form_EditAudioMD extends Zend_Form
'filters' => array('StringTrim')
));
// Add the submit button
// Add the submit button
$this->addElement('submit', 'submit', array(
'ignore' => true,
'class' => 'ui-button ui-state-default',
@ -132,7 +132,7 @@ class Application_Form_EditAudioMD extends Zend_Form
)
));
// Add the submit button
// Add the submit button
$this->addElement('button', 'cancel', array(
'ignore' => true,
'class' => 'ui-button ui-state-default ui-button-text-only md-cancel',

View File

@ -9,8 +9,8 @@ class Application_Form_EmailServerPreferences extends Zend_Form_SubForm
public function init()
{
$isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true;
$this->isSaas = $isSaas;
$this->isSaas = $isSaas;
$this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/preferences_email_server.phtml', "isSaas" => $isSaas))
));
@ -24,7 +24,7 @@ class Application_Form_EmailServerPreferences extends Zend_Form_SubForm
'ViewHelper'
)
));
$this->addElement('text', 'systemEmail', array(
'class' => 'input_text',
'label' => 'Reset Password \'From\' Email',
@ -32,7 +32,7 @@ class Application_Form_EmailServerPreferences extends Zend_Form_SubForm
'readonly' => true,
'decorators' => array('viewHelper')
));
$this->addElement('checkbox', 'configureMailServer', array(
'label' => 'Configure Mail Server',
'required' => false,
@ -41,7 +41,7 @@ class Application_Form_EmailServerPreferences extends Zend_Form_SubForm
'viewHelper'
)
));
$this->addElement('text', 'mailServer', array(
'class' => 'input_text',
'label' => 'Mail Server',
@ -53,7 +53,7 @@ class Application_Form_EmailServerPreferences extends Zend_Form_SubForm
new ConditionalNotEmpty(array('configureMailServer'=>'1'))
)
));
$this->addElement('text', 'email', array(
'class' => 'input_text',
'label' => 'Email Address',
@ -65,7 +65,7 @@ class Application_Form_EmailServerPreferences extends Zend_Form_SubForm
new ConditionalNotEmpty(array('configureMailServer'=>'1'))
)
));
$this->addElement('password', 'ms_password', array(
'class' => 'input_text',
'label' => 'Password',
@ -78,7 +78,7 @@ class Application_Form_EmailServerPreferences extends Zend_Form_SubForm
),
'renderPassword' => true
));
$port = new Zend_Form_Element_Text('port');
$port->class = 'input_text';
$port->setRequired(false)
@ -86,7 +86,7 @@ class Application_Form_EmailServerPreferences extends Zend_Form_SubForm
->setLabel('Port')
->setAttrib('readonly', true)
->setDecorators(array('viewHelper'));
$this->addElement($port);
}

View File

@ -2,13 +2,13 @@
class Application_Form_GeneralPreferences extends Zend_Form_SubForm
{
private $isSaas;
private $isSaas;
public function init()
{
$isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true;
$this->isSaas = $isSaas;
$this->isSaas = $isSaas;
$this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/preferences_general.phtml', "isSaas" => $isSaas))
));
@ -24,7 +24,7 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
'label' => 'Station Name',
'required' => false,
'filters' => array('StringTrim'),
'value' => Application_Model_Preference::GetValue("station_name"),
'value' => Application_Model_Preference::getValue("station_name"),
'decorators' => array(
'ViewHelper'
)
@ -98,16 +98,16 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
private function getWeekStartDays() {
$days = array(
'Sunday',
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday'
);
return $days;
$days = array(
'Sunday',
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday'
);
return $days;
}
}

View File

@ -2,33 +2,33 @@
class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
{
public function init()
{
global $CC_CONFIG;
$isDemo = isset($CC_CONFIG['demo']) && $CC_CONFIG['demo'] == 1;
$isStreamConfigable = Application_Model_Preference::GetEnableStreamConf() == "true";
$isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true;
$defaultFade = Application_Model_Preference::GetDefaultTransitionFade();
if($defaultFade == ""){
$defaultFade = '00.000000';
}
// automatic trasition on source disconnection
$auto_transition = new Zend_Form_Element_Checkbox("auto_transition");
$auto_transition->setLabel("Auto Switch Off")
->setValue(Application_Model_Preference::GetAutoTransition())
->setDecorators(array('ViewHelper'));
$this->addElement($auto_transition);
// automatic switch on upon source connection
$auto_switch = new Zend_Form_Element_Checkbox("auto_switch");
$auto_switch->setLabel("Auto Switch On")
->setValue(Application_Model_Preference::GetAutoSwitch())
->setDecorators(array('ViewHelper'));
$this->addElement($auto_switch);
// Default transition fade
$transition_fade = new Zend_Form_Element_Text("transition_fade");
$transition_fade->setLabel("Switch Transition Fade (s)")
@ -38,7 +38,7 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
->setValue($defaultFade)
->setDecorators(array('ViewHelper'));
$this->addElement($transition_fade);
//Master username
$master_username = new Zend_Form_Element_Text('master_username');
$master_username->setAttrib('autocomplete', 'off')
@ -48,7 +48,7 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
->setValue(Application_Model_Preference::GetLiveSteamMasterUsername())
->setDecorators(array('ViewHelper'));
$this->addElement($master_username);
//Master password
if($isDemo){
$master_password = new Zend_Form_Element_Text('master_password');
@ -64,7 +64,7 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
->setFilters(array('StringTrim'))
->setDecorators(array('ViewHelper'));
$this->addElement($master_password);
//Master source connection url
$master_dj_connection_url = new Zend_Form_Element_Text('master_dj_connection_url');
$master_dj_connection_url->setAttrib('readonly', true)
@ -72,7 +72,7 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
->setValue(Application_Model_Preference::GetMasterDJSourceConnectionURL())
->setDecorators(array('ViewHelper'));
$this->addElement($master_dj_connection_url);
//Show source connection url
$live_dj_connection_url = new Zend_Form_Element_Text('live_dj_connection_url');
$live_dj_connection_url->setAttrib('readonly', true)
@ -80,10 +80,10 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
->setValue(Application_Model_Preference::GetLiveDJSourceConnectionURL())
->setDecorators(array('ViewHelper'));
$this->addElement($live_dj_connection_url);
//liquidsoap harbor.input port
if (!$isSaas) {
$m_port = Application_Model_StreamSetting::GetMasterLiveSteamPort();
$m_port = Application_Model_StreamSetting::getMasterLiveStreamPort();
$master_dj_port = new Zend_Form_Element_Text('master_harbor_input_port');
$master_dj_port->setLabel("Master Source Port")
->setValue($m_port)
@ -91,8 +91,8 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
->addValidator('regex', false, array('pattern'=>'/^[0-9]+$/', 'messages'=>array('regexNotMatch'=>'Only numbers are allowed.')))
->setDecorators(array('ViewHelper'));
$this->addElement($master_dj_port);
$m_mount = Application_Model_StreamSetting::GetMasterLiveSteamMountPoint();
$m_mount = Application_Model_StreamSetting::getMasterLiveStreamMountPoint();
$master_dj_mount = new Zend_Form_Element_Text('master_harbor_input_mount_point');
$master_dj_mount->setLabel("Master Source Mount Point")
->setValue($m_mount)
@ -100,9 +100,9 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
array('regex', false, array('/^[^ &<>]+$/', 'messages' => 'Invalid character entered'))))
->setDecorators(array('ViewHelper'));
$this->addElement($master_dj_mount);
//liquidsoap harbor.input port
$l_port = Application_Model_StreamSetting::GetDJLiveSteamPort();
$l_port = Application_Model_StreamSetting::getDjLiveStreamPort();
$live_dj_port = new Zend_Form_Element_Text('dj_harbor_input_port');
$live_dj_port->setLabel("Show Source Port")
->setValue($l_port)
@ -110,8 +110,8 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
->addValidator('regex', false, array('pattern'=>'/^[0-9]+$/', 'messages'=>array('regexNotMatch'=>'Only numbers are allowed.')))
->setDecorators(array('ViewHelper'));
$this->addElement($live_dj_port);
$l_mount = Application_Model_StreamSetting::GetDJLiveSteamMountPoint();
$l_mount = Application_Model_StreamSetting::getDjLiveStreamMountPoint();
$live_dj_mount = new Zend_Form_Element_Text('dj_harbor_input_mount_point');
$live_dj_mount->setLabel("Show Source Mount Point")
->setValue($l_mount)
@ -132,34 +132,34 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
}
}
}
public function updateVariables(){
global $CC_CONFIG;
$isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true;
$isDemo = isset($CC_CONFIG['demo']) && $CC_CONFIG['demo'] == 1;
$master_dj_connection_url = Application_Model_Preference::GetMasterDJSourceConnectionURL();
$live_dj_connection_url = Application_Model_Preference::GetLiveDJSourceConnectionURL();
$this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/preferences_livestream.phtml', 'master_dj_connection_url'=>$master_dj_connection_url, 'live_dj_connection_url'=>$live_dj_connection_url, 'isSaas' => $isSaas, 'isDemo' => $isDemo))
));
}
public function isValid($data){
$isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true;
$isValid = parent::isValid($data);
if (!$isSaas) {
$master_harbor_input_port = $data['master_harbor_input_port'];
$dj_harbor_input_port = $data['dj_harbor_input_port'];
if($master_harbor_input_port == $dj_harbor_input_port && $master_harbor_input_port != ""){
$element = $this->getElement("dj_harbor_input_port");
$element->addError("You cannot use same port as Master DJ port.");
}
if($master_harbor_input_port != ""){
if(is_numeric($master_harbor_input_port)){
if($master_harbor_input_port != Application_Model_StreamSetting::GetMasterLiveSteamPort()){
if($master_harbor_input_port != Application_Model_StreamSetting::getMasterLiveStreamPort()){
$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
$res = socket_bind($sock, 0, $master_harbor_input_port);
if(!$res){
@ -175,7 +175,7 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
}
if($dj_harbor_input_port != ""){
if(is_numeric($dj_harbor_input_port)){
if($dj_harbor_input_port != Application_Model_StreamSetting::GetDJLiveSteamPort()){
if($dj_harbor_input_port != Application_Model_StreamSetting::getDjLiveStreamPort()){
$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
$res = socket_bind($sock, 0, $dj_harbor_input_port);
if(!$res){
@ -192,5 +192,5 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
}
return $isValid;
}
}

View File

@ -4,17 +4,17 @@ class Application_Form_Login extends Zend_Form
{
public function init()
{
{
global $CC_CONFIG;
// Set the method for the display form to POST
// Set the method for the display form to POST
$this->setMethod('post');
$this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/login.phtml'))
));
// Add username element
// Add username element
$this->addElement('text', 'username', array(
'label' => 'Username:',
'class' => 'input_text',
@ -28,8 +28,8 @@ class Application_Form_Login extends Zend_Form
'ViewHelper'
)
));
// Add password element
// Add password element
$this->addElement('password', 'password', array(
'label' => 'Password:',
'class' => 'input_text',
@ -43,7 +43,7 @@ class Application_Form_Login extends Zend_Form
'ViewHelper'
)
));
$recaptchaNeeded = false;
if(Application_Model_LoginAttempts::getAttempts($_SERVER['REMOTE_ADDR']) >= 3){
$recaptchaNeeded = true;
@ -52,8 +52,8 @@ class Application_Form_Login extends Zend_Form
// recaptcha
$this->addRecaptcha();
}
// Add the submit button
// Add the submit button
$this->addElement('submit', 'submit', array(
'ignore' => true,
'label' => 'Login',
@ -64,13 +64,13 @@ class Application_Form_Login extends Zend_Form
));
}
public function addRecaptcha(){
$pubKey = '6Ld4JsISAAAAAIxUKT4IjjOGi3DHqdoH2zk6WkYG';
$privKey = '6Ld4JsISAAAAAJynYlXdrE4hfTReTSxYFe5szdyv';
$recaptcha = new Zend_Service_ReCaptcha($pubKey, $privKey);
$captcha = new Zend_Form_Element_Captcha('captcha',
array(
'label' => 'Type the characters you see in the picture below.',

View File

@ -9,7 +9,7 @@ class Application_Form_PasswordChange extends Zend_Form
$this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/password-change.phtml'))
));
$this->addElement('password', 'password', array(
'label' => 'Password',
'required' => true,

View File

@ -9,7 +9,7 @@ class Application_Form_PasswordRestore extends Zend_Form
$this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/password-restore.phtml'))
));
$this->addElement('text', 'email', array(
'label' => 'E-mail',
'required' => true,
@ -29,7 +29,7 @@ class Application_Form_PasswordRestore extends Zend_Form
'ViewHelper'
)
));
$cancel = new Zend_Form_Element_Button("cancel");
$cancel->class = 'ui-button ui-widget ui-state-default ui-button-text-only center';
$cancel->setLabel("Cancel")

View File

@ -8,22 +8,22 @@ class Application_Form_Preferences extends Zend_Form
{
$this->setAction('/Preference');
$this->setMethod('post');
$isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true;
$this->isSaas = $isSaas;
$this->isSaas = $isSaas;
$this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/preferences.phtml', "isSaas" => $this->isSaas))
));
$general_pref = new Application_Form_GeneralPreferences();
$this->addSubForm($general_pref, 'preferences_general');
if (!$isSaas) {
$email_pref = new Application_Form_EmailServerPreferences();
$this->addSubForm($email_pref, 'preferences_email_server');
}
$soundcloud_pref = new Application_Form_SoundcloudPreferences();
$this->addSubForm($soundcloud_pref, 'preferences_soundcloud');

View File

@ -9,19 +9,19 @@ class Application_Form_RegisterAirtime extends Zend_Form
{
$this->setAction('/Showbuilder');
$this->setMethod('post');
$country_list = Application_Model_Preference::GetCountryList();
$privacyChecked = false;
if(Application_Model_Preference::GetPrivacyPolicyCheck() == 1){
$privacyChecked = true;
}
$this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/register-dialog.phtml', 'privacyChecked'=>$privacyChecked)),
array('File', array('viewScript' => 'form/register-dialog.phtml', 'placement' => false)))
);
// Station Name
$stnName = new Zend_Form_Element_Text("stnName");
$stnName->setLabel("Station Name")
@ -29,7 +29,7 @@ class Application_Form_RegisterAirtime extends Zend_Form
->setValue(Application_Model_Preference::GetStationName())
->setDecorators(array('ViewHelper'));
$this->addElement($stnName);
// Phone number
$this->addElement('text', 'Phone', array(
'class' => 'input_text',
@ -63,20 +63,20 @@ class Application_Form_RegisterAirtime extends Zend_Form
'decorators' => array(
'ViewHelper'
)
));
));
// county list dropdown
$this->addElement('select', 'Country', array(
'label' => 'Country:',
'required' => false,
'value' => Application_Model_Preference::GetStationCountry(),
'multiOptions' => $country_list,
'decorators' => array(
// county list dropdown
$this->addElement('select', 'Country', array(
'label' => 'Country:',
'required' => false,
'value' => Application_Model_Preference::GetStationCountry(),
'multiOptions' => $country_list,
'decorators' => array(
'ViewHelper'
)
));
// Station city
));
// Station city
$this->addElement('text', 'City', array(
'label' => 'City:',
'required' => false,
@ -85,29 +85,29 @@ class Application_Form_RegisterAirtime extends Zend_Form
'decorators' => array(
'ViewHelper'
)
));
// Station Description
$description = new Zend_Form_Element_Textarea('Description');
$description->class = 'input_text_area';
$description->setLabel('Station Description:')
->setRequired(false)
->setValue(Application_Model_Preference::GetStationDescription())
->setDecorators(array('ViewHelper'))
->setAttrib('ROWS','2')
->setAttrib('COLS','58');
$this->addElement($description);
// Station Logo
$upload = new Zend_Form_Element_File('Logo');
$upload->setLabel('Station Logo:')
->setRequired(false)
->setDecorators(array('File'))
->addValidator('Count', false, 1)
->addValidator('Extension', false, 'jpg,jpeg,png,gif')
->addFilter('ImageSize');
$this->addElement($upload);
));
// Station Description
$description = new Zend_Form_Element_Textarea('Description');
$description->class = 'input_text_area';
$description->setLabel('Station Description:')
->setRequired(false)
->setValue(Application_Model_Preference::GetStationDescription())
->setDecorators(array('ViewHelper'))
->setAttrib('ROWS','2')
->setAttrib('COLS','58');
$this->addElement($description);
// Station Logo
$upload = new Zend_Form_Element_File('Logo');
$upload->setLabel('Station Logo:')
->setRequired(false)
->setDecorators(array('File'))
->addValidator('Count', false, 1)
->addValidator('Extension', false, 'jpg,jpeg,png,gif')
->addFilter('ImageSize');
$this->addElement($upload);
//enable support feedback
$this->addElement('checkbox', 'SupportFeedback', array(
'label' => 'Send support feedback',
@ -116,37 +116,37 @@ class Application_Form_RegisterAirtime extends Zend_Form
'decorators' => array(
'ViewHelper'
)
));
));
// checkbox for publicise
$checkboxPublicise = new Zend_Form_Element_Checkbox("Publicise");
// checkbox for publicise
$checkboxPublicise = new Zend_Form_Element_Checkbox("Publicise");
$checkboxPublicise->setLabel('Promote my station on Sourcefabric.org')
->setRequired(false)
->setDecorators(array('ViewHelper'))
->setValue(Application_Model_Preference::GetPublicise());
$this->addElement($checkboxPublicise);
// text area for sending detail
// text area for sending detail
$this->addElement('textarea', 'SendInfo', array(
'class' => 'sending_textarea',
'required' => false,
'class' => 'sending_textarea',
'required' => false,
'filters' => array('StringTrim'),
'readonly' => true,
'rows' => 5,
'readonly' => true,
'rows' => 5,
'cols' => 61,
'value' => Application_Model_Preference::GetSystemInfo(false, true),
'decorators' => array(
'ViewHelper'
)
));
// checkbox for privacy policy
$checkboxPrivacy = new Zend_Form_Element_Checkbox("Privacy");
$checkboxPrivacy->setLabel("By checking this box, I agree to Sourcefabric's <a id=\"link_to_privacy\" href=\"http://www.sourcefabric.org/en/about/policy/\" onclick=\"window.open(this.href); return false;\">privacy policy</a>.")
->setDecorators(array('ViewHelper'));
$this->addElement($checkboxPrivacy);
}
// overriding isValid function
public function isValid ($data)
{

View File

@ -5,7 +5,7 @@ class Application_Form_ShowBuilder extends Zend_Form_SubForm
public function init()
{
$user = Application_Model_User::GetCurrentUser();
$user = Application_Model_User::getCurrentUser();
$this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/showbuilder.phtml'))

View File

@ -30,7 +30,7 @@ class Application_Form_SoundcloudPreferences extends Zend_Form_SubForm
'ViewHelper'
)
));
//enable downloadable for soundcloud
$this->addElement('checkbox', 'SoundCloudDownloadbleOption', array(
'label' => 'Automatically Mark Files "Downloadable" on SoundCloud',
@ -51,7 +51,7 @@ class Application_Form_SoundcloudPreferences extends Zend_Form_SubForm
'decorators' => array(
'ViewHelper'
),
// By default, 'allowEmpty' is true. This means that our custom
// validators are going to be skipped if this field is empty,
// which is something we don't want
@ -71,7 +71,7 @@ class Application_Form_SoundcloudPreferences extends Zend_Form_SubForm
'decorators' => array(
'ViewHelper'
),
// By default, 'allowEmpty' is true. This means that our custom
// validators are going to be skipped if this field is empty,
// which is something we don't want
@ -79,7 +79,7 @@ class Application_Form_SoundcloudPreferences extends Zend_Form_SubForm
'validators' => array(
new ConditionalNotEmpty(array('UploadToSoundcloudOption'=>'1'))
),
'renderPassword' => true
'renderPassword' => true
));
// Add the description element
@ -91,7 +91,7 @@ class Application_Form_SoundcloudPreferences extends Zend_Form_SubForm
'decorators' => array(
'ViewHelper'
)
));
));
//SoundCloud default genre
$this->addElement('text', 'SoundCloudGenre', array(

View File

@ -37,7 +37,7 @@ class Application_Form_StreamSetting extends Zend_Form
}
$this->addElement($output_type);
}
$icecast_vorbis_metadata = new Zend_Form_Element_Checkbox('icecast_vorbis_metadata');
$icecast_vorbis_metadata->setLabel('Icecast Vorbis Metadata')
->setRequired(false)

View File

@ -177,9 +177,9 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
}
$user->setAttrib('alt', 'regular_text');
$this->addElement($user);
$liquidsopa_error_msg = '<div class="stream-status status-info"><h3>Getting information from the server...</h3></div>';
$this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/stream-setting-form.phtml', "stream_number"=>$stream_number, "enabled"=>$enable->getValue(), "liquidsoap_error_msg"=>$liquidsopa_error_msg))
));

View File

@ -5,18 +5,18 @@ require_once 'customfilters/ImageSize.php';
class Application_Form_SupportSettings extends Zend_Form
{
private $isSass;
public function init()
{
$country_list = Application_Model_Preference::GetCountryList();
$isSass = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true;
$this->isSass = $isSass;
$this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/support-setting.phtml', "isSaas" => $isSass)),
array('File', array('viewScript' => 'form/support-setting.phtml', 'placement' => false)))
);
//Station name
$this->addElement('text', 'stationName', array(
'class' => 'input_text',
@ -24,7 +24,7 @@ class Application_Form_SupportSettings extends Zend_Form
'required' => true,
'filters' => array('StringTrim'),
'validator' => array('NotEmpty'),
'value' => Application_Model_Preference::GetValue("station_name"),
'value' => Application_Model_Preference::getValue("station_name"),
'decorators' => array(
'ViewHelper'
)
@ -63,20 +63,20 @@ class Application_Form_SupportSettings extends Zend_Form
'decorators' => array(
'ViewHelper'
)
));
));
// county list dropdown
$this->addElement('select', 'Country', array(
'label' => 'Country:',
'required' => false,
'value' => Application_Model_Preference::GetStationCountry(),
'multiOptions' => $country_list,
'decorators' => array(
// county list dropdown
$this->addElement('select', 'Country', array(
'label' => 'Country:',
'required' => false,
'value' => Application_Model_Preference::GetStationCountry(),
'multiOptions' => $country_list,
'decorators' => array(
'ViewHelper'
)
));
// Station city
));
// Station city
$this->addElement('text', 'City', array(
'label' => 'City:',
'required' => false,
@ -85,31 +85,31 @@ class Application_Form_SupportSettings extends Zend_Form
'decorators' => array(
'ViewHelper'
)
));
// Station Description
$description = new Zend_Form_Element_Textarea('Description');
$description->class = 'input_text_area';
$description->setLabel('Station Description:')
->setRequired(false)
->setValue(Application_Model_Preference::GetStationDescription())
->setDecorators(array('ViewHelper'))
->setAttrib('ROWS','2')
->setAttrib('COLS','58');
$this->addElement($description);
// Station Logo
$upload = new Zend_Form_Element_File('Logo');
$upload->setLabel('Station Logo:')
->setRequired(false)
->setDecorators(array('File'))
->addValidator('Count', false, 1)
->addValidator('Extension', false, 'jpg,jpeg,png,gif')
->addFilter('ImageSize');
$upload->setAttrib('accept', 'image/*');
$this->addElement($upload);
if(!$isSass){
));
// Station Description
$description = new Zend_Form_Element_Textarea('Description');
$description->class = 'input_text_area';
$description->setLabel('Station Description:')
->setRequired(false)
->setValue(Application_Model_Preference::GetStationDescription())
->setDecorators(array('ViewHelper'))
->setAttrib('ROWS','2')
->setAttrib('COLS','58');
$this->addElement($description);
// Station Logo
$upload = new Zend_Form_Element_File('Logo');
$upload->setLabel('Station Logo:')
->setRequired(false)
->setDecorators(array('File'))
->addValidator('Count', false, 1)
->addValidator('Extension', false, 'jpg,jpeg,png,gif')
->addFilter('ImageSize');
$upload->setAttrib('accept', 'image/*');
$this->addElement($upload);
if(!$isSass){
//enable support feedback
$this->addElement('checkbox', 'SupportFeedback', array(
'label' => 'Send support feedback',
@ -118,9 +118,9 @@ class Application_Form_SupportSettings extends Zend_Form
'decorators' => array(
'ViewHelper'
)
));
// checkbox for publicise
));
// checkbox for publicise
$checkboxPublicise = new Zend_Form_Element_Checkbox("Publicise");
$checkboxPublicise->setLabel('Promote my station on Sourcefabric.org')
->setRequired(false)
@ -130,28 +130,28 @@ class Application_Form_SupportSettings extends Zend_Form
$checkboxPublicise->setAttrib("disabled", "disabled");
}
$this->addElement($checkboxPublicise);
// text area for sending detail
// text area for sending detail
$this->addElement('textarea', 'SendInfo', array(
'class' => 'sending_textarea',
'required' => false,
'class' => 'sending_textarea',
'required' => false,
'filters' => array('StringTrim'),
'readonly' => true,
'cols' => 61,
'rows' => 5,
'readonly' => true,
'cols' => 61,
'rows' => 5,
'value' => Application_Model_Preference::GetSystemInfo(false, true),
'decorators' => array(
'ViewHelper'
)
));
// checkbox for privacy policy
$checkboxPrivacy = new Zend_Form_Element_Checkbox("Privacy");
$checkboxPrivacy->setLabel("By checking this box, I agree to Sourcefabric's <a id=\"link_to_privacy\" href=\"http://www.sourcefabric.org/en/about/policy/\" onclick=\"window.open(this.href); return false;\">privacy policy</a>.")
->setDecorators(array('ViewHelper'));
$this->addElement($checkboxPrivacy);
}
// submit button
$submit = new Zend_Form_Element_Submit("submit");
$submit->class = 'ui-button ui-state-default right-floated';
@ -160,7 +160,7 @@ class Application_Form_SupportSettings extends Zend_Form
->setDecorators(array('ViewHelper'));
$this->addElement($submit);
}
// overriding isValid function
public function isValid ($data)
{

View File

@ -16,7 +16,7 @@ class Zend_Filter_ImageSize implements Zend_Filter_Interface {
$origWidth = imagesx($image);
$origHeight = imagesy($image);
$ratio = max($origWidth, $origHeight) / 600;
if ($ratio > 1) {
// img too big! create a scaled down image
$newWidth = round($origWidth / $ratio);
@ -34,7 +34,7 @@ class Zend_Filter_ImageSize implements Zend_Filter_Interface {
$writeFunc($resized, $value);
}
}
return $value;
}
}

View File

@ -4,34 +4,34 @@
* Check if a field is empty but only when specific fields have specific values
*/
class ConditionalNotEmpty extends Zend_Validate_Abstract {
const KEY_IS_EMPTY = 'keyIsEmpty';
protected $_messageTemplates = array(
self::KEY_IS_EMPTY => 'Value is required and can\'t be empty'
);
protected $_fieldValues;
/**
* Constructs a new ConditionalNotEmpty validator.
*
*
* @param array $fieldValues - the names and expected values of the fields we're depending on;
* E.g., if we have a field that should only be validated when two other
* fields PARENT_1 and PARENT_2 have values of '1' and '0' respectively, then
* fields PARENT_1 and PARENT_2 have values of '1' and '0' respectively, then
* $fieldValues should contain ('PARENT_1'=>'1', 'PARENT_2'=>'0')
*/
public function __construct($fieldValues)
{
$this->_fieldValues = $fieldValues;
}
/**
* Implements Zend_Validate_Abstract.
* Given names and expected values of the fields we're depending on ($_fieldValues),
* this function returns true if the expected values doesn't match the actual user input,
* or if $value is not empty. Returns false otherwise.
*
*
* @param String $value - this field's value
* @param array $context - names and values of the rest of the fields in this form
* @return boolean - true if valid; false otherwise
@ -41,7 +41,7 @@ class ConditionalNotEmpty extends Zend_Validate_Abstract {
if ($value != "") {
return true;
}
if (is_array($context)) {
foreach($this->_fieldValues as $fieldName=>$fieldValue) {
if (!isset($context[$fieldName]) || $context[$fieldName] != $fieldValue) {
@ -53,7 +53,7 @@ class ConditionalNotEmpty extends Zend_Validate_Abstract {
return true;
}
}
$this->_error(self::KEY_IS_EMPTY);
return false;
}

View File

@ -1,53 +1,53 @@
<?php
class Application_Model_Auth {
const TOKEN_LIFETIME = 'P2D'; // DateInterval syntax
private function generateToken($action, $user_id)
{
$salt = md5("pro");
$token = self::generateRandomString();
$info = new CcSubjsToken();
$info->setDbUserId($user_id);
$info->setDbAction($action);
$info->setDbToken(sha1($token.$salt));
$info->setDbCreated(gmdate('Y-m-d H:i:s'));
$info->save();
Logging::debug("generated token {$token}");
return $token;
}
public function sendPasswordRestoreLink($user, $view)
{
const TOKEN_LIFETIME = 'P2D'; // DateInterval syntax
private function generateToken($action, $user_id)
{
$salt = md5("pro");
$token = self::generateRandomString();
$info = new CcSubjsToken();
$info->setDbUserId($user_id);
$info->setDbAction($action);
$info->setDbToken(sha1($token.$salt));
$info->setDbCreated(gmdate('Y-m-d H:i:s'));
$info->save();
Logging::debug("generated token {$token}");
return $token;
}
public function sendPasswordRestoreLink($user, $view)
{
$token = $this->generateToken('password.restore', $user->getDbId());
$e_link_protocol = empty($_SERVER['HTTPS']) ? "http" : "https";
$e_link_base = $_SERVER['SERVER_NAME'];
$e_link_path = $view->url(array('user_id' => $user->getDbId(), 'token' => $token), 'password-change');
$message = "Click this link: {$e_link_protocol}://{$e_link_base}{$e_link_path}";
$success = Application_Model_Email::send('Airtime Password Reset', $message, $user->getDbEmail());
return $success;
}
public function invalidateTokens($user, $action)
{
CcSubjsTokenQuery::create()
->filterByDbAction($action)
->filterByDbUserId($user->getDbId())
->delete();
}
$success = Application_Model_Email::send('Airtime Password Reset', $message, $user->getDbEmail());
return $success;
}
public function invalidateTokens($user, $action)
{
CcSubjsTokenQuery::create()
->filterByDbAction($action)
->filterByDbUserId($user->getDbId())
->delete();
}
public function checkToken($user_id, $token, $action)
{
$salt = md5("pro");
$salt = md5("pro");
$token_info = CcSubjsTokenQuery::create()
->filterByDbAction($action)
->filterByDbUserId($user_id)
@ -61,10 +61,10 @@ class Application_Model_Auth {
$now = new DateTime();
$token_life = new DateInterval(self::TOKEN_LIFETIME);
$token_created = new DateTime($token_info->getDbCreated(), new DateTimeZone("UTC"));
return $now->sub($token_life)->getTimestamp() < $token_created->getTimestamp();
}
}
/**
* Gets the adapter for authentication against a database table
*
@ -79,10 +79,10 @@ class Application_Model_Auth {
->setIdentityColumn('login')
->setCredentialColumn('pass')
->setCredentialTreatment('MD5(?)');
return $authAdapter;
}
/**
* Get random string
*

View File

@ -121,7 +121,7 @@ class Application_Model_Dashboard
}
} else {
//return the one that starts sooner.
if ($row[0]["starts"] <= $showInstance->getShowInstanceStart()){
return array("name"=>$row[0]["artist_name"]." - ".$row[0]["track_title"],
"starts"=>$row[0]["starts"],

View File

@ -1,104 +1,104 @@
<?php
class Application_Model_Datatables {
/*
* query used to return data for a paginated/searchable datatable.
*/
public static function findEntries($con, $displayColumns, $fromTable, $data, $dataProp = "aaData")
{
$where = array();
if ($data["sSearch"] !== "") {
$searchTerms = explode(" ", $data["sSearch"]);
}
$selectorCount = "SELECT COUNT(*) ";
$selectorRows = "SELECT ".join(",", $displayColumns)." ";
$sql = $selectorCount." FROM ".$fromTable;
$sqlTotalRows = $sql;
if (isset($searchTerms)) {
$searchCols = array();
for ($i = 0; $i < $data["iColumns"]; $i++) {
if ($data["bSearchable_".$i] == "true") {
$searchCols[] = $data["mDataProp_{$i}"];
}
}
$outerCond = array();
foreach ($searchTerms as $term) {
$innerCond = array();
foreach ($searchCols as $col) {
$escapedTerm = pg_escape_string($term);
$innerCond[] = "{$col}::text ILIKE '%{$escapedTerm}%'";
}
$outerCond[] = "(".join(" OR ", $innerCond).")";
}
$where[] = "(".join(" AND ", $outerCond).")";
}
// End Where clause
// Order By clause
$orderby = array();
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
$displayLength = intval($data["iDisplayLength"]);
if (count($where) > 0) {
$where = join(" AND ", $where);
$sql = $selectorCount." FROM ".$fromTable." WHERE ".$where;
$sqlTotalDisplayRows = $sql;
$sql = $selectorRows." FROM ".$fromTable." WHERE ".$where." ORDER BY ".$orderby;
//limit the results returned.
if ($displayLength !== -1) {
$sql .= " OFFSET ".$data["iDisplayStart"]." LIMIT ".$displayLength;
}
}
else {
$sql = $selectorRows." FROM ".$fromTable." ORDER BY ".$orderby;
//limit the results returned.
if ($displayLength !== -1) {
$sql .= " OFFSET ".$data["iDisplayStart"]." LIMIT ".$displayLength;
}
}
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::debug($e->getMessage());
}
return array(
"sEcho" => intval($data["sEcho"]),
"iTotalDisplayRecords" => intval($totalDisplayRows),
"iTotalRecords" => intval($totalRows),
$dataProp => $results
);
}
/*
* query used to return data for a paginated/searchable datatable.
*/
public static function findEntries($con, $displayColumns, $fromTable, $data, $dataProp = "aaData")
{
$where = array();
if ($data["sSearch"] !== "") {
$searchTerms = explode(" ", $data["sSearch"]);
}
$selectorCount = "SELECT COUNT(*) ";
$selectorRows = "SELECT ".join(",", $displayColumns)." ";
$sql = $selectorCount." FROM ".$fromTable;
$sqlTotalRows = $sql;
if (isset($searchTerms)) {
$searchCols = array();
for ($i = 0; $i < $data["iColumns"]; $i++) {
if ($data["bSearchable_".$i] == "true") {
$searchCols[] = $data["mDataProp_{$i}"];
}
}
$outerCond = array();
foreach ($searchTerms as $term) {
$innerCond = array();
foreach ($searchCols as $col) {
$escapedTerm = pg_escape_string($term);
$innerCond[] = "{$col}::text ILIKE '%{$escapedTerm}%'";
}
$outerCond[] = "(".join(" OR ", $innerCond).")";
}
$where[] = "(".join(" AND ", $outerCond).")";
}
// End Where clause
// Order By clause
$orderby = array();
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
$displayLength = intval($data["iDisplayLength"]);
if (count($where) > 0) {
$where = join(" AND ", $where);
$sql = $selectorCount." FROM ".$fromTable." WHERE ".$where;
$sqlTotalDisplayRows = $sql;
$sql = $selectorRows." FROM ".$fromTable." WHERE ".$where." ORDER BY ".$orderby;
//limit the results returned.
if ($displayLength !== -1) {
$sql .= " OFFSET ".$data["iDisplayStart"]." LIMIT ".$displayLength;
}
}
else {
$sql = $selectorRows." FROM ".$fromTable." ORDER BY ".$orderby;
//limit the results returned.
if ($displayLength !== -1) {
$sql .= " OFFSET ".$data["iDisplayStart"]." LIMIT ".$displayLength;
}
}
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::debug($e->getMessage());
}
return array(
"sEcho" => intval($data["sEcho"]),
"iTotalDisplayRecords" => intval($totalDisplayRows),
"iTotalRecords" => intval($totalRows),
$dataProp => $results
);
}
}

View File

@ -1,7 +1,7 @@
<?php
class Application_Model_Email {
/**
* Send email
*
@ -14,7 +14,7 @@ class Application_Model_Email {
{
$mailServerConfigured = Application_Model_Preference::GetMailServerConfigured() == true ? true : false;
$success = true;
if ($mailServerConfigured) {
$username = Application_Model_Preference::GetMailServerEmailAddress();
$password = Application_Model_Preference::GetMailServerPassword();
@ -23,25 +23,25 @@ class Application_Model_Email {
if (!empty($mailServerPort)) {
$port = Application_Model_Preference::GetMailServerPort();
}
$config = array(
'auth' => 'login',
'ssl' => 'ssl',
'username' => $username,
'password' => $password
);
if (isset($port)) {
$config['port'] = $port;
}
$transport = new Zend_Mail_Transport_Smtp($mailServer, $config);
$transport = new Zend_Mail_Transport_Smtp($mailServer, $config);
}
$mail = new Zend_Mail('utf-8');
$mail->setSubject($subject);
$mail->setBodyText($message);
foreach ((array) $tos as $to) {
$mail->addTo($to);
}
@ -60,8 +60,8 @@ class Application_Model_Email {
} catch (Exception $e) {
$success = false;
}
}
}
return $success;
}

View File

@ -26,7 +26,7 @@ class Application_Model_LiveLog
." WHERE state = 'L'"
." ORDER BY id";
$rows = $con->query($sql)->fetchAll();
if ($rows != null) {
$last_row = self::UpdateLastLogEndTime(array_pop($rows));
array_push($rows, $last_row);
@ -36,7 +36,7 @@ class Application_Model_LiveLog
$con->exec($sql_delete);
}
}
$skip = true;
$skip = true;
}
$hours = 0;
@ -55,13 +55,13 @@ class Application_Model_LiveLog
$intervals[$i] = 0;
}
}
// Trim milliseconds (DateInterval does not support)
$sec = explode(".", $intervals[2]);
if (isset($sec[0])) {
$intervals[2] = $sec[0];
}
$seconds += $intervals[2];
if ($seconds / 60 >= 1) {
$minutes += 1;
@ -89,7 +89,7 @@ class Application_Model_LiveLog
$minutes = (double)(($hours*60)+$minutes . "." . $seconds[0]);
}
else {
$minutes = (double)(($hours*60)+$minutes);
$minutes = (double)(($hours*60)+$minutes);
}
}
return $minutes;
@ -100,7 +100,7 @@ class Application_Model_LiveLog
}
}
public static function GetScheduledDuration($p_keepData=false)
public static function GetScheduledDuration($p_keepData=false)
{
try {
$con = Propel::getConnection();
@ -125,7 +125,7 @@ class Application_Model_LiveLog
." WHERE state = 'S'"
." ORDER BY id";
$rows = $con->query($sql)->fetchAll();
if ($rows != null) {
$last_row = self::UpdateLastLogEndTime(array_pop($rows));
array_push($rows, $last_row);
@ -135,7 +135,7 @@ class Application_Model_LiveLog
$con->exec($sql_delete);
}
}
$skip = true;
$skip = true;
}
$hours = 0;
@ -173,7 +173,7 @@ class Application_Model_LiveLog
}
}
$clip_length_seconds = $clip_length_intervals[0]*3600 + $clip_length_intervals[1]*60 + $clip_length_intervals[2];
$extra_time = $extra_time->format("%H:%i:%s");
//Convert extra_time into seconds;
$extra_time_intervals = explode(":", $extra_time);
@ -185,7 +185,7 @@ class Application_Model_LiveLog
$extra_time_seconds = $extra_time_intervals[0]*3600 + $extra_time_intervals[1]*60 + $extra_time_intervals[2];
$clip_length_seconds -= $extra_time_seconds;
//Convert new clip_length into "H-i-s" format
$clip_length_arr = array();
if ($clip_length_seconds / 3600 >= 1) {
@ -276,7 +276,7 @@ class Application_Model_LiveLog
public static function SetNewLogTime($state, $dateTime){
try {
$con = Propel::getConnection();
$scheduled = Application_Model_Preference::GetSourceSwitchStatus('scheduled_play');
if ($state == 'L' && $scheduled == 'on') {
self::SetEndTime('S', $dateTime);

View File

@ -44,35 +44,35 @@ class Application_Model_MusicDir {
$this->_dir->setExists($flag);
$this->_dir->save();
}
public function setWatchedFlag($flag){
$this->_dir->setWatched($flag);
$this->_dir->save();
}
public function getWatchedFlag(){
return $this->_dir->getWatched();
}
public function getExistsFlag(){
return $this->_dir->getExists();
}
/**
/**
* There are 2 cases where this function can be called.
* 1. When watched dir was removed
* 2. When some dir was watched, but it was unmounted
*
*
* In case of 1, $userAddedWatchedDir should be true
* In case of 2, $userAddedWatchedDir should be false
*
*
* When $userAddedWatchedDir is true, it will set "Watched" flag to false
* otherwise, it will set "Exists" flag to true
*/
*/
public function remove($userAddedWatchedDir=true)
{
$con = Propel::getConnection();
$music_dir_id = $this->getId();
$sql = "SELECT DISTINCT s.instance_id from cc_music_dirs as md "
@ -80,12 +80,12 @@ class Application_Model_MusicDir {
." RIGHT JOIN cc_schedule as s on s.file_id = f.id WHERE md.id = $music_dir_id";
$show_instances = $con->query($sql)->fetchAll();
// get all the files on this dir
$sql = "UPDATE cc_files SET file_exists = 'f' WHERE id IN (SELECT f.id FROM cc_music_dirs as md "
." LEFT JOIN cc_files as f on f.directory = md.id WHERE md.id = $music_dir_id)";
$affected = $con->exec($sql);
// set RemovedFlag to true
if ($userAddedWatchedDir) {
self::setWatchedFlag(false);
@ -93,7 +93,7 @@ class Application_Model_MusicDir {
self::setExistsFlag(false);
}
//$res = $this->_dir->delete();
foreach ($show_instances as $show_instance_row) {
$temp_show = new Application_Model_ShowInstance($show_instance_row["instance_id"]);
$temp_show->updateScheduledTime();
@ -133,7 +133,7 @@ class Application_Model_MusicDir {
public static function isPathValid($p_path){
$dirs = self::getWatchedDirs();
$dirs[] = self::getStorDir();
foreach ($dirs as $dirObj){
$dir = $dirObj->getDirectory();
$diff = strlen($dir) - strlen($p_path);
@ -156,15 +156,15 @@ class Application_Model_MusicDir {
/** There are 2 cases where this function can be called.
* 1. When watched dir was added
* 2. When some dir was watched, but it was unmounted somehow, but gets mounted again
*
*
* In case of 1, $userAddedWatchedDir should be true
* In case of 2, $userAddedWatchedDir should be false
*
*
* When $userAddedWatchedDir is true, it will set "Removed" flag to false
* otherwise, it will set "Exists" flag to true
*
*
* @param $nestedWatch - if true, bypass path check, and Watched to false
**/
**/
public static function addDir($p_path, $p_type, $userAddedWatchedDir=true, $nestedWatch=false)
{
if(!is_dir($p_path)){
@ -174,16 +174,16 @@ class Application_Model_MusicDir {
if($real_path != "/"){
$p_path = $real_path;
}
$exist_dir = self::getDirByPath($p_path);
if( $exist_dir == NULL ){
$temp_dir = new CcMusicDirs();
$dir = new Application_Model_MusicDir($temp_dir);
}else{
$dir = $exist_dir;
}
$dir->setType($p_type);
$p_path = Application_Common_OsPath::normpath($p_path)."/";
@ -203,7 +203,7 @@ class Application_Model_MusicDir {
$dir->setExistsFlag(true);
}
$dir->setDirectory($p_path);
return array("code"=>0);
} catch (NestedDirectoryException $nde){
$msg = $nde->getMessage();
@ -217,17 +217,17 @@ class Application_Model_MusicDir {
/** There are 2 cases where this function can be called.
* 1. When watched dir was added
* 2. When some dir was watched, but it was unmounted somehow, but gets mounted again
*
*
* In case of 1, $userAddedWatchedDir should be true
* In case of 2, $userAddedWatchedDir should be false
*
*
* When $userAddedWatchedDir is true, it will set "Watched" flag to true
* otherwise, it will set "Exists" flag to true
**/
**/
public static function addWatchedDir($p_path, $userAddedWatchedDir=true, $nestedWatch=false)
{
$res = self::addDir($p_path, "watched", $userAddedWatchedDir, $nestedWatch);
if ($res['code'] == 0){
//convert "linked" files (Airtime <= 1.8.2) to watched files.
@ -296,10 +296,10 @@ class Application_Model_MusicDir {
return $mus_dir;
}
}
/**
* Search and returns watched dirs
*
*
* @param $exists search condition with exists flag
* @param $watched search condition with watched flag
*/
@ -383,16 +383,16 @@ class Application_Model_MusicDir {
/** There are 2 cases where this function can be called.
* 1. When watched dir was removed
* 2. When some dir was watched, but it was unmounted
*
*
* In case of 1, $userAddedWatchedDir should be true
* In case of 2, $userAddedWatchedDir should be false
*
*
* When $userAddedWatchedDir is true, it will set "Watched" flag to false
* otherwise, it will set "Exists" flag to true
**/
**/
public static function removeWatchedDir($p_dir, $userAddedWatchedDir=true){
//make sure that $p_dir has a trailing "/"
//make sure that $p_dir has a trailing "/"
$real_path = Application_Common_OsPath::normpath($p_dir)."/";
if($real_path != "/"){
$p_dir = $real_path;
@ -412,7 +412,7 @@ class Application_Model_MusicDir {
public static function splitFilePath($p_filepath)
{
$mus_dir = self::getWatchedDirFromFilepath($p_filepath);
if(is_null($mus_dir)) {
return null;
}

View File

@ -20,17 +20,17 @@ class Application_Model_Playlist {
*/
private $id;
/**
/**
* propel object for this playlist.
*/
private $pl;
private $pl;
/**
/**
* info needed to insert a new playlist element.
*/
private $plItem = array(
private $plItem = array(
"id" => "",
"pos" => "",
"pos" => "",
"cliplength" => "",
"cuein" => "00:00:00",
"cueout" => "00:00:00",
@ -38,13 +38,13 @@ class Application_Model_Playlist {
"fadeout" => "0.0",
);
//using propel's phpNames.
private $categories = array(
"dc:title" => "Name",
"dc:creator" => "Creator",
"dc:description" => "Description",
"dcterms:extent" => "Length"
);
//using propel's phpNames.
private $categories = array(
"dc:title" => "Name",
"dc:creator" => "Creator",
"dc:description" => "Description",
"dcterms:extent" => "Length"
);
public function __construct($id=null, $con=null)
@ -90,12 +90,12 @@ 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->save($this->con);
$this->pl->setDbName($p_newname);
$this->pl->setDbMtime(new DateTime("now", new DateTimeZone("UTC")));
$this->pl->save($this->con);
}
/**
/**
* Get mnemonic playlist name
*
* @return string
@ -107,9 +107,9 @@ 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->save($this->con);
$this->pl->setDbDescription($p_description);
$this->pl->setDbMtime(new DateTime("now", new DateTimeZone("UTC")));
$this->pl->save($this->con);
}
public function getDescription()
@ -121,7 +121,7 @@ class Application_Model_Playlist {
return $this->pl->getCcSubjs()->getDbLogin();
}
public function getCreatorId() {
return $this->pl->getCcSubjs()->getDbId();
}
@ -145,7 +145,7 @@ class Application_Model_Playlist {
/**
* Get the entire playlist as a two dimentional array, sorted in order of play.
* @param boolean $filterFiles if this is true, it will only return files that has
* file_exists flag set to true
* file_exists flag set to true
* @return array
*/
public function getContents($filterFiles=false) {
@ -155,7 +155,7 @@ class Application_Model_Playlist {
$files = array();
$query = CcPlaylistcontentsQuery::create()
->filterByDbPlaylistId($this->id);
if($filterFiles){
$query->useCcFilesQuery()
->filterByDbFileExists(true)
@ -416,7 +416,7 @@ class Application_Model_Playlist {
* Remove audioClip from playlist
*
* @param array $p_items
* array of unique item ids to remove from the playlist..
* array of unique item ids to remove from the playlist..
*/
public function delAudioClips($p_items)
{
@ -452,11 +452,11 @@ class Application_Model_Playlist {
}
public function getFadeInfo($pos) {
public function getFadeInfo($pos) {
Logging::log("Getting fade info for pos {$pos}");
Logging::log("Getting fade info for pos {$pos}");
$row = CcPlaylistcontentsQuery::create()
$row = CcPlaylistcontentsQuery::create()
->joinWith(CcFilesPeer::OM_CLASS)
->filterByDbPlaylistId($this->id)
->filterByDbPosition($pos)
@ -466,24 +466,24 @@ class Application_Model_Playlist {
$fadeIn = $row->getDbFadein();
$fadeOut = $row->getDbFadeout();
return array($fadeIn, $fadeOut);
}
}
/**
* Change fadeIn and fadeOut values for playlist Element
*
* @param int $pos
* position of audioclip in playlist
* position of audioclip in playlist
* @param string $fadeIn
* new value in ss.ssssss or extent format
* new value in ss.ssssss or extent format
* @param string $fadeOut
* new value in ss.ssssss or extent format
* new value in ss.ssssss or extent format
* @return boolean
*/
public function changeFadeInfo($id, $fadeIn, $fadeOut)
{
//See issue CC-2065, pad the fadeIn and fadeOut so that it is TIME compatable with the DB schema
//For the top level PlayList either fadeIn or fadeOut will sometimes be Null so need a gaurd against
//setting it to nonNull for checks down below
//setting it to nonNull for checks down below
$fadeIn = $fadeIn?'00:00:'.$fadeIn:$fadeIn;
$fadeOut = $fadeOut?'00:00:'.$fadeOut:$fadeOut;
@ -502,8 +502,8 @@ class Application_Model_Playlist {
if (!is_null($fadeIn)) {
$sql = "SELECT INTERVAL '{$fadeIn}' > INTERVAL '{$clipLength}'";
$r = $this->con->query($sql);
$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;
@ -512,8 +512,8 @@ class Application_Model_Playlist {
}
if (!is_null($fadeOut)){
$sql = "SELECT INTERVAL '{$fadeOut}' > INTERVAL '{$clipLength}'";
$r = $this->con->query($sql);
$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;
@ -562,11 +562,11 @@ class Application_Model_Playlist {
* Change cueIn/cueOut values for playlist element
*
* @param int $pos
* position of audioclip in playlist
* position of audioclip in playlist
* @param string $cueIn
* new value in ss.ssssss or extent format
* new value in ss.ssssss or extent format
* @param string $cueOut
* new value in ss.ssssss or extent format
* new value in ss.ssssss or extent format
* @return boolean or pear error object
*/
public function changeClipLength($id, $cueIn, $cueOut)
@ -604,23 +604,23 @@ class Application_Model_Playlist {
$cueOut = $origLength;
}
$sql = "SELECT INTERVAL '{$cueIn}' > INTERVAL '{$cueOut}'";
$r = $this->con->query($sql);
$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);
$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);
$sql = "SELECT INTERVAL '{$cueOut}' - INTERVAL '{$cueIn}'";
$r = $this->con->query($sql);
$cliplength = $r->fetchColumn(0);
$row->setDbCuein($cueIn);
$row->setDbCueout($cueOut);
@ -629,16 +629,16 @@ class Application_Model_Playlist {
}
else if (!is_null($cueIn)) {
$sql = "SELECT INTERVAL '{$cueIn}' > INTERVAL '{$oldCueOut}'";
$r = $this->con->query($sql);
$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);
$r = $this->con->query($sql);
$cliplength = $r->fetchColumn(0);
$row->setDbCuein($cueIn);
$row->setDBCliplength($cliplength);
@ -649,23 +649,23 @@ class Application_Model_Playlist {
$cueOut = $origLength;
}
$sql = "SELECT INTERVAL '{$cueOut}' < INTERVAL '{$oldCueIn}'";
$r = $this->con->query($sql);
$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);
$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);
$r = $this->con->query($sql);
$cliplength = $r->fetchColumn(0);
$row->setDbCueout($cueOut);
$row->setDBCliplength($cliplength);
@ -673,15 +673,15 @@ class Application_Model_Playlist {
$cliplength = $row->getDbCliplength();
$sql = "SELECT INTERVAL '{$fadeIn}' > INTERVAL '{$cliplength}'";
$r = $this->con->query($sql);
$sql = "SELECT INTERVAL '{$fadeIn}' > INTERVAL '{$cliplength}'";
$r = $this->con->query($sql);
if ($r->fetchColumn(0)){
$fadeIn = $cliplength;
$row->setDbFadein($fadeIn);
}
$sql = "SELECT INTERVAL '{$fadeOut}' > INTERVAL '{$cliplength}'";
$r = $this->con->query($sql);
$sql = "SELECT INTERVAL '{$fadeOut}' > INTERVAL '{$cliplength}'";
$r = $this->con->query($sql);
if ($r->fetchColumn(0)){
$fadeOut = $cliplength;
$row->setDbFadein($fadeOut);

View File

@ -4,80 +4,80 @@ require_once 'formatters/LengthFormatter.php';
class Application_Model_PlayoutHistory {
private $con;
private $timezone;
//in UTC timezone
private $startDT;
//in UTC timezone
private $endDT;
private $epoch_now;
private $opts;
private $mDataPropMap = array(
"artist" => "file.artist_name",
"title" => "file.track_title",
"played" => "playout.played",
"length" => "file.length",
"composer" => "file.composer",
"copyright" => "file.copyright",
);
public function __construct($p_startDT, $p_endDT, $p_opts) {
$this->con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME);
$this->startDT = $p_startDT;
$this->endDT = $p_endDT;
$this->timezone = date_default_timezone_get();
$this->epoch_now = time();
$this->opts = $p_opts;
}
/*
* map front end mDataProp labels to proper column names for searching etc.
*/
private function translateColumns() {
for ($i = 0; $i < $this->opts["iColumns"]; $i++){
$this->opts["mDataProp_{$i}"] = $this->mDataPropMap[$this->opts["mDataProp_{$i}"]];
}
}
public function getItems() {
$this->translateColumns();
$select = array(
"file.track_title as title",
"file.artist_name as artist",
"playout.played",
"playout.file_id",
"file.composer",
"file.copyright",
"file.length"
);
$start = $this->startDT->format("Y-m-d H:i:s");
$end = $this->endDT->format("Y-m-d H:i:s");
$historyTable = "(
select count(schedule.file_id) as played, schedule.file_id as file_id
from cc_schedule as schedule
where schedule.starts >= '{$start}' and schedule.starts < '{$end}'
and schedule.playout_status > 0 and schedule.media_item_played != FALSE and schedule.broadcasted = 1
group by schedule.file_id
)
AS playout left join cc_files as file on (file.id = playout.file_id)";
private $con;
private $timezone;
//in UTC timezone
private $startDT;
//in UTC timezone
private $endDT;
private $epoch_now;
private $opts;
$results = Application_Model_Datatables::findEntries($this->con, $select, $historyTable, $this->opts, "history");
foreach ($results["history"] as &$row) {
$formatter = new LengthFormatter($row['length']);
$row['length'] = $formatter->format();
}
return $results;
}
}
private $mDataPropMap = array(
"artist" => "file.artist_name",
"title" => "file.track_title",
"played" => "playout.played",
"length" => "file.length",
"composer" => "file.composer",
"copyright" => "file.copyright",
);
public function __construct($p_startDT, $p_endDT, $p_opts) {
$this->con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME);
$this->startDT = $p_startDT;
$this->endDT = $p_endDT;
$this->timezone = date_default_timezone_get();
$this->epoch_now = time();
$this->opts = $p_opts;
}
/*
* map front end mDataProp labels to proper column names for searching etc.
*/
private function translateColumns() {
for ($i = 0; $i < $this->opts["iColumns"]; $i++){
$this->opts["mDataProp_{$i}"] = $this->mDataPropMap[$this->opts["mDataProp_{$i}"]];
}
}
public function getItems() {
$this->translateColumns();
$select = array(
"file.track_title as title",
"file.artist_name as artist",
"playout.played",
"playout.file_id",
"file.composer",
"file.copyright",
"file.length"
);
$start = $this->startDT->format("Y-m-d H:i:s");
$end = $this->endDT->format("Y-m-d H:i:s");
$historyTable = "(
select count(schedule.file_id) as played, schedule.file_id as file_id
from cc_schedule as schedule
where schedule.starts >= '{$start}' and schedule.starts < '{$end}'
and schedule.playout_status > 0 and schedule.media_item_played != FALSE and schedule.broadcasted = 1
group by schedule.file_id
)
AS playout left join cc_files as file on (file.id = playout.file_id)";
$results = Application_Model_Datatables::findEntries($this->con, $select, $historyTable, $this->opts, "history");
foreach ($results["history"] as &$row) {
$formatter = new LengthFormatter($row['length']);
$row['length'] = $formatter->format();
}
return $results;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -61,7 +61,7 @@ class Application_Model_RabbitMq
$channel->close();
$conn->close();
}
public static function SendMessageToShowRecorder($event_type)
{
global $CC_CONFIG;
@ -73,10 +73,10 @@ class Application_Model_RabbitMq
$CC_CONFIG["rabbitmq"]["vhost"]);
$channel = $conn->channel();
$channel->access_request($CC_CONFIG["rabbitmq"]["vhost"], false, false, true, true);
$EXCHANGE = 'airtime-pypo';
$channel->exchange_declare($EXCHANGE, 'direct', false, true);
$now = new DateTime("@".time()); //in UTC timezone
$end_timestamp = new DateTime("@".(time() + 3600*2)); //in UTC timezone
@ -87,7 +87,7 @@ class Application_Model_RabbitMq
}
$data = json_encode($temp);
$msg = new AMQPMessage($data, array('content_type' => 'text/plain'));
$channel->basic_publish($msg, $EXCHANGE);
$channel->close();
$conn->close();

View File

@ -81,7 +81,7 @@ class Application_Model_Schedule {
/* Alternate SQL...merge conflict and I'm not sure which on is right.... -MK
$sql = 'Select ft.artist_name, ft.track_title, st.starts as starts, st.ends as ends, st.media_item_played as media_item_played, si.ends as show_ends
FROM cc_schedule st LEFT JOIN cc_files ft ON st.file_id = ft.id
FROM cc_schedule st LEFT JOIN cc_files ft ON st.file_id = ft.id
WHERE ';
*/
@ -231,15 +231,15 @@ class Application_Model_Schedule {
return $row;
}
/*
*
* @param DateTime $p_startDateTime
*
* @param DateTime $p_endDateTime
*
* @return array $scheduledItems
*
*/
/*
*
* @param DateTime $p_startDateTime
*
* @param DateTime $p_endDateTime
*
* @return array $scheduledItems
*
*/
public static function GetScheduleDetailItems($p_start, $p_end, $p_shows)
{
global $CC_CONFIG;
@ -279,7 +279,7 @@ class Application_Model_Schedule {
}
$sql .= " ORDER BY si.starts, sched.starts;";
Logging::debug($sql);
$rows = $con->query($sql)->fetchAll();
@ -297,17 +297,17 @@ class Application_Model_Schedule {
$live_dj = Application_Model_Preference::GetSourceSwitchStatus('live_dj') == 'on'?true:false;
$master_dj = Application_Model_Preference::GetSourceSwitchStatus('master_dj') == 'on'?true:false;
$scheduled_play = Application_Model_Preference::GetSourceSwitchStatus('scheduled_play') == 'on'?true:false;
if(!$live_dj && !$master_dj && $scheduled_play){
$sql .= ", broadcasted=1";
}
$sql .= " WHERE id=$p_id";
$retVal = $con->exec($sql);
return $retVal;
}
public static function UpdateBrodcastedStatus($dateTime, $value){
global $CC_CONFIG;
$con = Propel::getConnection();
@ -551,7 +551,7 @@ class Application_Model_Schedule {
$data["media"][$kick_start]['end'] = $kick_start;
$data["media"][$kick_start]['event_type'] = "kick_out";
$data["media"][$kick_start]['type'] = "event";
if($kick_time !== $switch_off_time){
$switch_start = Application_Model_Schedule::AirtimeTimeToPypoTime($switch_off_time);
$data["media"][$switch_start]['start'] = $switch_start;
@ -562,16 +562,16 @@ class Application_Model_Schedule {
}
foreach ($items as $item){
$showInstance = CcShowInstancesQuery::create()->findPK($item["instance_id"]);
$showId = $showInstance->getDbShowId();
$show = CcShowQuery::create()->findPK($showId);
$showName = $show->getDbName();
$showEndDateTime = new DateTime($item["show_end"], $utcTimeZone);
$trackStartDateTime = new DateTime($item["start"], $utcTimeZone);
$trackEndDateTime = new DateTime($item["end"], $utcTimeZone);
if ($trackStartDateTime->getTimestamp() > $showEndDateTime->getTimestamp()){
continue;
}
@ -584,10 +584,10 @@ class Application_Model_Schedule {
$item["cue_out"] = $di->format("%H:%i:%s").".000";
$item["end"] = $showEndDateTime->format("Y-m-d H:i:s");
}
$storedFile = Application_Model_StoredFile::Recall($item["file_id"]);
$uri = $storedFile->getFilePath();
$start = Application_Model_Schedule::AirtimeTimeToPypoTime($item["start"]);
$data["media"][$start] = array(
'id' => $storedFile->getGunid(),
@ -614,7 +614,7 @@ class Application_Model_Schedule {
$con = Propel::getConnection();
$con->exec("TRUNCATE TABLE ".$CC_CONFIG["scheduleTable"]);
}
public static function deleteWithFileId($fileId){
global $CC_CONFIG;
$con = Propel::getConnection();
@ -626,18 +626,18 @@ class Application_Model_Schedule {
$isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true;
$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();
$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();
$formWhat->removeDecorator('DtDdWrapper');
$formWho->removeDecorator('DtDdWrapper');
$formWhen->removeDecorator('DtDdWrapper');
$formRepeats->removeDecorator('DtDdWrapper');
$formStyle->removeDecorator('DtDdWrapper');
$formLive->removeDecorator('DtDdWrapper');
$formWhat->removeDecorator('DtDdWrapper');
$formWho->removeDecorator('DtDdWrapper');
$formWhen->removeDecorator('DtDdWrapper');
$formRepeats->removeDecorator('DtDdWrapper');
$formStyle->removeDecorator('DtDdWrapper');
$formLive->removeDecorator('DtDdWrapper');
$p_view->what = $formWhat;
$p_view->when = $formWhen;
@ -646,7 +646,7 @@ class Application_Model_Schedule {
$p_view->style = $formStyle;
$p_view->live = $formLive;
$formWhat->populate(array('add_show_id' => '-1',
$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',
@ -671,29 +671,29 @@ class Application_Model_Schedule {
}
$p_view->addNewShow = true;
}
/* This function is responsible for handling the case where an individual
/* 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).
* There is still lots of clean-up to do. For example we shouldn't be passing $controller into
* this method to manipulate the view (this should be done inside the controller function). With
* 2.1 deadline looming, this is OK for now. -Martin */
public static function updateShowInstance($data, $controller){
$isSaas = (Application_Model_Preference::GetPlanLevel() != 'disabled');
$formWhat = new Application_Form_AddShowWhat();
$formWhen = new Application_Form_AddShowWhen();
$formRepeats = new Application_Form_AddShowRepeats();
$formWho = new Application_Form_AddShowWho();
$formStyle = new Application_Form_AddShowStyle();
$formLive = new Application_Form_AddShowLiveStream();
$formWhat->removeDecorator('DtDdWrapper');
$formWhen->removeDecorator('DtDdWrapper');
$formRepeats->removeDecorator('DtDdWrapper');
$formWho->removeDecorator('DtDdWrapper');
$formStyle->removeDecorator('DtDdWrapper');
$formLive->removeDecorator('DtDdWrapper');
$formWhat = new Application_Form_AddShowWhat();
$formWhen = new Application_Form_AddShowWhen();
$formRepeats = new Application_Form_AddShowRepeats();
$formWho = new Application_Form_AddShowWho();
$formStyle = new Application_Form_AddShowStyle();
$formLive = new Application_Form_AddShowLiveStream();
$formWhat->removeDecorator('DtDdWrapper');
$formWhen->removeDecorator('DtDdWrapper');
$formRepeats->removeDecorator('DtDdWrapper');
$formWho->removeDecorator('DtDdWrapper');
$formStyle->removeDecorator('DtDdWrapper');
$formLive->removeDecorator('DtDdWrapper');
if(!$isSaas){
$formRecord = new Application_Form_AddShowRR();
$formAbsoluteRebroadcast = new Application_Form_AddShowAbsoluteRebroadcastDates();
@ -704,21 +704,21 @@ class Application_Model_Schedule {
$formRebroadcast->removeDecorator('DtDdWrapper');
}
$when = $formWhen->isValid($data);
if($when && $formWhen->checkReliantFields($data, true, null, true)) {
if($when && $formWhen->checkReliantFields($data, true, null, true)) {
$start_dt = new DateTime($data['add_show_start_date']." ".$data['add_show_start_time'], new DateTimeZone(date_default_timezone_get()));
$start_dt->setTimezone(new DateTimeZone('UTC'));
$end_dt = new DateTime($data['add_show_end_date_no_repeat']." ".$data['add_show_end_time'], new DateTimeZone(date_default_timezone_get()));
$end_dt->setTimezone(new DateTimeZone('UTC'));
$ccShowInstance = CcShowInstancesQuery::create()->findPK($data["add_show_instance_id"]);
$ccShowInstance->setDbStarts($start_dt);
$ccShowInstance->setDbEnds($end_dt);
$ccShowInstance->save();
$ccShowInstance->save();
Application_Model_Schedule::createNewFormSections($controller->view);
return true;
} else {
$formWhat->disable();
@ -727,36 +727,36 @@ class Application_Model_Schedule {
$formWho->disable();
$formStyle->disable();
//$formLive->disable();
$controller->view->what = $formWhat;
$controller->view->when = $formWhen;
$controller->view->repeats = $formRepeats;
$controller->view->who = $formWho;
$controller->view->style = $formStyle;
$controller->view->live = $formLive;
$controller->view->live = $formLive;
if(!$isSaas){
$controller->view->rr = $formRecord;
$controller->view->absoluteRebroadcast = $formAbsoluteRebroadcast;
$controller->view->rebroadcast = $formRebroadcast;
//$formRecord->disable();
//$formAbsoluteRebroadcast->disable();
//$formRebroadcast->disable();
}
return false;
}
}
}
/* This function is responsible for handling the case where the entire show (not a single show instance)
/* This function is responsible for handling the case where the entire show (not a single show instance)
* was edited (via the context menu in the Calendar).
* There is still lots of clean-up to do. For example we shouldn't be passing $controller into
* this method to manipulate the view (this should be done inside the controller function). With
* 2.1 deadline looming, this is OK for now.
* Another clean-up is to move all the form manipulation to the proper form class.....
* -Martin
* -Martin
*/
public static function addUpdateShow($data, $controller, $validateStartDate, $originalStartDate=null, $update=false, $instanceId=null){
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new Application_Model_User($userInfo->id);
$isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
@ -765,22 +765,22 @@ class Application_Model_Schedule {
$record = false;
$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();
$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();
$formWhat->removeDecorator('DtDdWrapper');
$formWho->removeDecorator('DtDdWrapper');
$formWhen->removeDecorator('DtDdWrapper');
$formRepeats->removeDecorator('DtDdWrapper');
$formStyle->removeDecorator('DtDdWrapper');
$formLive->removeDecorator('DtDdWrapper');
$formWhat->removeDecorator('DtDdWrapper');
$formWho->removeDecorator('DtDdWrapper');
$formWhen->removeDecorator('DtDdWrapper');
$formRepeats->removeDecorator('DtDdWrapper');
$formStyle->removeDecorator('DtDdWrapper');
$formLive->removeDecorator('DtDdWrapper');
$what = $formWhat->isValid($data);
$when = $formWhen->isValid($data);
$live = $formLive->isValid($data);
$what = $formWhat->isValid($data);
$when = $formWhen->isValid($data);
$live = $formLive->isValid($data);
if($when) {
$when = $formWhen->checkReliantFields($data, $validateStartDate, $originalStartDate, $update, $instanceId);
}
@ -798,11 +798,11 @@ class Application_Model_Schedule {
$mValue = 0;
if($hPos !== false){
$hValue = trim(substr($data["add_show_duration"], 0, $hPos));
$hValue = trim(substr($data["add_show_duration"], 0, $hPos));
}
if($mPos !== false){
$hPos = $hPos === FALSE ? 0 : $hPos+1;
$mValue = trim(substr($data["add_show_duration"], $hPos, -1 ));
$mValue = trim(substr($data["add_show_duration"], $hPos, -1 ));
}
$data["add_show_duration"] = $hValue.":".$mValue;
@ -821,7 +821,7 @@ class Application_Model_Schedule {
}
if($data["add_show_repeats"]) {
$repeats = $formRepeats->isValid($data);
$repeats = $formRepeats->isValid($data);
if($repeats) {
$repeats = $formRepeats->checkReliantFields($data);
}
@ -857,8 +857,8 @@ class Application_Model_Schedule {
}
}
$who = $formWho->isValid($data);
$style = $formStyle->isValid($data);
$who = $formWho->isValid($data);
$style = $formStyle->isValid($data);
if ($what && $when && $repeats && $who && $style && $live) {
if(!$isSaas){
if($record && $rebroadAb && $rebroad){
@ -882,7 +882,7 @@ class Application_Model_Schedule {
$controller->view->rebroadcast = $formRebroadcast;
$controller->view->live = $formLive;
//$controller->view->addNewShow = !$editShow;
//$controller->view->form = $controller->view->render('schedule/add-show-form.phtml');
return false;
@ -898,14 +898,14 @@ class Application_Model_Schedule {
//$controller->view->newForm = $controller->view->render('schedule/add-show-form.phtml');
return true;
}
} else {
} else {
$controller->view->what = $formWhat;
$controller->view->when = $formWhen;
$controller->view->repeats = $formRepeats;
$controller->view->who = $formWho;
$controller->view->style = $formStyle;
$controller->view->live = $formLive;
if(!$isSaas){
$controller->view->rr = $formRecord;
$controller->view->absoluteRebroadcast = $formAbsoluteRebroadcast;
@ -916,14 +916,14 @@ class Application_Model_Schedule {
return false;
}
}
public static function checkOverlappingShows($show_start, $show_end, $update=false, $instanceId=null) {
public static function checkOverlappingShows($show_start, $show_end, $update=false, $instanceId=null) {
global $CC_CONFIG;
$overlapping = false;
$con = Propel::getConnection();
if ($update) {
$sql = "SELECT id, starts, ends FROM ".$CC_CONFIG["showInstances"]."
where ends <= '{$show_end->format('Y-m-d H:i:s')}'
@ -933,12 +933,12 @@ class Application_Model_Schedule {
where ends <= '{$show_end->format('Y-m-d H:i:s')}' order by ends";
}
$rows = $con->query($sql);
foreach($rows as $row) {
$start = new DateTime($row["starts"], new DateTimeZone('UTC'));
$end = new DateTime($row["ends"], new DateTimeZone('UTC'));
if ($show_start->getTimestamp() < $end->getTimestamp() &&
if ($show_start->getTimestamp() < $end->getTimestamp() &&
$show_end->getTimestamp() > $start->getTimestamp()) {
$overlapping = true;
break;

View File

@ -12,46 +12,46 @@ class Application_Model_Scheduler {
"fadeout" => "00:00:00",
"sched_id" => null,
);
private $epochNow;
private $nowDT;
private $user;
private $checkUserPermissions = true;
public function __construct() {
$this->con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME);
$this->epochNow = microtime(true);
$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"));
}
$this->user = Application_Model_User::GetCurrentUser();
}
$this->user = Application_Model_User::getCurrentUser();
}
public function setCheckUserPermissions($value) {
$this->checkUserPermissions = $value;
}
/*
* make sure any incoming requests for scheduling are ligit.
*
* @param array $items, an array containing pks of cc_schedule items.
*/
private function validateRequest($items) {
$nowEpoch = floatval($this->nowDT->format("U.u"));
for ($i = 0; $i < count($items); $i++) {
$id = $items[$i]["id"];
//could be added to the beginning of a show, which sends id = 0;
if ($id > 0) {
$schedInfo[$id] = $items[$i]["instance"];
@ -59,11 +59,11 @@ class Application_Model_Scheduler {
$instanceInfo[$items[$i]["instance"]] = $items[$i]["timestamp"];
}
if (count($instanceInfo) === 0) {
throw new Exception("Invalid Request.");
}
$schedIds = array();
if (isset($schedInfo)) {
$schedIds = array_keys($schedInfo);
@ -71,41 +71,41 @@ class Application_Model_Scheduler {
$schedItems = CcScheduleQuery::create()->findPKs($schedIds, $this->con);
$instanceIds = array_keys($instanceInfo);
$showInstances = CcShowInstancesQuery::create()->findPKs($instanceIds, $this->con);
//an item has been deleted
if (count($schedIds) !== count($schedItems)) {
throw new OutDatedScheduleException("The schedule you're viewing is out of date! (sched mismatch)");
}
//a show has been deleted
if (count($instanceIds) !== count($showInstances)) {
throw new OutDatedScheduleException("The schedule you're viewing is out of date! (instance mismatch)");
}
foreach ($schedItems as $schedItem) {
$id = $schedItem->getDbId();
$instance = $schedItem->getCcShowInstances($this->con);
if (intval($schedInfo[$id]) !== $instance->getDbId()) {
throw new OutDatedScheduleException("The schedule you're viewing is out of date!");
}
}
foreach ($showInstances as $instance) {
$id = $instance->getDbId();
$show = $instance->getCcShow($this->con);
if ($this->checkUserPermissions && $this->user->canSchedule($show->getDbId()) === false) {
throw new Exception("You are not allowed to schedule show {$show->getDbName()}.");
}
$showEndEpoch = floatval($instance->getDbEnds("U.u"));
if ($showEndEpoch < $nowEpoch) {
throw new OutDatedScheduleException("The show {$show->getDbName()} is over and cannot be scheduled.");
}
$ts = intval($instanceInfo[$id]);
$lastSchedTs = intval($instance->getDbLastScheduled("U")) ? : 0;
if ($ts < $lastSchedTs) {
@ -196,17 +196,17 @@ class Application_Model_Scheduler {
$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;
}
private function findNextStartTime($DT, $instance) {
$sEpoch = $DT->format("U.u");
$nEpoch = $this->epochNow;
@ -215,7 +215,7 @@ class Application_Model_Scheduler {
//need some kind of placeholder for cc_schedule.
//playout_status will be -1.
$nextDT = $this->nowDT;
$length = bcsub($nEpoch , $sEpoch , 6);
$cliplength = Application_Model_Playlist::secondsToPlaylistTime($length);
@ -231,10 +231,10 @@ class Application_Model_Scheduler {
else {
$nextDT = $DT;
}
return $nextDT;
}
/*
* @param int $showInstance
* @param array $exclude
@ -267,7 +267,7 @@ class Application_Model_Scheduler {
$itemStartDT = $itemEndDT;
}
$schedule->save($this->con);
}
@ -291,20 +291,20 @@ class Application_Model_Scheduler {
}
$startProfile = microtime(true);
foreach ($scheduleItems as $schedule) {
$id = intval($schedule["id"]);
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 {
$instance = CcShowInstancesQuery::create()->findPK($schedule["instance"], $this->con);
$showStartDT = $instance->getDbStarts(null);
@ -316,16 +316,16 @@ class Application_Model_Scheduler {
}
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));
@ -359,26 +359,26 @@ class Application_Model_Scheduler {
}
if ($adjustSched === true) {
$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->save($this->con);
$nextStartDT = $endTimeDT;
$nextStartDT = $endTimeDT;
}
$pend = microtime(true);
Logging::debug("adjusting all following items.");
Logging::debug(floatval($pend) - floatval($pstart));
}
}
$endProfile = microtime(true);
Logging::debug("finished adding scheduled items.");
Logging::debug(floatval($endProfile) - floatval($startProfile));
@ -389,22 +389,22 @@ class Application_Model_Scheduler {
->find($this->con);
$startProfile = microtime(true);
foreach ($instances as $instance) {
$instance->updateScheduleStatus($this->con);
}
$endProfile = microtime(true);
Logging::debug("updating show instances status.");
Logging::debug(floatval($endProfile) - floatval($startProfile));
$startProfile = microtime(true);
//update the last scheduled timestamp.
CcShowInstancesQuery::create()
->filterByPrimaryKeys($affectedShowInstances)
->update(array('DbLastScheduled' => new DateTime("now", new DateTimeZone("UTC"))), $this->con);
$endProfile = microtime(true);
Logging::debug("updating last scheduled timestamp.");
Logging::debug(floatval($endProfile) - floatval($startProfile));
@ -426,7 +426,7 @@ class Application_Model_Scheduler {
$schedFiles = array();
try {
$this->validateRequest($scheduleItems);
foreach ($mediaItems as $media) {
@ -451,31 +451,31 @@ class Application_Model_Scheduler {
public function moveItem($selectedItems, $afterItems, $adjustSched = true) {
$startProfile = microtime(true);
$this->con->beginTransaction();
$this->con->useDebug(true);
try {
$this->validateRequest($selectedItems);
$this->validateRequest($afterItems);
$endProfile = microtime(true);
Logging::debug("validating move request took:");
Logging::debug(floatval($endProfile) - floatval($startProfile));
$afterInstance = CcShowInstancesQuery::create()->findPK($afterItems[0]["instance"], $this->con);
//map show instances to cc_schedule primary keys.
$modifiedMap = array();
$movedData = array();
//prepare each of the selected items.
for ($i = 0; $i < count($selectedItems); $i++) {
$selected = CcScheduleQuery::create()->findPk($selectedItems[$i]["id"], $this->con);
$selectedInstance = $selected->getCcShowInstances($this->con);
$data = $this->fileInfo;
$data["id"] = $selected->getDbFileId();
$data["cliplength"] = $selected->getDbClipLength();
@ -484,48 +484,48 @@ class Application_Model_Scheduler {
$data["fadein"] = $selected->getDbFadeIn();
$data["fadeout"] = $selected->getDbFadeOut();
$data["sched_id"] = $selected->getDbId();
$movedData[] = $data;
//figure out which items must be removed from calculated show times.
$showInstanceId = $selectedInstance->getDbId();
$schedId = $selected->getDbId();
if (isset($modifiedMap[$showInstanceId])) {
array_push($modifiedMap[$showInstanceId], $schedId);
array_push($modifiedMap[$showInstanceId], $schedId);
}
else {
$modifiedMap[$showInstanceId] = array($schedId);
}
}
}
//calculate times excluding the to be moved items.
foreach ($modifiedMap as $instance => $schedIds) {
$startProfile = microtime(true);
$this->removeGaps($instance, $schedIds);
$endProfile = microtime(true);
Logging::debug("removing gaps from instance $instance:");
Logging::debug(floatval($endProfile) - floatval($startProfile));
}
$startProfile = microtime(true);
$this->insertAfter($afterItems, $movedData, $adjustSched);
$endProfile = microtime(true);
Logging::debug("inserting after removing gaps.");
Logging::debug(floatval($endProfile) - floatval($startProfile));
$afterInstanceId = $afterInstance->getDbId();
$modified = array_keys($modifiedMap);
//need to adjust shows we have moved items from.
foreach($modified as $instanceId) {
$instance = CcShowInstancesQuery::create()->findPK($instanceId, $this->con);
$instance->updateScheduleStatus($this->con);
}
$this->con->useDebug(false);
$this->con->commit();
@ -543,9 +543,9 @@ class Application_Model_Scheduler {
$this->con->beginTransaction();
try {
$this->validateRequest($scheduledItems);
$scheduledIds = array();
foreach ($scheduledItems as $item) {
$scheduledIds[] = $item["id"];
@ -555,25 +555,25 @@ class Application_Model_Scheduler {
//check to make sure all items selected are up to date
foreach ($removedItems as $removedItem) {
$instance = $removedItem->getCcShowInstances($this->con);
//check to truncate the currently playing item instead of deleting it.
if ($removedItem->isCurrentItem($this->epochNow)) {
$nEpoch = $this->epochNow;
$sEpoch = $removedItem->getDbStarts('U.u');
$length = bcsub($nEpoch , $sEpoch , 6);
$cliplength = Application_Model_Playlist::secondsToPlaylistTime($length);
$cueinSec = Application_Model_Playlist::playlistTimeToSeconds($removedItem->getDbCueIn());
$cueOutSec = bcadd($cueinSec , $length, 6);
$cueout = Application_Model_Playlist::secondsToPlaylistTime($cueOutSec);
$removedItem->setDbCueOut($cueout)
->setDbClipLength($cliplength)
->setDbEnds($this->nowDT)
->setDbEnds($this->nowDT)
->save($this->con);
}
else {
@ -619,27 +619,27 @@ class Application_Model_Scheduler {
throw $e;
}
}
/*
* Used for cancelling the current show instance.
*
*
* @param $p_id id of the show instance to cancel.
*/
public function cancelShow($p_id) {
$this->con->beginTransaction();
try {
$instance = CcShowInstancesQuery::create()->findPK($p_id);
if (!$instance->getDbRecord()) {
$items = CcScheduleQuery::create()
->filterByDbInstanceId($p_id)
->filterByDbEnds($this->nowDT, Criteria::GREATER_THAN)
->find($this->con);
if (count($items) > 0) {
$remove = array();
$ts = $this->nowDT->format('U');
@ -657,12 +657,12 @@ class Application_Model_Scheduler {
$rebroadcasts = $instance->getCcShowInstancessRelatedByDbId(null, $this->con);
$rebroadcasts->delete($this->con);
}
$instance->setDbEnds($this->nowDT);
$instance->save($this->con);
$this->con->commit();
if ($instance->getDbRecord()) {
Application_Model_RabbitMq::SendMessageToShowRecorder("cancel_recording");
}
@ -670,7 +670,7 @@ class Application_Model_Scheduler {
catch (Exception $e) {
$this->con->rollback();
throw $e;
}
}
}
}

View File

@ -17,7 +17,7 @@ class Application_Model_ServiceRegister {
if ($p_ipAddress == "::1"){
$p_ipAddress = "127.0.0.1";
}
$component->setDbIp($p_ipAddress);
$component->save();
}

View File

@ -21,25 +21,25 @@ class Application_Model_Show {
$show->setDbName($name);
Application_Model_RabbitMq::PushSchedule();
}
public function setAirtimeAuthFlag($flag){
$show = CcShowQuery::create()->findPK($this->_showId);
$show->setDbLiveStreamUsingAirtimeAuth($flag);
$show->save();
}
public function setCustomAuthFlag($flag){
$show = CcShowQuery::create()->findPK($this->_showId);
$show->setDbLiveStreamUsingCustomAuth($flag);
$show->save();
}
public function setCustomUsername($username){
$show = CcShowQuery::create()->findPK($this->_showId);
$show->setDbLiveStreamUser($username);
$show->save();
}
public function setCustomPassword($password){
$show = CcShowQuery::create()->findPK($this->_showId);
$show->setDbLiveStreamPass($password);
@ -303,8 +303,6 @@ class Application_Model_Show {
." AND starts > TIMESTAMP '$timestamp'"
." AND show_id = $showId";
//Logging::log($sql);
$con->exec($sql);
}
@ -557,7 +555,7 @@ class Application_Model_Show {
$con->exec($sql);
}
/**
* Get the start date of the current show in UTC timezone.
*
@ -594,8 +592,8 @@ class Application_Model_Show {
* The start date in the format YYYY-MM-DD
*/
public function getStartDate(){
list($date,) = explode(" ", $this->getStartDateAndTime());
return $date;
list($date,) = explode(" ", $this->getStartDateAndTime());
return $date;
}
/**
@ -606,8 +604,8 @@ class Application_Model_Show {
*/
public function getStartTime(){
list(,$time) = explode(" ", $this->getStartDateAndTime());
return $time;
list(,$time) = explode(" ", $this->getStartDateAndTime());
return $time;
}
/**
@ -1251,8 +1249,8 @@ class Application_Model_Show {
$rebroadcasts = $con->query($sql)->fetchAll();
if ($showInstance->isRecorded()){
$showInstance->deleteRebroadcasts();
self::createRebroadcastInstances($rebroadcasts, $currentUtcTimestamp, $show_id, $show_instance_id, $start, $duration, $timezone);
$showInstance->deleteRebroadcasts();
self::createRebroadcastInstances($rebroadcasts, $currentUtcTimestamp, $show_id, $show_instance_id, $start, $duration, $timezone);
}
}
}
@ -1307,13 +1305,13 @@ class Application_Model_Show {
if ($show->hasInstanceOnDate($utcStartDateTime)){
$ccShowInstance = $show->getInstanceOnDate($utcStartDateTime);
if ($ccShowInstance->getDbModifiedInstance()){
//show instance on this date has been deleted.
list($start, $utcStartDateTime) = self::advanceRepeatingDate($p_interval, $start, $timezone);
continue;
}
$newInstance = false;
} else {
$ccShowInstance = new CcShowInstances();
@ -1349,7 +1347,7 @@ class Application_Model_Show {
Application_Model_Show::setNextPop($start, $show_id, $day);
}
private static function advanceRepeatingDate($p_interval, $start, $timezone){
$startDt = new DateTime($start, new DateTimeZone($timezone));
if ($p_interval == 'P1M'){
@ -1369,19 +1367,19 @@ class Application_Model_Show {
do {
$dt->add(new DateInterval($p_interval));
} while(!checkdate($dt->format("m"), $startDt->format("d"), $dt->format("Y")));
$dt->setDate($dt->format("Y"), $dt->format("m"), $startDt->format("d"));
} else {
$dt = new DateTime($start, new DateTimeZone($timezone));
$dt->add(new DateInterval($p_interval));
}
$start = $dt->format("Y-m-d H:i:s");
$dt->setTimezone(new DateTimeZone('UTC'));
$utcStartDateTime = $dt;
return array($start, $utcStartDateTime);
}
@ -1585,7 +1583,7 @@ class Application_Model_Show {
$days = $interval->format('%a');
$shows = Application_Model_Show::getShows($p_start, $p_end);
$nowEpoch = time();
foreach ($shows as $show) {
$options = array();
@ -1594,14 +1592,14 @@ class Application_Model_Show {
if (intval($days) <= 7) {
$options["percent"] = Application_Model_Show::getPercentScheduled($show["starts"], $show["ends"], $show["time_filled"]);
}
if (isset($show["parent_starts"])) {
$parentStartsDT = new DateTime($show["parent_starts"], new DateTimeZone("UTC"));
$parentStartsEpoch = intval($parentStartsDT->format("U"));
}
$startsDT = new DateTime($show["starts"], new DateTimeZone("UTC"));
$endsDT = new DateTime($show["ends"], new DateTimeZone("UTC"));
$startsEpoch = intval($startsDT->format("U"));
$endsEpoch = intval($endsDT->format("U"));
@ -1689,7 +1687,7 @@ class Application_Model_Show {
$showDay = CcShowDaysQuery::create()
->filterByDbShowId($this->_showId)
->findOne();
$showDay->setDbFirstShow($dt)->setDbStartTime($dt)
->save();
@ -1730,10 +1728,11 @@ class Application_Model_Show {
$con = Propel::getConnection();
if($timeNow == null){
$date = new Application_Common_DateHelper;
$timeNow = $date->getUtcTimestamp();
$timeNow = $date->getUtcTimestamp();
}
//TODO, returning starts + ends twice (once with an alias). Unify this after the 2.0 release. --Martin
$sql = "SELECT si.starts as start_timestamp, si.ends as end_timestamp, s.name, s.id, si.id as instance_id, si.record, s.url, starts, ends"
$sql = "SELECT si.starts as start_timestamp, si.ends as end_timestamp, s.name,"
." s.id, si.id as instance_id, si.record, s.url, starts, ends"
." FROM $CC_CONFIG[showInstances] si, $CC_CONFIG[showTable] s"
." WHERE si.show_id = s.id"
." AND si.starts <= TIMESTAMP '$timeNow'"
@ -1746,21 +1745,23 @@ class Application_Model_Show {
}
/**
* Gets the current show, previous and next with an 2day window from the given timeNow, so timeNow-2days and timeNow+2days.
* Gets the current show, previous and next with an 2day window from
* the given timeNow, so timeNow-2days and timeNow+2days.
*/
public static function getPrevCurrentNext($p_timeNow)
{
global $CC_CONFIG;
$con = Propel::getConnection();
//TODO, returning starts + ends twice (once with an alias). Unify this after the 2.0 release. --Martin
$sql = "SELECT si.starts as start_timestamp, si.ends as end_timestamp, s.name, s.id, si.id as instance_id, si.record, s.url, starts, ends"
$sql = "SELECT si.starts as start_timestamp, si.ends as end_timestamp, s.name,"
." s.id, si.id as instance_id, si.record, s.url, starts, ends"
." FROM $CC_CONFIG[showInstances] si, $CC_CONFIG[showTable] s"
." WHERE si.show_id = s.id"
." AND si.starts > TIMESTAMP '$p_timeNow' - INTERVAL '2 days'"
." AND si.ends < TIMESTAMP '$p_timeNow' + INTERVAL '2 days'"
." AND modified_instance != TRUE"
." ORDER BY si.starts";
$rows = $con->query($sql)->fetchAll(PDO::FETCH_ASSOC);
$numberOfRows = count($rows);
@ -1770,10 +1771,11 @@ class Application_Model_Show {
$timeNowAsMillis = strtotime($p_timeNow);
for( $i = 0; $i < $numberOfRows; ++$i ){
for ($i = 0; $i < $numberOfRows; ++$i) {
//Find the show that is within the current time.
if ((strtotime($rows[$i]['starts']) <= $timeNowAsMillis) && (strtotime($rows[$i]['ends']) > $timeNowAsMillis)){
if ( $i - 1 >= 0){
if ((strtotime($rows[$i]['starts']) <= $timeNowAsMillis)
&& (strtotime($rows[$i]['ends']) > $timeNowAsMillis)) {
if ($i-1 >= 0) {
$results['previousShow'][0] = array(
"id"=>$rows[$i-1]['id'],
"instance_id"=>$rows[$i-1]['instance_id'],
@ -1789,7 +1791,7 @@ class Application_Model_Show {
$results['currentShow'][0] = $rows[$i];
if ( isset($rows[$i+1])){
if (isset($rows[$i+1])) {
$results['nextShow'][0] = array(
"id"=>$rows[$i+1]['id'],
"instance_id"=>$rows[$i+1]['instance_id'],
@ -1801,7 +1803,6 @@ class Application_Model_Show {
"ends"=>$rows[$i+1]['ends'],
"record"=>$rows[$i+1]['record'],
"type"=>"show");
}
break;
}
@ -1839,7 +1840,7 @@ class Application_Model_Show {
"record"=>$rows[$previousShowIndex]['record'],
"type"=>"show");
}
return $results;
}
@ -1855,7 +1856,7 @@ class Application_Model_Show {
* @param String $timeEnd - interval end time (in UTC)
* @return array - the next $limit number of shows within the time interval
*/
public static function GetNextShows($timeStart, $limit = "0", $timeEnd = "")
public static function getNextShows($timeStart, $limit = "0", $timeEnd = "")
{
global $CC_CONFIG;
$con = Propel::getConnection();
@ -1878,7 +1879,7 @@ class Application_Model_Show {
." ORDER BY si.starts";
// defaults to retrieve all shows within the interval if $limit not set
if($limit != "0") {
if ($limit != "0") {
$sql = $sql . " LIMIT $limit";
}
@ -1893,20 +1894,22 @@ class Application_Model_Show {
* @param type $rows arrays of arrays containing database query result
* @param type $columnsToConvert array of column names to convert
*/
public static function ConvertToLocalTimeZone(&$rows, $columnsToConvert) {
public static function convertToLocalTimeZone(&$rows, $columnsToConvert)
{
$timezone = date_default_timezone_get();
if (!is_array($rows)) {
return;
}
foreach($rows as &$row) {
foreach($columnsToConvert as $column) {
foreach ($rows as &$row) {
foreach ($columnsToConvert as $column) {
$row[$column] = Application_Common_DateHelper::ConvertToLocalDateTimeString($row[$column]);
}
}
}
public static function GetMaxLengths() {
public static function getMaxLengths()
{
global $CC_CONFIG;
$con = Propel::getConnection();

View File

@ -14,14 +14,14 @@ class Application_Model_ShowBuilder {
private $user;
private $opts;
private $pos;
private $contentDT;
private $epoch_now;
private $currentShow;
private $showInstances = array();
private $defaultRowArray = array(
"header" => false,
"footer" => false,
@ -54,16 +54,16 @@ class Application_Model_ShowBuilder {
$this->startDT = $p_startDT;
$this->endDT = $p_endDT;
$this->timezone = date_default_timezone_get();
$this->user = Application_Model_User::GetCurrentUser();
$this->user = Application_Model_User::getCurrentUser();
$this->opts = $p_opts;
$this->epoch_now = floatval(microtime(true));
$this->currentShow = false;
}
private function getUsersShows() {
$shows = array();
$host_shows = CcShowHostsQuery::create()
->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)
->filterByDbHost($this->user->getId())
@ -72,7 +72,7 @@ class Application_Model_ShowBuilder {
foreach ($host_shows as $host_show) {
$shows[] = $host_show->getDbShow();
}
return $shows;
}
@ -84,15 +84,15 @@ class Application_Model_ShowBuilder {
return;
}
if ($this->user->canSchedule($p_item["show_id"]) == true) {
if ($this->user->canSchedule($p_item["show_id"]) == true) {
$row["allowed"] = true;
}
}
}
private function getItemColor($p_item, &$row) {
$defaultColor = "ffffff";
$defaultBackground = "3366cc";
$color = $p_item["show_color"];
if ($color === '') {
$color = $defaultColor;
@ -101,7 +101,7 @@ class Application_Model_ShowBuilder {
if ($backgroundColor === '') {
$backgroundColor = $defaultBackground;
}
$row["color"] = $color;
$row["backgroundColor"] = $backgroundColor;
}
@ -123,7 +123,7 @@ class Application_Model_ShowBuilder {
}
$row["timestamp"] = $ts;
}
/*
* marks a row's status.
* 0 = past
@ -131,7 +131,7 @@ class Application_Model_ShowBuilder {
* 2 = future
*/
private function getScheduledStatus($p_epochItemStart, $p_epochItemEnd, &$row) {
if ($row["footer"] === true && $this->epoch_now > $p_epochItemStart && $this->epoch_now > $p_epochItemEnd) {
$row["scheduled"] = 0;
}
@ -144,7 +144,7 @@ class Application_Model_ShowBuilder {
else if ($row["header"] === true && $this->epoch_now < $p_epochItemEnd) {
$row["scheduled"] = 2;
}
//item is in the past.
else if ($this->epoch_now > $p_epochItemEnd) {
$row["scheduled"] = 0;
@ -156,7 +156,7 @@ class Application_Model_ShowBuilder {
//how many seconds the view should wait to redraw itself.
$row["refresh"] = $p_epochItemEnd - $this->epoch_now;
}
//item is in the future.
else if ($this->epoch_now < $p_epochItemStart) {
$row["scheduled"] = 2;
@ -176,31 +176,31 @@ class Application_Model_ShowBuilder {
$showEndDT = new DateTime($p_item["si_ends"], new DateTimeZone("UTC"));
$showEndDT->setTimezone(new DateTimeZone($this->timezone));
$endsEpoch = floatval($showEndDT->format("U.u"));
//is a rebroadcast show
if (intval($p_item["si_rebroadcast"]) === 1) {
$row["rebroadcast"] = true;
$parentInstance = CcShowInstancesQuery::create()->findPk($p_item["parent_show"]);
$name = $parentInstance->getCcShow()->getDbName();
$dt = $parentInstance->getDbStarts(null);
$dt->setTimezone(new DateTimeZone($this->timezone));
$time = $dt->format("Y-m-d H:i");
$row["rebroadcast_title"] = "Rebroadcast of {$name} from {$time}";
}
else if (intval($p_item["si_record"]) === 1) {
$row["record"] = true;
if (Application_Model_Preference::GetUploadToSoundcloudOption()) {
$file = Application_Model_StoredFile::Recall($p_item["si_file_id"]);
if (isset($file)) {
$sid = $file->getSoundCloudId();
$row["soundcloud_id"] = $sid;
}
}
}
}
if ($startsEpoch < $this->epoch_now && $endsEpoch > $this->epoch_now) {
$row["currentShow"] = true;
$this->currentShow = true;
@ -221,7 +221,7 @@ class Application_Model_ShowBuilder {
$row["title"] = $p_item["show_name"];
$row["instance"] = intval($p_item["si_id"]);
$row["image"] = '';
$this->getScheduledStatus($startsEpoch, $endsEpoch, $row);
$this->contentDT = $showStartDT;
@ -254,7 +254,7 @@ class Application_Model_ShowBuilder {
$row["instance"] = intval($p_item["si_id"]);
$row["starts"] = $schedStartDT->format("H:i:s");
$row["ends"] = $schedEndDT->format("H:i:s");
$formatter = new LengthFormatter($p_item['file_length']);
$row['runtime'] = $formatter->format();
@ -266,7 +266,7 @@ class Application_Model_ShowBuilder {
$row["cueout"] = $p_item["cue_out"];
$row["fadein"] = round(substr($p_item["fade_in"], 6), 6);
$row["fadeout"] = round(substr($p_item["fade_out"], 6), 6);
$row["pos"] = $this->pos++;
$this->contentDT = $schedEndDT;
@ -275,10 +275,10 @@ class Application_Model_ShowBuilder {
else if (intval($p_item["si_record"]) === 1) {
$row["record"] = true;
$row["instance"] = intval($p_item["si_id"]);
$showStartDT = new DateTime($p_item["si_starts"], new DateTimeZone("UTC"));
$showEndDT = new DateTime($p_item["si_ends"], new DateTimeZone("UTC"));
$startsEpoch = floatval($showStartDT->format("U.u"));
$endsEpoch = floatval($showEndDT->format("U.u"));
@ -289,7 +289,7 @@ class Application_Model_ShowBuilder {
$row["id"] = 0 ;
$row["instance"] = intval($p_item["si_id"]);
}
if (intval($p_item["si_rebroadcast"]) === 1) {
$row["rebroadcast"] = true;
}
@ -320,23 +320,23 @@ class Application_Model_ShowBuilder {
$timeFilled = new TimeFilledFormatter($runtime);
$row["fRuntime"] = $timeFilled->format();
$showStartDT = new DateTime($p_item["si_starts"], new DateTimeZone("UTC"));
$showStartDT->setTimezone(new DateTimeZone($this->timezone));
$startsEpoch = floatval($showStartDT->format("U.u"));
$showEndDT = new DateTime($p_item["si_ends"], new DateTimeZone("UTC"));
$showEndDT->setTimezone(new DateTimeZone($this->timezone));
$endsEpoch = floatval($showEndDT->format("U.u"));
$row["refresh"] = floatval($showEndDT->format("U.u")) - $this->epoch_now;
if ($this->currentShow === true) {
$row["currentShow"] = true;
}
$this->getScheduledStatus($startsEpoch, $endsEpoch, $row);
$this->isAllowed($p_item, $row);
return $row;
}
@ -349,7 +349,7 @@ class Application_Model_ShowBuilder {
public function hasBeenUpdatedSince($timestamp, $instances) {
$outdated = false;
$shows = Application_Model_Show::getShows($this->startDT, $this->endDT);
if ($this->opts["showFilter"] !== 0) {
$include[] = $this->opts["showFilter"];
}
@ -357,22 +357,22 @@ class Application_Model_ShowBuilder {
$include = $this->getUsersShows();
}
$currentInstances = array();
foreach ($shows as $show) {
if (empty($include) || in_array($show["show_id"], $include)) {
$currentInstances[] = $show["instance_id"];
if (isset($show["last_scheduled"])) {
$dt = new DateTime($show["last_scheduled"], new DateTimeZone("UTC"));
}
else {
$dt = new DateTime($show["created"], new DateTimeZone("UTC"));
}
//check if any of the shows have a more recent timestamp.
$showTimeStamp = intval($dt->format("U"));
if ($timestamp < $showTimeStamp) {
@ -411,7 +411,7 @@ class Application_Model_ShowBuilder {
for ($i = 0, $rows = count($scheduled_items); $i < $rows; $i++) {
$item = $scheduled_items[$i];
//don't send back data for filler rows.
if (isset($item["playout_status"]) && $item["playout_status"] < 0) {
continue;
@ -425,11 +425,11 @@ class Application_Model_ShowBuilder {
//pass in the previous row as it's the last row for the previous show.
$display_items[] = $this->makeFooterRow($scheduled_items[$i-1]);
}
$display_items[] = $this->makeHeaderRow($item);
$current_id = $item["si_id"];
$this->pos = 1;
}
@ -449,7 +449,7 @@ class Application_Model_ShowBuilder {
if (count($scheduled_items) > 0) {
$display_items[] = $this->makeFooterRow($scheduled_items[count($scheduled_items)-1]);
}
return array("schedule" => $display_items, "showInstances" => $this->showInstances);
}
}

View File

@ -30,7 +30,7 @@ class Application_Model_ShowInstance {
public function getShow(){
return new Application_Model_Show($this->getShowId());
}
public function deleteRebroadcasts(){
$con = Propel::getConnection();
@ -42,7 +42,7 @@ class Application_Model_ShowInstance {
." AND instance_id = $instance_id"
." AND rebroadcast = 1";
$con->exec($sql);
$con->exec($sql);
}
/* This function is weird. It should return a boolean, but instead returns
@ -256,11 +256,11 @@ class Application_Model_ShowInstance {
if ($today_timestamp > $newStartsDateTime->getTimestamp()) {
return "Can't move show into past";
}
//check if show is overlapping
$overlapping = Application_Model_Schedule::checkOverlappingShows($newStartsDateTime, $newEndsDateTime, true, $this->getShowInstanceId());
if ($overlapping) {
return "Cannot schedule overlapping shows";
return "Cannot schedule overlapping shows";
}
if ($this->isRecorded()) {
@ -579,7 +579,7 @@ class Application_Model_ShowInstance {
public function getTimeScheduled()
{
$time = $this->_showInstance->getDbTimeFilled();
if ($time != "00:00:00" && !empty($time)) {
$time_arr = explode(".", $time);
if (count($time_arr) > 1) {
@ -593,7 +593,7 @@ class Application_Model_ShowInstance {
} else {
$time = "00:00:00.00";
}
return $time;
}
@ -637,7 +637,7 @@ class Application_Model_ShowInstance {
} else {
$returnStr = $hours . ":" . $interval->format("%I:%S") . ".00";
}
return $returnStr;
}
@ -670,30 +670,30 @@ class Application_Model_ShowInstance {
public function getLastAudioItemEnd()
{
$con = Propel::getConnection();
$con = Propel::getConnection();
$sql = "SELECT ends FROM cc_schedule "
."WHERE instance_id = {$this->_instanceId} "
."ORDER BY ends DESC "
."LIMIT 1";
$sql = "SELECT ends FROM cc_schedule "
."WHERE instance_id = {$this->_instanceId} "
."ORDER BY ends DESC "
."LIMIT 1";
$query = $con->query($sql)->fetchColumn(0);
$query = $con->query($sql)->fetchColumn(0);
return ($query !== false) ? $query : NULL;
}
}
public function getShowEndGapTime(){
$showEnd = $this->getShowInstanceEnd();
$lastItemEnd = $this->getLastAudioItemEnd();
$showEnd = $this->getShowInstanceEnd();
$lastItemEnd = $this->getLastAudioItemEnd();
if (is_null($lastItemEnd)){
$lastItemEnd = $this->getShowInstanceStart();
}
if (is_null($lastItemEnd)){
$lastItemEnd = $this->getShowInstanceStart();
}
$diff = strtotime($showEnd) - strtotime($lastItemEnd);
$diff = strtotime($showEnd) - strtotime($lastItemEnd);
return ($diff < 0) ? 0 : $diff;
}
return ($diff < 0) ? 0 : $diff;
}
public static function GetLastShowInstance($p_timeNow){
global $CC_CONFIG;
@ -777,14 +777,14 @@ class Application_Model_ShowInstance {
$con = Propel::getConnection();
$sql = "SELECT ends
FROM cc_show_instances as si
FROM cc_show_instances as si
JOIN cc_show as sh ON si.show_id = sh.id
WHERE si.ends > '$p_startTime' and si.ends < '$p_endTime' and (sh.live_stream_using_airtime_auth or live_stream_using_custom_auth)
ORDER BY si.ends";
WHERE si.ends > '$p_startTime' and si.ends < '$p_endTime' and (sh.live_stream_using_airtime_auth or live_stream_using_custom_auth)
ORDER BY si.ends";
return $con->query($sql)->fetchAll();
}
function isRepeating(){
if ($this->getShow()->isRepeating()){
return true;

View File

@ -5,7 +5,7 @@ class Application_Model_Soundcloud {
private $_soundcloud;
public function __construct()
public function __construct()
{
global $CC_CONFIG;
@ -35,7 +35,7 @@ class Application_Model_Soundcloud {
}
$downloadable = Application_Model_Preference::GetSoundCloudDownloadbleOption() == '1'?true:false;
$track_data = array(
'track[sharing]' => 'private',
'track[title]' => $filename,
@ -77,7 +77,7 @@ class Application_Model_Soundcloud {
if ($license != "") {
$track_data['track[license]'] = $license;
}
$response = json_decode(
$this->_soundcloud->post('tracks', $track_data),
true

View File

@ -91,7 +91,7 @@ class Application_Model_StoredFile {
}
else {
$dbMd = array();
if (isset($p_md["MDATA_KEY_YEAR"])){
// We need to make sure to clean this value before inserting into database.
// If value is outside of range [-2^31, 2^31-1] then postgresl will throw error
@ -100,9 +100,9 @@ class Application_Model_StoredFile {
// new garbage value won't cause errors). If the value is 2012-01-01, then substring to
// first 4 digits is an OK result.
// CC-3771
$year = $p_md["MDATA_KEY_YEAR"];
if (strlen($year) > 4){
$year = substr($year, 0, 4);
}
@ -111,7 +111,7 @@ class Application_Model_StoredFile {
}
$p_md["MDATA_KEY_YEAR"] = $year;
}
foreach ($p_md as $mdConst => $mdValue) {
if (defined($mdConst)){
$dbMd[constant($mdConst)] = $mdValue;
@ -161,9 +161,9 @@ class Application_Model_StoredFile {
* Set metadata element value
*
* @param string $category
* Metadata element by metadata constant
* Metadata element by metadata constant
* @param string $value
* value to store, if NULL then delete record
* value to store, if NULL then delete record
*/
public function setMetadataValue($p_category, $p_value)
{
@ -176,9 +176,9 @@ class Application_Model_StoredFile {
* Set metadata element value
*
* @param string $category
* Metadata element by db column
* Metadata element by db column
* @param string $value
* value to store, if NULL then delete record
* value to store, if NULL then delete record
*/
public function setDbColMetadataValue($p_category, $p_value)
{
@ -245,12 +245,12 @@ class Application_Model_StoredFile {
{
$c = get_defined_constants(true);
$md = array();
/* Create a copy of dbMD here and create a "filepath" key inside of
/* Create a copy of dbMD here and create a "filepath" key inside of
* it. The reason we do this here, instead of creating this key inside
* dbMD is because "filepath" isn't really metadata, and we don't want
* dbMD is because "filepath" isn't really metadata, and we don't want
* filepath updated everytime the metadata changes. Also it needs extra
* processing before we can write it to the database (needs to be split
* processing before we can write it to the database (needs to be split
* into base and relative path)
* */
$dbmd_copy = $this->_dbMD;
@ -273,9 +273,9 @@ class Application_Model_StoredFile {
* Set state of virtual file
*
* @param string $p_state
* 'empty'|'incomplete'|'ready'|'edited'
* 'empty'|'incomplete'|'ready'|'edited'
* @param int $p_editedby
* user id | 'NULL' for clear editedBy field
* user id | 'NULL' for clear editedBy field
* @return TRUE
*/
public function setState($p_state, $p_editedby=NULL)
@ -330,7 +330,7 @@ class Application_Model_StoredFile {
$music_dir = Application_Model_MusicDir::getDirByPK($this->_file->getDbDirectory());
$type = $music_dir->getType();
if (file_exists($filepath) && $type == "stor") {
$data = array("filepath" => $filepath, "delete" => 1);
Application_Model_RabbitMq::SendMessageToMediaMonitor("file_delete", $data);
@ -343,7 +343,7 @@ class Application_Model_StoredFile {
$this->_file->setDbFileExists(false);
$this->_file->save();
}
/**
* This function is for when media monitor detects deletion of file
* and trying to update airtime side
@ -367,7 +367,7 @@ class Application_Model_StoredFile {
* Return suitable extension.
*
* @return string
* file extension without a dot
* file extension without a dot
*/
public function getFileExtension()
{
@ -395,7 +395,7 @@ class Application_Model_StoredFile {
return $directory.$filepath;
}
/**
* Set real filename of raw media data
*
@ -500,9 +500,9 @@ Logging::log("getting media! - 2");
* be NULL.
*
* @param int $p_id
* local id
* local id
* @param string $p_gunid
* global unique id of file
* global unique id of file
* @param string $p_md5sum
* MD5 sum of the file
* @param boolean $exist
@ -570,7 +570,7 @@ Logging::log("getting media! - 2");
* by gunid.
*
* @param string $p_gunid
* global unique id of file
* global unique id of file
* @return Application_Model_StoredFile|NULL
*/
public static function RecallByGunid($p_gunid)
@ -624,7 +624,7 @@ Logging::log("getting media! - 2");
public static function searchLibraryFiles($datatables) {
$con = Propel::getConnection(CcFilesPeer::DATABASE_NAME);
$con = Propel::getConnection(CcFilesPeer::DATABASE_NAME);
$displayColumns = array("id", "track_title", "artist_name", "album_title", "genre", "length",
"year", "utime", "mtime", "ftype", "track_number", "mood", "bpm", "composer", "info_url",
@ -871,26 +871,26 @@ Logging::log("getting media! - 2");
return $result;
}
}
if (chmod($audio_file, 0644) === false){
Logging::log("Warning: couldn't change permissions of $audio_file to 0644");
}
//check to see if there is enough space in $stor to continue.
if (self::isEnoughDiskSpaceToCopy($stor, $audio_file)){
$audio_stor = Application_Common_OsPath::join($stor, "organize", $fileName);
if (self::liquidsoapFilePlayabilityTest($audio_file)){
Logging::log("copyFileToStor: moving file $audio_file to $audio_stor");
//Martin K.: changed to rename: Much less load + quicker since this is an atomic operation
if (@rename($audio_file, $audio_stor) === false) {
#something went wrong likely there wasn't enough space in the audio_stor to move the file too.
#warn the user that the file wasn't uploaded and they should check if there is enough disk space.
unlink($audio_file);//remove the file after failed rename
$result = array("code" => 108, "message" => "The file was not uploaded, this error can occur if the computer hard drive does not have enough disk space.");
}
}
} else {
$result = array("code" => 110, "message" => "This file appears to be corrupted and will not be added to media library.");
}
@ -901,23 +901,23 @@ Logging::log("getting media! - 2");
}
return $result;
}
/*
* Pass the file through Liquidsoap and test if it is readable. Return True if readable, and False otherwise.
*/
public static function liquidsoapFilePlayabilityTest($audio_file){
$LIQUIDSOAP_ERRORS = array('TagLib: MPEG::Properties::read() -- Could not find a valid last MPEG frame in the stream.');
// Ask Liquidsoap if file is playable
$command = sprintf("/usr/bin/airtime-liquidsoap -c 'output.dummy(audio_to_stereo(single(\"%s\")))' 2>&1", $audio_file);
exec($command, $output, $rv);
$isError = count($output) > 0 && in_array($output[0], $LIQUIDSOAP_ERRORS);
return ($rv == 0 && !$isError);
return ($rv == 0 && !$isError);
}
public static function getFileCount()
{
global $CC_CONFIG;
@ -960,28 +960,28 @@ Logging::log("getting media! - 2");
return $results;
}
/* Gets number of tracks uploaded to
* Soundcloud in the last 24 hours
*/
public static function getSoundCloudUploads()
{
try {
$con = Propel::getConnection();
$sql = "SELECT soundcloud_id as id, soundcloud_upload_time"
$con = Propel::getConnection();
$sql = "SELECT soundcloud_id as id, soundcloud_upload_time"
." FROM CC_FILES"
." WHERE (id != -2 and id != -3) and"
." (soundcloud_upload_time >= (now() - (INTERVAL '1 day')))";
$rows = $con->query($sql)->fetchAll();
return count($rows);
} catch (Exception $e) {
header('HTTP/1.0 503 Service Unavailable');
Logging::log("Could not connect to database.");
exit;
exit;
}
}
public function setSoundCloudLinkToFile($link_to_file)
@ -1021,10 +1021,10 @@ Logging::log("getting media! - 2");
public function getSoundCloudErrorMsg(){
return $this->_file->getDbSoundCloudErrorMsg();
}
public function getDirectory(){
return $this->_file->getDbDirectory();
}
return $this->_file->getDbDirectory();
}
public function setFileExistsFlag($flag){
$this->_file->setDbFileExists($flag)
@ -1032,7 +1032,7 @@ Logging::log("getting media! - 2");
}
public function setSoundCloudUploadTime($time){
$this->_file->setDbSoundCloundUploadTime($time)
->save();
->save();
}
public function getFileExistsFlag(){

View File

@ -1,7 +1,7 @@
<?php
class Application_Model_StreamSetting {
public static function SetValue($key, $value, $type)
public static function setValue($key, $value, $type)
{
global $CC_CONFIG;
$con = Propel::getConnection();
@ -27,7 +27,7 @@ class Application_Model_StreamSetting {
return $con->exec($sql);
}
public static function GetValue($key)
public static function getValue($key)
{
global $CC_CONFIG;
$con = Propel::getConnection();
@ -37,14 +37,14 @@ class Application_Model_StreamSetting {
." WHERE keyname = '$key'";
$result = $con->query($sql)->fetchColumn(0);
if ($result == 0)
if ($result == 0) {
return "";
else {
} else {
$sql = "SELECT value FROM cc_stream_setting"
." WHERE keyname = '$key'";
$result = $con->query($sql)->fetchColumn(0);
return ($result !== false) ? $result : NULL;
return ($result !== false) ? $result : null;
}
}
@ -130,16 +130,24 @@ class Application_Model_StreamSetting {
}
if (!isset($exists["master_live_stream_port"])) {
$rows[] = (array("keyname" =>"master_live_stream_port", "value"=>self::GetMasterLiveSteamPort(), "type"=>"integer"));
$rows[] = array("keyname" =>"master_live_stream_port",
"value"=>self::getMasterLiveStreamPort(),
"type"=>"integer");
}
if (!isset($exists["master_live_stream_mp"])) {
$rows[] = (array("keyname" =>"master_live_stream_mp", "value"=>self::GetMasterLiveSteamMountPoint(), "type"=>"string"));
$rows[] = array("keyname" =>"master_live_stream_mp",
"value"=>self::getMasterLiveStreamMountPoint(),
"type"=>"string");
}
if (!isset($exists["dj_live_stream_port"])) {
$rows[] = (array("keyname" =>"dj_live_stream_port", "value"=>self::GetDJLiveSteamPort(), "type"=>"integer"));
$rows[] = array("keyname" =>"dj_live_stream_port",
"value"=>self::getDjLiveStreamPort(),
"type"=>"integer");
}
if (!isset($exists["dj_live_stream_mp"])) {
$rows[] = (array("keyname" =>"dj_live_stream_mp", "value"=>self::GetDJLiveSteamMountPoint(), "type"=>"string"));
$rows[] = array("keyname" =>"dj_live_stream_mp",
"value"=>self::getDjLiveStreamMountPoint(),
"type"=>"string");
}
return $rows;
}
@ -155,7 +163,7 @@ class Application_Model_StreamSetting {
{
$con = Propel::getConnection();
foreach ($data as $key=>$d) {
foreach ($data as $key => $d) {
if ($key == "output_sound_device" || $key == "icecast_vorbis_metadata") {
$v = $d == 1?"true":"false";
$sql = "UPDATE cc_stream_setting SET value='$v' WHERE keyname='$key'";
@ -166,13 +174,13 @@ class Application_Model_StreamSetting {
} else if (is_array($d)) {
$temp = explode('_', $key);
$prefix = $temp[0];
foreach ($d as $k=>$v) {
foreach ($d as $k => $v) {
$keyname = $prefix . "_" . $k;
if ($k == 'enable') {
$v = $d['enable'] == 1 ? 'true' : 'false';
}
$v = trim($v);
#escape double single quotes CC-3926
$v = str_replace("'", "''", $v);
$sql = "UPDATE cc_stream_setting SET value='$v' WHERE keyname='$keyname'";
@ -233,7 +241,7 @@ class Application_Model_StreamSetting {
." WHERE keyname = '$keyname'";
$result = $con->query($sql)->fetchColumn(0);
return ($result !== false) ? $result : NULL;
return ($result !== false) ? $result : null;
}
public static function getStreamEnabled($stream_id)
@ -264,7 +272,8 @@ class Application_Model_StreamSetting {
$enabled_stream = self::getEnabledStreamIds();
foreach ($enabled_stream as $stream) {
$keys = "'".$stream."_output', "."'".$stream."_type', "."'".$stream."_bitrate', "."'".$stream."_host'";
$keys = "'".$stream."_output', "."'".$stream."_type', "."'"
.$stream."_bitrate', "."'".$stream."_host'";
$sql = "SELECT keyname, value FROM cc_stream_setting"
." WHERE keyname IN ($keys)";
@ -280,35 +289,43 @@ class Application_Model_StreamSetting {
return $out;
}
public static function SetMasterLiveSteamPort($value){
self::SetValue("master_live_stream_port", $value, "integer");
public static function setMasterLiveStreamPort($value)
{
self::setValue("master_live_stream_port", $value, "integer");
}
public static function GetMasterLiveSteamPort(){
return self::GetValue("master_live_stream_port");
public static function getMasterLiveStreamPort()
{
return self::getValue("master_live_stream_port");
}
public static function SetMasterLiveSteamMountPoint($value){
self::SetValue("master_live_stream_mp", $value, "string");
public static function setMasterLiveStreamMountPoint($value)
{
self::setValue("master_live_stream_mp", $value, "string");
}
public static function GetMasterLiveSteamMountPoint(){
return self::GetValue("master_live_stream_mp");
public static function getMasterLiveStreamMountPoint()
{
return self::getValue("master_live_stream_mp");
}
public static function SetDJLiveSteamPort($value){
self::SetValue("dj_live_stream_port", $value, "integer");
public static function setDjLiveStreamPort($value)
{
self::setValue("dj_live_stream_port", $value, "integer");
}
public static function GetDJLiveSteamPort(){
return self::GetValue("dj_live_stream_port");
public static function getDjLiveStreamPort()
{
return self::getValue("dj_live_stream_port");
}
public static function SetDJLiveSteamMountPoint($value){
self::SetValue("dj_live_stream_mp", $value, "string");
public static function setDjLiveStreamMountPoint($value)
{
self::setValue("dj_live_stream_mp", $value, "string");
}
public static function GetDJLiveSteamMountPoint(){
return self::GetValue("dj_live_stream_mp");
public static function getDjLiveStreamMountPoint()
{
return self::getValue("dj_live_stream_mp");
}
}

View File

@ -18,102 +18,6 @@ class Application_Model_Subjects {
/* ======================================================= public methods */
/**
* Check login and password
*
* @param string $login
* @param string $pass
* optional
* @return boolean|int|PEAR_Error
*/
public static function Authenticate($login, $pass='')
{
global $CC_CONFIG;
$con = Propel::getConnection();
$cpass = md5($pass);
$sql = "SELECT id FROM ".$CC_CONFIG['subjTable']
." WHERE login='$login' AND pass='$cpass' AND type='U'"
." LIMIT 1";
$query = $con->query($sql)->fetchColumn(0);
return $query;
}
/**
* Change user password
*
* @param string $login
* @param string $oldpass
* old password (optional for 'superuser mode')
* @param string $pass
* optional
* @param boolean $passenc
* optional, password already encrypted if true
* @return boolean|PEAR_Error
*/
public static function Passwd($login, $oldpass=null, $pass='', $passenc=FALSE)
{
global $CC_CONFIG;
$con = Propel::getConnection();
if (!$passenc) {
$cpass = md5($pass);
} else {
$cpass = $pass;
}
if (!is_null($oldpass)) {
$oldcpass = md5($oldpass);
$oldpCond = "AND pass='$oldcpass'";
} else {
$oldpCond = '';
}
$sql = "UPDATE ".$CC_CONFIG['subjTable']." SET pass='$cpass'"
." WHERE login='$login' $oldpCond AND type='U'";
$con->exec($sql);
return TRUE;
}
/* --------------------------------------------------------------- groups */
/* --------------------------------------------------------- info methods */
/**
* Get subject id from login
*
* @param string $login
* @return int|false
*/
public static function GetSubjId($login)
{
global $CC_CONFIG;
$con = Propel::getConnection();
$sql = "SELECT id FROM ".$CC_CONFIG['subjTable']
." WHERE login='$login'";
$query = $con->query($sql)->fetchColumn(0);
return ($query !== false) ? $query : NULL;
}
/**
* Return true if uid is direct member of gid
*
* @param int $uid
* local user id
* @param int $gid
* local group id
* @return boolean
*/
public static function IsMemberOf($uid, $gid)
{
global $CC_CONFIG;
$con = Propel::getConnection();
$sql = "SELECT count(*) as cnt"
." FROM ".$CC_CONFIG['smembTable']
." WHERE uid='$uid' AND gid='$gid'";
$res = $con->query($sql)->fetchColumn(0);
return (intval($res) > 0);
}
public static function increaseLoginAttempts($login)
{
global $CC_CONFIG;
@ -131,7 +35,7 @@ class Application_Model_Subjects {
$sql = "UPDATE ".$CC_CONFIG['subjTable']." SET login_attempts = '0'"
." WHERE login='$login'";
$res = $con->exec($sql);
return TRUE;
return true;
}
public static function getLoginAttempts($login)

View File

@ -9,15 +9,15 @@ class Application_Model_Systemstatus
$monit_password = $CC_CONFIG['monit_password'];
$url = "http://$p_ip:2812/_status?format=xml";
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERPWD, "$monit_user:$monit_password");
//wait a max of 3 seconds before aborting connection attempt
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
$result = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
@ -32,7 +32,7 @@ class Application_Model_Systemstatus
return $docRoot;
}
public static function ExtractServiceInformation($p_docRoot, $p_serviceName){
$starting = array(
@ -43,7 +43,7 @@ class Application_Model_Systemstatus
"memory_perc"=>"0%",
"memory_kb"=>"0",
"cpu_perc"=>"0%");
$notMonitored = array(
"name"=>$p_serviceName,
"process_id"=>"NOT MONITORED",
@ -53,7 +53,7 @@ class Application_Model_Systemstatus
"memory_kb"=>"0",
"cpu_perc"=>"0%"
);
$notRunning = array(
"name"=>$p_serviceName,
"process_id"=>"FAILED",
@ -65,7 +65,7 @@ class Application_Model_Systemstatus
);
$data = $notRunning;
if (!is_null($p_docRoot)){
foreach ($p_docRoot->getElementsByTagName("service") AS $item)
{
@ -93,7 +93,7 @@ class Application_Model_Systemstatus
if ($process_id->length > 0){
$data["name"] = $process_id->item(0)->nodeValue;
}
$process_id = $item->getElementsByTagName("pid");
if ($process_id->length > 0){
$data["process_id"] = $process_id->item(0)->nodeValue;
@ -104,13 +104,13 @@ class Application_Model_Systemstatus
if ($uptime->length > 0){
$data["uptime_seconds"] = $uptime->item(0)->nodeValue;
}
$memory = $item->getElementsByTagName("memory");
if ($memory->length > 0){
$data["memory_perc"] = $memory->item(0)->getElementsByTagName("percenttotal")->item(0)->nodeValue."%";
$data["memory_kb"] = $memory->item(0)->getElementsByTagName("kilobytetotal")->item(0)->nodeValue;
}
$cpu = $item->getElementsByTagName("cpu");
if ($cpu->length > 0){
$data["cpu_perc"] = $cpu->item(0)->getElementsByTagName("percent")->item(0)->nodeValue."%";
@ -127,7 +127,7 @@ class Application_Model_Systemstatus
foreach($keys as $key) {
$data[$key] = "UNKNOWN";
}
$docRoot = self::GetMonitStatus("localhost");
if (!is_null($docRoot)){
foreach ($docRoot->getElementsByTagName("platform") AS $item)
@ -140,7 +140,7 @@ class Application_Model_Systemstatus
}
}
}
return $data;
}
@ -151,14 +151,14 @@ class Application_Model_Systemstatus
return null;
} else {
$ip = $component->getDbIp();
$docRoot = self::GetMonitStatus($ip);
$data = self::ExtractServiceInformation($docRoot, "airtime-playout");
return $data;
}
}
public static function GetLiquidsoapStatus(){
$component = CcServiceRegisterQuery::create()->findOneByDbName("pypo");
@ -166,14 +166,14 @@ class Application_Model_Systemstatus
return null;
} else {
$ip = $component->getDbIp();
$docRoot = self::GetMonitStatus($ip);
$data = self::ExtractServiceInformation($docRoot, "airtime-liquidsoap");
return $data;
}
}
public static function GetMediaMonitorStatus(){
$component = CcServiceRegisterQuery::create()->findOneByDbName("media-monitor");
@ -181,15 +181,15 @@ class Application_Model_Systemstatus
return null;
} else {
$ip = $component->getDbIp();
$docRoot = self::GetMonitStatus($ip);
$data = self::ExtractServiceInformation($docRoot, "airtime-media-monitor");
return $data;
}
}
public static function GetIcecastStatus(){
public static function GetIcecastStatus(){
$docRoot = self::GetMonitStatus("localhost");
$data = self::ExtractServiceInformation($docRoot, "icecast2");
@ -197,7 +197,7 @@ class Application_Model_Systemstatus
}
public static function GetRabbitMqStatus(){
if (isset($_SERVER["RABBITMQ_HOST"])){
$rabbitmq_host = $_SERVER["RABBITMQ_HOST"];
} else {
@ -208,18 +208,18 @@ class Application_Model_Systemstatus
return $data;
}
public static function GetDiskInfo(){
$partions = array();
if (isset($_SERVER['AIRTIME_SRV'])){
//connect to DB and find how much total space user has allocated.
$totalSpace = Application_Model_Preference::GetDiskQuota();
$storPath = Application_Model_MusicDir::getStorDir()->getDirectory();
list($usedSpace,) = preg_split("/[\s]+/", exec("du -bs $storPath"));
$partitions[$totalSpace]->totalSpace = $totalSpace;
$partitions[$totalSpace]->totalFreeSpace = $totalSpace - $usedSpace;
Logging::log($partitions[$totalSpace]->totalFreeSpace);
@ -228,7 +228,7 @@ class Application_Model_Systemstatus
* into the same partitions by comparing the partition sizes. */
$musicDirs = Application_Model_MusicDir::getWatchedDirs();
$musicDirs[] = Application_Model_MusicDir::getStorDir();
foreach($musicDirs as $md){
$totalSpace = disk_total_space($md->getDirectory());
@ -238,7 +238,7 @@ class Application_Model_Systemstatus
$partitions[$totalSpace]->totalFreeSpace = disk_free_space($md->getDirectory());
}
$partitions[$totalSpace]->dirs[] = $md->getDirectory();
}
}

View File

@ -11,191 +11,220 @@ class Application_Model_User {
public function __construct($userId)
{
if (empty($userId)){
if (empty($userId)) {
$this->_userInstance = $this->createUser();
}
else {
} else {
$this->_userInstance = CcSubjsQuery::create()->findPK($userId);
if (is_null($this->_userInstance)){
if (is_null($this->_userInstance)) {
throw new Exception();
}
}
}
public function getId() {
public function getId()
{
return $this->_userInstance->getDbId();
}
public function isGuest() {
public function isGuest()
{
return $this->getType() == UTYPE_GUEST;
}
public function isHost($showId) {
return $this->isUserType(UTYPE_HOST, $showId);
public function isHost($showId)
{
return $this->isUserType(UTYPE_HOST, $showId);
}
public function isPM() {
public function isPM()
{
return $this->isUserType(UTYPE_PROGRAM_MANAGER);
}
public function isAdmin() {
public function isAdmin()
{
return $this->isUserType(UTYPE_ADMIN);
}
public function canSchedule($p_showId) {
$type = $this->getType();
$result = false;
public function canSchedule($p_showId)
{
$type = $this->getType();
$result = false;
if ( $type === UTYPE_ADMIN ||
if ($type === UTYPE_ADMIN ||
$type === UTYPE_PROGRAM_MANAGER ||
CcShowHostsQuery::create()->filterByDbShow($p_showId)->filterByDbHost($this->getId())->count() > 0 )
{
$result = true;
}
CcShowHostsQuery::create()->filterByDbShow($p_showId)->filterByDbHost($this->getId())->count() > 0) {
$result = true;
}
return $result;
return $result;
}
public function isUserType($type, $showId=''){
if(is_array($type)){
$result = false;
foreach($type as $t){
switch($t){
case UTYPE_ADMIN:
$result = $this->_userInstance->getDbType() === 'A';
break;
case UTYPE_HOST:
$userId = $this->_userInstance->getDbId();
$result = CcShowHostsQuery::create()->filterByDbShow($showId)->filterByDbHost($userId)->count() > 0;
break;
case UTYPE_PROGRAM_MANAGER:
$result = $this->_userInstance->getDbType() === 'P';
break;
}
if($result){
return $result;
}
}
}else{
switch($type){
case UTYPE_ADMIN:
return $this->_userInstance->getDbType() === 'A';
case UTYPE_HOST:
$userId = $this->_userInstance->getDbId();
return CcShowHostsQuery::create()->filterByDbShow($showId)->filterByDbHost($userId)->count() > 0;
case UTYPE_PROGRAM_MANAGER:
return $this->_userInstance->getDbType() === 'P';
}
}
public function isUserType($type, $showId='')
{
if (is_array($type)) {
$result = false;
foreach ($type as $t) {
switch($t){
case UTYPE_ADMIN:
$result = $this->_userInstance->getDbType() === 'A';
break;
case UTYPE_HOST:
$userId = $this->_userInstance->getDbId();
$result = CcShowHostsQuery::create()
->filterByDbShow($showId)
->filterByDbHost($userId)->count() > 0;
break;
case UTYPE_PROGRAM_MANAGER:
$result = $this->_userInstance->getDbType() === 'P';
break;
}
if ($result) {
return $result;
}
}
} else {
switch($type) {
case UTYPE_ADMIN:
return $this->_userInstance->getDbType() === 'A';
case UTYPE_HOST:
$userId = $this->_userInstance->getDbId();
return CcShowHostsQuery::create()->filterByDbShow($showId)->filterByDbHost($userId)->count() > 0;
case UTYPE_PROGRAM_MANAGER:
return $this->_userInstance->getDbType() === 'P';
}
}
}
public function setLogin($login){
public function setLogin($login)
{
$user = $this->_userInstance;
$user->setDbLogin($login);
}
public function setPassword($password){
public function setPassword($password)
{
$user = $this->_userInstance;
$user->setDbPass(md5($password));
}
public function setFirstName($firstName){
public function setFirstName($firstName)
{
$user = $this->_userInstance;
$user->setDbFirstName($firstName);
}
public function setLastName($lastName){
public function setLastName($lastName)
{
$user = $this->_userInstance;
$user->setDbLastName($lastName);
}
public function setType($type){
public function setType($type)
{
$user = $this->_userInstance;
$user->setDbType($type);
}
public function setEmail($email){
public function setEmail($email)
{
$user = $this->_userInstance;
$user->setDbEmail(strtolower($email));
}
public function setCellPhone($cellPhone){
public function setCellPhone($cellPhone)
{
$user = $this->_userInstance;
$user->setDbCellPhone($cellPhone);
}
public function setSkype($skype){
public function setSkype($skype)
{
$user = $this->_userInstance;
$user->setDbSkypeContact($skype);
}
public function setJabber($jabber){
public function setJabber($jabber)
{
$user = $this->_userInstance;
$user->setDbJabberContact($jabber);
}
public function getLogin(){
public function getLogin()
{
$user = $this->_userInstance;
return $user->getDbLogin();
}
public function getPassword(){
public function getPassword()
{
$user = $this->_userInstance;
return $user->getDbPass();
}
public function getFirstName(){
public function getFirstName()
{
$user = $this->_userInstance;
return $user->getDbFirstName();
}
public function getLastName(){
public function getLastName()
{
$user = $this->_userInstance;
return $user->getDbLastName();
}
public function getType(){
public function getType()
{
$user = $this->_userInstance;
return $user->getDbType();
}
public function getEmail(){
public function getEmail()
{
$user = $this->_userInstance;
return $user->getDbEmail();
}
public function getCellPhone(){
public function getCellPhone()
{
$user = $this->_userInstance;
return $user->getDbCellPhone();
}
public function getSkype(){
public function getSkype()
{
$user = $this->_userInstance;
return $user->getDbSkypeContact();
}
public function getJabber(){
public function getJabber()
{
$user = $this->_userInstance;
return $user->getDbJabberContact();
}
public function save(){
public function save()
{
$this->_userInstance->save();
}
public function delete(){
if (!$this->_userInstance->isDeleted())
public function delete()
{
if (!$this->_userInstance->isDeleted()) {
$this->_userInstance->delete();
}
}
private function createUser() {
private function createUser()
{
$user = new CcSubjs();
return $user;
}
public static function getUsers($type, $search=NULL)
public static function getUsers($type, $search=null)
{
$con = Propel::getConnection();
@ -203,12 +232,11 @@ class Application_Model_User {
$sql = $sql_gen;
if (is_array($type)) {
for($i=0; $i<count($type); $i++) {
for ($i=0; $i<count($type); $i++) {
$type[$i] = "type = '{$type[$i]}'";
}
$sql_type = join(" OR ", $type);
}
else {
} else {
$sql_type = "type = {$type}";
}
@ -225,39 +253,40 @@ class Application_Model_User {
return $con->query($sql)->fetchAll();;
}
public static function getUserCount($type=NULL){
public static function getUserCount($type=null)
{
$con = Propel::getConnection();
$sql = '';
$sql_gen = "SELECT count(*) AS cnt FROM cc_subjs ";
if (!isset($type)) {
$sql = $sql_gen;
}
else{
if (is_array($type)) {
for ($i=0; $i<count($type); $i++) {
$type[$i] = "type = '{$type[$i]}'";
}
$sql_type = join(" OR ", $type);
}
else {
$sql_type = "type = {$type}";
}
$sql = $sql_gen;
} else {
if (is_array($type)) {
for ($i=0; $i<count($type); $i++) {
$type[$i] = "type = '{$type[$i]}'";
}
$sql_type = join(" OR ", $type);
} else {
$sql_type = "type = {$type}";
}
$sql = $sql_gen ." WHERE (". $sql_type.") ";
$sql = $sql_gen ." WHERE (". $sql_type.") ";
}
$query = $con->query($sql)->fetchColumn(0);
return ($query !== false) ? $query : NULL;
return ($query !== false) ? $query : null;
}
public static function getHosts($search=NULL) {
public static function getHosts($search=null)
{
return Application_Model_User::getUsers(array('H'), $search);
}
public static function getUsersDataTablesInfo($datatables) {
public static function getUsersDataTablesInfo($datatables)
{
$con = Propel::getConnection(CcSubjsPeer::DATABASE_NAME);
$con = Propel::getConnection(CcSubjsPeer::DATABASE_NAME);
$displayColumns = array("id", "login", "first_name", "last_name", "type");
$fromTable = "cc_subjs";
@ -273,8 +302,8 @@ class Application_Model_User {
$res = Application_Model_Datatables::findEntries($con, $displayColumns, $fromTable, $datatables);
// mark record which is for the current user
foreach($res['aaData'] as &$record){
if($record['login'] == $username){
foreach ($res['aaData'] as &$record) {
if ($record['login'] == $username) {
$record['delete'] = "self";
} else {
$record['delete'] = "";
@ -284,7 +313,8 @@ class Application_Model_User {
return $res;
}
public static function getUserData($id){
public static function getUserData($id)
{
$con = Propel::getConnection();
$sql = "SELECT login, first_name, last_name, type, id, email, cell_phone, skype_contact, jabber_contact"
@ -294,26 +324,18 @@ class Application_Model_User {
return $con->query($sql)->fetch();
}
public static function GetUserID($login){
$user = CcSubjsQuery::create()->findOneByDbLogin($login);
if (is_null($user)){
return -1;
} else {
return $user->getDbId();
}
}
public static function GetCurrentUser() {
public static function getCurrentUser()
{
$userinfo = Zend_Auth::getInstance()->getStorage()->read();
if (is_null($userinfo)){
if (is_null($userinfo)) {
return null;
} else {
try {
return new self($userinfo->id);
} catch (Exception $e){
} catch (Exception $e) {
//we get here if $userinfo->id is defined, but doesn't exist
//in the database anymore.
//in the database anymore.
Zend_Auth::getInstance()->clearIdentity();
return null;
}

View File

@ -13,7 +13,7 @@
*/
class CcFiles extends BaseCcFiles {
public function getDbLength($format = "H:i:s.u")
public function getDbLength($format = "H:i:s.u")
{
return parent::getDbLength($format);
}

View File

@ -1,10 +1,10 @@
<?php
class Common {
public static function setTimeInSub($row, $col, $time)
class Common {
public static function setTimeInSub($row, $col, $time)
{
$class = get_class($row).'Peer';
$class = get_class($row).'Peer';
$con = Propel::getConnection($class::DATABASE_NAME);

View File

@ -17,8 +17,8 @@ class StoredFileTest extends PHPUnit_TestCase {
|| ($metadata["audio"]["dataformat"] != "mp3")
|| ($metadata["dc:type"] != "Speech")) {
$str = " [dc:description] = " . $metadata["dc:description"] ."\n"
. " [audio][dataformat] = " . $metadata["audio"]["dataformat"]."\n"
. " [dc:type] = ".$metadata["dc:type"]."\n";
. " [audio][dataformat] = " . $metadata["audio"]["dataformat"]."\n"
. " [dc:type] = ".$metadata["dc:type"]."\n";
$this->fail("Metadata has unexpected values:\n".$str);
}
//var_dump($metadata);

View File

@ -29,7 +29,7 @@ class MediaMonitorCommon:
return filter(lambda e: len(e) > 0, [ f.strip(" \n") for f in dirty_files ])
def find_command(self, directory, extra_arguments=""):
""" Builds a find command that respects supported_file_formats list
""" Builds a find command that respects supported_file_formats list
Note: Use single quotes to quote arguments """
ext_globs = [ "-iname '*.%s'" % ext for ext in self.supported_file_formats ]
find_glob = ' -o '.join(ext_globs)
@ -51,7 +51,7 @@ class MediaMonitorCommon:
def is_audio_file(self, filename):
info = filename.split(".")
if len(info) < 2: return false # handle cases like filename="mp3"
if len(info) < 2: return False # handle cases like filename="mp3"
return info[-1].lower() in self.supported_file_formats
#check if file is readable by "nobody"
@ -101,7 +101,7 @@ class MediaMonitorCommon:
will attempt to make the file world readable by modifying the file's permission's
as well as the file's parent directory permissions. We should only call this function
on files in Airtime's stor directory, not watched directories!
Returns True if we were able to make the file world readable. False otherwise.
"""
original_file = pathname
@ -278,7 +278,7 @@ class MediaMonitorCommon:
try:
"""
File name charset encoding is UTF-8.
File name charset encoding is UTF-8.
"""
stdout = stdout.decode("UTF-8")
except Exception:

@ -1 +1 @@
Subproject commit 492242f4bb7367afebbf2f096067cb5a5d3c0449
Subproject commit 0653ec0b89362921f075af96ee8772538b801a7c