CC-2166: Packaging Improvements. Moved the Zend app into airtime_mvc. It is now installed to /var/www/airtime. Storage is now set to /srv/airtime/stor. Utils are now installed to /usr/lib/airtime/utils/. Added install/airtime-dircheck.php as a simple test to see if everything is install/uninstalled correctly.
This commit is contained in:
parent
514777e8d2
commit
b11cbd8159
4546 changed files with 138 additions and 51 deletions
319
airtime_mvc/application/controllers/ApiController.php
Normal file
319
airtime_mvc/application/controllers/ApiController.php
Normal file
|
@ -0,0 +1,319 @@
|
|||
<?php
|
||||
|
||||
class ApiController extends Zend_Controller_Action
|
||||
{
|
||||
|
||||
public function init()
|
||||
{
|
||||
/* Initialize action controller here */
|
||||
$context = $this->_helper->getHelper('contextSwitch');
|
||||
$context->addActionContext('version', 'json')
|
||||
->addActionContext('recorded-shows', 'json')
|
||||
->addActionContext('upload-recorded', 'json')
|
||||
->initContext();
|
||||
}
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
// action body
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Airtime version. i.e "1.7.0 alpha"
|
||||
*
|
||||
* First checks to ensure the correct API key was
|
||||
* supplied, then returns AIRTIME_VERSION as defined
|
||||
* in application/conf.php
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
public function versionAction()
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
|
||||
// disable the view and the layout
|
||||
$this->view->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender(true);
|
||||
|
||||
$api_key = $this->_getParam('api_key');
|
||||
if (!in_array($api_key, $CC_CONFIG["apiKey"]))
|
||||
{
|
||||
header('HTTP/1.0 401 Unauthorized');
|
||||
print 'You are not allowed to access this resource.';
|
||||
exit;
|
||||
}
|
||||
$jsonStr = json_encode(array("version"=>AIRTIME_VERSION));
|
||||
echo $jsonStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows remote client to download requested media file.
|
||||
*
|
||||
* @return void
|
||||
* The given value increased by the increment amount.
|
||||
*/
|
||||
public function getMediaAction()
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
|
||||
// disable the view and the layout
|
||||
$this->view->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender(true);
|
||||
|
||||
$api_key = $this->_getParam('api_key');
|
||||
if(!in_array($api_key, $CC_CONFIG["apiKey"]))
|
||||
{
|
||||
header('HTTP/1.0 401 Unauthorized');
|
||||
print 'You are not allowed to access this resource.';
|
||||
exit;
|
||||
}
|
||||
|
||||
$filename = $this->_getParam("file");
|
||||
$file_id = substr($filename, 0, strpos($filename, "."));
|
||||
if (ctype_alnum($file_id) && strlen($file_id) == 32) {
|
||||
$media = StoredFile::RecallByGunid($file_id);
|
||||
if ($media != null && !PEAR::isError($media)) {
|
||||
$filepath = $media->getRealFilePath();
|
||||
if(!is_file($filepath))
|
||||
{
|
||||
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
|
||||
//print 'Resource in database, but not in storage. Sorry.';
|
||||
exit;
|
||||
}
|
||||
|
||||
// !! binary mode !!
|
||||
$fp = fopen($filepath, 'rb');
|
||||
|
||||
// possibly use fileinfo module here in the future.
|
||||
// http://www.php.net/manual/en/book.fileinfo.php
|
||||
$ext = pathinfo($filename, PATHINFO_EXTENSION);
|
||||
if ($ext == "ogg")
|
||||
header("Content-Type: audio/ogg");
|
||||
else if ($ext == "mp3")
|
||||
header("Content-Type: audio/mpeg");
|
||||
|
||||
|
||||
header("Content-Length: " . filesize($filepath));
|
||||
fpassthru($fp);
|
||||
return;
|
||||
}
|
||||
}
|
||||
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
|
||||
exit;
|
||||
}
|
||||
|
||||
public function liveInfoAction()
|
||||
{
|
||||
if (Application_Model_Preference::GetAllow3rdPartyApi()){
|
||||
// disable the view and the layout
|
||||
$this->view->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender(true);
|
||||
|
||||
$result = Schedule::GetPlayOrderRange(0, 1);
|
||||
|
||||
$date = new DateHelper;
|
||||
$timeNow = $date->getTimestamp();
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
|
||||
// disable the view and the layout
|
||||
$this->view->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender(true);
|
||||
|
||||
$api_key = $this->_getParam('api_key');
|
||||
|
||||
if(!in_array($api_key, $CC_CONFIG["apiKey"]))
|
||||
{
|
||||
header('HTTP/1.0 401 Unauthorized');
|
||||
print 'You are not allowed to access this resource. ';
|
||||
exit;
|
||||
}
|
||||
|
||||
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||
|
||||
$result = Schedule::GetScheduledPlaylists();
|
||||
echo json_encode($result);
|
||||
}
|
||||
|
||||
public function notifyMediaItemStartPlayAction()
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
|
||||
// disable the view and the layout
|
||||
$this->view->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender(true);
|
||||
|
||||
$api_key = $this->_getParam('api_key');
|
||||
if(!in_array($api_key, $CC_CONFIG["apiKey"]))
|
||||
{
|
||||
header('HTTP/1.0 401 Unauthorized');
|
||||
print 'You are not allowed to access this resource.';
|
||||
exit;
|
||||
}
|
||||
|
||||
$schedule_group_id = $this->_getParam("schedule_id");
|
||||
$media_id = $this->_getParam("media_id");
|
||||
$result = Schedule::UpdateMediaPlayedStatus($media_id);
|
||||
|
||||
if (!PEAR::isError($result)) {
|
||||
echo json_encode(array("status"=>1, "message"=>""));
|
||||
} else {
|
||||
echo json_encode(array("status"=>0, "message"=>"DB Error:".$result->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
public function notifyScheduleGroupPlayAction()
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
|
||||
// disable the view and the layout
|
||||
$this->view->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender(true);
|
||||
|
||||
$api_key = $this->_getParam('api_key');
|
||||
if(!in_array($api_key, $CC_CONFIG["apiKey"]))
|
||||
{
|
||||
header('HTTP/1.0 401 Unauthorized');
|
||||
print 'You are not allowed to access this resource.';
|
||||
exit;
|
||||
}
|
||||
|
||||
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||
|
||||
$schedule_group_id = $this->_getParam("schedule_id");
|
||||
if (is_numeric($schedule_group_id)) {
|
||||
$sg = new ScheduleGroup($schedule_group_id);
|
||||
if ($sg->exists()) {
|
||||
$result = $sg->notifyGroupStartPlay();
|
||||
if (!PEAR::isError($result)) {
|
||||
echo json_encode(array("status"=>1, "message"=>""));
|
||||
exit;
|
||||
} else {
|
||||
echo json_encode(array("status"=>0, "message"=>"DB Error:".$result->getMessage()));
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
echo json_encode(array("status"=>0, "message"=>"Schedule group does not exist: ".$schedule_group_id));
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
echo json_encode(array("status"=>0, "message"=>"Incorrect or non-numeric arguments given."));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function recordedShowsAction()
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
|
||||
$api_key = $this->_getParam('api_key');
|
||||
if (!in_array($api_key, $CC_CONFIG["apiKey"]))
|
||||
{
|
||||
header('HTTP/1.0 401 Unauthorized');
|
||||
print 'You are not allowed to access this resource.';
|
||||
exit;
|
||||
}
|
||||
|
||||
$today_timestamp = date("Y-m-d H:i:s");
|
||||
$now = new DateTime($today_timestamp);
|
||||
$end_timestamp = $now->add(new DateInterval("PT2H"));
|
||||
$end_timestamp = $end_timestamp->format("Y-m-d H:i:s");
|
||||
$this->view->shows = Show::getShows($today_timestamp, $end_timestamp, $excludeInstance=NULL, $onlyRecord=TRUE);
|
||||
}
|
||||
|
||||
public function uploadRecordedAction()
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
|
||||
$api_key = $this->_getParam('api_key');
|
||||
if (!in_array($api_key, $CC_CONFIG["apiKey"]))
|
||||
{
|
||||
header('HTTP/1.0 401 Unauthorized');
|
||||
print 'You are not allowed to access this resource.';
|
||||
exit;
|
||||
}
|
||||
|
||||
$upload_dir = ini_get("upload_tmp_dir");
|
||||
$file = StoredFile::uploadFile($upload_dir);
|
||||
|
||||
$show_instance = $this->_getParam('show_instance');
|
||||
$show_inst = new ShowInstance($show_instance);
|
||||
|
||||
$show_inst->setRecordedFile($file->getId());
|
||||
$show_name = $show_inst->getName();
|
||||
$show_genre = $show_inst->getGenre();
|
||||
$show_start_time = $show_inst->getShowStart();
|
||||
|
||||
if(Application_Model_Preference::GetDoSoundCloudUpload())
|
||||
{
|
||||
for($i=0; $i<$CC_CONFIG['soundcloud-connection-retries']; $i++) {
|
||||
|
||||
$show = new Show($show_inst->getShowId());
|
||||
$description = $show->getDescription();
|
||||
$hosts = $show->getHosts();
|
||||
|
||||
$tags = array_merge($hosts, array($show_name));
|
||||
|
||||
try {
|
||||
$soundcloud = new ATSoundcloud();
|
||||
$soundcloud_id = $soundcloud->uploadTrack($file->getRealFilePath(), $file->getName(), $description, $tags, $show_start_time, $show_genre);
|
||||
$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();
|
||||
}
|
||||
}
|
||||
|
27
airtime_mvc/application/controllers/DashboardController.php
Normal file
27
airtime_mvc/application/controllers/DashboardController.php
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
class DashboardController extends Zend_Controller_Action
|
||||
{
|
||||
|
||||
public function init()
|
||||
{
|
||||
/* Initialize action controller here */
|
||||
}
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
// action body
|
||||
}
|
||||
|
||||
public function helpAction()
|
||||
{
|
||||
// action body
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
58
airtime_mvc/application/controllers/ErrorController.php
Normal file
58
airtime_mvc/application/controllers/ErrorController.php
Normal file
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
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';
|
||||
break;
|
||||
default:
|
||||
// application error
|
||||
$this->getResponse()->setHttpResponseCode(500);
|
||||
$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;
|
||||
}
|
||||
|
||||
public function getLog()
|
||||
{
|
||||
$bootstrap = $this->getInvokeArg('bootstrap');
|
||||
if (!$bootstrap->hasPluginResource('Log')) {
|
||||
return false;
|
||||
}
|
||||
$log = $bootstrap->getResource('Log');
|
||||
return $log;
|
||||
}
|
||||
|
||||
public function deniedAction()
|
||||
{
|
||||
// action body
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
28
airtime_mvc/application/controllers/IndexController.php
Normal file
28
airtime_mvc/application/controllers/IndexController.php
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
class IndexController extends Zend_Controller_Action
|
||||
{
|
||||
|
||||
public function init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$this->_forward('index', 'login');
|
||||
}
|
||||
|
||||
public function mainAction()
|
||||
{
|
||||
$this->_helper->layout->setLayout('layout');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
195
airtime_mvc/application/controllers/LibraryController.php
Normal file
195
airtime_mvc/application/controllers/LibraryController.php
Normal file
|
@ -0,0 +1,195 @@
|
|||
<?php
|
||||
|
||||
class LibraryController extends Zend_Controller_Action
|
||||
{
|
||||
|
||||
protected $pl_sess = null;
|
||||
protected $search_sess = null;
|
||||
|
||||
public function init()
|
||||
{
|
||||
$ajaxContext = $this->_helper->getHelper('AjaxContext');
|
||||
$ajaxContext->addActionContext('contents', 'json')
|
||||
->addActionContext('delete', 'json')
|
||||
->addActionContext('context-menu', 'json')
|
||||
->addActionContext('get-file-meta-data', 'html')
|
||||
->initContext();
|
||||
|
||||
$this->pl_sess = new Zend_Session_Namespace(UI_PLAYLIST_SESSNAME);
|
||||
$this->search_sess = new Zend_Session_Namespace("search");
|
||||
}
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$this->view->headScript()->appendFile('/js/contextmenu/jjmenu.js','text/javascript');
|
||||
$this->view->headScript()->appendFile('/js/jplayer/jquery.jplayer.min.js');
|
||||
$this->view->headScript()->appendFile('/js/datatables/js/jquery.dataTables.js','text/javascript');
|
||||
$this->view->headScript()->appendFile('/js/airtime/library/library.js','text/javascript');
|
||||
$this->view->headScript()->appendFile('/js/airtime/library/advancedsearch.js','text/javascript');
|
||||
|
||||
$this->view->headLink()->appendStylesheet('/css/media_library.css');
|
||||
$this->view->headLink()->appendStylesheet('/css/contextmenu.css');
|
||||
|
||||
$this->_helper->layout->setLayout('library');
|
||||
$this->_helper->viewRenderer->setResponseSegment('library');
|
||||
|
||||
$form = new Application_Form_AdvancedSearch();
|
||||
$form->addGroup(1, 1);
|
||||
|
||||
$this->search_sess->next_group = 2;
|
||||
$this->search_sess->next_row[1] = 2;
|
||||
$this->view->form = $form;
|
||||
$this->view->md = $this->search_sess->md;
|
||||
|
||||
$this->_helper->actionStack('index', 'playlist');
|
||||
}
|
||||
|
||||
public function contextMenuAction()
|
||||
{
|
||||
$id = $this->_getParam('id');
|
||||
$type = $this->_getParam('type');
|
||||
|
||||
$params = '/format/json/id/#id#/type/#type#';
|
||||
|
||||
$pl_sess = $this->pl_sess;
|
||||
|
||||
if($type === "au") {
|
||||
|
||||
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Library/delete'.$params, 'callback' => 'window["deleteAudioClip"]'),
|
||||
'title' => 'Delete');
|
||||
|
||||
if(isset($pl_sess->id)) {
|
||||
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Playlist/add-item'.$params, 'callback' => 'window["setSPLContent"]'),
|
||||
'title' => 'Add to Playlist');
|
||||
}
|
||||
|
||||
$menu[] = array('action' => array('type' => 'gourl', 'url' => '/Library/edit-file-md/id/#id#'),
|
||||
'title' => 'Edit Metadata');
|
||||
|
||||
}
|
||||
else if($type === "pl") {
|
||||
|
||||
if(!isset($pl_sess->id) || $pl_sess->id !== $id) {
|
||||
$menu[] = array('action' =>
|
||||
array('type' => 'ajax',
|
||||
'url' => '/Playlist/edit'.$params,
|
||||
'callback' => 'window["openDiffSPL"]'),
|
||||
'title' => 'Edit');
|
||||
}
|
||||
else if(isset($pl_sess->id) && $pl_sess->id === $id) {
|
||||
$menu[] = array('action' =>
|
||||
array('type' => 'ajax',
|
||||
'url' => '/Playlist/close'.$params,
|
||||
'callback' => 'window["noOpenPL"]'),
|
||||
'title' => 'Close');
|
||||
}
|
||||
|
||||
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Playlist/metadata/format/json/id/#id#', 'callback' => 'window["createPlaylistMetaForm"]'),
|
||||
'title' => 'Edit Metadata');
|
||||
|
||||
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Playlist/delete'.$params, 'callback' => 'window["deletePlaylist"]'),
|
||||
'title' => 'Delete');
|
||||
|
||||
}
|
||||
|
||||
//returns format jjmenu is looking for.
|
||||
die(json_encode($menu));
|
||||
}
|
||||
|
||||
public function deleteAction()
|
||||
{
|
||||
$id = $this->_getParam('id');
|
||||
|
||||
if (!is_null($id)) {
|
||||
$file = StoredFile::Recall($id);
|
||||
|
||||
if (PEAR::isError($file)) {
|
||||
$this->view->message = $file->getMessage();
|
||||
return;
|
||||
}
|
||||
else if(is_null($file)) {
|
||||
$this->view->message = "file doesn't exist";
|
||||
return;
|
||||
}
|
||||
|
||||
$res = $file->delete();
|
||||
|
||||
if (PEAR::isError($res)) {
|
||||
$this->view->message = $res->getMessage();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$this->view->id = $id;
|
||||
}
|
||||
|
||||
public function contentsAction()
|
||||
{
|
||||
$post = $this->getRequest()->getPost();
|
||||
$datatables = StoredFile::searchFilesForPlaylistBuilder($post);
|
||||
|
||||
die(json_encode($datatables));
|
||||
}
|
||||
|
||||
public function editFileMdAction()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
$form = new Application_Form_EditAudioMD();
|
||||
|
||||
$file_id = $this->_getParam('id', null);
|
||||
$file = StoredFile::Recall($file_id);
|
||||
|
||||
if ($request->isPost()) {
|
||||
if ($form->isValid($request->getPost())) {
|
||||
|
||||
$formdata = $form->getValues();
|
||||
$file->replaceDbMetadata($formdata);
|
||||
|
||||
$this->_helper->redirector('index');
|
||||
}
|
||||
}
|
||||
|
||||
$form->populate($file->md);
|
||||
$this->view->form = $form;
|
||||
}
|
||||
|
||||
public function getFileMetaDataAction()
|
||||
{
|
||||
$id = $this->_getParam('id');
|
||||
$type = $this->_getParam('type');
|
||||
|
||||
if($type == "au") {
|
||||
$file = StoredFile::Recall($id);
|
||||
$this->view->type = $type;
|
||||
$this->view->md = $file->md;
|
||||
}
|
||||
else if($type == "pl") {
|
||||
$file = Playlist::Recall($id);
|
||||
$this->view->type = $type;
|
||||
$this->view->md = $file->getAllPLMetaData();
|
||||
$this->view->contents = $file->getContents();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
95
airtime_mvc/application/controllers/LoginController.php
Normal file
95
airtime_mvc/application/controllers/LoginController.php
Normal file
|
@ -0,0 +1,95 @@
|
|||
<?php
|
||||
|
||||
class LoginController extends Zend_Controller_Action
|
||||
{
|
||||
|
||||
public function init()
|
||||
{
|
||||
/* Initialize action controller here */
|
||||
}
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
if(Zend_Auth::getInstance()->hasIdentity())
|
||||
{
|
||||
$this->_redirect('Nowplaying');
|
||||
}
|
||||
|
||||
//uses separate layout without a navigation.
|
||||
$this->_helper->layout->setLayout('login');
|
||||
|
||||
$request = $this->getRequest();
|
||||
$form = new Application_Form_Login();
|
||||
|
||||
$message = "Please enter your user name and password";
|
||||
|
||||
if($request->isPost())
|
||||
{
|
||||
if($form->isValid($request->getPost()))
|
||||
{
|
||||
|
||||
$authAdapter = $this->getAuthAdapter();
|
||||
|
||||
//get the username and password from the form
|
||||
$username = $form->getValue('username');
|
||||
$password = $form->getValue('password');
|
||||
|
||||
//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);
|
||||
|
||||
$this->_redirect('Nowplaying');
|
||||
}
|
||||
else
|
||||
{
|
||||
$message = "Wrong username or password provided. Please try again.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->view->message = $message;
|
||||
$this->view->form = $form;
|
||||
$this->view->airtimeVersion = AIRTIME_VERSION;
|
||||
$this->view->airtimeCopyright = AIRTIME_COPYRIGHT_DATE;
|
||||
}
|
||||
|
||||
public function logoutAction()
|
||||
{
|
||||
Zend_Auth::getInstance()->clearIdentity();
|
||||
$this->_redirect('login/index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the adapter for authentication against a database table
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
protected function getAuthAdapter()
|
||||
{
|
||||
$dbAdapter = Zend_Db_Table::getDefaultAdapter();
|
||||
$authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter);
|
||||
|
||||
$authAdapter->setTableName('cc_subjs')
|
||||
->setIdentityColumn('login')
|
||||
->setCredentialColumn('pass')
|
||||
->setCredentialTreatment('MD5(?)');
|
||||
|
||||
return $authAdapter;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
48
airtime_mvc/application/controllers/NowplayingController.php
Normal file
48
airtime_mvc/application/controllers/NowplayingController.php
Normal file
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
class NowplayingController extends Zend_Controller_Action
|
||||
{
|
||||
|
||||
public function init()
|
||||
{
|
||||
$ajaxContext = $this->_helper->getHelper('AjaxContext');
|
||||
$ajaxContext->addActionContext('get-data-grid-data', 'json')
|
||||
->initContext();
|
||||
}
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$this->view->headScript()->appendFile('/js/datatables/js/jquery.dataTables.min.js','text/javascript');
|
||||
$this->view->headScript()->appendFile('/js/playlist/nowplayingdatagrid.js','text/javascript');
|
||||
$this->view->headScript()->appendFile('/js/playlist/nowview.js','text/javascript');
|
||||
}
|
||||
|
||||
public function getDataGridDataAction()
|
||||
{
|
||||
$viewType = $this->_request->getParam('view');
|
||||
$dateString = $this->_request->getParam('date');
|
||||
$this->view->entries = Application_Model_Nowplaying::GetDataGridData($viewType, $dateString);
|
||||
}
|
||||
|
||||
public function livestreamAction()
|
||||
{
|
||||
//use bare bones layout (no header bar or menu)
|
||||
$this->_helper->layout->setLayout('bare');
|
||||
}
|
||||
|
||||
public function dayViewAction()
|
||||
{
|
||||
$this->view->headScript()->appendFile('/js/datatables/js/jquery.dataTables.min.js','text/javascript');
|
||||
$this->view->headScript()->appendFile('/js/playlist/nowplayingdatagrid.js','text/javascript');
|
||||
$this->view->headScript()->appendFile('/js/playlist/dayview.js','text/javascript');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
362
airtime_mvc/application/controllers/PlaylistController.php
Normal file
362
airtime_mvc/application/controllers/PlaylistController.php
Normal file
|
@ -0,0 +1,362 @@
|
|||
<?php
|
||||
|
||||
class PlaylistController extends Zend_Controller_Action
|
||||
{
|
||||
|
||||
protected $pl_sess = null;
|
||||
|
||||
public function init()
|
||||
{
|
||||
$ajaxContext = $this->_helper->getHelper('AjaxContext');
|
||||
$ajaxContext->addActionContext('add-item', 'json')
|
||||
->addActionContext('delete-item', 'json')
|
||||
->addActionContext('set-fade', 'json')
|
||||
->addActionContext('set-cue', 'json')
|
||||
->addActionContext('move-item', 'json')
|
||||
->addActionContext('close', 'json')
|
||||
->addActionContext('new', 'json')
|
||||
->addActionContext('metadata', 'json')
|
||||
->addActionContext('edit', 'json')
|
||||
->addActionContext('delete-active', 'json')
|
||||
->addActionContext('delete', 'json')
|
||||
->addActionContext('set-playlist-fades', 'json')
|
||||
->initContext();
|
||||
|
||||
$this->pl_sess = new Zend_Session_Namespace(UI_PLAYLIST_SESSNAME);
|
||||
}
|
||||
|
||||
private function getPlaylist()
|
||||
{
|
||||
$pl_sess = $this->pl_sess;
|
||||
|
||||
if(isset($pl_sess->id)) {
|
||||
|
||||
$pl = Playlist::Recall($pl_sess->id);
|
||||
if($pl === FALSE) {
|
||||
unset($pl_sess->id);
|
||||
return;
|
||||
}
|
||||
return $pl;
|
||||
}
|
||||
}
|
||||
|
||||
private function changePlaylist($pl_id)
|
||||
{
|
||||
$pl_sess = $this->pl_sess;
|
||||
|
||||
if(isset($pl_sess->id)) {
|
||||
|
||||
$pl = Playlist::Recall($pl_sess->id);
|
||||
if($pl !== FALSE) {
|
||||
$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;
|
||||
}
|
||||
|
||||
private function closePlaylist($pl)
|
||||
{
|
||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
$res = $pl->unlock($userInfo->id);
|
||||
|
||||
$pl_sess = $this->pl_sess;
|
||||
unset($pl_sess->id);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$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->view->pl = $this->getPlaylist();
|
||||
}
|
||||
|
||||
public function newAction()
|
||||
{
|
||||
$pl_sess = $this->pl_sess;
|
||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
|
||||
$pl = new Playlist();
|
||||
$pl->create("Untitled Playlist");
|
||||
$pl->setPLMetaData('dc:creator', $userInfo->login);
|
||||
|
||||
$this->changePlaylist($pl->getId());
|
||||
$form = new Application_Form_PlaylistMetadata();
|
||||
$this->view->fieldset = $form;
|
||||
$this->view->form = $this->view->render('playlist/new.phtml');
|
||||
}
|
||||
|
||||
public function metadataAction()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
$form = new Application_Form_PlaylistMetadata();
|
||||
|
||||
$pl_id = $this->_getParam('id', null);
|
||||
//not a new playlist
|
||||
if(!is_null($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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
$this->view->pl = $pl;
|
||||
$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');
|
||||
}
|
||||
|
||||
public function editAction()
|
||||
{
|
||||
$pl_id = $this->_getParam('id', null);
|
||||
|
||||
if(!is_null($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);
|
||||
}
|
||||
|
||||
public function addItemAction()
|
||||
{
|
||||
$id = $this->_getParam('id');
|
||||
$pos = $this->_getParam('pos', null);
|
||||
|
||||
if (!is_null($id)) {
|
||||
|
||||
$pl = $this->getPlaylist();
|
||||
$res = $pl->addAudioClip($id, $pos);
|
||||
|
||||
if (PEAR::isError($res)) {
|
||||
$this->view->message = $res->getMessage();
|
||||
}
|
||||
|
||||
$this->view->pl = $pl;
|
||||
$this->view->html = $this->view->render('playlist/update.phtml');
|
||||
$this->view->name = $pl->getName();
|
||||
$this->view->length = $pl->getLength();
|
||||
|
||||
unset($this->view->pl);
|
||||
return;
|
||||
}
|
||||
$this->view->message = "a file is not chosen";
|
||||
}
|
||||
|
||||
public function moveItemAction()
|
||||
{
|
||||
$oldPos = $this->_getParam('oldPos');
|
||||
$newPos = $this->_getParam('newPos');
|
||||
|
||||
$pl = $this->getPlaylist();
|
||||
|
||||
$pl->moveAudioClip($oldPos, $newPos);
|
||||
|
||||
$this->view->pl = $pl;
|
||||
$this->view->html = $this->view->render('playlist/update.phtml');
|
||||
$this->view->name = $pl->getName();
|
||||
$this->view->length = $pl->getLength();
|
||||
|
||||
unset($this->view->pl);
|
||||
}
|
||||
|
||||
public function deleteItemAction()
|
||||
{
|
||||
$positions = $this->_getParam('pos', array());
|
||||
|
||||
if (!is_array($positions))
|
||||
$positions = array($positions);
|
||||
|
||||
//so the automatic updating of playlist positioning doesn't affect removal.
|
||||
sort($positions);
|
||||
$positions = array_reverse($positions);
|
||||
|
||||
$pl = $this->getPlaylist();
|
||||
|
||||
foreach ($positions as $pos) {
|
||||
$pl->delAudioClip($pos);
|
||||
}
|
||||
|
||||
$this->view->pl = $pl;
|
||||
$this->view->html = $this->view->render('playlist/update.phtml');
|
||||
$this->view->name = $pl->getName();
|
||||
$this->view->length = $pl->getLength();
|
||||
|
||||
unset($this->view->pl);
|
||||
}
|
||||
|
||||
public function setCueAction()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
$pos = $this->_getParam('pos');
|
||||
$pl = $this->getPlaylist();
|
||||
|
||||
if($request->isPost()) {
|
||||
$cueIn = $this->_getParam('cueIn', null);
|
||||
$cueOut = $this->_getParam('cueOut', null);
|
||||
|
||||
$response = $pl->changeClipLength($pos, $cueIn, $cueOut);
|
||||
|
||||
$this->view->response = $response;
|
||||
return;
|
||||
}
|
||||
|
||||
$cues = $pl->getCueInfo($pos);
|
||||
|
||||
$this->view->pos = $pos;
|
||||
$this->view->cueIn = $cues[0];
|
||||
$this->view->cueOut = $cues[1];
|
||||
$this->view->origLength = $cues[2];
|
||||
$this->view->html = $this->view->render('playlist/set-cue.phtml');
|
||||
}
|
||||
|
||||
public function setFadeAction()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
$pos = $this->_getParam('pos');
|
||||
$pl = $this->getPlaylist();
|
||||
|
||||
if($request->isPost()) {
|
||||
$fadeIn = $this->_getParam('fadeIn', null);
|
||||
$fadeOut = $this->_getParam('fadeOut', null);
|
||||
|
||||
$response = $pl->changeFadeInfo($pos, $fadeIn, $fadeOut);
|
||||
|
||||
$this->view->response = $response;
|
||||
return;
|
||||
}
|
||||
|
||||
$this->view->pos = intval($pos);
|
||||
|
||||
$fades = $pl->getFadeInfo($pos+1);
|
||||
$this->view->fadeIn = $fades[0];
|
||||
|
||||
$fades = $pl->getFadeInfo($pos);
|
||||
$this->view->fadeOut = $fades[1];
|
||||
$this->view->html = $this->view->render('playlist/set-fade.phtml');
|
||||
}
|
||||
|
||||
public function deleteAction()
|
||||
{
|
||||
$id = $this->_getParam('id', null);
|
||||
$pl = Playlist::Recall($id);
|
||||
|
||||
if ($pl !== FALSE) {
|
||||
|
||||
Playlist::Delete($id);
|
||||
|
||||
$pl_sess = $this->pl_sess;
|
||||
|
||||
if($pl_sess->id === $id){
|
||||
unset($pl_sess->id);
|
||||
}
|
||||
}
|
||||
|
||||
$this->view->id = $id;
|
||||
}
|
||||
|
||||
public function deleteActiveAction()
|
||||
{
|
||||
$pl = $this->getPlaylist();
|
||||
Playlist::Delete($pl->getId());
|
||||
|
||||
$pl_sess = $this->pl_sess;
|
||||
unset($pl_sess->id);
|
||||
|
||||
$this->view->html = $this->view->render('playlist/index.phtml');
|
||||
}
|
||||
|
||||
public function closeAction()
|
||||
{
|
||||
$pl = $this->getPlaylist();
|
||||
$this->closePlaylist($pl);
|
||||
|
||||
$this->view->html = $this->view->render('playlist/index.phtml');
|
||||
}
|
||||
|
||||
public function setPlaylistFadesAction()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
$pl = $this->getPlaylist();
|
||||
|
||||
if($request->isPost()) {
|
||||
$fadeIn = $this->_getParam('fadeIn', null);
|
||||
$fadeOut = $this->_getParam('fadeOut', null);
|
||||
|
||||
if($fadeIn)
|
||||
$response = $pl->changeFadeInfo(0, $fadeIn, $fadeOut);
|
||||
else if($fadeOut)
|
||||
$response = $pl->changeFadeInfo($pl->getSize(), $fadeIn, $fadeOut);
|
||||
|
||||
$this->view->response = $response;
|
||||
return;
|
||||
}
|
||||
|
||||
$fades = $pl->getFadeInfo(0);
|
||||
$this->view->fadeIn = $fades[0];
|
||||
|
||||
$fades = $pl->getFadeInfo($pl->getSize());
|
||||
$this->view->fadeOut = $fades[1];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
44
airtime_mvc/application/controllers/PluploadController.php
Normal file
44
airtime_mvc/application/controllers/PluploadController.php
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
class PluploadController extends Zend_Controller_Action
|
||||
{
|
||||
|
||||
public function init()
|
||||
{
|
||||
$ajaxContext = $this->_helper->getHelper('AjaxContext');
|
||||
$ajaxContext->addActionContext('upload', 'json')
|
||||
->addActionContext('upload-recorded', 'json')
|
||||
->initContext();
|
||||
}
|
||||
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
// action body
|
||||
}
|
||||
|
||||
public function uploadAction()
|
||||
{
|
||||
$upload_dir = ini_get("upload_tmp_dir") . DIRECTORY_SEPARATOR . "plupload";
|
||||
$file = StoredFile::uploadFile($upload_dir);
|
||||
|
||||
die('{"jsonrpc" : "2.0", "id" : '.$file->getId().' }');
|
||||
}
|
||||
|
||||
public function pluploadAction()
|
||||
{
|
||||
$this->view->headScript()->appendFile('/js/plupload/plupload.full.min.js','text/javascript');
|
||||
$this->view->headScript()->appendFile('/js/plupload/jquery.plupload.queue.min.js','text/javascript');
|
||||
$this->view->headScript()->appendFile('/js/airtime/library/plupload.js','text/javascript');
|
||||
|
||||
$this->view->headLink()->appendStylesheet('/css/plupload.queue.css');
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
48
airtime_mvc/application/controllers/PreferenceController.php
Normal file
48
airtime_mvc/application/controllers/PreferenceController.php
Normal file
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
class PreferenceController extends Zend_Controller_Action
|
||||
{
|
||||
|
||||
public function init()
|
||||
{
|
||||
/* Initialize action controller here */
|
||||
}
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$this->view->headScript()->appendFile('/js/airtime/preferences/preferences.js','text/javascript');
|
||||
|
||||
$request = $this->getRequest();
|
||||
$this->view->statusMsg = "";
|
||||
|
||||
$form = new Application_Form_Preferences();
|
||||
|
||||
if ($request->isPost()) {
|
||||
|
||||
if ($form->isValid($request->getPost())) {
|
||||
|
||||
$values = $form->getValues();
|
||||
|
||||
Application_Model_Preference::SetHeadTitle($values["preferences_general"]["stationName"], $this->view);
|
||||
Application_Model_Preference::SetDefaultFade($values["preferences_general"]["stationDefaultFade"]);
|
||||
Application_Model_Preference::SetStreamLabelFormat($values["preferences_general"]["streamFormat"]);
|
||||
Application_Model_Preference::SetAllow3rdPartyApi($values["preferences_general"]["thirdPartyApi"]);
|
||||
|
||||
Application_Model_Preference::SetDoSoundCloudUpload($values["preferences_soundcloud"]["UseSoundCloud"]);
|
||||
Application_Model_Preference::SetSoundCloudUser($values["preferences_soundcloud"]["SoundCloudUser"]);
|
||||
Application_Model_Preference::SetSoundCloudPassword($values["preferences_soundcloud"]["SoundCloudPassword"]);
|
||||
Application_Model_Preference::SetSoundCloudTags($values["preferences_soundcloud"]["SoundCloudTags"]);
|
||||
Application_Model_Preference::SetSoundCloudGenre($values["preferences_soundcloud"]["SoundCloudGenre"]);
|
||||
Application_Model_Preference::SetSoundCloudTrackType($values["preferences_soundcloud"]["SoundCloudTrackType"]);
|
||||
Application_Model_Preference::SetSoundCloudLicense($values["preferences_soundcloud"]["SoundCloudLicense"]);
|
||||
|
||||
$this->view->statusMsg = "<div class='success'>Preferences updated.</div>";
|
||||
}
|
||||
}
|
||||
|
||||
$this->view->form = $form;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
695
airtime_mvc/application/controllers/ScheduleController.php
Normal file
695
airtime_mvc/application/controllers/ScheduleController.php
Normal file
|
@ -0,0 +1,695 @@
|
|||
<?php
|
||||
|
||||
class ScheduleController extends Zend_Controller_Action
|
||||
{
|
||||
|
||||
protected $sched_sess = null;
|
||||
|
||||
public function init()
|
||||
{
|
||||
$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('move-show', 'json')
|
||||
->addActionContext('resize-show', 'json')
|
||||
->addActionContext('delete-show', 'json')
|
||||
->addActionContext('schedule-show', 'json')
|
||||
->addActionContext('schedule-show-dialog', 'json')
|
||||
->addActionContext('show-content-dialog', 'json')
|
||||
->addActionContext('clear-show', 'json')
|
||||
->addActionContext('get-current-playlist', 'json')
|
||||
->addActionContext('find-playlists', 'json')
|
||||
->addActionContext('remove-group', 'json')
|
||||
->addActionContext('edit-show', 'json')
|
||||
->addActionContext('add-show', 'json')
|
||||
->addActionContext('cancel-show', 'json')
|
||||
->addActionContext('get-form', 'json')
|
||||
->addActionContext('upload-to-sound-cloud', 'json')
|
||||
->initContext();
|
||||
|
||||
$this->sched_sess = new Zend_Session_Namespace("schedule");
|
||||
}
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$this->view->headScript()->appendFile('/js/contextmenu/jjmenu.js','text/javascript');
|
||||
$this->view->headScript()->appendFile('/js/datatables/js/jquery.dataTables.js','text/javascript');
|
||||
$this->view->headScript()->appendFile('/js/fullcalendar/fullcalendar.js','text/javascript');
|
||||
$this->view->headScript()->appendFile('/js/timepicker/jquery.ui.timepicker-0.0.6.js','text/javascript');
|
||||
$this->view->headScript()->appendFile('/js/colorpicker/js/colorpicker.js','text/javascript');
|
||||
$this->view->headScript()->appendFile('/js/airtime/schedule/full-calendar-functions.js','text/javascript');
|
||||
$this->view->headScript()->appendFile('/js/airtime/schedule/add-show.js','text/javascript');
|
||||
$this->view->headScript()->appendFile('/js/airtime/schedule/schedule.js','text/javascript');
|
||||
|
||||
$this->view->headLink()->appendStylesheet('/css/jquery-ui-timepicker.css');
|
||||
$this->view->headLink()->appendStylesheet('/css/fullcalendar.css');
|
||||
$this->view->headLink()->appendStylesheet('/css/colorpicker/css/colorpicker.css');
|
||||
$this->view->headLink()->appendStylesheet('/css/add-show.css');
|
||||
$this->view->headLink()->appendStylesheet('/css/contextmenu.css');
|
||||
|
||||
$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();
|
||||
$formRecord = new Application_Form_AddShowRR();
|
||||
$formAbsoluteRebroadcast = new Application_Form_AddShowAbsoluteRebroadcastDates();
|
||||
$formRebroadcast = new Application_Form_AddShowRebroadcastDates();
|
||||
|
||||
$formWhat->removeDecorator('DtDdWrapper');
|
||||
$formWho->removeDecorator('DtDdWrapper');
|
||||
$formWhen->removeDecorator('DtDdWrapper');
|
||||
$formRepeats->removeDecorator('DtDdWrapper');
|
||||
$formStyle->removeDecorator('DtDdWrapper');
|
||||
$formRecord->removeDecorator('DtDdWrapper');
|
||||
|
||||
$this->view->what = $formWhat;
|
||||
$this->view->when = $formWhen;
|
||||
$this->view->repeats = $formRepeats;
|
||||
$this->view->who = $formWho;
|
||||
$this->view->style = $formStyle;
|
||||
$this->view->rr = $formRecord;
|
||||
$this->view->absoluteRebroadcast = $formAbsoluteRebroadcast;
|
||||
$this->view->rebroadcast = $formRebroadcast;
|
||||
$this->view->addNewShow = true;
|
||||
|
||||
$formWhat->populate(array('add_show_id' => '-1'));
|
||||
|
||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
$user = new User($userInfo->id);
|
||||
$this->view->isAdmin = $user->isAdmin();
|
||||
}
|
||||
|
||||
public function eventFeedAction()
|
||||
{
|
||||
$start = $this->_getParam('start', null);
|
||||
$end = $this->_getParam('end', null);
|
||||
|
||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
$user = new User($userInfo->id);
|
||||
if($user->isAdmin())
|
||||
$editable = true;
|
||||
else
|
||||
$editable = false;
|
||||
|
||||
$this->view->events = Show::getFullCalendarEvents($start, $end, $editable);
|
||||
}
|
||||
|
||||
public function moveShowAction()
|
||||
{
|
||||
$deltaDay = $this->_getParam('day');
|
||||
$deltaMin = $this->_getParam('min');
|
||||
$showInstanceId = $this->_getParam('showInstanceId');
|
||||
|
||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
$user = new User($userInfo->id);
|
||||
|
||||
if($user->isAdmin()) {
|
||||
$show = new ShowInstance($showInstanceId);
|
||||
$error = $show->moveShow($deltaDay, $deltaMin);
|
||||
}
|
||||
|
||||
if(isset($error))
|
||||
$this->view->error = $error;
|
||||
|
||||
}
|
||||
|
||||
public function resizeShowAction()
|
||||
{
|
||||
$deltaDay = $this->_getParam('day');
|
||||
$deltaMin = $this->_getParam('min');
|
||||
$showInstanceId = $this->_getParam('showInstanceId');
|
||||
|
||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
$user = new User($userInfo->id);
|
||||
|
||||
if($user->isAdmin()) {
|
||||
$show = new ShowInstance($showInstanceId);
|
||||
$error = $show->resizeShow($deltaDay, $deltaMin);
|
||||
}
|
||||
|
||||
if(isset($error))
|
||||
$this->view->error = $error;
|
||||
}
|
||||
|
||||
public function deleteShowAction()
|
||||
{
|
||||
$showInstanceId = $this->_getParam('id');
|
||||
|
||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
$user = new User($userInfo->id);
|
||||
|
||||
if($user->isAdmin()) {
|
||||
$show = new ShowInstance($showInstanceId);
|
||||
$show->deleteShow();
|
||||
}
|
||||
}
|
||||
|
||||
public function uploadToSoundCloudAction()
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
$show_instance = $this->_getParam('id');
|
||||
$show_inst = new ShowInstance($show_instance);
|
||||
|
||||
$file = $show_inst->getRecordedFile();
|
||||
|
||||
if(is_null($file)) {
|
||||
$this->view->error = "Recorded file does not exist";
|
||||
return;
|
||||
}
|
||||
|
||||
$show_name = $show_inst->getName();
|
||||
$show_genre = $show_inst->getGenre();
|
||||
$show_start_time = $show_inst->getShowStart();
|
||||
|
||||
if(Application_Model_Preference::GetDoSoundCloudUpload())
|
||||
{
|
||||
for($i=0; $i<$CC_CONFIG['soundcloud-connection-retries']; $i++) {
|
||||
|
||||
$show = new Show($show_inst->getShowId());
|
||||
$description = $show->getDescription();
|
||||
$hosts = $show->getHosts();
|
||||
|
||||
$tags = array_merge($hosts, array($show_name));
|
||||
|
||||
try {
|
||||
$soundcloud = new ATSoundcloud();
|
||||
$soundcloud_id = $soundcloud->uploadTrack($file->getRealFilePath(), $file->getName(), $description, $tags, $show_start_time, $show_genre);
|
||||
$show_inst->setSoundCloudFileId($soundcloud_id);
|
||||
$this->view->soundcloud_id = $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']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function makeContextMenuAction()
|
||||
{
|
||||
$id = $this->_getParam('id');
|
||||
$today_timestamp = date("Y-m-d H:i:s");
|
||||
|
||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
$user = new User($userInfo->id);
|
||||
$show = new ShowInstance($id);
|
||||
|
||||
$params = '/format/json/id/#id#';
|
||||
|
||||
if (strtotime($today_timestamp) < strtotime($show->getShowStart())) {
|
||||
|
||||
if (($user->isHost($show->getShowId()) || $user->isAdmin()) && !$show->isRecorded() && !$show->isRebroadcast()) {
|
||||
|
||||
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/schedule-show-dialog'.$params,
|
||||
'callback' => 'window["buildScheduleDialog"]'), 'title' => 'Add / Remove Content');
|
||||
|
||||
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/clear-show'.$params,
|
||||
'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Remove All Content');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(!$show->isRecorded()) {
|
||||
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/show-content-dialog'.$params,
|
||||
'callback' => 'window["buildContentDialog"]'), 'title' => 'Show Content');
|
||||
}
|
||||
|
||||
if (strtotime($show->getShowEnd()) <= strtotime($today_timestamp)
|
||||
&& is_null($show->getSoundCloudFileId())
|
||||
&& Application_Model_Preference::GetDoSoundCloudUpload()) {
|
||||
$menu[] = array('action' => array('type' => 'fn',
|
||||
'callback' => "window['uploadToSoundCloud']($id)"),
|
||||
'title' => 'Upload to Soundcloud');
|
||||
}
|
||||
|
||||
|
||||
if (strtotime($show->getShowStart()) <= strtotime($today_timestamp) &&
|
||||
strtotime($today_timestamp) < strtotime($show->getShowEnd()) &&
|
||||
$user->isAdmin() && !$show->isRecorded()) {
|
||||
$menu[] = array('action' => array('type' => 'fn',
|
||||
'callback' => "window['confirmCancelShow']($id)"),
|
||||
'title' => 'Cancel Current Show');
|
||||
}
|
||||
|
||||
if (strtotime($today_timestamp) < strtotime($show->getShowStart())) {
|
||||
|
||||
if ($user->isAdmin()) {
|
||||
|
||||
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/edit-show/format/json/id/'.$id,
|
||||
'callback' => 'window["beginEditShow"]'), 'title' => 'Edit Show');
|
||||
//$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/cancel-show'.$params,
|
||||
// 'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Edit This Instance and All Following');
|
||||
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/delete-show'.$params,
|
||||
'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Delete This Instance');
|
||||
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/cancel-show'.$params,
|
||||
'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Delete This Instance and All Following');
|
||||
}
|
||||
}
|
||||
|
||||
//returns format jjmenu is looking for.
|
||||
die(json_encode($menu));
|
||||
}
|
||||
|
||||
public function scheduleShowAction()
|
||||
{
|
||||
$showInstanceId = $this->sched_sess->showInstanceId;
|
||||
$search = $this->_getParam('search', null);
|
||||
$plId = $this->_getParam('plId');
|
||||
|
||||
if($search == "") {
|
||||
$search = null;
|
||||
}
|
||||
|
||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
$user = new User($userInfo->id);
|
||||
$show = new ShowInstance($showInstanceId);
|
||||
|
||||
if($user->isHost($show->getShowId()) || $user->isAdmin()) {
|
||||
$show->scheduleShow(array($plId));
|
||||
}
|
||||
|
||||
$this->view->showContent = $show->getShowContent();
|
||||
$this->view->timeFilled = $show->getTimeScheduled();
|
||||
$this->view->percentFilled = $show->getPercentScheduled();
|
||||
|
||||
$this->view->chosen = $this->view->render('schedule/scheduled-content.phtml');
|
||||
unset($this->view->showContent);
|
||||
}
|
||||
|
||||
public function clearShowAction()
|
||||
{
|
||||
$showInstanceId = $this->_getParam('id');
|
||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
$user = new User($userInfo->id);
|
||||
$show = new ShowInstance($showInstanceId);
|
||||
|
||||
if($user->isHost($show->getShowId()) || $user->isAdmin())
|
||||
$show->clearShow();
|
||||
}
|
||||
|
||||
public function getCurrentPlaylistAction()
|
||||
{
|
||||
$this->view->entries = Schedule::GetPlayOrderRange();
|
||||
}
|
||||
|
||||
public function findPlaylistsAction()
|
||||
{
|
||||
$post = $this->getRequest()->getPost();
|
||||
|
||||
$show = new ShowInstance($this->sched_sess->showInstanceId);
|
||||
$playlists = $show->searchPlaylistsForShow($post);
|
||||
|
||||
//for datatables
|
||||
die(json_encode($playlists));
|
||||
}
|
||||
|
||||
public function removeGroupAction()
|
||||
{
|
||||
$showInstanceId = $this->sched_sess->showInstanceId;
|
||||
$group_id = $this->_getParam('groupId');
|
||||
$search = $this->_getParam('search', null);
|
||||
|
||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
$user = new User($userInfo->id);
|
||||
$show = new ShowInstance($showInstanceId);
|
||||
|
||||
if($user->isHost($show->getShowId()) || $user->isAdmin()) {
|
||||
$show->removeGroupFromShow($group_id);
|
||||
}
|
||||
|
||||
$this->view->showContent = $show->getShowContent();
|
||||
$this->view->timeFilled = $show->getTimeScheduled();
|
||||
$this->view->percentFilled = $show->getPercentScheduled();
|
||||
$this->view->chosen = $this->view->render('schedule/scheduled-content.phtml');
|
||||
unset($this->view->showContent);
|
||||
}
|
||||
|
||||
public function scheduleShowDialogAction()
|
||||
{
|
||||
$showInstanceId = $this->_getParam('id');
|
||||
$this->sched_sess->showInstanceId = $showInstanceId;
|
||||
|
||||
$show = new ShowInstance($showInstanceId);
|
||||
$start_timestamp = $show->getShowStart();
|
||||
$end_timestamp = $show->getShowEnd();
|
||||
|
||||
//check to make sure show doesn't overlap.
|
||||
if(Show::getShows($start_timestamp, $end_timestamp, array($showInstanceId))) {
|
||||
$this->view->error = "cannot schedule an overlapping show.";
|
||||
return;
|
||||
}
|
||||
|
||||
$start = explode(" ", $start_timestamp);
|
||||
$end = explode(" ", $end_timestamp);
|
||||
$startTime = explode(":", $start[1]);
|
||||
$endTime = explode(":", $end[1]);
|
||||
$dateInfo_s = getDate(strtotime($start_timestamp));
|
||||
$dateInfo_e = getDate(strtotime($end_timestamp));
|
||||
|
||||
$this->view->showContent = $show->getShowContent();
|
||||
$this->view->timeFilled = $show->getTimeScheduled();
|
||||
$this->view->showName = $show->getName();
|
||||
$this->view->showLength = $show->getShowLength();
|
||||
$this->view->percentFilled = $show->getPercentScheduled();
|
||||
|
||||
$this->view->s_wday = $dateInfo_s['weekday'];
|
||||
$this->view->s_month = $dateInfo_s['month'];
|
||||
$this->view->s_day = $dateInfo_s['mday'];
|
||||
$this->view->e_wday = $dateInfo_e['weekday'];
|
||||
$this->view->e_month = $dateInfo_e['month'];
|
||||
$this->view->e_day = $dateInfo_e['mday'];
|
||||
$this->view->startTime = sprintf("%d:%02d", $startTime[0], $startTime[1]);
|
||||
$this->view->endTime = sprintf("%d:%02d", $endTime[0], $endTime[1]);
|
||||
|
||||
$this->view->chosen = $this->view->render('schedule/scheduled-content.phtml');
|
||||
$this->view->dialog = $this->view->render('schedule/schedule-show-dialog.phtml');
|
||||
unset($this->view->showContent);
|
||||
}
|
||||
|
||||
public function showContentDialogAction()
|
||||
{
|
||||
$showInstanceId = $this->_getParam('id');
|
||||
$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);
|
||||
}
|
||||
|
||||
public function editShowAction()
|
||||
{
|
||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
$user = new User($userInfo->id);
|
||||
if(!$user->isAdmin()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$showInstanceId = $this->_getParam('id');
|
||||
|
||||
$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();
|
||||
$formRecord = new Application_Form_AddShowRR();
|
||||
$formAbsoluteRebroadcast = new Application_Form_AddShowAbsoluteRebroadcastDates();
|
||||
$formRebroadcast = new Application_Form_AddShowRebroadcastDates();
|
||||
|
||||
$formWhat->removeDecorator('DtDdWrapper');
|
||||
$formWho->removeDecorator('DtDdWrapper');
|
||||
$formWhen->removeDecorator('DtDdWrapper');
|
||||
$formRepeats->removeDecorator('DtDdWrapper');
|
||||
$formStyle->removeDecorator('DtDdWrapper');
|
||||
$formRecord->removeDecorator('DtDdWrapper');
|
||||
$formAbsoluteRebroadcast->removeDecorator('DtDdWrapper');
|
||||
$formRebroadcast->removeDecorator('DtDdWrapper');
|
||||
|
||||
$this->view->what = $formWhat;
|
||||
$this->view->when = $formWhen;
|
||||
$this->view->repeats = $formRepeats;
|
||||
$this->view->who = $formWho;
|
||||
$this->view->style = $formStyle;
|
||||
$this->view->rr = $formRecord;
|
||||
$this->view->absoluteRebroadcast = $formAbsoluteRebroadcast;
|
||||
$this->view->rebroadcast = $formRebroadcast;
|
||||
$this->view->addNewShow = false;
|
||||
|
||||
$showInstance = new ShowInstance($showInstanceId);
|
||||
$show = new Show($showInstance->getShowId());
|
||||
|
||||
$formWhat->populate(array('add_show_id' => $show->getId(),
|
||||
'add_show_name' => $show->getName(),
|
||||
'add_show_url' => $show->getUrl(),
|
||||
'add_show_genre' => $show->getGenre(),
|
||||
'add_show_description' => $show->getDescription()));
|
||||
|
||||
$formWhen->populate(array('add_show_start_date' => $show->getStartDate(),
|
||||
'add_show_start_time' => Show::removeSecondsFromTime($show->getStartTime()),
|
||||
'add_show_duration' => $show->getDuration(),
|
||||
'add_show_repeats' => $show->isRepeating() ? 1 : 0));
|
||||
|
||||
$days = array();
|
||||
$showDays = CcShowDaysQuery::create()->filterByDbShowId($showInstance->getShowId())->find();
|
||||
foreach($showDays as $showDay){
|
||||
array_push($days, $showDay->getDbDay());
|
||||
}
|
||||
|
||||
$formRepeats->populate(array('add_show_repeat_type' => $show->getRepeatType(),
|
||||
'add_show_day_check' => $days,
|
||||
'add_show_end_date' => $show->getRepeatingEndDate(),
|
||||
'add_show_no_end' => ($show->getRepeatingEndDate() == '')));
|
||||
|
||||
$formRecord->populate(array('add_show_record' => $show->isRecorded(),
|
||||
'add_show_rebroadcast' => $show->isRebroadcast()));
|
||||
$formRecord->getElement('add_show_record')->setOptions(array('disabled' => true));
|
||||
|
||||
|
||||
|
||||
$rebroadcastsRelative = $show->getRebroadcastsRelative();
|
||||
$rebroadcastFormValues = array();
|
||||
$i = 1;
|
||||
foreach ($rebroadcastsRelative as $rebroadcast){
|
||||
$rebroadcastFormValues["add_show_rebroadcast_date_$i"] = $rebroadcast['day_offset'];
|
||||
$rebroadcastFormValues["add_show_rebroadcast_time_$i"] = Show::removeSecondsFromTime($rebroadcast['start_time']);
|
||||
$i++;
|
||||
}
|
||||
$formRebroadcast->populate($rebroadcastFormValues);
|
||||
|
||||
$rebroadcastsAbsolute = $show->getRebroadcastsAbsolute();
|
||||
$rebroadcastAbsoluteFormValues = array();
|
||||
$i = 1;
|
||||
foreach ($rebroadcastsAbsolute as $rebroadcast){
|
||||
$rebroadcastAbsoluteFormValues["add_show_rebroadcast_date_absolute_$i"] = $rebroadcast['start_date'];
|
||||
$rebroadcastAbsoluteFormValues["add_show_rebroadcast_time_absolute_$i"] = Show::removeSecondsFromTime($rebroadcast['start_time']);
|
||||
$i++;
|
||||
}
|
||||
$formAbsoluteRebroadcast->populate($rebroadcastAbsoluteFormValues);
|
||||
|
||||
$hosts = array();
|
||||
$showHosts = CcShowHostsQuery::create()->filterByDbShow($showInstance->getShowId())->find();
|
||||
foreach($showHosts as $showHost){
|
||||
array_push($hosts, $showHost->getDbHost());
|
||||
}
|
||||
$formWho->populate(array('add_show_hosts' => $hosts));
|
||||
|
||||
|
||||
$formStyle->populate(array('add_show_background_color' => $show->getBackgroundColor(),
|
||||
'add_show_color' => $show->getColor()));
|
||||
|
||||
$this->view->newForm = $this->view->render('schedule/add-show-form.phtml');
|
||||
$this->view->entries = 5;
|
||||
}
|
||||
|
||||
public function getFormAction(){
|
||||
$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();
|
||||
$formRecord = new Application_Form_AddShowRR();
|
||||
$formAbsoluteRebroadcast = new Application_Form_AddShowAbsoluteRebroadcastDates();
|
||||
$formRebroadcast = new Application_Form_AddShowRebroadcastDates();
|
||||
|
||||
$formWhat->removeDecorator('DtDdWrapper');
|
||||
$formWho->removeDecorator('DtDdWrapper');
|
||||
$formWhen->removeDecorator('DtDdWrapper');
|
||||
$formRepeats->removeDecorator('DtDdWrapper');
|
||||
$formStyle->removeDecorator('DtDdWrapper');
|
||||
$formRecord->removeDecorator('DtDdWrapper');
|
||||
|
||||
$this->view->what = $formWhat;
|
||||
$this->view->when = $formWhen;
|
||||
$this->view->repeats = $formRepeats;
|
||||
$this->view->who = $formWho;
|
||||
$this->view->style = $formStyle;
|
||||
$this->view->rr = $formRecord;
|
||||
$this->view->absoluteRebroadcast = $formAbsoluteRebroadcast;
|
||||
$this->view->rebroadcast = $formRebroadcast;
|
||||
$this->view->addNewShow = true;
|
||||
|
||||
$formWhat->populate(array('add_show_id' => '-1'));
|
||||
|
||||
$this->view->form = $this->view->render('schedule/add-show-form.phtml');
|
||||
}
|
||||
|
||||
public function addShowAction()
|
||||
{
|
||||
$js = $this->_getParam('data');
|
||||
$data = array();
|
||||
|
||||
//need to convert from serialized jQuery array.
|
||||
foreach($js as $j){
|
||||
$data[$j["name"]] = $j["value"];
|
||||
}
|
||||
|
||||
$data['add_show_hosts'] = $this->_getParam('hosts');
|
||||
$data['add_show_day_check'] = $this->_getParam('days');
|
||||
|
||||
if($data['add_show_day_check'] == "") {
|
||||
$data['add_show_day_check'] = null;
|
||||
}
|
||||
|
||||
$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();
|
||||
$formRecord = new Application_Form_AddShowRR();
|
||||
$formAbsoluteRebroadcast = new Application_Form_AddShowAbsoluteRebroadcastDates();
|
||||
$formRebroadcast = new Application_Form_AddShowRebroadcastDates();
|
||||
|
||||
$formWhat->removeDecorator('DtDdWrapper');
|
||||
$formWho->removeDecorator('DtDdWrapper');
|
||||
$formWhen->removeDecorator('DtDdWrapper');
|
||||
$formRepeats->removeDecorator('DtDdWrapper');
|
||||
$formStyle->removeDecorator('DtDdWrapper');
|
||||
$formRecord->removeDecorator('DtDdWrapper');
|
||||
$formAbsoluteRebroadcast->removeDecorator('DtDdWrapper');
|
||||
$formRebroadcast->removeDecorator('DtDdWrapper');
|
||||
|
||||
$this->view->what = $formWhat;
|
||||
$this->view->when = $formWhen;
|
||||
$this->view->repeats = $formRepeats;
|
||||
$this->view->who = $formWho;
|
||||
$this->view->style = $formStyle;
|
||||
$this->view->rr = $formRecord;
|
||||
$this->view->absoluteRebroadcast = $formAbsoluteRebroadcast;
|
||||
$this->view->rebroadcast = $formRebroadcast;
|
||||
$this->view->addNewShow = true;
|
||||
|
||||
$what = $formWhat->isValid($data);
|
||||
$when = $formWhen->isValid($data);
|
||||
if($when) {
|
||||
$when = $formWhen->checkReliantFields($data);
|
||||
}
|
||||
|
||||
if($data["add_show_repeats"]) {
|
||||
|
||||
$repeats = $formRepeats->isValid($data);
|
||||
if($repeats) {
|
||||
$repeats = $formRepeats->checkReliantFields($data);
|
||||
}
|
||||
|
||||
$formAbsoluteRebroadcast->reset();
|
||||
//make it valid, results don't matter anyways.
|
||||
$rebroadAb = 1;
|
||||
|
||||
if ($data["add_show_rebroadcast"]) {
|
||||
$rebroad = $formRebroadcast->isValid($data);
|
||||
if($rebroad) {
|
||||
$rebroad = $formRebroadcast->checkReliantFields($data);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$rebroad = 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$formRebroadcast->reset();
|
||||
//make it valid, results don't matter anyways.
|
||||
$repeats = 1;
|
||||
$rebroad = 1;
|
||||
|
||||
if ($data["add_show_rebroadcast"]) {
|
||||
$rebroadAb = $formAbsoluteRebroadcast->isValid($data);
|
||||
if($rebroadAb) {
|
||||
$rebroadAb = $formAbsoluteRebroadcast->checkReliantFields($data);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$rebroadAb = 1;
|
||||
}
|
||||
}
|
||||
|
||||
$who = $formWho->isValid($data);
|
||||
$style = $formStyle->isValid($data);
|
||||
$record = $formRecord->isValid($data);
|
||||
|
||||
if ($what && $when && $repeats && $who && $style && $record && $rebroadAb && $rebroad) {
|
||||
|
||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
$user = new User($userInfo->id);
|
||||
if ($user->isAdmin()) {
|
||||
Show::create($data);
|
||||
}
|
||||
|
||||
//send back a new form for the user.
|
||||
$formWhat->reset();
|
||||
$formWhat->populate(array('add_show_id' => '-1'));
|
||||
|
||||
$formWho->reset();
|
||||
$formWhen->reset();
|
||||
$formWhen->populate(array('add_show_start_date' => date("Y-m-d"),
|
||||
'add_show_start_time' => '0:00',
|
||||
'add_show_duration' => '1:00'));
|
||||
$formRepeats->reset();
|
||||
$formRepeats->populate(array('add_show_end_date' => date("Y-m-d")));
|
||||
|
||||
$formStyle->reset();
|
||||
$formRecord->reset();
|
||||
$formAbsoluteRebroadcast->reset();
|
||||
$formRebroadcast->reset();
|
||||
|
||||
$this->view->newForm = $this->view->render('schedule/add-show-form.phtml');
|
||||
}
|
||||
else {
|
||||
|
||||
$this->view->form = $this->view->render('schedule/add-show-form.phtml');
|
||||
}
|
||||
}
|
||||
|
||||
public function cancelShowAction()
|
||||
{
|
||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
$user = new User($userInfo->id);
|
||||
|
||||
if($user->isAdmin()) {
|
||||
$showInstanceId = $this->_getParam('id');
|
||||
|
||||
$showInstance = new ShowInstance($showInstanceId);
|
||||
$show = new Show($showInstance->getShowId());
|
||||
|
||||
$show->cancelShow($showInstance->getShowStart());
|
||||
}
|
||||
}
|
||||
|
||||
public function cancelCurrentShowAction()
|
||||
{
|
||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
$user = new User($userInfo->id);
|
||||
|
||||
if($user->isAdmin()) {
|
||||
$showInstanceId = $this->_getParam('id');
|
||||
$show = new ShowInstance($showInstanceId);
|
||||
$show->clearShow();
|
||||
$show->deleteShow();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
90
airtime_mvc/application/controllers/SearchController.php
Normal file
90
airtime_mvc/application/controllers/SearchController.php
Normal file
|
@ -0,0 +1,90 @@
|
|||
<?php
|
||||
|
||||
class SearchController extends Zend_Controller_Action
|
||||
{
|
||||
protected $search_sess = null;
|
||||
|
||||
private function addGroup($group_id) {
|
||||
|
||||
$form = new Application_Form_AdvancedSearch();
|
||||
|
||||
$form->addGroup($group_id, 1);
|
||||
$group = $form->getSubForm('group_'.$group_id);
|
||||
|
||||
return $group->__toString();
|
||||
}
|
||||
|
||||
private function addFieldToGroup($group_id, $row_id) {
|
||||
|
||||
$form = new Application_Form_AdvancedSearch();
|
||||
|
||||
$form->addGroup($group_id);
|
||||
$group = $form->getSubForm('group_'.$group_id);
|
||||
|
||||
$group->addRow($row_id);
|
||||
|
||||
return $group->__toString();
|
||||
}
|
||||
|
||||
public function init()
|
||||
{
|
||||
$ajaxContext = $this->_helper->getHelper('AjaxContext');
|
||||
$ajaxContext->addActionContext('newfield', 'json')
|
||||
->addActionContext('newgroup', 'json')
|
||||
->addActionContext('index', 'json')
|
||||
->addActionContext('display', 'json')
|
||||
->initContext();
|
||||
|
||||
$this->search_sess = new Zend_Session_Namespace("search");
|
||||
}
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$data = $this->_getParam('data');
|
||||
$form = new Application_Form_AdvancedSearch();
|
||||
|
||||
// Form has been submitted
|
||||
$form->preValidation($data);
|
||||
|
||||
//if (!$form->isValid($data)) {
|
||||
//$this->view->form = $form->__toString();
|
||||
//return;
|
||||
//}
|
||||
|
||||
// valid form was submitted set as search criteria.
|
||||
$this->search_sess->md = $data;
|
||||
}
|
||||
|
||||
public function displayAction()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function newfieldAction()
|
||||
{
|
||||
$group_id = $this->_getParam('group', 1);
|
||||
$row_id = $this->search_sess->next_row[$group_id];
|
||||
|
||||
$this->view->html = $this->addFieldToGroup($group_id, $row_id);
|
||||
$this->view->row = $row_id;
|
||||
|
||||
$this->search_sess->next_row[$group_id] = $row_id + 1;
|
||||
}
|
||||
|
||||
public function newgroupAction()
|
||||
{
|
||||
$group_id = $this->search_sess->next_group;
|
||||
|
||||
$this->view->html = $this->addGroup($group_id);
|
||||
|
||||
$this->search_sess->next_group = $group_id + 1;
|
||||
$this->search_sess->next_row[$group_id] = 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
101
airtime_mvc/application/controllers/UserController.php
Normal file
101
airtime_mvc/application/controllers/UserController.php
Normal file
|
@ -0,0 +1,101 @@
|
|||
<?php
|
||||
|
||||
class UserController extends Zend_Controller_Action
|
||||
{
|
||||
|
||||
public function init()
|
||||
{
|
||||
$ajaxContext = $this->_helper->getHelper('AjaxContext');
|
||||
$ajaxContext->addActionContext('get-hosts', 'json')
|
||||
->addActionContext('get-user-data-table-info', 'json')
|
||||
->addActionContext('get-user-data', 'json')
|
||||
->addActionContext('remove-user', 'json')
|
||||
->initContext();
|
||||
}
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
}
|
||||
|
||||
public function addUserAction()
|
||||
{
|
||||
$this->view->headScript()->appendFile('/js/datatables/js/jquery.dataTables.js','text/javascript');
|
||||
$this->view->headScript()->appendFile('/js/airtime/user/user.js','text/javascript');
|
||||
$request = $this->getRequest();
|
||||
$form = new Application_Form_AddUser();
|
||||
|
||||
$this->view->successMessage = "";
|
||||
|
||||
if ($request->isPost()) {
|
||||
if ($form->isValid($request->getPost())) {
|
||||
|
||||
$formdata = $form->getValues();
|
||||
if ($form->validateLogin($formdata)){
|
||||
$user = new User($formdata['user_id']);
|
||||
$user->setFirstName($formdata['first_name']);
|
||||
$user->setLastName($formdata['last_name']);
|
||||
$user->setLogin($formdata['login']);
|
||||
if ($formdata['password'] != "xxxxxx")
|
||||
$user->setPassword($formdata['password']);
|
||||
$user->setType($formdata['type']);
|
||||
$user->setEmail($formdata['email']);
|
||||
$user->setSkype($formdata['skype']);
|
||||
$user->setJabber($formdata['jabber']);
|
||||
$user->save();
|
||||
|
||||
$form->reset();
|
||||
|
||||
if (strlen($formdata['user_id']) == 0){
|
||||
$this->view->successMessage = "<div class='success'>User added successfully!</div>";
|
||||
} else {
|
||||
$this->view->successMessage = "<div class='success'>User updated successfully!</div>";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->view->form = $form;
|
||||
}
|
||||
|
||||
public function getHostsAction()
|
||||
{
|
||||
$search = $this->_getParam('term');
|
||||
$this->view->hosts = User::getHosts($search);
|
||||
}
|
||||
|
||||
public function getUserDataTableInfoAction()
|
||||
{
|
||||
$post = $this->getRequest()->getPost();
|
||||
$users = User::getUsersDataTablesInfo($post);
|
||||
|
||||
die(json_encode($users));
|
||||
}
|
||||
|
||||
public function getUserDataAction()
|
||||
{
|
||||
$id = $this->_getParam('id');
|
||||
$this->view->entries = User::GetUserData($id);
|
||||
}
|
||||
|
||||
public function removeUserAction()
|
||||
{
|
||||
// action body
|
||||
$id = $this->_getParam('id');
|
||||
$user = new User($id);
|
||||
|
||||
$this->view->entries = $user->delete();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
177
airtime_mvc/application/controllers/plugins/Acl_plugin.php
Normal file
177
airtime_mvc/application/controllers/plugins/Acl_plugin.php
Normal file
|
@ -0,0 +1,177 @@
|
|||
<?php
|
||||
|
||||
class Zend_Controller_Plugin_Acl extends Zend_Controller_Plugin_Abstract
|
||||
{
|
||||
/**
|
||||
* @var Zend_Acl
|
||||
**/
|
||||
protected $_acl;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
**/
|
||||
protected $_roleName;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
**/
|
||||
protected $_errorPage;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param mixed $aclData
|
||||
* @param $roleName
|
||||
* @return void
|
||||
**/
|
||||
public function __construct(Zend_Acl $aclData, $roleName = 'G')
|
||||
{
|
||||
$this->_errorPage = array('module' => 'default',
|
||||
'controller' => 'error',
|
||||
'action' => 'denied');
|
||||
|
||||
$this->_roleName = $roleName;
|
||||
|
||||
if (null !== $aclData) {
|
||||
$this->setAcl($aclData);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the ACL object
|
||||
*
|
||||
* @param mixed $aclData
|
||||
* @return void
|
||||
**/
|
||||
public function setAcl(Zend_Acl $aclData)
|
||||
{
|
||||
$this->_acl = $aclData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ACL object
|
||||
*
|
||||
* @return Zend_Acl
|
||||
**/
|
||||
public function getAcl()
|
||||
{
|
||||
return $this->_acl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ACL role used
|
||||
*
|
||||
* @return string
|
||||
* @author
|
||||
**/
|
||||
public function getRoleName()
|
||||
{
|
||||
return $this->_roleName;
|
||||
}
|
||||
|
||||
public function setRoleName($type)
|
||||
{
|
||||
$this->_roleName = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the error page
|
||||
*
|
||||
* @param string $action
|
||||
* @param string $controller
|
||||
* @param string $module
|
||||
* @return void
|
||||
**/
|
||||
public function setErrorPage($action, $controller = 'error', $module = null)
|
||||
{
|
||||
$this->_errorPage = array('module' => $module,
|
||||
'controller' => $controller,
|
||||
'action' => $action);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the error page
|
||||
*
|
||||
* @return array
|
||||
**/
|
||||
public function getErrorPage()
|
||||
{
|
||||
return $this->_errorPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Predispatch
|
||||
* Checks if the current user identified by roleName has rights to the requested url (module/controller/action)
|
||||
* If not, it will call denyAccess to be redirected to errorPage
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
public function preDispatch(Zend_Controller_Request_Abstract $request)
|
||||
{
|
||||
$controller = strtolower($request->getControllerName());
|
||||
|
||||
if ($controller == 'api'){
|
||||
|
||||
$this->setRoleName("G");
|
||||
}
|
||||
else if (!Zend_Auth::getInstance()->hasIdentity()){
|
||||
|
||||
if ($controller !== 'login') {
|
||||
|
||||
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();
|
||||
|
||||
//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);
|
||||
|
||||
Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl($this->_acl);
|
||||
Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole($this->_roleName);
|
||||
|
||||
$resourceName = '';
|
||||
|
||||
if ($request->getModuleName() != 'default') {
|
||||
$resourceName .= strtolower($request->getModuleName()) . ':';
|
||||
}
|
||||
|
||||
$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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deny Access Function
|
||||
* Redirects to errorPage, this can be called from an action using the action helper
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
public function denyAccess()
|
||||
{
|
||||
$this->_request->setModuleName($this->_errorPage['module']);
|
||||
$this->_request->setControllerName($this->_errorPage['controller']);
|
||||
$this->_request->setActionName($this->_errorPage['action']);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
class RabbitMqPlugin extends Zend_Controller_Plugin_Abstract
|
||||
{
|
||||
public function dispatchLoopShutdown()
|
||||
{
|
||||
RabbitMq::PushScheduleFinal();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue