Merge branch 'master' of dev.sourcefabric.org:campcaster

This commit is contained in:
naomiaro 2011-03-31 21:03:06 -04:00
commit 7a49137edd
62 changed files with 1367 additions and 647 deletions

View file

@ -8,13 +8,6 @@ return array (
'BaseCcAccessPeer' => 'airtime/om/BaseCcAccessPeer.php',
'BaseCcAccess' => 'airtime/om/BaseCcAccess.php',
'BaseCcAccessQuery' => 'airtime/om/BaseCcAccessQuery.php',
'CcBackupTableMap' => 'airtime/map/CcBackupTableMap.php',
'CcBackupPeer' => 'airtime/CcBackupPeer.php',
'CcBackup' => 'airtime/CcBackup.php',
'CcBackupQuery' => 'airtime/CcBackupQuery.php',
'BaseCcBackupPeer' => 'airtime/om/BaseCcBackupPeer.php',
'BaseCcBackup' => 'airtime/om/BaseCcBackup.php',
'BaseCcBackupQuery' => 'airtime/om/BaseCcBackupQuery.php',
'CcFilesTableMap' => 'airtime/map/CcFilesTableMap.php',
'CcFilesPeer' => 'airtime/CcFilesPeer.php',
'CcFiles' => 'airtime/CcFiles.php',
@ -113,11 +106,4 @@ return array (
'BaseCcSubjsPeer' => 'airtime/om/BaseCcSubjsPeer.php',
'BaseCcSubjs' => 'airtime/om/BaseCcSubjs.php',
'BaseCcSubjsQuery' => 'airtime/om/BaseCcSubjsQuery.php',
'CcTransTableMap' => 'airtime/map/CcTransTableMap.php',
'CcTransPeer' => 'airtime/CcTransPeer.php',
'CcTrans' => 'airtime/CcTrans.php',
'CcTransQuery' => 'airtime/CcTransQuery.php',
'BaseCcTransPeer' => 'airtime/om/BaseCcTransPeer.php',
'BaseCcTrans' => 'airtime/om/BaseCcTrans.php',
'BaseCcTransQuery' => 'airtime/om/BaseCcTransQuery.php',
);

View file

@ -1,98 +1,56 @@
<?php
/* THIS FILE IS NOT MEANT FOR CUSTOMIZING.
* PLEASE EDIT THE FOLLOWING TO CHANGE YOUR CONFIG:
* /etc/airtime/airtime.conf
* /etc/airtime/pypo.cfg
* /etc/airtime/recorder.cfg
*/
define('AIRTIME_VERSION', '1.7.0-alpha');
define('AIRTIME_COPYRIGHT_DATE', '2010-2011');
define('AIRTIME_REST_VERSION', '1.1');
// These are the default values for the config.
global $CC_CONFIG;
$values = load_airtime_config();
// **********************************
// ***** START CUSTOMIZING HERE *****
// **********************************
// Set the location where you want to store all of your audio files.
//
// For example:
// $baseFilesDir = '/home/john/radio-files';
$baseFilesDir = __DIR__.'/../../files';
$CC_CONFIG = array(
// Set the URL of your installation
'storageUrlHost' => 'localhost',
'storageUrlPort' => 80,
// Name of the web server user
'webServerUser' => 'www-data',
'webServerUser' => $values['general']['webServerUser'],
'rabbitmq' => array("host" => "127.0.0.1",
"port" => "5672",
"user" => "guest",
"password" => "guest",
"vhost" => "/"),
'rabbitmq' => $values['rabbitmq'],
// ***********************************************************************
// STOP CUSTOMIZING HERE
//
// You don't need to touch anything below this point.
// ***********************************************************************
'baseFilesDir' => $baseFilesDir,
'baseFilesDir' => $values['general']['baseFilesDir'],
// main directory for storing binary media files
'storageDir' => "$baseFilesDir/stor",
'storageDir' => $values['general']['baseFilesDir']."/stor",
// Database config
'dsn' => $values['database'],
'dsn' => array(
'username' => $values['database']['dbuser'],
'password' => $values['database']['dbpass'],
'hostspec' => $values['database']['host'],
'phptype' => 'pgsql',
'database' => $values['database']['dbname']),
// prefix for table names in the database
'tblNamePrefix' => 'cc_',
/* ================================================ storage configuration */
'apiKey' => $values['api_key'],
'apiKey' => array($values['general']['api_key']),
'apiPath' => '/api/',
'soundcloud-client-id' => '2CLCxcSXYzx7QhhPVHN4A',
'soundcloud-client-secret' => 'pZ7beWmF06epXLHVUP1ufOg2oEnIt9XhE8l8xt0bBs',
'soundcloud-connection-retries' => $values['soundcloud']['connection_retries'],
'soundcloud-connection-wait' => $values['soundcloud']['time_between_retries'],
"rootDir" => __DIR__."/../..",
'pearPath' => dirname(__FILE__).'/../../library/pear',
'zendPath' => dirname(__FILE__).'/../../library/Zend',
'phingPath' => dirname(__FILE__).'/../../library/phing',
// name of admin group
//'AdminsGr' => 'Admins',
// name of station preferences group
// 'StationPrefsGr'=> 'StationPrefs',
// name of 'all users' group
//'AllGr' => 'All',
/* ==================================== application-specific configuration */
// 'objtypes' => array(
// 'Storage' => array(/*'Folder',*/ 'File' /*, 'Replica'*/),
// 'File' => array(),
// 'audioclip' => array(),
// 'playlist' => array(),
// ),
// 'allowedActions'=> array(
// 'File' => array('editPrivs', 'write', 'read'),
// 'audioclip' => array('editPrivs', 'write', 'read'),
// 'playlist' => array('editPrivs', 'write', 'read'),
// ),
// 'allActions' => array(
// 'editPrivs', 'write', 'read', 'subjects'
// ),
/* =================================================== cron configuration */
'cronUserName' => 'www-data',
# 'lockfile' => dirname(__FILE__).'/cron/cron.lock',
'lockfile' => dirname(__FILE__).'/stor/buffer/cron.lock',
'cronfile' => dirname(__FILE__).'/cron/croncall.php',
'paramdir' => dirname(__FILE__).'/cron/params',
// 'systemPrefId' => "0", // ID for system prefs in prefs table
);
// Add database table names
@ -119,11 +77,6 @@ $CC_CONFIG['permSequence'] = $CC_CONFIG['permTable'].'_id';
$CC_CONFIG['subjSequence'] = $CC_CONFIG['subjTable'].'_id';
$CC_CONFIG['smembSequence'] = $CC_CONFIG['smembTable'].'_id';
// System users/groups - they cannot be deleted
//$CC_CONFIG['sysSubjs'] = array(
// 'root', /*$CC_CONFIG['AdminsGr'],*/ /*$CC_CONFIG['AllGr'],*/ $CC_CONFIG['StationPrefsGr']
//);
// Add libs to the PHP path
$old_include_path = get_include_path();
set_include_path('.'.PATH_SEPARATOR.$CC_CONFIG['pearPath']
@ -131,15 +84,6 @@ set_include_path('.'.PATH_SEPARATOR.$CC_CONFIG['pearPath']
.PATH_SEPARATOR.$old_include_path);
function load_airtime_config(){
$ini_array = parse_ini_file(dirname(__FILE__).'/../../build/airtime.conf', true);
return array(
'database' => array(
'username' => $ini_array['database']['dbuser'],
'password' => $ini_array['database']['dbpass'],
'hostspec' => $ini_array['database']['host'],
'phptype' => 'pgsql',
'database' => $ini_array['database']['dbname']),
'api_key' => array($ini_array['general']['api_key'])
);
$ini_array = parse_ini_file('/etc/airtime/airtime.conf', true);
return $ini_array;
}

View file

@ -103,27 +103,55 @@ class ApiController extends Zend_Controller_Action
exit;
}
public function liveInfoAction(){
global $CC_CONFIG;
public function liveInfoAction()
{
if (Application_Model_Preference::GetAllow3rdPartyApi()){
// disable the view and the layout
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
// disable the view and the layout
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$result = Schedule::GetPlayOrderRange(0, 1);
$result = Schedule::GetPlayOrderRange(0, 1);
$date = new Application_Model_DateHelper;
$timeNow = $date->getDate();
$result = array("env"=>APPLICATION_ENV,
"schedulerTime"=>gmdate("Y-m-d H:i:s"),
"currentShow"=>Show_DAL::GetCurrentShow($timeNow),
"nextShow"=>Show_DAL::GetNextShows($timeNow, 5),
"timezone"=> date("T"),
"timezoneOffset"=> date("Z"));
//echo json_encode($result);
header("Content-type: text/javascript");
echo $_GET['callback'].'('.json_encode($result).')';
} else {
header('HTTP/1.0 401 Unauthorized');
print 'You are not allowed to access this resource. ';
exit;
}
}
$date = new Application_Model_DateHelper;
$timeNow = $date->getDate();
$result = array("env"=>APPLICATION_ENV,
"schedulerTime"=>gmdate("Y-m-d H:i:s"),
"currentShow"=>Show_DAL::GetCurrentShow($timeNow),
"nextShow"=>Show_DAL::GetNextShows($timeNow, 5),
"timezone"=> date("T"),
"timezoneOffset"=> date("Z"));
//echo json_encode($result);
header("Content-type: text/javascript");
echo $_GET['callback'].'('.json_encode($result).')';
public function weekInfoAction()
{
if (Application_Model_Preference::GetAllow3rdPartyApi()){
// disable the view and the layout
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$dow = array("sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday");
$result = array();
for ($i=0; $i<7; $i++){
$result[$dow[$i]] = Show_DAL::GetShowsByDayOfWeek($i);
}
header("Content-type: text/javascript");
echo $_GET['callback'].'('.json_encode($result).')';
} else {
header('HTTP/1.0 401 Unauthorized');
print 'You are not allowed to access this resource. ';
exit;
}
}
public function scheduleAction()
@ -254,11 +282,27 @@ class ApiController extends Zend_Controller_Action
if(Application_Model_Preference::GetDoSoundCloudUpload())
{
$show = new Show($show_inst->getShowId());
$description = $show->getDescription();
for($i=0; $i<$CC_CONFIG['soundcloud-connection-retries']; $i++) {
$soundcloud = new ATSoundcloud();
$soundcloud->uploadTrack($file->getRealFilePath(), $file->getName(), $description);
$show = new Show($show_inst->getShowId());
$description = $show->getDescription();
$hosts = $show->getHosts();
try {
$soundcloud = new ATSoundcloud();
$soundcloud_id = $soundcloud->uploadTrack($file->getRealFilePath(), $file->getName(), $description, $hosts);
$show_inst->setSoundCloudFileId($soundcloud_id);
break;
}
catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
$code = $e->getHttpCode();
if(!in_array($code, array(0, 100))) {
break;
}
}
sleep($CC_CONFIG['soundcloud-connection-wait']);
}
}
$this->view->id = $file->getId();

View file

@ -28,7 +28,7 @@ class PlaylistController extends Zend_Controller_Action
private function getPlaylist()
{
$pl_sess = $this->pl_sess;
if(isset($pl_sess->id)) {
$pl = Playlist::Recall($pl_sess->id);
@ -43,7 +43,7 @@ class PlaylistController extends Zend_Controller_Action
private function changePlaylist($pl_id)
{
$pl_sess = $this->pl_sess;
if(isset($pl_sess->id)) {
$pl = Playlist::Recall($pl_sess->id);
@ -51,13 +51,13 @@ class PlaylistController extends Zend_Controller_Action
$this->closePlaylist($pl);
}
}
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$pl = Playlist::Recall($pl_id);
if($pl === FALSE) {
return FALSE;
}
}
$pl->lock($userInfo->id);
$pl_sess->id = $pl_id;
}
@ -78,7 +78,7 @@ class PlaylistController extends Zend_Controller_Action
$this->view->headScript()->appendFile('/js/airtime/library/spl.js','text/javascript');
$this->view->headLink()->appendStylesheet('/css/playlist_builder.css');
$this->_helper->viewRenderer->setResponseSegment('spl');
$this->_helper->viewRenderer->setResponseSegment('spl');
$this->view->pl = $this->getPlaylist();
}
@ -88,10 +88,10 @@ class PlaylistController extends Zend_Controller_Action
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$pl = new Playlist();
$pl_id = $pl->create("Untitled Playlist");
$pl->create("Untitled Playlist");
$pl->setPLMetaData('dc:creator', $userInfo->login);
$this->changePlaylist($pl_id);
$this->changePlaylist($pl->getId());
$form = new Application_Form_PlaylistMetadata();
$this->view->fieldset = $form;
$this->view->form = $this->view->render('playlist/new.phtml');
@ -105,25 +105,25 @@ class PlaylistController extends Zend_Controller_Action
$pl_id = $this->_getParam('id', null);
//not a new playlist
if(!is_null($pl_id)) {
$this->changePlaylist($pl_id);
$this->changePlaylist($pl_id);
$pl = $this->getPlaylist();
$title = $pl->getPLMetaData(UI_MDATA_KEY_TITLE);
$desc = $pl->getPLMetaData(UI_MDATA_KEY_DESCRIPTION);
$data = array( 'title' => $title, 'description' => $desc);
$form->populate($data);
$data = array( 'title' => $title, 'description' => $desc);
$form->populate($data);
}
if ($request->isPost()) {
$title = $this->_getParam('title', null);
$description = $this->_getParam('description', null);
$pl = $this->getPlaylist();
if($title)
$pl->setName($title);
if(isset($description)) {
$pl->setPLMetaData(UI_MDATA_KEY_DESCRIPTION, $description);
}
@ -132,7 +132,7 @@ class PlaylistController extends Zend_Controller_Action
$this->view->html = $this->view->render('playlist/index.phtml');
unset($this->view->pl);
}
$this->view->fieldset = $form;
$this->view->form = $this->view->render('playlist/new.phtml');
}
@ -140,13 +140,13 @@ class PlaylistController extends Zend_Controller_Action
public function editAction()
{
$pl_id = $this->_getParam('id', null);
if(!is_null($pl_id)) {
$this->changePlaylist($pl_id);
$this->changePlaylist($pl_id);
}
$pl = $this->getPlaylist();
$this->view->pl = $pl;
$this->view->html = $this->view->render('playlist/index.phtml');
unset($this->view->pl);
@ -158,7 +158,7 @@ class PlaylistController extends Zend_Controller_Action
$pos = $this->_getParam('pos', null);
if (!is_null($id)) {
$pl = $this->getPlaylist();
$res = $pl->addAudioClip($id, $pos);
@ -181,7 +181,7 @@ class PlaylistController extends Zend_Controller_Action
{
$oldPos = $this->_getParam('oldPos');
$newPos = $this->_getParam('newPos');
$pl = $this->getPlaylist();
$pl->moveAudioClip($oldPos, $newPos);
@ -197,7 +197,7 @@ class PlaylistController extends Zend_Controller_Action
public function deleteItemAction()
{
$positions = $this->_getParam('pos', array());
if (!is_array($positions))
$positions = array($positions);
@ -208,7 +208,7 @@ class PlaylistController extends Zend_Controller_Action
$pl = $this->getPlaylist();
foreach ($positions as $pos) {
$pl->delAudioClip($pos);
$pl->delAudioClip($pos);
}
$this->view->pl = $pl;
@ -274,7 +274,7 @@ class PlaylistController extends Zend_Controller_Action
{
$id = $this->_getParam('id', null);
$pl = Playlist::Recall($id);
if ($pl !== FALSE) {
Playlist::Delete($id);
@ -291,7 +291,7 @@ class PlaylistController extends Zend_Controller_Action
public function deleteActiveAction()
{
$pl = $this->getPlaylist();
$pl = $this->getPlaylist();
Playlist::Delete($pl->getId());
$pl_sess = $this->pl_sess;
@ -304,7 +304,7 @@ class PlaylistController extends Zend_Controller_Action
{
$pl = $this->getPlaylist();
$this->closePlaylist($pl);
$this->view->html = $this->view->render('playlist/index.phtml');
}

View file

@ -30,11 +30,13 @@ class PreferenceController extends Zend_Controller_Action
Application_Model_Preference::SetHeadTitle($values["stationName"], $this->view);
Application_Model_Preference::SetDefaultFade($values["stationDefaultFade"]);
Application_Model_Preference::SetStreamLabelFormat($values["streamFormat"]);
Application_Model_Preference::SetAllow3rdPartyApi($values["thirdPartyApi"]);
Application_Model_Preference::SetDoSoundCloudUpload($values["UseSoundCloud"]);
Application_Model_Preference::SetSoundCloudUser($values["SoundCloudUser"]);
Application_Model_Preference::SetSoundCloudPassword($values["SoundCloudPassword"]);
Application_Model_Preference::SetSoundCloudPassword($values["SoundCloudPassword"]);
Application_Model_Preference::SetSoundCloudTags($values["SoundCloudTags"]);
$this->view->statusMsg = "Preferences Updated.";
$this->view->statusMsg = "<div class='success'>Preferences updated.</div>";
}
$this->view->form = $form;

View file

@ -176,11 +176,11 @@ class ScheduleController extends Zend_Controller_Action
if (strtotime($show->getShowStart()) <= strtotime($today_timestamp) &&
strtotime($today_timestamp) < strtotime($show->getShowEnd())) {
strtotime($today_timestamp) < strtotime($show->getShowEnd()) &&
$user->isAdmin()) {
$menu[] = array('action' => array('type' => 'fn',
//'url' => '/Schedule/cancel-current-show'.$params,
'callback' => "window['confirmCancelShow']($id)"),
'title' => 'Cancel Current Show');
'callback' => "window['confirmCancelShow']($id)"),
'title' => 'Cancel Current Show');
}
if (strtotime($today_timestamp) < strtotime($show->getShowStart())) {
@ -319,6 +319,17 @@ class ScheduleController extends Zend_Controller_Action
$showInstanceId = $this->_getParam('id');
$show = new ShowInstance($showInstanceId);
$originalShowId = $show->isRebroadcast();
if (!is_null($originalShowId)){
$originalShow = new ShowInstance($originalShowId);
$originalShowName = $originalShow->getName();
$originalShowStart = $originalShow->getShowStart();
$timestamp = strtotime($originalShowStart);
$this->view->additionalShowInfo =
"Rebroadcast of show \"$originalShowName\" from "
.date("l, F jS", $timestamp)." at ".date("G:i", $timestamp);
}
$this->view->showContent = $show->getShowListContent();
$this->view->dialog = $this->view->render('schedule/show-content-dialog.phtml');
unset($this->view->showContent);
@ -397,8 +408,8 @@ class ScheduleController extends Zend_Controller_Action
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new User($userInfo->id);
if($user->isAdmin()) {
Show::addShow($data);
if ($user->isAdmin()) {
Show::create($data);
}
//send back a new form for the user.

View file

@ -89,7 +89,28 @@ class Application_Form_EditAudioMD extends Zend_Form
'ignore' => true,
'class' => 'ui-button ui-state-default',
'label' => 'Submit',
'decorators' => array(
'ViewHelper'
)
));
// Add the submit button
$this->addElement('button', 'cancel', array(
'ignore' => true,
'class' => 'ui-button ui-state-default',
'label' => 'Cancel',
'onclick' => 'javascript:document.location="/Library"',
'decorators' => array(
'ViewHelper'
)
));
$this->addDisplayGroup(array('submit', 'cancel'), 'submitButtons', array(
'decorators' => array(
'FormElements',
array('HtmlTag', array('tag' => 'dd', 'class' => 'element')),
),
));
}

View file

@ -42,6 +42,13 @@ class Application_Form_Preferences extends Zend_Form
$stream_format->setValue(Application_Model_Preference::GetStreamLabelFormat());
$this->addElement($stream_format);
$third_party_api = new Zend_Form_Element_Radio('thirdPartyApi');
$third_party_api->setLabel('Allow Remote Websites To Access Show Schedule Info');
$third_party_api->setMultiOptions(array("Disabled",
"Enabled"));
$third_party_api->setValue(Application_Model_Preference::GetAllow3rdPartyApi());
$this->addElement($third_party_api);
$this->addElement('checkbox', 'UseSoundCloud', array(
'label' => 'Automatically Upload Recorded Shows To SoundCloud',
@ -59,7 +66,7 @@ class Application_Form_Preferences extends Zend_Form
));
//SoundCloud Password
$this->addElement('text', 'SoundCloudPassword', array(
$this->addElement('password', 'SoundCloudPassword', array(
'class' => 'input_text',
'label' => 'SoundCloud Password:',
'required' => false,
@ -67,6 +74,14 @@ class Application_Form_Preferences extends Zend_Form
'value' => Application_Model_Preference::GetSoundCloudPassword()
));
// Add the description element
$this->addElement('textarea', 'SoundCloudTags', array(
'label' => 'space separated SoundCloud Tags',
'required' => false,
'class' => 'input_text_area',
'value' => Application_Model_Preference::GetSoundCloudTags()
));
$this->addElement('submit', 'submit', array(
'class' => 'ui-button ui-state-default',
'ignore' => true,

View file

@ -102,27 +102,9 @@ class Playlist {
return $res;
}
public static function Insert($p_values)
public static function Delete($id)
{
// Create the StoredPlaylist object
$storedPlaylist = new Playlist();
$storedPlaylist->name = isset($p_values['filename']) ? $p_values['filename'] : date("H:i:s");
$storedPlaylist->mtime = new DateTime("now");
$pl = new CcPlaylist();
$pl->setDbName($storedPlaylist->name);
$pl->setDbState("incomplete");
$pl->setDbMtime($storedPlaylist->mtime);
$pl->save();
$storedPlaylist->id = $pl->getDbId();
$storedPlaylist->setState('ready');
return $storedPlaylist->id;
}
public static function Delete($id) {
$pl = CcPlaylistQuery::create()->findPK($id);
if($pl === NULL)
return FALSE;
@ -207,7 +189,7 @@ class Playlist {
return $this->name;
}
$pl = CcPlaylistQuery::create()->findPK($id);
if($pl === NULL)
if ($pl === NULL)
return FALSE;
return $pl->getDbName();
@ -395,18 +377,27 @@ class Playlist {
}
/**
* Create instance of Playlist object and insert empty file
* Create instance of a Playlist object.
*
* @param string $fname
* name of new file
* @return instance of Playlist object
* @param string $p_fname
* Name of the playlist
* @return Playlist
*/
public function create($fname=NULL)
public function create($p_fname=NULL)
{
$values = array("filename" => $fname);
$pl_id = Playlist::Insert($values);
$this->id = $pl_id;
return $this->id;
$this->name = !empty($p_fname) ? $p_fname : date("H:i:s");
$this->mtime = new DateTime("now");
$pl = new CcPlaylist();
$pl->setDbName($this->name);
$pl->setDbState("incomplete");
$pl->setDbMtime($this->mtime);
$pl->save();
$this->id = $pl->getDbId();
$this->setState('ready');
return $this;
}
/**

View file

@ -117,12 +117,34 @@ class Application_Model_Preference
}
public static function SetSoundCloudPassword($password) {
Application_Model_Preference::SetValue("soundcloud_password", $password);
if (strlen($password) > 0)
Application_Model_Preference::SetValue("soundcloud_password", $password);
}
public static function GetSoundCloudPassword() {
return Application_Model_Preference::GetValue("soundcloud_password");
}
public static function SetSoundCloudTags($tags) {
Application_Model_Preference::SetValue("soundcloud_tags", $tags);
}
public static function GetSoundCloudTags() {
return Application_Model_Preference::GetValue("soundcloud_tags");
}
public static function SetAllow3rdPartyApi($bool) {
Application_Model_Preference::SetValue("third_party_api", $bool);
}
public static function GetAllow3rdPartyApi() {
$val = Application_Model_Preference::GetValue("third_party_api");
if (strlen($val) == 0){
return "0";
} else {
return $val;
}
}
}

View file

@ -27,6 +27,8 @@ class ScheduleGroup {
/**
* Add a music clip or playlist to the schedule.
*
* @param int $p_showInstance
* ID of the show.
* @param $p_datetime
* In the format YYYY-MM-DD HH:MM:SS.mmmmmm
* @param $p_audioFileId
@ -40,7 +42,7 @@ class ScheduleGroup {
* Return PEAR_Error if the item could not be added.
* Error code 555 is a scheduling conflict.
*/
public function add($show_instance, $p_datetime, $p_audioFileId = null, $p_playlistId = null, $p_options = null) {
public function add($p_showInstance, $p_datetime, $p_audioFileId = null, $p_playlistId = null, $p_options = null) {
global $CC_CONFIG, $CC_DBC;
if (!is_null($p_audioFileId)) {
@ -64,7 +66,7 @@ class ScheduleGroup {
$sql = "INSERT INTO ".$CC_CONFIG["scheduleTable"]
." (instance_id, starts, ends, clip_length, group_id, file_id, cue_out)"
." VALUES ($show_instance, TIMESTAMP '$p_datetime', "
." VALUES ($p_showInstance, TIMESTAMP '$p_datetime', "
." (TIMESTAMP '$p_datetime' + INTERVAL '$length'),"
." '$length',"
." {$this->groupId}, $p_audioFileId, '$length')";
@ -103,7 +105,7 @@ class ScheduleGroup {
$sql = "INSERT INTO ".$CC_CONFIG["scheduleTable"]
." (instance_id, playlist_id, starts, ends, group_id, file_id,"
." clip_length, cue_in, cue_out, fade_in, fade_out)"
." VALUES ($show_instance, $p_playlistId, TIMESTAMP '$itemStartTime', "
." VALUES ($p_showInstance, $p_playlistId, TIMESTAMP '$itemStartTime', "
." (TIMESTAMP '$itemStartTime' + INTERVAL '$trackLength'),"
." '{$this->groupId}', '{$row['file_id']}', '$trackLength', '{$row['cuein']}',"
." '{$row['cueout']}', '{$row['fadein']}','{$row['fadeout']}')";
@ -466,6 +468,30 @@ class Schedule {
{
global $CC_CONFIG, $CC_DBC;
$sql = "SELECT DISTINCT"
." pt.name,"
." ft.track_title,"
." ft.artist_name,"
." ft.album_title,"
." st.starts,"
." st.ends,"
." st.clip_length,"
." st.media_item_played,"
." st.group_id,"
." show.name as show_name,"
." st.instance_id"
." FROM $CC_CONFIG[scheduleTable] st"
." LEFT JOIN $CC_CONFIG[filesTable] ft"
." ON st.file_id = ft.id"
." LEFT JOIN $CC_CONFIG[playListTable] pt"
." ON st.playlist_id = pt.id"
." LEFT JOIN $CC_CONFIG[showInstances] si"
." ON st.instance_id = si.id"
." LEFT JOIN $CC_CONFIG[showTable] show"
." ON si.show_id = show.id"
." WHERE st.starts < si.ends";
/*
$sql = "SELECT DISTINCT pt.name, ft.track_title, ft.artist_name, ft.album_title, st.starts, st.ends, st.clip_length, st.media_item_played, st.group_id, show.name as show_name, st.instance_id"
." FROM $CC_CONFIG[scheduleTable] st, $CC_CONFIG[filesTable] ft, $CC_CONFIG[playListTable] pt, $CC_CONFIG[showInstances] si, $CC_CONFIG[showTable] show"
." WHERE st.playlist_id = pt.id"
@ -473,6 +499,7 @@ class Schedule {
." AND st.instance_id = si.id"
." AND si.show_id = show.id"
." AND st.starts < si.ends";
*/
if ($timePeriod < 0){
$sql .= " AND st.ends < TIMESTAMP '$timeStamp'"
@ -628,17 +655,24 @@ class Schedule {
* @param string $p_toDateTime
* In the format "YYYY-MM-DD-HH-mm-SS"
*/
public static function GetScheduledPlaylists()
public static function GetScheduledPlaylists($p_fromDateTime = null, $p_toDateTime = null)
{
global $CC_CONFIG, $CC_DBC;
$t1 = new DateTime();
$range_start = $t1->format("Y-m-d H:i:s");
$t2 = new DateTime();
$t2->add(new DateInterval("PT24H"));
$range_end = $t2->format("Y-m-d H:i:s");
if (is_null($p_fromDateTime)) {
$t1 = new DateTime();
$range_start = $t1->format("Y-m-d H:i:s");
} else {
$range_start = Schedule::PypoTimeToAirtimeTime($p_fromDateTime);
}
if (is_null($p_fromDateTime)) {
$t2 = new DateTime();
$t2->add(new DateInterval("PT24H"));
$range_end = $t2->format("Y-m-d H:i:s");
} else {
$range_end = Schedule::PypoTimeToAirtimeTime($p_toDateTime);
}
// Scheduler wants everything in a playlist
$data = Schedule::GetItems($range_start, $range_end, true);
$playlists = array();

View file

@ -58,6 +58,29 @@ class Show {
$show->setDbBackgroundColor($backgroundColor);
}
public function getId()
{
return $this->_showId;
}
public function getHosts()
{
global $CC_DBC;
$sql = "SELECT first_name, last_name
FROM cc_show_hosts LEFT JOIN cc_subjs ON cc_show_hosts.subjs_id = cc_subjs.id
WHERE show_id = {$this->_showId}";
$hosts = $CC_DBC->GetAll($sql);
$res = array();
foreach($hosts as $host) {
$res[] = $host['first_name']." ".$host['last_name'];
}
return $res;
}
public function cancelShow($day_timestamp)
{
global $CC_DBC;
@ -75,8 +98,17 @@ class Show {
RabbitMq::PushSchedule();
}
//end dates are non inclusive.
public static function addShow($data)
/**
* Create a show.
*
* Note: end dates are non inclusive.
*
* @param array $data
* @return int
* Show ID
*/
public static function create($data)
{
$con = Propel::getConnection(CcShowPeer::DATABASE_NAME);
@ -88,11 +120,11 @@ class Show {
$r = $con->query($sql);
$startDow = $r->fetchColumn(0);
if($data['add_show_no_end']) {
if ($data['add_show_no_end']) {
$endDate = NULL;
$data['add_show_repeats'] = 1;
}
else if($data['add_show_repeats']) {
else if ($data['add_show_repeats']) {
$sql = "SELECT date '{$data['add_show_end_date']}' + INTERVAL '1 day' ";
$r = $con->query($sql);
$endDate = $r->fetchColumn(0);
@ -104,15 +136,15 @@ class Show {
}
//only want the day of the week from the start date.
if(!$data['add_show_repeats']) {
if (!$data['add_show_repeats']) {
$data['add_show_day_check'] = array($startDow);
}
else if($data['add_show_repeats'] && $data['add_show_day_check'] == "") {
else if ($data['add_show_repeats'] && $data['add_show_day_check'] == "") {
$data['add_show_day_check'] = array($startDow);
}
//find repeat type or set to a non repeating show.
if($data['add_show_repeats']) {
if ($data['add_show_repeats']) {
$repeat_type = $data["add_show_repeat_type"];
}
else {
@ -129,7 +161,7 @@ class Show {
$showId = $show->getDbId();
if($data['add_show_record']){
if ($data['add_show_record']){
$isRecorded = 1;
}
else {
@ -137,7 +169,7 @@ class Show {
}
//don't set day for monthly repeat type, it's invalid.
if($data['add_show_repeats'] && $data["add_show_repeat_type"] == 2) {
if ($data['add_show_repeats'] && $data["add_show_repeat_type"] == 2) {
$showDay = new CcShowDays();
$showDay->setDbFirstShow($data['add_show_start_date']);
$showDay->setDbLastShow($endDate);
@ -150,7 +182,7 @@ class Show {
}
else {
foreach ($data['add_show_day_check'] as $day) {
if($startDow !== $day){
if ($startDow !== $day){
if ($startDow > $day)
$daysAdd = 6 - $startDow + 1 + $day;
@ -165,7 +197,7 @@ class Show {
$start = $data['add_show_start_date'];
}
if(strtotime($start) < strtotime($endDate) || is_null($endDate)) {
if (strtotime($start) < strtotime($endDate) || is_null($endDate)) {
$showDay = new CcShowDays();
$showDay->setDbFirstShow($start);
$showDay->setDbLastShow($endDate);
@ -181,11 +213,11 @@ class Show {
}
//adding rows to cc_show_rebroadcast
if($data['add_show_record'] && $data['add_show_rebroadcast'] && $repeat_type != -1) {
if ($data['add_show_record'] && $data['add_show_rebroadcast'] && $repeat_type != -1) {
for($i=1; $i<=5; $i++) {
for ($i=1; $i<=5; $i++) {
if($data['add_show_rebroadcast_date_'.$i]) {
if ($data['add_show_rebroadcast_date_'.$i]) {
$showRebroad = new CcShowRebroadcast();
$showRebroad->setDbDayOffset($data['add_show_rebroadcast_date_'.$i]);
$showRebroad->setDbStartTime($data['add_show_rebroadcast_time_'.$i]);
@ -194,11 +226,11 @@ class Show {
}
}
}
else if($data['add_show_record'] && $data['add_show_rebroadcast'] && $repeat_type == -1){
else if ($data['add_show_record'] && $data['add_show_rebroadcast'] && $repeat_type == -1){
for($i=1; $i<=5; $i++) {
for ($i=1; $i<=5; $i++) {
if($data['add_show_rebroadcast_absolute_date_'.$i]) {
if ($data['add_show_rebroadcast_absolute_date_'.$i]) {
$sql = "SELECT date '{$data['add_show_rebroadcast_absolute_date_'.$i]}' - date '{$data['add_show_start_date']}' ";
$r = $con->query($sql);
$offset_days = $r->fetchColumn(0);
@ -212,7 +244,7 @@ class Show {
}
}
if(is_array($data['add_show_hosts'])) {
if (is_array($data['add_show_hosts'])) {
//add selected hosts to cc_show_hosts table.
foreach ($data['add_show_hosts'] as $host) {
$showHost = new CcShowHosts();
@ -222,10 +254,19 @@ class Show {
}
}
Show::populateShowUntilLastGeneratedDate($showId);
Show::populateShowUntil($showId);
RabbitMq::PushSchedule();
return $showId;
}
/**
* @param string $start_timestamp
* In the format "YYYY-MM-DD HH:mm:ss"
* @param string $end_timestamp
* In the format "YYYY-MM-DD HH:mm:ss"
* @param unknown_type $excludeInstance
* @param boolean $onlyRecord
*/
public static function getShows($start_timestamp, $end_timestamp, $excludeInstance=NULL, $onlyRecord=FALSE)
{
global $CC_DBC;
@ -283,7 +324,7 @@ class Show {
$next_date = $first_show." ".$start_time;
if(strtotime($next_date) < strtotime($end_timestamp)) {
if (strtotime($next_date) < strtotime($end_timestamp)) {
$start = $next_date;
@ -327,7 +368,8 @@ class Show {
//for a show with repeat_type == 0,1,2
private static function populateRepeatingShow($show_id, $next_pop_date, $first_show, $last_show,
$start_time, $duration, $day, $record, $end_timestamp, $interval) {
$start_time, $duration, $day, $record, $end_timestamp, $interval)
{
global $CC_DBC;
if(isset($next_pop_date)) {
@ -404,53 +446,86 @@ class Show {
}
}
//used to catch up a newly added show
private static function populateShowUntilLastGeneratedDate($show_id) {
global $CC_DBC;
$showsPopUntil = Application_Model_Preference::GetShowsPopulatedUntil();
$sql = "SELECT * FROM cc_show_days WHERE show_id = {$show_id}";
/**
* Generate repeating show instances for a single show up to the given date.
* If no date is given, use the one in the user's preferences, which is stored
* automatically by FullCalendar as the furthest date in the future the user
* has looked at.
*
* @param int $p_showId
* @param string $p_date
* In the format "YYYY-MM-DD HH:mm:ss"
*/
public static function populateShowUntil($p_showId, $p_date = NULL)
{
global $CC_DBC;
if (is_null($p_date)) {
$p_date = Application_Model_Preference::GetShowsPopulatedUntil();
if ($p_date == "") {
$today_timestamp = date("Y-m-d");
Application_Model_Preference::SetShowsPopulatedUntil($today_timestamp);
}
}
$sql = "SELECT * FROM cc_show_days WHERE show_id = {$p_showId}";
$res = $CC_DBC->GetAll($sql);
foreach($res as $row) {
foreach ($res as $row) {
Show::populateShow($row["repeat_type"], $row["show_id"], $row["next_pop_date"], $row["first_show"],
$row["last_show"], $row["start_time"], $row["duration"], $row["day"], $row["record"], $showsPopUntil);
$row["last_show"], $row["start_time"], $row["duration"], $row["day"], $row["record"], $p_date);
}
}
public static function populateShowsUntil($pop_timestamp, $end_timestamp) {
/**
* Generate all the repeating shows in the given range.
*
* @param string $p_startTimestamp
* In the format "YYYY-MM-DD HH:mm:ss"
* @param string $p_endTimestamp
* In the format "YYYY-MM-DD HH:mm:ss"
*/
public static function populateAllShowsInRange($p_startTimestamp, $p_endTimestamp)
{
global $CC_DBC;
if($pop_timestamp != "") {
if ($p_startTimestamp != "") {
$sql = "SELECT * FROM cc_show_days
WHERE last_show IS NULL
OR first_show < '{$end_timestamp}' AND last_show > '{$pop_timestamp}'";
WHERE last_show IS NULL
OR first_show < '{$p_endTimestamp}' AND last_show > '{$p_startTimestamp}'";
}
else {
$today_timestamp = date("Y-m-d");
$sql = "SELECT * FROM cc_show_days
WHERE last_show IS NULL
OR first_show < '{$end_timestamp}' AND last_show > '{$today_timestamp}'";
WHERE last_show IS NULL
OR first_show < '{$p_endTimestamp}' AND last_show > '{$today_timestamp}'";
}
$res = $CC_DBC->GetAll($sql);
foreach($res as $row) {
foreach ($res as $row) {
Show::populateShow($row["repeat_type"], $row["show_id"], $row["next_pop_date"], $row["first_show"],
$row["last_show"], $row["start_time"], $row["duration"], $row["day"], $row["record"], $end_timestamp);
$row["last_show"], $row["start_time"], $row["duration"], $row["day"], $row["record"], $p_endTimestamp);
}
}
public static function getFullCalendarEvents($start, $end, $editable=false) {
/**
*
* @param string $start
* In the format "YYYY-MM-DD HH:mm:ss"
* @param string $end
* In the format "YYYY-MM-DD HH:mm:ss"
* @param boolean $editable
*/
public static function getFullCalendarEvents($start, $end, $editable=false)
{
$events = array();
$showsPopUntil = Application_Model_Preference::GetShowsPopulatedUntil();
//if fullcalendar is requesting shows past our previous populated until date, generate shows up until this point.
if($showsPopUntil == "" || strtotime($showsPopUntil) < strtotime($end)) {
Show::populateShowsUntil($showsPopUntil, $end);
if ($showsPopUntil == "" || strtotime($showsPopUntil) < strtotime($end)) {
Show::populateAllShowsInRange($showsPopUntil, $end);
Application_Model_Preference::SetShowsPopulatedUntil($end);
}
@ -458,7 +533,7 @@ class Show {
$today_timestamp = date("Y-m-d H:i:s");
foreach ($shows as $show) {
if($editable && strtotime($today_timestamp) < strtotime($show["starts"]))
if ($editable && strtotime($today_timestamp) < strtotime($show["starts"]))
$events[] = Show::makeFullCalendarEvent($show, array("editable" => true));
else
$events[] = Show::makeFullCalendarEvent($show);
@ -549,6 +624,19 @@ class ShowInstance {
return $showInstance->getDbEnds();
}
public function setSoundCloudFileId($p_soundcloud_id)
{
$showInstance = CcShowInstancesQuery::create()->findPK($this->_instanceId);
$showInstance->setDbSoundCloudId($p_soundcloud_id)
->save();
}
public function getSoundCloudFileId()
{
$showInstance = CcShowInstancesQuery::create()->findPK($this->_instanceId);
return $showInstance->getDbSoundCloudId();
}
public function setShowStart($start)
{
$showInstance = CcShowInstancesQuery::create()->findPK($this->_instanceId);
@ -665,6 +753,10 @@ class ShowInstance {
RabbitMq::PushSchedule();
}
/**
* Get the group ID for this show.
*
*/
private function getLastGroupId()
{
global $CC_DBC;
@ -673,13 +765,18 @@ class ShowInstance {
return $res;
}
/**
* Add a playlist as the last item of the current show.
*
* @param int $plId
* Playlist ID.
*/
public function addPlaylistToShow($plId)
{
$sched = new ScheduleGroup();
$lastGroupId = $this->getLastGroupId();
if(is_null($lastGroupId)) {
if (is_null($lastGroupId)) {
$groupId = $sched->add($this->_instanceId, $this->getShowStart(), null, $plId);
}
else {
@ -688,14 +785,18 @@ class ShowInstance {
RabbitMq::PushSchedule();
}
public function addFileToShow($file_id)
/**
* Add a media file as the last item in the show.
*
* @param int $file_id
*/
public function addFileToShow($file_id)
{
$sched = new ScheduleGroup();
$lastGroupId = $this->getLastGroupId();
if(is_null($lastGroupId)) {
$groupId = $sched->add($this->_instanceId, $this->getShowStart(), $file_id);
if (is_null($lastGroupId)) {
$groupId = $sched->add($this->_instanceId, $this->getShowStart(), $file_id);
}
else {
$groupId = $sched->addFileAfter($this->_instanceId, $lastGroupId, $file_id);
@ -703,12 +804,18 @@ class ShowInstance {
RabbitMq::PushSchedule();
}
public function scheduleShow($plIds) {
foreach($plIds as $plId) {
$this->addPlaylistToShow($plId);
}
}
/**
* Add the given playlists to the show.
*
* @param array $plIds
* An array of playlist IDs.
*/
public function scheduleShow($plIds)
{
foreach ($plIds as $plId) {
$this->addPlaylistToShow($plId);
}
}
public function removeGroupFromShow($group_id)
{
@ -871,10 +978,6 @@ class Show_DAL {
{
global $CC_CONFIG, $CC_DBC;
$timestamp = explode(" ", $timeNow);
$date = $timestamp[0];
$time = $timestamp[1];
$sql = "SELECT si.starts as start_timestamp, si.ends as end_timestamp, s.name, s.id, si.id as instance_id, si.record"
." FROM $CC_CONFIG[showInstances] si, $CC_CONFIG[showTable] s"
." WHERE si.show_id = s.id"
@ -930,7 +1033,31 @@ class Show_DAL {
." OR (si.starts < TIMESTAMP '$timeNow' + INTERVAL '$end seconds' AND si.ends > TIMESTAMP '$timeNow' + INTERVAL '$end seconds'))"
//checking for st.starts IS NULL so that the query also returns shows that do not have any items scheduled.
." AND (st.starts < si.ends OR st.starts IS NULL)"
." ORDER BY st.starts";
." ORDER BY si.starts, st.starts";
return $CC_DBC->GetAll($sql);
}
public static function GetShowsByDayOfWeek($day){
//DOW FROM TIMESTAMP
//The day of the week (0 - 6; Sunday is 0) (for timestamp values only)
//SELECT EXTRACT(DOW FROM TIMESTAMP '2001-02-16 20:38:40');
//Result: 5
global $CC_CONFIG, $CC_DBC;
$sql = "SELECT"
." si.starts as show_starts,"
." si.ends as show_ends,"
." s.name as show_name,"
." s.url as url"
." FROM $CC_CONFIG[showInstances] si"
." LEFT JOIN $CC_CONFIG[showTable] s"
." ON si.show_id = s.id"
." WHERE EXTRACT(DOW FROM si.starts) = $day"
." AND EXTRACT(WEEK FROM si.starts) = EXTRACT(WEEK FROM localtimestamp)";
//echo $sql;
return $CC_DBC->GetAll($sql);
}

View file

@ -32,26 +32,31 @@ class ATSoundcloud {
{
if($this->getToken())
{
$tags = join(" ", $tags);
if(count($tags)) {
$tags = join(" ", $tags);
$tags = $tags." ".Application_Model_Preference::GetSoundCloudTags();
}
else {
$tags = Application_Model_Preference::GetSoundCloudTags();
}
$track_data = array(
'track[sharing]' => 'private',
'track[title]' => $filename,
'track[asset_data]' => '@' . $filepath,
'track[tag_list]' => $tags,
'track[description]' => $description
'track[description]' => $description,
'track[downloadable]' => true,
);
try {
$response = json_decode(
$this->_soundcloud->post('tracks', $track_data),
true
);
}
catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
echo $e->getMessage();
}
}
$response = json_decode(
$this->_soundcloud->post('tracks', $track_data),
true
);
return $response["id"];
}
}
}

View file

@ -1481,9 +1481,7 @@ class StoredFile {
public function getFileUrl()
{
global $CC_CONFIG;
return "http://".$CC_CONFIG["storageUrlHost"]
.$CC_CONFIG["apiPath"]."get-media/file/"
.$this->gunid.".".$this->getFileExtension();
return $this->gunid.".".$this->getFileExtension();
}
/**

View file

@ -47,7 +47,7 @@ class CcShowDaysTableMap extends TableMap {
$this->addColumn('REPEAT_TYPE', 'DbRepeatType', 'TINYINT', true, null, null);
$this->addColumn('NEXT_POP_DATE', 'DbNextPopDate', 'DATE', false, null, null);
$this->addForeignKey('SHOW_ID', 'DbShowId', 'INTEGER', 'cc_show', 'ID', true, null, null);
$this->addColumn('RECORD', 'DbRecord', 'TINYINT', false, null, null);
$this->addColumn('RECORD', 'DbRecord', 'TINYINT', false, null, 0);
// validators
} // initialize()

View file

@ -46,6 +46,7 @@ class CcShowInstancesTableMap extends TableMap {
$this->addColumn('REBROADCAST', 'DbRebroadcast', 'TINYINT', false, null, 0);
$this->addForeignKey('INSTANCE_ID', 'DbOriginalShow', 'INTEGER', 'cc_show_instances', 'ID', false, null, null);
$this->addForeignKey('FILE_ID', 'DbRecordedFile', 'INTEGER', 'cc_files', 'ID', false, null, null);
$this->addColumn('SOUNDCLOUD_ID', 'DbSoundCloudId', 'INTEGER', false, null, null);
// validators
} // initialize()

View file

@ -80,6 +80,7 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent
/**
* The value for the record field.
* Note: this column has a database default value of: 0
* @var int
*/
protected $record;
@ -103,6 +104,27 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
/**
* Applies default values to this object.
* This method should be called from the object's constructor (or
* equivalent initialization method).
* @see __construct()
*/
public function applyDefaultValues()
{
$this->record = 0;
}
/**
* Initializes internal state of BaseCcShowDays object.
* @see applyDefaults()
*/
public function __construct()
{
parent::__construct();
$this->applyDefaultValues();
}
/**
* Get the [id] column value.
*
@ -607,7 +629,7 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent
$v = (int) $v;
}
if ($this->record !== $v) {
if ($this->record !== $v || $this->isNew()) {
$this->record = $v;
$this->modifiedColumns[] = CcShowDaysPeer::RECORD;
}
@ -625,6 +647,10 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent
*/
public function hasOnlyDefaultValues()
{
if ($this->record !== 0) {
return false;
}
// otherwise, everything was equal, so return TRUE
return true;
} // hasOnlyDefaultValues()
@ -1357,6 +1383,7 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent
$this->alreadyInSave = false;
$this->alreadyInValidation = false;
$this->clearAllReferences();
$this->applyDefaultValues();
$this->resetModified();
$this->setNew(true);
$this->setDeleted(false);

View file

@ -74,6 +74,12 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
*/
protected $file_id;
/**
* The value for the soundcloud_id field.
* @var int
*/
protected $soundcloud_id;
/**
* @var CcShow
*/
@ -261,6 +267,16 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
return $this->file_id;
}
/**
* Get the [soundcloud_id] column value.
*
* @return int
*/
public function getDbSoundCloudId()
{
return $this->soundcloud_id;
}
/**
* Set the value of [id] column.
*
@ -491,6 +507,26 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
return $this;
} // setDbRecordedFile()
/**
* Set the value of [soundcloud_id] column.
*
* @param int $v new value
* @return CcShowInstances The current object (for fluent API support)
*/
public function setDbSoundCloudId($v)
{
if ($v !== null) {
$v = (int) $v;
}
if ($this->soundcloud_id !== $v) {
$this->soundcloud_id = $v;
$this->modifiedColumns[] = CcShowInstancesPeer::SOUNDCLOUD_ID;
}
return $this;
} // setDbSoundCloudId()
/**
* Indicates whether the columns in this object are only set to default values.
*
@ -539,6 +575,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
$this->rebroadcast = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null;
$this->instance_id = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null;
$this->file_id = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null;
$this->soundcloud_id = ($row[$startcol + 8] !== null) ? (int) $row[$startcol + 8] : null;
$this->resetModified();
$this->setNew(false);
@ -547,7 +584,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
$this->ensureConsistency();
}
return $startcol + 8; // 8 = CcShowInstancesPeer::NUM_COLUMNS - CcShowInstancesPeer::NUM_LAZY_LOAD_COLUMNS).
return $startcol + 9; // 9 = CcShowInstancesPeer::NUM_COLUMNS - CcShowInstancesPeer::NUM_LAZY_LOAD_COLUMNS).
} catch (Exception $e) {
throw new PropelException("Error populating CcShowInstances object", $e);
@ -968,6 +1005,9 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
case 7:
return $this->getDbRecordedFile();
break;
case 8:
return $this->getDbSoundCloudId();
break;
default:
return null;
break;
@ -1000,6 +1040,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
$keys[5] => $this->getDbRebroadcast(),
$keys[6] => $this->getDbOriginalShow(),
$keys[7] => $this->getDbRecordedFile(),
$keys[8] => $this->getDbSoundCloudId(),
);
if ($includeForeignObjects) {
if (null !== $this->aCcShow) {
@ -1066,6 +1107,9 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
case 7:
$this->setDbRecordedFile($value);
break;
case 8:
$this->setDbSoundCloudId($value);
break;
} // switch()
}
@ -1098,6 +1142,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
if (array_key_exists($keys[5], $arr)) $this->setDbRebroadcast($arr[$keys[5]]);
if (array_key_exists($keys[6], $arr)) $this->setDbOriginalShow($arr[$keys[6]]);
if (array_key_exists($keys[7], $arr)) $this->setDbRecordedFile($arr[$keys[7]]);
if (array_key_exists($keys[8], $arr)) $this->setDbSoundCloudId($arr[$keys[8]]);
}
/**
@ -1117,6 +1162,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
if ($this->isColumnModified(CcShowInstancesPeer::REBROADCAST)) $criteria->add(CcShowInstancesPeer::REBROADCAST, $this->rebroadcast);
if ($this->isColumnModified(CcShowInstancesPeer::INSTANCE_ID)) $criteria->add(CcShowInstancesPeer::INSTANCE_ID, $this->instance_id);
if ($this->isColumnModified(CcShowInstancesPeer::FILE_ID)) $criteria->add(CcShowInstancesPeer::FILE_ID, $this->file_id);
if ($this->isColumnModified(CcShowInstancesPeer::SOUNDCLOUD_ID)) $criteria->add(CcShowInstancesPeer::SOUNDCLOUD_ID, $this->soundcloud_id);
return $criteria;
}
@ -1185,6 +1231,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
$copyObj->setDbRebroadcast($this->rebroadcast);
$copyObj->setDbOriginalShow($this->instance_id);
$copyObj->setDbRecordedFile($this->file_id);
$copyObj->setDbSoundCloudId($this->soundcloud_id);
if ($deepCopy) {
// important: temporarily setNew(false) because this affects the behavior of
@ -1676,6 +1723,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
$this->rebroadcast = null;
$this->instance_id = null;
$this->file_id = null;
$this->soundcloud_id = null;
$this->alreadyInSave = false;
$this->alreadyInValidation = false;
$this->clearAllReferences();

View file

@ -26,7 +26,7 @@ abstract class BaseCcShowInstancesPeer {
const TM_CLASS = 'CcShowInstancesTableMap';
/** The total number of columns. */
const NUM_COLUMNS = 8;
const NUM_COLUMNS = 9;
/** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0;
@ -55,6 +55,9 @@ abstract class BaseCcShowInstancesPeer {
/** the column name for the FILE_ID field */
const FILE_ID = 'cc_show_instances.FILE_ID';
/** the column name for the SOUNDCLOUD_ID field */
const SOUNDCLOUD_ID = 'cc_show_instances.SOUNDCLOUD_ID';
/**
* An identiy map to hold any loaded instances of CcShowInstances objects.
* This must be public so that other peer classes can access this when hydrating from JOIN
@ -71,12 +74,12 @@ abstract class BaseCcShowInstancesPeer {
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('DbId', 'DbStarts', 'DbEnds', 'DbShowId', 'DbRecord', 'DbRebroadcast', 'DbOriginalShow', 'DbRecordedFile', ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbStarts', 'dbEnds', 'dbShowId', 'dbRecord', 'dbRebroadcast', 'dbOriginalShow', 'dbRecordedFile', ),
BasePeer::TYPE_COLNAME => array (self::ID, self::STARTS, self::ENDS, self::SHOW_ID, self::RECORD, self::REBROADCAST, self::INSTANCE_ID, self::FILE_ID, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID', 'STARTS', 'ENDS', 'SHOW_ID', 'RECORD', 'REBROADCAST', 'INSTANCE_ID', 'FILE_ID', ),
BasePeer::TYPE_FIELDNAME => array ('id', 'starts', 'ends', 'show_id', 'record', 'rebroadcast', 'instance_id', 'file_id', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
BasePeer::TYPE_PHPNAME => array ('DbId', 'DbStarts', 'DbEnds', 'DbShowId', 'DbRecord', 'DbRebroadcast', 'DbOriginalShow', 'DbRecordedFile', 'DbSoundCloudId', ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbStarts', 'dbEnds', 'dbShowId', 'dbRecord', 'dbRebroadcast', 'dbOriginalShow', 'dbRecordedFile', 'dbSoundCloudId', ),
BasePeer::TYPE_COLNAME => array (self::ID, self::STARTS, self::ENDS, self::SHOW_ID, self::RECORD, self::REBROADCAST, self::INSTANCE_ID, self::FILE_ID, self::SOUNDCLOUD_ID, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID', 'STARTS', 'ENDS', 'SHOW_ID', 'RECORD', 'REBROADCAST', 'INSTANCE_ID', 'FILE_ID', 'SOUNDCLOUD_ID', ),
BasePeer::TYPE_FIELDNAME => array ('id', 'starts', 'ends', 'show_id', 'record', 'rebroadcast', 'instance_id', 'file_id', 'soundcloud_id', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, )
);
/**
@ -86,12 +89,12 @@ abstract class BaseCcShowInstancesPeer {
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
*/
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbStarts' => 1, 'DbEnds' => 2, 'DbShowId' => 3, 'DbRecord' => 4, 'DbRebroadcast' => 5, 'DbOriginalShow' => 6, 'DbRecordedFile' => 7, ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbStarts' => 1, 'dbEnds' => 2, 'dbShowId' => 3, 'dbRecord' => 4, 'dbRebroadcast' => 5, 'dbOriginalShow' => 6, 'dbRecordedFile' => 7, ),
BasePeer::TYPE_COLNAME => array (self::ID => 0, self::STARTS => 1, self::ENDS => 2, self::SHOW_ID => 3, self::RECORD => 4, self::REBROADCAST => 5, self::INSTANCE_ID => 6, self::FILE_ID => 7, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'STARTS' => 1, 'ENDS' => 2, 'SHOW_ID' => 3, 'RECORD' => 4, 'REBROADCAST' => 5, 'INSTANCE_ID' => 6, 'FILE_ID' => 7, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'starts' => 1, 'ends' => 2, 'show_id' => 3, 'record' => 4, 'rebroadcast' => 5, 'instance_id' => 6, 'file_id' => 7, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbStarts' => 1, 'DbEnds' => 2, 'DbShowId' => 3, 'DbRecord' => 4, 'DbRebroadcast' => 5, 'DbOriginalShow' => 6, 'DbRecordedFile' => 7, 'DbSoundCloudId' => 8, ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbStarts' => 1, 'dbEnds' => 2, 'dbShowId' => 3, 'dbRecord' => 4, 'dbRebroadcast' => 5, 'dbOriginalShow' => 6, 'dbRecordedFile' => 7, 'dbSoundCloudId' => 8, ),
BasePeer::TYPE_COLNAME => array (self::ID => 0, self::STARTS => 1, self::ENDS => 2, self::SHOW_ID => 3, self::RECORD => 4, self::REBROADCAST => 5, self::INSTANCE_ID => 6, self::FILE_ID => 7, self::SOUNDCLOUD_ID => 8, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'STARTS' => 1, 'ENDS' => 2, 'SHOW_ID' => 3, 'RECORD' => 4, 'REBROADCAST' => 5, 'INSTANCE_ID' => 6, 'FILE_ID' => 7, 'SOUNDCLOUD_ID' => 8, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'starts' => 1, 'ends' => 2, 'show_id' => 3, 'record' => 4, 'rebroadcast' => 5, 'instance_id' => 6, 'file_id' => 7, 'soundcloud_id' => 8, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, )
);
/**
@ -171,6 +174,7 @@ abstract class BaseCcShowInstancesPeer {
$criteria->addSelectColumn(CcShowInstancesPeer::REBROADCAST);
$criteria->addSelectColumn(CcShowInstancesPeer::INSTANCE_ID);
$criteria->addSelectColumn(CcShowInstancesPeer::FILE_ID);
$criteria->addSelectColumn(CcShowInstancesPeer::SOUNDCLOUD_ID);
} else {
$criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.STARTS');
@ -180,6 +184,7 @@ abstract class BaseCcShowInstancesPeer {
$criteria->addSelectColumn($alias . '.REBROADCAST');
$criteria->addSelectColumn($alias . '.INSTANCE_ID');
$criteria->addSelectColumn($alias . '.FILE_ID');
$criteria->addSelectColumn($alias . '.SOUNDCLOUD_ID');
}
}

View file

@ -14,6 +14,7 @@
* @method CcShowInstancesQuery orderByDbRebroadcast($order = Criteria::ASC) Order by the rebroadcast column
* @method CcShowInstancesQuery orderByDbOriginalShow($order = Criteria::ASC) Order by the instance_id column
* @method CcShowInstancesQuery orderByDbRecordedFile($order = Criteria::ASC) Order by the file_id column
* @method CcShowInstancesQuery orderByDbSoundCloudId($order = Criteria::ASC) Order by the soundcloud_id column
*
* @method CcShowInstancesQuery groupByDbId() Group by the id column
* @method CcShowInstancesQuery groupByDbStarts() Group by the starts column
@ -23,6 +24,7 @@
* @method CcShowInstancesQuery groupByDbRebroadcast() Group by the rebroadcast column
* @method CcShowInstancesQuery groupByDbOriginalShow() Group by the instance_id column
* @method CcShowInstancesQuery groupByDbRecordedFile() Group by the file_id column
* @method CcShowInstancesQuery groupByDbSoundCloudId() Group by the soundcloud_id column
*
* @method CcShowInstancesQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method CcShowInstancesQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
@ -59,6 +61,7 @@
* @method CcShowInstances findOneByDbRebroadcast(int $rebroadcast) Return the first CcShowInstances filtered by the rebroadcast column
* @method CcShowInstances findOneByDbOriginalShow(int $instance_id) Return the first CcShowInstances filtered by the instance_id column
* @method CcShowInstances findOneByDbRecordedFile(int $file_id) Return the first CcShowInstances filtered by the file_id column
* @method CcShowInstances findOneByDbSoundCloudId(int $soundcloud_id) Return the first CcShowInstances filtered by the soundcloud_id column
*
* @method array findByDbId(int $id) Return CcShowInstances objects filtered by the id column
* @method array findByDbStarts(string $starts) Return CcShowInstances objects filtered by the starts column
@ -68,6 +71,7 @@
* @method array findByDbRebroadcast(int $rebroadcast) Return CcShowInstances objects filtered by the rebroadcast column
* @method array findByDbOriginalShow(int $instance_id) Return CcShowInstances objects filtered by the instance_id column
* @method array findByDbRecordedFile(int $file_id) Return CcShowInstances objects filtered by the file_id column
* @method array findByDbSoundCloudId(int $soundcloud_id) Return CcShowInstances objects filtered by the soundcloud_id column
*
* @package propel.generator.airtime.om
*/
@ -411,6 +415,37 @@ abstract class BaseCcShowInstancesQuery extends ModelCriteria
return $this->addUsingAlias(CcShowInstancesPeer::FILE_ID, $dbRecordedFile, $comparison);
}
/**
* Filter the query on the soundcloud_id column
*
* @param int|array $dbSoundCloudId The value to use as filter.
* Accepts an associative array('min' => $minValue, 'max' => $maxValue)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CcShowInstancesQuery The current query, for fluid interface
*/
public function filterByDbSoundCloudId($dbSoundCloudId = null, $comparison = null)
{
if (is_array($dbSoundCloudId)) {
$useMinMax = false;
if (isset($dbSoundCloudId['min'])) {
$this->addUsingAlias(CcShowInstancesPeer::SOUNDCLOUD_ID, $dbSoundCloudId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($dbSoundCloudId['max'])) {
$this->addUsingAlias(CcShowInstancesPeer::SOUNDCLOUD_ID, $dbSoundCloudId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CcShowInstancesPeer::SOUNDCLOUD_ID, $dbSoundCloudId, $comparison);
}
/**
* Filter the query by a related CcShow object
*

View file

@ -0,0 +1,98 @@
<?php
set_include_path(__DIR__.'/..' . PATH_SEPARATOR . get_include_path());
set_include_path(__DIR__.'/../../../library' . PATH_SEPARATOR . get_include_path());
require_once __DIR__.'/../Shows.php';
require_once __DIR__.'/../StoredFile.php';
require_once __DIR__.'/../Playlist.php';
require_once __DIR__.'/../Schedule.php';
require_once __DIR__.'/../Preference.php';
require_once __DIR__.'/../RabbitMq.php';
require_once __DIR__.'/../../configs/conf.php';
require_once __DIR__.'/../../../install/include/AirtimeIni.php';
require_once __DIR__.'/../../../install/include/AirtimeInstall.php';
require_once __DIR__.'/../../../library/propel/runtime/lib/Propel.php';
Propel::init(__DIR__.'/../../configs/airtime-conf.php');
AirtimeInstall::DbConnect(true);
// Create a playlist
$playlist = new Playlist();
$playlist->create("Calendar Load test playlist ".uniqid());
// Add a file
$values = array("filepath" => __DIR__."/test10001.mp3");
$storedFile = StoredFile::Insert($values, false);
$result = $playlist->addAudioClip($storedFile->getId());
// Add a file
$values = array("filepath" => __DIR__."/test10002.mp3");
$storedFile2 = StoredFile::Insert($values, false);
$result = $playlist->addAudioClip($storedFile2->getId());
$result = $playlist->addAudioClip($storedFile2->getId());
echo "Created playlist ".$playlist->getName()." with ID ".$playlist->getId()."\n";
// Create the shows
$data = array();
$currentDate = date("Y\\-m\\-d");
$year = date("Y");
$month = date("m");
$day = date("d");
$nextDay = $currentDate;
#echo $currentDate;
$currentHour = date("H");
$setHour = $currentHour + 1;
$showNumber = 1;
for ($days=1; $days<100; $days=$days+1)
{
// Adding shows until the end of the day
while ($setHour < 24)
{
echo 'Adding show: '.$nextDay. ' '.$setHour.":00\n";
$data['add_show_name'] = 'automated show '.$showNumber;
$data['add_show_start_date'] = $nextDay;
$data['add_show_start_time'] = $setHour.':00';
$showNumber = $showNumber + 1;
$data['add_show_duration'] = '1:00';
$data['add_show_no_end'] = 0;
$data['add_show_repeats'] = 0;
$data['add_show_description'] = 'automated show';
$data['add_show_url'] = 'http://www.OfirGal.com';
$data['add_show_color'] = "";
$data['add_show_background_color'] = "";
$data['add_show_record'] = 0;
$data['add_show_hosts'] ="";
$showId = Show::create($data);
Show::populateShowUntil($showId, "2012-01-01 00:00:00");
// populating the show with a playlist
$show = new ShowInstance($showId);
$show->scheduleShow(array($playlist->getId()));
$setHour = $setHour + 1;
}
// set the next day
$setHour = 0;
if ($day<30) {
$day = $day + 1;
} else {
$day = 1;
if ($month<12)
{
$month = $month + 1;
} else {
$month = 1;
$year = $year + 1;
}
}
$nextDay = $year."-".$month."-".$day;
}

View file

@ -1,7 +1,7 @@
<div id="schedule-add-show" class="tabs ui-widget ui-widget-content block-shadow alpha-block padded">
<div class="button-bar">
<a href="#" id="add-show-close" class="icon-link"><span class="ui-icon ui-icon-circle-close"></span>Close</a>
<button aria-disabled="false" role="button" id="add-show-submit" class="right-floated ui-button ui-widget ui-state-default ui-button-text-icon-primary">
<button aria-disabled="false" role="button" class="add-show-submit right-floated ui-button ui-widget ui-state-default ui-button-text-icon-primary">
<span class="ui-icon ui-icon-plusthick"></span>
<span class="ui-button-text">Add this show</span>
</button>
@ -30,5 +30,11 @@
<div id="schedule-show-style" class="collapsible-content">
<?php echo $this->style; ?>
</div>
<div class="button-bar">
<button aria-disabled="false" role="button" class="add-show-submit right-floated ui-button ui-widget ui-state-default ui-button-text-icon-primary">
<span class="ui-icon ui-icon-plusthick"></span>
<span class="ui-button-text">Add this show</span>
</button>
</div>
</div>

View file

@ -1,4 +1,5 @@
<div id="show_content_dialog">
<div><?php echo $this->additionalShowInfo; ?></div>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="datatable">
<tr>
<th>Start</th>