diff --git a/.gitignore b/.gitignore
index 2db593e69..3f52a5722 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,5 @@
.*
*.pyc
/files
-python_apps/pypo/liquidsoap/liquidsoap
+python_apps/pypo/liquidsoap_bin/liquidsoap
build/build.properties
diff --git a/.zfproject.xml b/.zfproject.xml
index 48c691121..1ff9e3914 100644
--- a/.zfproject.xml
+++ b/.zfproject.xml
@@ -127,6 +127,7 @@
+
@@ -378,18 +379,18 @@
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CREDITS b/CREDITS
index d0dc998a5..b6108f552 100644
--- a/CREDITS
+++ b/CREDITS
@@ -2,6 +2,10 @@
CREDITS
=======
+Version 1.9.0
+-------------
+Same as previous version.
+
Version 1.8.2
-------------
Welcome to James Moon!
diff --git a/Changelog b/Changelog
index 5e2a2e38c..8c3440cf1 100644
--- a/Changelog
+++ b/Changelog
@@ -1,4 +1,72 @@
-1.8.2 - May 25, 2011
+1.9.0 - August 9, 2011
+
+The cool stuff:
+ * New file storage system.
+ - Human-readable file structure. The directory structure and file names on
+ disk are now human-readable. This means you can easily find files using
+ your file browser on your server.
+ - Magic file synchronization. Edits to your files are automatically
+ noticed by Airtime. If you edit any files on disk, such as trimming the
+ length of a track, Airtime will automatically notice this and adjust the
+ playlist lengths and shows for that audio file.
+ - Auto-import and multiple-directory support. You can set any number of
+ directories to be watched by Airtime. Any new files you add to watched
+ directories will be automatically imported into Airtime, and any deleted
+ files will be automatically removed.
+ - The "airtime-import" command line tool can now set watched directories
+ and change the storage directory.
+ - Graceful recovery from reboot. If the playout engine starts up and
+ detects that a show should be playing at the current time, it will skip
+ to the right point in the track and start playing. Previously, Airtime
+ would not play anything until the next show started. This also fixes a
+ problem where the metadata on the stream was lost when a file had
+ cue-in/out values set. Thanks to the Liquidsoap developers for
+ implementing the ability to do all of this!
+ - Output to Shoutcast. Now both Shoutcast and Icecast are supported.
+ - A new "Program Manager" role. A program manager can create shows but
+ can't change the preferences or modify users.
+ - No more rebooting after install! Airtime now uses standard SystemV initd
+ scripts instead of non-standard daemontools. This also makes for a much
+ faster install.
+ - Frontend widgets are much easier to use and their theme can be modified
+ with CSS (Click here for more info and installation instructions).
+ - Improved installation - only one command to install on Ubuntu!
+
+ * Improvements:
+ - Cumulative time shown on playlists. The Playlist Builder now shows the
+ total time since the beginning of the playlist for each song.
+ - "End Time" instead of "Duration". In the Add/Edit Show dialog, we
+ replaced the "Duration" field with "End Time". Users reported that this
+ was a much more intuitive way to schedule the show. Duration is still
+ shown as a read-only field.
+ - Feedback & promotion system. Airtime now includes a way to send feedback
+ and promote your site on the Sourcefabric web page. This will greatly
+ enhance our ability to understand who is using the software, which in
+ turn will allow us to make appropriate features and receive grant
+ funding.
+ - The show recorder can now instantly cancel a show thanks to the use of
+ RabbitMQ.
+ - Only admins have the ability to delete files now.
+ - The playout engine now runs with a higher priority. This should help
+ prevent any problems with audio skipping.
+ - Airtime has been contained. It is now easier to run other apps on the
+ same system with Airtime because it no longer messes with the system-wide
+ Python or PHP configurations. The python libraries needed for Airtime are
+ now contained in a local Python virtualenv, and the PHP config variables
+ are set in the Apache virtualhost and .htaccess files.
+ - Message indicating import status is now displayed on Playlist Builder
+ page( above the search box).
+
+ * Bug fixes:
+ - Fixed bug where you couldn't import a file with a name longer than 255
+ characters.
+ - Fixed bug where searching an audio archive of 15K+ files was slow.
+ - Fixed bug where upgrading from more than one version back
+ (e.g. 1.8.0 -> 1.9.0) did not work.
+ - Fixed bug where the wrong file length was reported for very large CBR
+ mp3 files (thanks to mutagen developers for the patch!)
+
+1.8.2 - June 8, 2011
Highlights:
* Improvements:
- You can now download audio files from the search screen and from the "Show Content" screen.
@@ -23,7 +91,8 @@ Highlights:
- Fixed problem with Record Check box occasionally being greyed-out when creating new show
- Fixed a problem with default genre not being applied to recorded shows
- Fixed a problem where shows repeating bi-weekly or monthly did not update properly when edited.
-
+ - Fixed problem when a user changed the name of a recorded show right before it started playing would cause the recorded audio not to be linked to the show.
+ - and many more...
1.8.1 - May 2, 2011
* Fixed issue where an track's progress bar would keep updating, even if the track was no longer playing.
diff --git a/LICENSE_3RD_PARTY b/LICENSE_3RD_PARTY
index 7cdd2c98f..1b6aebdc7 100644
--- a/LICENSE_3RD_PARTY
+++ b/LICENSE_3RD_PARTY
@@ -1,78 +1,73 @@
This application uses the following 3rd Party software:
-------------
+----------------------
+Common Non-linked Code
+----------------------
+ * Linux (Ubuntu & Debian)
+
+ * RabbitMQ (works with version 1.7.2 and above)
+ - What is it: Interprocess Message Passing with Queuing
+ - Web site: http://www.rabbitmq.com/
+ - License: Mozilla Public License (http://www.rabbitmq.com/mpl.html)
+
+ * monit
+ - What is it: Monitors processes and restarts them if they die
+ - Web site: http://mmonit.com/monit/
+ - License: GPLv3
+
+-----------
+Airtime Web
+-----------
Linked code:
-------------
* Zend Framework 1.10.3
+ - What is it: Framework for PHP web apps
- Web site: http://framework.zend.com/
- License: New BSD license
- Compatible with GPLv3: Yes
* PEAR
+ - What is it: PHP library
- Notes: We only use the PEAR base class PEAR_Error, in the "PEAR" PEAR library.
- License: New BSD License
- Compatible with GPLv3? Yes.
- * GetID3
- - Web site: http://getid3.sourceforge.net/
- - License: GPLv2
- - Compatible with GPLv3? Yes
-
* Propel ORM
+ - What is it: Maps DB data into PHP objects
- Web site: http://www.propelorm.org/
- License: MIT/Expat License
- Compatible with the GPL: Yes. See http://www.gnu.org/licenses/license-list.html
* Phing
+ - What is it: PHP project build system
- Web site: http://phing.info/trac/
- Note: Only used for development, not needed to run Airtime.
- License: LGPLv3
- * Soundcloud php api wrapper
- - Web site: https://github.com/mptre/php-soundcloud/blob/master/Services/Soundcloud.php
- - License: MIT
- - Compatible with the GPL: Yes. See http://www.gnu.org/licenses/license-list.html
-
- * Kombu
- - Web site: http://pypi.python.org/pypi/kombu/
- - License: New BSD
- - Compatible with GPLv3? Yes.
-
* PHP-AMQPLIB
+ - What is it: PHP library to interact with RabbitMQ
- Web site: https://github.com/tnc/php-amqplib
- License: LGPLv2.1
- Compatible with GPLv3? Yes
-----------------
-Non-linked code:
-----------------
- * Linux
+ * Soundcloud PHP API wrapper
+ - What is it: PHP library to upload to SoundCloud
+ - Web site: https://github.com/mptre/php-soundcloud/blob/master/Services/Soundcloud.php
+ - License: MIT
+ - Compatible with the GPL: Yes. See http://www.gnu.org/licenses/license-list.html
+Non-linked code:
* Apache Web Server 2.2
- Web site: http://httpd.apache.org/
+ - License: Apache 2.0. See http://httpd.apache.org/docs/2.2/license.html
* PostgreSQL 8.4
- Web site: http://www.postgresql.org/
- - License: The PostgreSQL License. See http://www.opensource.org/licenses/postgresql
+ - License: The PostgreSQL License. See http://www.postgresql.org/about/licence
* PHP 5.3
- Web site: http://www.php.net/
- License: The PHP License. See http://www.php.net/license/3_01.txt
- * Python 2.6
- - Web site: http://www.python.org/
- - License: PSF License. See http://docs.python.org/license.html
-
- * Liquidsoap (pre-release of 1.0)
- - Web site: http://savonet.sourceforge.net/
- - License: GPLv2
-
- * mp3cut from the package poc-streamer
-
- * ecasound 2.7.2
- - Web site: http://www.eca.cx/ecasound/
- - License: GPLv2
-
* jQuery
- Web site: http://jquery.com/
- License: MIT and GPL. See http://jquery.org/license
@@ -106,5 +101,75 @@ Non-linked code:
- Web site: http://fgelinas.com/code/timepicker/
- License: Dual licensed under the MIT or GPL Version 2 licenses.
+ * Data Tables
+ - Web site: http://www.datatables.net/
+ - License: GPLv2 or BSD 3-Clause
+
+ * Server Browse
+ - Web site: http://code.google.com/p/jq-serverbrowse/
+ - License: BSD 2-Clause
+
+-------------
+Media-Monitor
+-------------
+Linked code:
+ * Mutagen
+ - What is it: Parser of audio file metadata
+ - Web site: http://code.google.com/p/mutagen/
+ - License: GPLv2-only
+
+ * Kombu
+ - What is it: Python interface to RabbitMQ
+ - Web site: http://pypi.python.org/pypi/kombu/
+ - License: New BSD
+ - Compatible with GPLv3? Yes.
+
+ * pyinotify
+ - Python interface to inotify
+ - Web site: https://github.com/seb-m/pyinotify
+ - License: MIT
+
+Non-linked code:
+ * Python 2.6
+ - Web site: http://www.python.org/
+ - License: PSF License. See http://docs.python.org/license.html
+
+-------------
+Show Recorder
+-------------
+Linked code:
+ * Kombu
+ - What is it: Python interface to RabbitMQ
+ - Web site: http://pypi.python.org/pypi/kombu/
+ - License: New BSD
+ - Compatible with GPLv3? Yes.
+
+Non-linked code:
+ * Python 2.6
+ - Web site: http://www.python.org/
+ - License: PSF License. See http://docs.python.org/license.html
+
+ * ecasound 2.7.2
+ - What is it: Records audio from line-in
+ - Web site: http://www.eca.cx/ecasound/
+ - License: GPLv2
+
+----
+Pypo
+----
+Linked code:
+ * Kombu
+ - Web site: http://pypi.python.org/pypi/kombu/
+ - License: New BSD
+ - Compatible with GPLv3? Yes.
+
+Non-linked code:
+ * Python 2.6
+ - Web site: http://www.python.org/
+ - License: PSF License. See http://docs.python.org/license.html
+
+ * Liquidsoap (pre-release of 1.0)
+ - Web site: http://savonet.sourceforge.net/
+ - License: GPLv2
diff --git a/VERSION b/VERSION
index 1ec57110d..b12c06c18 100644
--- a/VERSION
+++ b/VERSION
@@ -1,2 +1,2 @@
PRODUCT_ID=Airtime
-PRODUCT_RELEASE=1.8.2
+PRODUCT_RELEASE=1.9.0
diff --git a/airtime_mvc/application/Bootstrap.php b/airtime_mvc/application/Bootstrap.php
index cf4d08731..c60840fb4 100644
--- a/airtime_mvc/application/Bootstrap.php
+++ b/airtime_mvc/application/Bootstrap.php
@@ -16,6 +16,7 @@ require_once __DIR__."/configs/conf.php";
require_once 'DB.php';
require_once 'Soundcloud.php';
+require_once 'MusicDir.php';
require_once 'Playlist.php';
require_once 'StoredFile.php';
require_once 'Schedule.php';
diff --git a/airtime_mvc/application/configs/ACL.php b/airtime_mvc/application/configs/ACL.php
index 0bf2b6d43..5fa4b7a05 100644
--- a/airtime_mvc/application/configs/ACL.php
+++ b/airtime_mvc/application/configs/ACL.php
@@ -6,7 +6,8 @@ $ccAcl = new Zend_Acl();
$ccAcl->addRole(new Zend_Acl_Role('G'))
->addRole(new Zend_Acl_Role('H'), 'G')
- ->addRole(new Zend_Acl_Role('A'), 'H');
+ ->addRole(new Zend_Acl_Role('P'), 'H')
+ ->addRole(new Zend_Acl_Role('A'), 'P');
$ccAcl->add(new Zend_Acl_Resource('library'))
->add(new Zend_Acl_Resource('index'))
diff --git a/airtime_mvc/application/configs/classmap-airtime-conf.php b/airtime_mvc/application/configs/classmap-airtime-conf.php
index e529ed6a2..7dec19b57 100644
--- a/airtime_mvc/application/configs/classmap-airtime-conf.php
+++ b/airtime_mvc/application/configs/classmap-airtime-conf.php
@@ -8,6 +8,13 @@ return array (
'BaseCcAccessPeer' => 'airtime/om/BaseCcAccessPeer.php',
'BaseCcAccess' => 'airtime/om/BaseCcAccess.php',
'BaseCcAccessQuery' => 'airtime/om/BaseCcAccessQuery.php',
+ 'CcMusicDirsTableMap' => 'airtime/map/CcMusicDirsTableMap.php',
+ 'CcMusicDirsPeer' => 'airtime/CcMusicDirsPeer.php',
+ 'CcMusicDirs' => 'airtime/CcMusicDirs.php',
+ 'CcMusicDirsQuery' => 'airtime/CcMusicDirsQuery.php',
+ 'BaseCcMusicDirsPeer' => 'airtime/om/BaseCcMusicDirsPeer.php',
+ 'BaseCcMusicDirs' => 'airtime/om/BaseCcMusicDirs.php',
+ 'BaseCcMusicDirsQuery' => 'airtime/om/BaseCcMusicDirsQuery.php',
'CcFilesTableMap' => 'airtime/map/CcFilesTableMap.php',
'CcFilesPeer' => 'airtime/CcFilesPeer.php',
'CcFiles' => 'airtime/CcFiles.php',
@@ -106,4 +113,11 @@ return array (
'BaseCcSubjsPeer' => 'airtime/om/BaseCcSubjsPeer.php',
'BaseCcSubjs' => 'airtime/om/BaseCcSubjs.php',
'BaseCcSubjsQuery' => 'airtime/om/BaseCcSubjsQuery.php',
+ 'CcCountryTableMap' => 'airtime/map/CcCountryTableMap.php',
+ 'CcCountryPeer' => 'airtime/CcCountryPeer.php',
+ 'CcCountry' => 'airtime/CcCountry.php',
+ 'CcCountryQuery' => 'airtime/CcCountryQuery.php',
+ 'BaseCcCountryPeer' => 'airtime/om/BaseCcCountryPeer.php',
+ 'BaseCcCountry' => 'airtime/om/BaseCcCountry.php',
+ 'BaseCcCountryQuery' => 'airtime/om/BaseCcCountryQuery.php',
);
\ No newline at end of file
diff --git a/airtime_mvc/application/configs/conf.php b/airtime_mvc/application/configs/conf.php
index 23e28ee32..51899021a 100644
--- a/airtime_mvc/application/configs/conf.php
+++ b/airtime_mvc/application/configs/conf.php
@@ -65,11 +65,7 @@ class Config {
$CC_CONFIG['baseUrl'] = $values['general']['base_url'];
$CC_CONFIG['basePort'] = $values['general']['base_port'];
-
- $CC_CONFIG['baseFilesDir'] = $values['general']['base_files_dir'];
- // main directory for storing binary media files
- $CC_CONFIG['storageDir'] = $values['general']['base_files_dir']."/stor";
-
+
// Database config
$CC_CONFIG['dsn']['username'] = $values['database']['dbuser'];
$CC_CONFIG['dsn']['password'] = $values['database']['dbpass'];
diff --git a/airtime_mvc/application/configs/constants.php b/airtime_mvc/application/configs/constants.php
index c27ed510a..1eb796bf1 100644
--- a/airtime_mvc/application/configs/constants.php
+++ b/airtime_mvc/application/configs/constants.php
@@ -1,22 +1,34 @@
'user',
'action' => 'add-user',
'resource' => 'user'
+ ),
+ array(
+ 'label' => 'Manage Media Folders',
+ 'module' => 'default',
+ 'controller' => 'Preference',
+ 'action' => 'directory-config'
)
)
),
diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php
index 1b9a03b06..a02183492 100644
--- a/airtime_mvc/application/controllers/ApiController.php
+++ b/airtime_mvc/application/controllers/ApiController.php
@@ -9,8 +9,16 @@ class ApiController extends Zend_Controller_Action
$context = $this->_helper->getHelper('contextSwitch');
$context->addActionContext('version', 'json')
->addActionContext('recorded-shows', 'json')
+ ->addActionContext('upload-file', 'json')
->addActionContext('upload-recorded', 'json')
+ ->addActionContext('media-monitor-setup', 'json')
+ ->addActionContext('media-item-status', 'json')
->addActionContext('reload-metadata', 'json')
+ ->addActionContext('list-all-files', 'json')
+ ->addActionContext('list-all-watched-dirs', 'json')
+ ->addActionContext('add-watched-dir', 'json')
+ ->addActionContext('remove-watched-dir', 'json')
+ ->addActionContext('set-storage-dir', 'json')
->initContext();
}
@@ -20,7 +28,7 @@ class ApiController extends Zend_Controller_Action
}
/**
- * Returns Airtime version. i.e "1.7.0 alpha"
+ * Returns Airtime version. i.e "1.7.0-beta"
*
* First checks to ensure the correct API key was
* supplied, then returns AIRTIME_VERSION as defined
@@ -52,7 +60,7 @@ class ApiController extends Zend_Controller_Action
* Allows remote client to download requested media file.
*
* @return void
- * The given value increased by the increment amount.
+ *
*/
public function getMediaAction()
{
@@ -63,13 +71,17 @@ class ApiController extends Zend_Controller_Action
$this->_helper->viewRenderer->setNoRender(true);
$api_key = $this->_getParam('api_key');
- $download = $this->_getParam('download');
+ $download = ("true" == $this->_getParam('download'));
- if(!in_array($api_key, $CC_CONFIG["apiKey"]))
+ $logger = Logging::getLogger();
+
+ if(!in_array($api_key, $CC_CONFIG["apiKey"]) &&
+ is_null(Zend_Auth::getInstance()->getStorage()->read()))
{
header('HTTP/1.0 401 Unauthorized');
print 'You are not allowed to access this resource.';
- exit;
+ $logger->info("401 Unauthorized");
+ return;
}
$filename = $this->_getParam("file");
@@ -77,43 +89,56 @@ class ApiController extends Zend_Controller_Action
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.';
+ $filepath = $media->getFilePath();
+ if(is_file($filepath)){
+ // 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");
+ if ($download){
+ //path_info breaks up a file path into seperate pieces of informaiton.
+ //We just want the basename which is the file name with the path
+ //information stripped away. We are using Content-Disposition to specify
+ //to the browser what name the file should be saved as.
+ //
+ // By james.moon:
+ // I'm removing pathinfo() since it strips away UTF-8 characters.
+ // Using manualy parsing
+ $full_path = $media->getPropelOrm()->getDbFilepath();
+ $file_base_name = strrchr($full_path, '/');
+ $file_base_name = substr($file_base_name, 1);
+ header('Content-Disposition: attachment; filename="'.$file_base_name.'"');
+ }
+ header("Content-Length: " . filesize($filepath));
+
+ // !! binary mode !!
+ $fp = fopen($filepath, 'rb');
+
+ //We can have multiple levels of output buffering. Need to
+ //keep looping until all have been disabled!!!
+ //http://www.php.net/manual/en/function.ob-end-flush.php
+ while (@ob_end_flush());
+
+ fpassthru($fp);
+ fclose($fp);
+
+ //make sure to exit here so that no other output is sent.
exit;
+ } else {
+ $logger->err('Resource in database, but not in storage: "'.$filepath.'"');
}
-
-
- // 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");
- if ($download){
- header('Content-Disposition: attachment; filename="'.$media->getName().'"');
- }
- header("Content-Length: " . filesize($filepath));
-
- // !! binary mode !!
- $fp = fopen($filepath, 'rb');
-
- //We can have multiple levels of output buffering. Need to
- //keep looping until all have been disabled!!!
- //http://www.php.net/manual/en/function.ob-end-flush.php
- while (@ob_end_flush());
-
- fpassthru($fp);
- fclose($fp);
-
- return;
+ } else {
+ $logger->err('$media != null && !PEAR::isError($media)');
}
+ } else {
+ $logger->err('ctype_alnum($file_id) && strlen($file_id) == 32');
}
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
- exit;
+ $logger->info("404 Not Found");
+ return;
}
public function liveInfoAction()
@@ -282,6 +307,24 @@ class ApiController extends Zend_Controller_Action
}
}
+ public function uploadFileAction()
+ {
+ 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");
+ StoredFile::uploadFile($upload_dir);
+ $fileName = isset($_REQUEST["name"]) ? $_REQUEST["name"] : '';
+ StoredFile::copyFileToStor($upload_dir, $fileName);
+ }
+
public function uploadRecordedAction()
{
global $CC_CONFIG;
@@ -293,18 +336,24 @@ class ApiController extends Zend_Controller_Action
print 'You are not allowed to access this resource.';
exit;
}
-
+
+ //this file id is the recording for this show instance.
+ $show_instance_id = $this->_getParam('showinstanceid');
+ $file_id = $this->_getParam('fileid');
+
+ $this->view->fileid = $file_id;
+ $this->view->showinstanceid = $show_instance_id;
+
+
$showCanceled = false;
- $show_instance = $this->_getParam('show_instance');
-
- $upload_dir = ini_get("upload_tmp_dir");
- $file = StoredFile::uploadFile($upload_dir);
-
- $show_name = "";
+ $file = StoredFile::Recall($file_id);
+ //$show_instance = $this->_getParam('show_instance');
+
+ $show_name = null;
try {
- $show_inst = new ShowInstance($show_instance);
-
- $show_inst->setRecordedFile($file->getId());
+ $show_inst = new ShowInstance($show_instance_id);
+
+ $show_inst->setRecordedFile($file_id);
$show_name = $show_inst->getName();
$show_genre = $show_inst->getGenre();
$show_start_time = $show_inst->getShowStart();
@@ -317,12 +366,19 @@ class ApiController extends Zend_Controller_Action
//the library), now lets just return.
$showCanceled = true;
}
-
- $tmpTitle = !(empty($show_name))?$show_name."-":"";
- $tmpTitle .= $file->getName();
-
- $file->setMetadataValue(UI_MDATA_KEY_TITLE, $tmpTitle);
-
+
+ if (isset($show_name)) {
+ $tmpTitle = "$show_name-$show_start_time";
+ $tmpTitle = str_replace(" ", "-", $tmpTitle);
+ }
+ else {
+ $tmpTitle = $file->getName();
+ }
+
+ $file->setMetadataValue('MDATA_KEY_TITLE', $tmpTitle);
+ $file->setMetadataValue('MDATA_KEY_CREATOR', "Airtime Show Recorder");
+ $file->setMetadataValue('MDATA_KEY_TRACKNUMBER', null);
+
if (!$showCanceled && Application_Model_Preference::GetDoSoundCloudUpload())
{
for ($i=0; $i<$CC_CONFIG['soundcloud-connection-retries']; $i++) {
@@ -335,7 +391,7 @@ class ApiController extends Zend_Controller_Action
try {
$soundcloud = new ATSoundcloud();
- $soundcloud_id = $soundcloud->uploadTrack($file->getRealFilePath(), $tmpTitle, $description, $tags, $show_start_time, $show_genre);
+ $soundcloud_id = $soundcloud->uploadTrack($file->getFilePath(), $tmpTitle, $description, $tags, $show_start_time, $show_genre);
$show_inst->setSoundCloudFileId($soundcloud_id);
break;
}
@@ -350,13 +406,17 @@ class ApiController extends Zend_Controller_Action
}
}
- $this->view->id = $file->getId();
+ $this->view->id = $file_id;
+
}
- public function reloadMetadataAction() {
-
+ public function mediaMonitorSetupAction() {
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"]))
{
@@ -365,22 +425,186 @@ class ApiController extends Zend_Controller_Action
exit;
}
- $md = $this->_getParam('md');
+ $this->view->stor = MusicDir::getStorDir()->getDirectory();
+ }
- $file = StoredFile::Recall(null, $md['gunid']);
- if (PEAR::isError($file) || is_null($file)) {
- $this->view->response = "File not in Airtime's Database";
- return;
+ public function reloadMetadataAction() {
+ global $CC_CONFIG;
+
+ $request = $this->getRequest();
+ $api_key = $request->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;
}
- $res = $file->replaceDbMetadata($md);
+ $mode = $request->getParam('mode');
+ $params = $request->getParams();
- if (PEAR::isError($res)) {
- $this->view->response = "Metadata Change Failed";
+ $md = array();
+ //extract all file metadata params from the request.
+ foreach ($params as $key => $value) {
+ if (preg_match('/^MDATA_KEY/', $key)) {
+ $md[$key] = $value;
+ }
}
- else {
- $this->view->response = "Success!";
+
+ // update import timestamp
+ Application_Model_Preference::SetImportTimestamp();
+
+ if ($mode == "create") {
+ $filepath = $md['MDATA_KEY_FILEPATH'];
+ $filepath = str_replace("\\", "", $filepath);
+
+ $file = StoredFile::RecallByFilepath($filepath);
+
+ if (is_null($file)) {
+ $file = StoredFile::Insert($md);
+ }
+ else {
+ $this->view->error = "File already exists in Airtime.";
+ return;
+ }
}
+ else if ($mode == "modify") {
+ $filepath = $md['MDATA_KEY_FILEPATH'];
+ $filepath = str_replace("\\", "", $filepath);
+ $file = StoredFile::RecallByFilepath($filepath);
+
+ //File is not in database anymore.
+ if (is_null($file)) {
+ $this->view->error = "File does not exist in Airtime.";
+ return;
+ }
+ //Updating a metadata change.
+ else {
+ $file->setMetadata($md);
+ }
+ }
+ else if ($mode == "moved") {
+ $md5 = $md['MDATA_KEY_MD5'];
+ $file = StoredFile::RecallByMd5($md5);
+
+ if (is_null($file)) {
+ $this->view->error = "File doesn't exist in Airtime.";
+ return;
+ }
+ else {
+ $filepath = $md['MDATA_KEY_FILEPATH'];
+ $filepath = str_replace("\\", "", $filepath);
+ $file->setFilePath($filepath);
+ //$file->setMetadata($md);
+ }
+ }
+ else if ($mode == "delete") {
+ $filepath = $md['MDATA_KEY_FILEPATH'];
+ $filepath = str_replace("\\", "", $filepath);
+ $file = StoredFile::RecallByFilepath($filepath);
+
+ if (is_null($file)) {
+ $this->view->error = "File doesn't exist in Airtime.";
+ return;
+ }
+ else {
+ $file->delete();
+ }
+ }
+ $this->view->id = $file->getId();
+ }
+
+ public function listAllFilesAction() {
+ global $CC_CONFIG;
+
+ $request = $this->getRequest();
+ $api_key = $request->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;
+ }
+ $dir_id = $request->getParam('dir_id');
+
+ $this->view->files = StoredFile::listAllFiles($dir_id);
+ }
+
+ public function listAllWatchedDirsAction() {
+ global $CC_CONFIG;
+
+ $request = $this->getRequest();
+ $api_key = $request->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;
+ }
+
+ $result = array();
+
+ $arrWatchedDirs = MusicDir::getWatchedDirs();
+ $storDir = MusicDir::getStorDir();
+
+ $result[$storDir->getId()] = $storDir->getDirectory();
+
+ foreach ($arrWatchedDirs as $watchedDir){
+ $result[$watchedDir->getId()] = $watchedDir->getDirectory();
+ }
+
+ $this->view->dirs = $result;
+ }
+
+ public function addWatchedDirAction() {
+ global $CC_CONFIG;
+
+ $request = $this->getRequest();
+ $api_key = $request->getParam('api_key');
+ $path = base64_decode($request->getParam('path'));
+
+ if (!in_array($api_key, $CC_CONFIG["apiKey"]))
+ {
+ header('HTTP/1.0 401 Unauthorized');
+ print 'You are not allowed to access this resource.';
+ exit;
+ }
+
+ $this->view->msg = MusicDir::addWatchedDir($path);
+ }
+
+ public function removeWatchedDirAction() {
+ global $CC_CONFIG;
+
+ $request = $this->getRequest();
+ $api_key = $request->getParam('api_key');
+ $path = base64_decode($request->getParam('path'));
+
+ if (!in_array($api_key, $CC_CONFIG["apiKey"]))
+ {
+ header('HTTP/1.0 401 Unauthorized');
+ print 'You are not allowed to access this resource.';
+ exit;
+ }
+
+ $this->view->msg = MusicDir::removeWatchedDir($path);
+ }
+
+ public function setStorageDirAction() {
+ global $CC_CONFIG;
+
+ $request = $this->getRequest();
+ $api_key = $request->getParam('api_key');
+ $path = base64_decode($request->getParam('path'));
+
+ if (!in_array($api_key, $CC_CONFIG["apiKey"]))
+ {
+ header('HTTP/1.0 401 Unauthorized');
+ print 'You are not allowed to access this resource.';
+ exit;
+ }
+
+ $this->view->msg = MusicDir::setStorDir($path);
}
}
diff --git a/airtime_mvc/application/controllers/LibraryController.php b/airtime_mvc/application/controllers/LibraryController.php
index 180402d7c..67efa7638 100644
--- a/airtime_mvc/application/controllers/LibraryController.php
+++ b/airtime_mvc/application/controllers/LibraryController.php
@@ -28,6 +28,7 @@ class LibraryController extends Zend_Controller_Action
$this->view->headScript()->appendFile($baseUrl.'/js/jplayer/jquery.jplayer.min.js');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/js/jquery.dataTables.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.pluginAPI.js','text/javascript');
+ $this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.fnSetFilteringDelay.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/library.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/advancedsearch.js','text/javascript');
@@ -54,18 +55,23 @@ class LibraryController extends Zend_Controller_Action
$id = $this->_getParam('id');
$type = $this->_getParam('type');
+ $request = $this->getRequest();
+ $baseUrl = $request->getBaseUrl();
$params = '/format/json/id/#id#/type/#type#';
$paramsPop = str_replace('#id#', $id, $params);
$paramsPop = str_replace('#type#', $type, $paramsPop);
+ $userInfo = Zend_Auth::getInstance()->getStorage()->read();
+ $user = new User($userInfo->id);
+
$pl_sess = $this->pl_sess;
if($type === "au") {
if(isset($pl_sess->id)) {
- $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Playlist/add-item'.$params, 'callback' => 'window["setSPLContent"]'),
+ $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Playlist/add-item'.$params, 'callback' => 'window["setSPLContent"]'),
'title' => 'Add to Playlist');
}
@@ -78,13 +84,16 @@ class LibraryController extends Zend_Controller_Action
$file_id = $this->_getParam('id', null);
$file = StoredFile::Recall($file_id);
- $url = $file->getFileURL().'/api_key/'.$CC_CONFIG["apiKey"][0].'/download/true';
+ $url = $file->getRelativeFileUrl($baseUrl).'/api_key/'.$CC_CONFIG["apiKey"][0].'/download/true';
$menu[] = array('action' => array('type' => 'gourl', 'url' => $url),
'title' => 'Download');
- $menu[] = array('action' => array('type' => 'fn',
- 'callback' => "window['confirmDeleteAudioClip']('$paramsPop')"),
- 'title' => 'Delete');
+
+ if ($user->isAdmin()) {
+ $menu[] = array('action' => array('type' => 'fn',
+ 'callback' => "window['confirmDeleteAudioClip']('$paramsPop')"),
+ 'title' => 'Delete');
+ }
}
else if($type === "pl") {
@@ -118,28 +127,38 @@ class LibraryController extends Zend_Controller_Action
public function deleteAction()
{
$id = $this->_getParam('id');
+ $userInfo = Zend_Auth::getInstance()->getStorage()->read();
+ $user = new User($userInfo->id);
- if (!is_null($id)) {
- $file = StoredFile::Recall($id);
+ if ($user->isAdmin()) {
- if (PEAR::isError($file)) {
- $this->view->message = $file->getMessage();
- return;
- }
- else if(is_null($file)) {
- $this->view->message = "file doesn't exist";
- return;
+ 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;
+ }
+ else {
+ $res = settype($res, "integer");
+ $data = array("filepath" => $file->getFilePath(), "delete" => $res);
+ RabbitMq::SendMessageToMediaMonitor("file_delete", $data);
+ }
}
- $res = $file->delete();
-
- if (PEAR::isError($res)) {
- $this->view->message = $res->getMessage();
- return;
- }
+ $this->view->id = $id;
}
-
- $this->view->id = $id;
}
public function contentsAction()
@@ -147,6 +166,12 @@ class LibraryController extends Zend_Controller_Action
$post = $this->getRequest()->getPost();
$datatables = StoredFile::searchFilesForPlaylistBuilder($post);
+ //format clip lengh to 1 decimal
+ foreach($datatables["aaData"] as &$data){
+ $sec = Playlist::playlistTimeToSeconds($data[5]);
+ $data[5] = Playlist::secondsToPlaylistTime($sec);
+ }
+
die(json_encode($datatables));
}
@@ -162,18 +187,17 @@ class LibraryController extends Zend_Controller_Action
if ($form->isValid($request->getPost())) {
$formdata = $form->getValues();
- $file->replaceDbMetadata($formdata);
+ $file->setDbColMetadata($formdata);
- $data = $formdata;
- $data['filepath'] = $file->getRealFilePath();
- //wait for 1.9.0 release
- //RabbitMq::SendFileMetaData($data);
+ $data = $file->getMetadata();
+
+ RabbitMq::SendMessageToMediaMonitor("md_update", $data);
$this->_helper->redirector('index');
}
}
- $form->populate($file->md);
+ $form->populate($file->getDbColMetadata());
$this->view->form = $form;
}
@@ -185,7 +209,7 @@ class LibraryController extends Zend_Controller_Action
if($type == "au") {
$file = StoredFile::Recall($id);
$this->view->type = $type;
- $this->view->md = $file->md;
+ $this->view->md = $file->getMetadata();
}
else if($type == "pl") {
$file = Playlist::Recall($id);
@@ -195,25 +219,4 @@ class LibraryController extends Zend_Controller_Action
}
}
-
-
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/airtime_mvc/application/controllers/LoginController.php b/airtime_mvc/application/controllers/LoginController.php
index 3d93fea00..107c50872 100644
--- a/airtime_mvc/application/controllers/LoginController.php
+++ b/airtime_mvc/application/controllers/LoginController.php
@@ -49,7 +49,10 @@ class LoginController extends Zend_Controller_Action
//the default storage is a session with namespace Zend_Auth
$authStorage = $auth->getStorage();
$authStorage->write($userInfo);
-
+
+ $tempSess = new Zend_Session_Namespace("referrer");
+ $tempSess->referrer = 'login';
+
$this->_redirect('Nowplaying');
}
else
diff --git a/airtime_mvc/application/controllers/NowplayingController.php b/airtime_mvc/application/controllers/NowplayingController.php
index f52b8dd58..257b354a2 100644
--- a/airtime_mvc/application/controllers/NowplayingController.php
+++ b/airtime_mvc/application/controllers/NowplayingController.php
@@ -7,6 +7,8 @@ class NowplayingController extends Zend_Controller_Action
{
$ajaxContext = $this->_helper->getHelper('AjaxContext');
$ajaxContext->addActionContext('get-data-grid-data', 'json')
+ ->addActionContext('register', 'json')
+ ->addActionContext('remindme', 'json')
->initContext();
}
@@ -18,6 +20,62 @@ class NowplayingController extends Zend_Controller_Action
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/js/jquery.dataTables.min.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/nowplaying/nowplayingdatagrid.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/nowplaying/nowview.js','text/javascript');
+
+ $refer_sses = new Zend_Session_Namespace('referrer');
+ $userInfo = Zend_Auth::getInstance()->getStorage()->read();
+ $user = new User($userInfo->id);
+
+ if ($request->isPost()) {
+ $form = new Application_Form_RegisterAirtime();
+
+ $values = $request->getPost();
+ if ($values["Publicise"] != 1){
+ Application_Model_Preference::SetSupportFeedback($values["SupportFeedback"]);
+ // unset session
+ Zend_Session::namespaceUnset('referrer');
+ }
+ else if ($values["Publicise"] == '1' && $form->isValid($values)) {
+ Application_Model_Preference::SetHeadTitle($values["stnName"], $this->view);
+ Application_Model_Preference::SetPhone($values["Phone"]);
+ Application_Model_Preference::SetEmail($values["Email"]);
+ Application_Model_Preference::SetStationWebSite($values["StationWebSite"]);
+ Application_Model_Preference::SetPublicise($values["Publicise"]);
+
+ $form->Logo->receive();
+ $imagePath = $form->Logo->getFileName();
+
+ Application_Model_Preference::SetStationCountry($values["Country"]);
+ Application_Model_Preference::SetStationCity($values["City"]);
+ Application_Model_Preference::SetStationDescription($values["Description"]);
+ Application_Model_Preference::SetStationLogo($imagePath);
+ Application_Model_Preference::SetSupportFeedback($values["SupportFeedback"]);
+ // unset session
+ Zend_Session::namespaceUnset('referrer');
+ }else{
+ var_dump($form->getMessages());
+ $logo = Application_Model_Preference::GetStationLogo();
+ if($logo){
+ $this->view->logoImg = $logo;
+ }
+ $this->view->dialog = $form;
+ $this->view->headScript()->appendFile($baseUrl.'/js/airtime/nowplaying/register.js','text/javascript');
+ }
+ }else{
+ //popup if previous page was login
+ if($refer_sses->referrer == 'login' && Application_Model_Nowplaying::ShouldShowPopUp()
+ && !Application_Model_Preference::GetSupportFeedback() && $user->isAdmin()){
+
+ $form = new Application_Form_RegisterAirtime();
+
+
+ $logo = Application_Model_Preference::GetStationLogo();
+ if($logo){
+ $this->view->logoImg = $logo;
+ }
+ $this->view->dialog = $form;
+ $this->view->headScript()->appendFile($baseUrl.'/js/airtime/nowplaying/register.js','text/javascript');
+ }
+ }
}
public function getDataGridDataAction()
@@ -43,6 +101,22 @@ class NowplayingController extends Zend_Controller_Action
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/nowplaying/nowplayingdatagrid.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/nowplaying/dayview.js','text/javascript');
}
+
+ public function remindmeAction()
+ {
+ // unset session
+ Zend_Session::namespaceUnset('referrer');
+ $now = date("Y-m-d H:i:s");
+ Application_Model_Preference::SetRemindMeDate($now);
+ die();
+ }
+
+ public function donotshowregistrationpopupAction()
+ {
+ // unset session
+ Zend_Session::namespaceUnset('referrer');
+ die();
+ }
}
diff --git a/airtime_mvc/application/controllers/PlaylistController.php b/airtime_mvc/application/controllers/PlaylistController.php
index a3ece83ab..ec2cc345b 100644
--- a/airtime_mvc/application/controllers/PlaylistController.php
+++ b/airtime_mvc/application/controllers/PlaylistController.php
@@ -113,8 +113,8 @@ class PlaylistController extends Zend_Controller_Action
$this->changePlaylist($pl_id);
$pl = $this->getPlaylist();
- $title = $pl->getPLMetaData(UI_MDATA_KEY_TITLE);
- $desc = $pl->getPLMetaData(UI_MDATA_KEY_DESCRIPTION);
+ $title = $pl->getPLMetaData("dc:title");
+ $desc = $pl->getPLMetaData("dc:description");
$data = array( 'title' => $title, 'description' => $desc);
$form->populate($data);
@@ -130,7 +130,7 @@ class PlaylistController extends Zend_Controller_Action
$pl->setName($title);
if(isset($description)) {
- $pl->setPLMetaData(UI_MDATA_KEY_DESCRIPTION, $description);
+ $pl->setPLMetaData("dc:description", $description);
}
$this->view->pl = $pl;
diff --git a/airtime_mvc/application/controllers/PluploadController.php b/airtime_mvc/application/controllers/PluploadController.php
index 56c07bc23..73d35196a 100644
--- a/airtime_mvc/application/controllers/PluploadController.php
+++ b/airtime_mvc/application/controllers/PluploadController.php
@@ -7,6 +7,7 @@ class PluploadController extends Zend_Controller_Action
{
$ajaxContext = $this->_helper->getHelper('AjaxContext');
$ajaxContext->addActionContext('upload', 'json')
+ ->addActionContext('copyfile', 'json')
->initContext();
}
@@ -25,9 +26,17 @@ class PluploadController extends Zend_Controller_Action
public function uploadAction()
{
$upload_dir = ini_get("upload_tmp_dir") . DIRECTORY_SEPARATOR . "plupload";
- $file = StoredFile::uploadFile($upload_dir);
+ StoredFile::uploadFile($upload_dir);
- die('{"jsonrpc" : "2.0", "id" : '.$file->getId().' }');
+ die('{"jsonrpc" : "2.0"}');
+ }
+
+ public function copyfileAction(){
+ $upload_dir = ini_get("upload_tmp_dir") . DIRECTORY_SEPARATOR . "plupload";
+ $filename = $this->_getParam('name');
+ StoredFile::copyFileToStor($upload_dir, $filename);
+
+ die('{"jsonrpc" : "2.0"}');
}
}
diff --git a/airtime_mvc/application/controllers/PreferenceController.php b/airtime_mvc/application/controllers/PreferenceController.php
index 23727b9f1..cf5d29b1b 100644
--- a/airtime_mvc/application/controllers/PreferenceController.php
+++ b/airtime_mvc/application/controllers/PreferenceController.php
@@ -6,6 +6,15 @@ class PreferenceController extends Zend_Controller_Action
public function init()
{
/* Initialize action controller here */
+ $ajaxContext = $this->_helper->getHelper('AjaxContext');
+ $ajaxContext/*->addActionContext('register', 'json')
+ ->addActionContext('remindme', 'json')*/
+ ->addActionContext('server-browse', 'json')
+ ->addActionContext('change-stor-directory', 'json')
+ ->addActionContext('reload-watch-directory', 'json')
+ ->addActionContext('remove-watch-directory', 'json')
+ ->addActionContext('is-import-in-progress', 'json')
+ ->initContext();
}
public function indexAction()
@@ -15,34 +24,149 @@ class PreferenceController extends Zend_Controller_Action
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/preferences/preferences.js','text/javascript');
$this->view->statusMsg = "";
-
- $form = new Application_Form_Preferences();
-
- if ($request->isPost()) {
-
- if ($form->isValid($request->getPost())) {
+ $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::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::SetDoSoundCloudUpload($values["preferences_soundcloud"]["UseSoundCloud"]);
Application_Model_Preference::SetSoundCloudUser($values["preferences_soundcloud"]["SoundCloudUser"]);
- Application_Model_Preference::SetSoundCloudPassword($values["preferences_soundcloud"]["SoundCloudPassword"]);
+ 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"]);
-
+
+ Application_Model_Preference::SetSoundCloudLicense($values["preferences_soundcloud"]["SoundCloudLicense"]);
+
+ Application_Model_Preference::SetPhone($values["preferences_support"]["Phone"]);
+ Application_Model_Preference::SetEmail($values["preferences_support"]["Email"]);
+ Application_Model_Preference::SetStationWebSite($values["preferences_support"]["StationWebSite"]);
+ Application_Model_Preference::SetSupportFeedback($values["preferences_support"]["SupportFeedback"]);
+ Application_Model_Preference::SetPublicise($values["preferences_support"]["Publicise"]);
+
+ $form->getSubForm('preferences_support')->Logo->receive();
+ $imagePath = $form->getSubForm('preferences_support')->Logo->getFileName();
+
+ Application_Model_Preference::SetStationCountry($values["preferences_support"]["Country"]);
+ Application_Model_Preference::SetStationCity($values["preferences_support"]["City"]);
+ Application_Model_Preference::SetStationDescription($values["preferences_support"]["Description"]);
+ Application_Model_Preference::SetStationLogo($imagePath);
+
$this->view->statusMsg = "Preferences updated.
";
}
}
-
+ $logo = Application_Model_Preference::GetStationLogo();
+ if($logo){
+ $this->view->logoImg = $logo;
+ }
$this->view->form = $form;
}
+
+ public function directoryConfigAction()
+ {
+ $request = $this->getRequest();
+ $baseUrl = $request->getBaseUrl();
+
+ $this->view->headScript()->appendFile($baseUrl.'/js/serverbrowse/serverbrowser.js','text/javascript');
+ $this->view->headScript()->appendFile($baseUrl.'/js/airtime/preferences/musicdirs.js','text/javascript');
+
+ $watched_dirs_pref = new Application_Form_WatchedDirPreferences();
+
+ $this->view->form = $watched_dirs_pref;
+ }
+
+ public function serverBrowseAction()
+ {
+ $request = $this->getRequest();
+ $path = $request->getParam("path", null);
+
+ $result = array();
+
+ if(is_null($path))
+ {
+ $element = array();
+ $element["name"] = "path should be specified";
+ $element["isFolder"] = false;
+ $element["isError"] = true;
+ $result[$path] = $element;
+ }
+ else
+ {
+ $path = $path.'/';
+ $handle = opendir($path);
+ while (false !== ($file = readdir($handle))) {
+ if ($file != "." && $file != "..") {
+ //only show directories that aren't private.
+ if (is_dir($path.$file) && substr($file, 0, 1) != ".") {
+ $element = array();
+ $element["name"] = $file;
+ $element["isFolder"] = true;
+ $element["isError"] = false;
+ $result[$file] = $element;
+ }
+ }
+ }
+ }
+ ksort($result);
+ //returns format serverBrowse is looking for.
+ die(json_encode($result));
+ }
+
+ public function changeStorDirectoryAction()
+ {
+ $chosen = $this->getRequest()->getParam("dir");
+ $element = $this->getRequest()->getParam("element");
+ $watched_dirs_form = new Application_Form_WatchedDirPreferences();
+
+ $res = MusicDir::setStorDir($chosen);
+ if($res['code'] != 0){
+ $watched_dirs_form->populate(array('storageFolder' => $chosen));
+ $watched_dirs_form->getElement($element)->setErrors(array($res['error']));
+ }
+
+ $this->view->subform = $watched_dirs_form->render();
+ }
+
+ public function reloadWatchDirectoryAction()
+ {
+ $chosen = $this->getRequest()->getParam("dir");
+ $element = $this->getRequest()->getParam("element");
+ $watched_dirs_form = new Application_Form_WatchedDirPreferences();
+
+ $res = MusicDir::addWatchedDir($chosen);
+ if($res['code'] != 0){
+ $watched_dirs_form->populate(array('watchedFolder' => $chosen));
+ $watched_dirs_form->getElement($element)->setErrors(array($res['error']));
+ }
+
+ $this->view->subform = $watched_dirs_form->render();
+ }
+
+ public function removeWatchDirectoryAction()
+ {
+ $chosen = $this->getRequest()->getParam("dir");
+
+ $dir = MusicDir::removeWatchedDir($chosen);
+
+ $watched_dirs_form = new Application_Form_WatchedDirPreferences();
+ $this->view->subform = $watched_dirs_form->render();
+ }
+
+ public function isImportInProgressAction(){
+ $now = time();
+ $res = false;
+ if(Application_Model_Preference::GetImportTimestamp()+10 > $now){
+ $res = true;
+ }
+ die(json_encode($res));
+ }
}
diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php
index 6377f13a2..953cfee52 100644
--- a/airtime_mvc/application/controllers/ScheduleController.php
+++ b/airtime_mvc/application/controllers/ScheduleController.php
@@ -59,6 +59,7 @@ class ScheduleController extends Zend_Controller_Action
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new User($userInfo->id);
$this->view->isAdmin = $user->isAdmin();
+ $this->view->isProgramManager = $user->isUserType('P');
}
public function eventFeedAction()
@@ -68,7 +69,7 @@ class ScheduleController extends Zend_Controller_Action
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new User($userInfo->id);
- if($user->isAdmin())
+ if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER)))
$editable = true;
else
$editable = false;
@@ -85,7 +86,7 @@ class ScheduleController extends Zend_Controller_Action
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new User($userInfo->id);
- if($user->isAdmin()) {
+ if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
$show = new ShowInstance($showInstanceId);
$error = $show->moveShow($deltaDay, $deltaMin);
}
@@ -104,7 +105,7 @@ class ScheduleController extends Zend_Controller_Action
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new User($userInfo->id);
- if($user->isAdmin()) {
+ if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
$show = new ShowInstance($showInstanceId);
$error = $show->resizeShow($deltaDay, $deltaMin);
}
@@ -120,7 +121,7 @@ class ScheduleController extends Zend_Controller_Action
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new User($userInfo->id);
- if($user->isAdmin()) {
+ if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
$show = new ShowInstance($showInstanceId);
$show->deleteShow();
}
@@ -155,7 +156,7 @@ class ScheduleController extends Zend_Controller_Action
try {
$soundcloud = new ATSoundcloud();
- $soundcloud_id = $soundcloud->uploadTrack($file->getRealFilePath(), $file->getName(), $description, $tags, $show_start_time, $show_genre);
+ $soundcloud_id = $soundcloud->uploadTrack($file->getFilePath(), $file->getName(), $description, $tags, $show_start_time, $show_genre);
$show_inst->setSoundCloudFileId($soundcloud_id);
$this->view->soundcloud_id = $soundcloud_id;
break;
@@ -182,10 +183,10 @@ class ScheduleController extends Zend_Controller_Action
$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()) {
+ if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER, UTYPE_HOST),$show->getShowId()) && !$show->isRecorded() && !$show->isRebroadcast()) {
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/schedule-show-dialog'.$params,
'callback' => 'window["buildScheduleDialog"]'), 'title' => 'Add / Remove Content');
@@ -213,7 +214,7 @@ class ScheduleController extends Zend_Controller_Action
if (strtotime($show->getShowStart()) <= strtotime($today_timestamp) &&
strtotime($today_timestamp) < strtotime($show->getShowEnd()) &&
- $user->isAdmin()) {
+ $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
$menu[] = array('action' => array('type' => 'fn',
'callback' => "window['confirmCancelShow']($id)"),
'title' => 'Cancel Current Show');
@@ -221,7 +222,7 @@ class ScheduleController extends Zend_Controller_Action
if (strtotime($today_timestamp) < strtotime($show->getShowStart())) {
- if ($user->isAdmin()) {
+ if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/edit-show/format/json/id/'.$id,
'callback' => 'window["beginEditShow"]'), 'title' => 'Edit Show');
@@ -231,7 +232,7 @@ class ScheduleController extends Zend_Controller_Action
'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Delete This Instance and All Following');
}
}
-
+
//returns format jjmenu is looking for.
die(json_encode($menu));
}
@@ -250,7 +251,7 @@ class ScheduleController extends Zend_Controller_Action
$user = new User($userInfo->id);
$show = new ShowInstance($showInstanceId);
- if($user->isHost($show->getShowId()) || $user->isAdmin()) {
+ if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER, UTYPE_HOST),$show->getShowId())) {
$show->scheduleShow(array($plId));
}
@@ -269,7 +270,7 @@ class ScheduleController extends Zend_Controller_Action
$user = new User($userInfo->id);
$show = new ShowInstance($showInstanceId);
- if($user->isHost($show->getShowId()) || $user->isAdmin())
+ if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER, UTYPE_HOST),$show->getShowId()))
$show->clearShow();
}
@@ -284,6 +285,11 @@ class ScheduleController extends Zend_Controller_Action
$show = new ShowInstance($this->sched_sess->showInstanceId);
$playlists = $show->searchPlaylistsForShow($post);
+ foreach( $playlists['aaData'] as &$data){
+ // calling two functions to format time to 1 decimal place
+ $sec = Playlist::playlistTimeToSeconds($data[4]);
+ $data[4] = Playlist::secondsToPlaylistTime($sec);
+ }
//for datatables
die(json_encode($playlists));
@@ -299,7 +305,7 @@ class ScheduleController extends Zend_Controller_Action
$user = new User($userInfo->id);
$show = new ShowInstance($showInstanceId);
- if($user->isHost($show->getShowId()) || $user->isAdmin()) {
+ if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER, UTYPE_HOST),$show->getShowId())) {
$show->removeGroupFromShow($group_id);
}
@@ -377,7 +383,7 @@ class ScheduleController extends Zend_Controller_Action
{
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new User($userInfo->id);
- if(!$user->isAdmin()) {
+ if(!$user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
return;
}
@@ -422,7 +428,9 @@ class ScheduleController extends Zend_Controller_Action
$formWhen->populate(array('add_show_start_date' => $show->getStartDate(),
'add_show_start_time' => DateHelper::removeSecondsFromTime($show->getStartTime()),
- 'add_show_duration' => $show->getDuration(),
+ 'add_show_end_date_no_repeat' => $show->getEndDate(),
+ 'add_show_end_time' => DateHelper::removeSecondsFromTime($show->getEndTime()),
+ 'add_show_duration' => $show->getDuration(true),
'add_show_repeats' => $show->isRepeating() ? 1 : 0));
if ($show->isStartDateTimeInPast()){
@@ -541,6 +549,29 @@ class ScheduleController extends Zend_Controller_Action
$when = $formWhen->checkReliantFields($data, $startDateModified);
}
+
+ //The way the following code works is that is parses the hour and
+ //minute from a string with the format "1h 20m" or "2h" or "36m".
+ //So we are detecting whether an hour or minute value exists via strpos
+ //and then parse appropriately. A better way to do this in the future is
+ //actually pass the format from javascript in the format hh:mm so we don't
+ //have to do this extra String parsing.
+ $hPos = strpos($data["add_show_duration"], 'h');
+ $mPos = strpos($data["add_show_duration"], 'm');
+
+ $hValue = 0;
+ $mValue = 0;
+
+ if($hPos !== false){
+ $hValue = trim(substr($data["add_show_duration"], 0, $hPos));
+ }
+ if($mPos !== false){
+ $hPos = $hPos === FALSE ? 0 : $hPos+1;
+ $mValue = trim(substr($data["add_show_duration"], $hPos, -1 ));
+ }
+
+ $data["add_show_duration"] = $hValue.":".$mValue;
+
if($data["add_show_repeats"]) {
$repeats = $formRepeats->isValid($data);
if($repeats) {
@@ -597,7 +628,7 @@ class ScheduleController extends Zend_Controller_Action
if ($what && $when && $repeats && $who && $style && $record && $rebroadAb && $rebroad) {
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new User($userInfo->id);
- if ($user->isAdmin()) {
+ if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
Show::create($data);
}
@@ -635,7 +666,7 @@ class ScheduleController extends Zend_Controller_Action
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new User($userInfo->id);
- if($user->isAdmin()) {
+ if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
$showInstanceId = $this->_getParam('id');
$showInstance = new ShowInstance($showInstanceId);
@@ -650,7 +681,7 @@ class ScheduleController extends Zend_Controller_Action
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new User($userInfo->id);
- if($user->isAdmin()) {
+ if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
$showInstanceId = $this->_getParam('id');
$show = new ShowInstance($showInstanceId);
$show->clearShow();
diff --git a/airtime_mvc/application/forms/AddShowWhen.php b/airtime_mvc/application/forms/AddShowWhen.php
index 847f26005..e843727a3 100644
--- a/airtime_mvc/application/forms/AddShowWhen.php
+++ b/airtime_mvc/application/forms/AddShowWhen.php
@@ -5,50 +5,78 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
public function init()
{
+ // Add start date element
+ $startDate = new Zend_Form_Element_Text('add_show_start_date');
+ $startDate->class = 'input_text';
+ $startDate->setRequired(true)
+ ->setLabel('Date/Time Start:')
+ ->setValue(date("Y-m-d"))
+ ->setFilters(array('StringTrim'))
+ ->setValidators(array(
+ 'NotEmpty',
+ array('date', false, array('YYYY-MM-DD'))))
+ ->setDecorators(array(
+ array(array('open'=>'HtmlTag'), array('tag' => 'dd', 'openOnly'=>true)),
+ 'ViewHelper',
+ 'Description',
+ array('Label', array('tag' =>'dt'))));
+ $this->addElement($startDate);
+
+ // Add start time element
+ $startTime = new Zend_Form_Element_Text('add_show_start_time');
+ $startTime->class = 'input_text';
+ $startTime->setRequired(true)
+ ->setValue('00:00')
+ ->setFilters(array('StringTrim'))
+ ->setValidators(array(
+ 'NotEmpty',
+ array('date', false, array('HH:mm')),
+ array('regex', false, array('/^[0-9:]+$/', 'messages' => 'Invalid character entered'))))
+ ->setDecorators(array(
+ 'ViewHelper',
+ 'Errors',
+ array(array('close'=>'HtmlTag'), array('tag' => 'dd', 'closeOnly'=>true))));
+ $this->addElement($startTime);
- //$this->setDisableLoadDefaultDecorators(true);
- //$this->removeDecorator('DtDdWrapper');
-
- // Add start date element
- $this->addElement('text', 'add_show_start_date', array(
- 'label' => 'Date Start:',
- 'class' => 'input_text',
- 'required' => true,
- 'value' => date("Y-m-d"),
- 'filters' => array('StringTrim'),
- 'validators' => array(
- 'NotEmpty',
- array('date', false, array('YYYY-MM-DD'))
- )
- ));
-
- // Add start time element
- $this->addElement('text', 'add_show_start_time', array(
- 'label' => 'Start Time:',
- 'class' => 'input_text',
- 'required' => true,
- 'value' => '0:00',
- 'filters' => array('StringTrim'),
- 'validators' => array(
- 'NotEmpty',
- array('date', false, array('HH:mm')),
- array('regex', false, array('/^[0-9:]+$/', 'messages' => 'Invalid character entered'))
- )
- ));
-
- // Add duration element
+ // Add end date element
+ $endDate = new Zend_Form_Element_Text('add_show_end_date_no_repeat');
+ $endDate->class = 'input_text';
+ $endDate->setRequired(true)
+ ->setLabel('Date/Time End:')
+ ->setValue(date("Y-m-d"))
+ ->setFilters(array('StringTrim'))
+ ->setValidators(array(
+ 'NotEmpty',
+ array('date', false, array('YYYY-MM-DD'))))
+ ->setDecorators(array(
+ array(array('open'=>'HtmlTag'), array('tag' => 'dd', 'openOnly'=>true)),
+ 'ViewHelper',
+ 'Description',
+ array('Label', array('tag' =>'dt'))));
+ $this->addElement($endDate);
+
+ // Add end time element
+ $endTime = new Zend_Form_Element_Text('add_show_end_time');
+ $endTime->class = 'input_text';
+ $endTime->setRequired(true)
+ ->setValue('01:00')
+ ->setFilters(array('StringTrim'))
+ ->setValidators(array(
+ 'NotEmpty',
+ array('date', false, array('HH:mm')),
+ array('regex', false, array('/^[0-9:]+$/', 'messages' => 'Invalid character entered'))))
+ ->setDecorators(array(
+ 'ViewHelper',
+ 'Errors',
+ array(array('close'=>'HtmlTag'), array('tag' => 'dd', 'closeOnly'=>true))));
+ $this->addElement($endTime);
+
+ // Add duration element
$this->addElement('text', 'add_show_duration', array(
- 'label' => 'Duration:',
+ 'label' => 'Duration:',
'class' => 'input_text',
- 'value' => '1:00',
- 'required' => true,
- 'filters' => array('StringTrim'),
- 'validators' => array(
- 'NotEmpty',
- array('regex', false,
- array('/^\d+:[0-5][0-9]$/',
- 'messages' => 'enter a duration: HH:mm'))
- )
+ 'value' => '01h00m',
+ 'readonly' => true
));
// Add repeats element
@@ -69,15 +97,22 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
$now_epoch = strtotime($now_timestamp);
$start_epoch = strtotime($start_timestamp);
- if ((($formData['add_show_id'] != -1) && $startDateModified) || ($formData['add_show_id'] == -1)){
- if($start_epoch < $now_epoch) {
- $this->getElement('add_show_start_time')->setErrors(array('Cannot create show in the past'));
- $valid = false;
- }
- }
- if(strtotime("00:00") == strtotime($formData["add_show_duration"])) {
- $this->getElement('add_show_duration')->setErrors(array('Cannot have duration 00:00'));
+ if ((($formData['add_show_id'] != -1) && $startDateModified) || ($formData['add_show_id'] == -1)){
+ if($start_epoch < $now_epoch) {
+ $this->getElement('add_show_start_time')->setErrors(array('Cannot create show in the past'));
+ $valid = false;
+ }
+ }
+
+ if( $formData["add_show_duration"] == "0m" ) {
+ $this->getElement('add_show_duration')->setErrors(array('Cannot have duration 0m'));
+ $valid = false;
+ }elseif(strpos($formData["add_show_duration"], 'h') !== false && intval(substr($formData["add_show_duration"], 0, strpos($formData["add_show_duration"], 'h'))) > 24) {
+ $this->getElement('add_show_duration')->setErrors(array('Cannot have duration greater than 24h'));
+ $valid = false;
+ }elseif( strstr($formData["add_show_duration"], '-') ){
+ $this->getElement('add_show_duration')->setErrors(array('Cannot have duration < 0m'));
$valid = false;
}
diff --git a/airtime_mvc/application/forms/AddShowWho.php b/airtime_mvc/application/forms/AddShowWho.php
index f7fa04b4f..76da90c28 100644
--- a/airtime_mvc/application/forms/AddShowWho.php
+++ b/airtime_mvc/application/forms/AddShowWho.php
@@ -21,7 +21,7 @@ class Application_Form_AddShowWho extends Zend_Form_SubForm
//Add hosts selection
$hosts = new Zend_Form_Element_MultiCheckbox('add_show_hosts');
- $hosts->setLabel('Hosts:')
+ $hosts->setLabel('DJs:')
->setMultiOptions($options);
$this->addElement($hosts);
diff --git a/airtime_mvc/application/forms/AddUser.php b/airtime_mvc/application/forms/AddUser.php
index 58bc91543..4ff63dc12 100644
--- a/airtime_mvc/application/forms/AddUser.php
+++ b/airtime_mvc/application/forms/AddUser.php
@@ -73,7 +73,8 @@ class Application_Form_AddUser extends Zend_Form
$select->setAttrib('style', 'width: 40%');
$select->setMultiOptions(array(
"G" => "Guest",
- "H" => "Host",
+ "H" => "DJ",
+ "P" => "Program Manager",
"A" => "Admin"
));
$select->setRequired(true);
diff --git a/airtime_mvc/application/forms/EditAudioMD.php b/airtime_mvc/application/forms/EditAudioMD.php
index 14ff80484..5e9b5969b 100644
--- a/airtime_mvc/application/forms/EditAudioMD.php
+++ b/airtime_mvc/application/forms/EditAudioMD.php
@@ -101,34 +101,41 @@ class Application_Form_EditAudioMD extends Zend_Form
'filters' => array('StringTrim')
));
- // Add mood field
+ // Add bmp field
$this->addElement('text', 'bpm', array(
'label' => 'BPM:',
'class' => 'input_text',
'filters' => array('StringTrim')
));
- // Add mood field
+ // Add copyright field
$this->addElement('text', 'copyright', array(
'label' => 'Copyright:',
'class' => 'input_text',
'filters' => array('StringTrim')
));
- // Add mood field
+ // Add isrc number field
$this->addElement('text', 'isrc_number', array(
'label' => 'ISRC Number:',
'class' => 'input_text',
'filters' => array('StringTrim')
));
- // Add mood field
+ // Add website field
$this->addElement('text', 'info_url', array(
'label' => 'Website:',
'class' => 'input_text',
'filters' => array('StringTrim')
));
+ // Add language field
+ $this->addElement('text', 'language', array(
+ 'label' => 'Language:',
+ 'class' => 'input_text',
+ 'filters' => array('StringTrim')
+ ));
+
// Add the submit button
$this->addElement('submit', 'submit', array(
'ignore' => true,
diff --git a/airtime_mvc/application/forms/GeneralPreferences.php b/airtime_mvc/application/forms/GeneralPreferences.php
index 0e5b55590..3e5ba710e 100644
--- a/airtime_mvc/application/forms/GeneralPreferences.php
+++ b/airtime_mvc/application/forms/GeneralPreferences.php
@@ -12,7 +12,7 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
//Station name
$this->addElement('text', 'stationName', array(
'class' => 'input_text',
- 'label' => 'Station Name:',
+ 'label' => 'Station Name',
'required' => true,
'filters' => array('StringTrim'),
'validators' => array('NotEmpty'),
@@ -33,15 +33,15 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
'label' => 'Default Fade:',
'required' => false,
'filters' => array('StringTrim'),
- 'validators' => array(array('regex', false,
- array('/^[0-2][0-3]:[0-5][0-9]:[0-5][0-9](\.\d{1,6})?$/',
+ 'validators' => array(array('regex', false,
+ array('/^[0-2][0-3]:[0-5][0-9]:[0-5][0-9](\.\d{1,6})?$/',
'messages' => 'enter a time 00:00:00{.000000}'))),
'value' => $defaultFade,
'decorators' => array(
'ViewHelper'
)
));
-
+
$stream_format = new Zend_Form_Element_Radio('streamFormat');
$stream_format->setLabel('Stream Label:');
$stream_format->setMultiOptions(array("Artist - Title",
@@ -58,6 +58,7 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
$third_party_api->setValue(Application_Model_Preference::GetAllow3rdPartyApi());
$third_party_api->setDecorators(array('ViewHelper'));
$this->addElement($third_party_api);
+
}
diff --git a/airtime_mvc/application/forms/PlaylistMetadata.php b/airtime_mvc/application/forms/PlaylistMetadata.php
index fb546f35a..15de97699 100644
--- a/airtime_mvc/application/forms/PlaylistMetadata.php
+++ b/airtime_mvc/application/forms/PlaylistMetadata.php
@@ -1,7 +1,6 @@
setDecorators(array(
array('ViewScript', array('viewScript' => 'form/preferences.phtml'))
));
-
+
$general_pref = new Application_Form_GeneralPreferences();
$this->addSubForm($general_pref, 'preferences_general');
$soundcloud_pref = new Application_Form_SoundcloudPreferences();
$this->addSubForm($soundcloud_pref, 'preferences_soundcloud');
+
+ $support_pref = new Application_Form_SupportPreferences();
+ $this->addSubForm($support_pref, 'preferences_support');
$this->addElement('submit', 'submit', array(
'class' => 'ui-button ui-state-default right-floated',
@@ -25,6 +28,6 @@ class Application_Form_Preferences extends Zend_Form
'decorators' => array(
'ViewHelper'
)
- ));
+ ));
}
}
diff --git a/airtime_mvc/application/forms/RegisterAirtime.php b/airtime_mvc/application/forms/RegisterAirtime.php
new file mode 100644
index 000000000..e31e67c3b
--- /dev/null
+++ b/airtime_mvc/application/forms/RegisterAirtime.php
@@ -0,0 +1,147 @@
+setAction('/Nowplaying');
+ $this->setMethod('post');
+
+ $country_list = Application_Model_Preference::GetCountryList();
+
+ $this->setDecorators(array(
+ array('ViewScript', array('viewScript' => 'form/register-dialog.phtml')),
+ array('File', array('viewScript' => 'form/register-dialog.phtml', 'placement' => false)))
+ );
+
+ // Station Name
+ $stnName = new Zend_Form_Element_Text("stnName");
+ $stnName->setLabel("Station Name")
+ ->setRequired(true)
+ ->setValue(Application_Model_Preference::GetStationName())
+ ->setDecorators(array('ViewHelper'));
+ $this->addElement($stnName);
+
+ // Phone number
+ $this->addElement('text', 'Phone', array(
+ 'class' => 'input_text',
+ 'label' => 'Phone:',
+ 'required' => false,
+ 'filters' => array('StringTrim'),
+ 'value' => Application_Model_Preference::GetPhone(),
+ 'decorators' => array(
+ 'ViewHelper'
+ )
+ ));
+
+ //Email
+ $this->addElement('text', 'Email', array(
+ 'class' => 'input_text',
+ 'label' => 'Email:',
+ 'required' => false,
+ 'filters' => array('StringTrim'),
+ 'value' => Application_Model_Preference::GetEmail(),
+ 'decorators' => array(
+ 'ViewHelper'
+ )
+ ));
+
+ // Station Web Site
+ $this->addElement('text', 'StationWebSite', array(
+ 'label' => 'Station Web Site:',
+ 'required' => false,
+ 'class' => 'input_text',
+ 'value' => Application_Model_Preference::GetStationWebSite(),
+ 'decorators' => array(
+ 'ViewHelper'
+ )
+ ));
+
+ // county list dropdown
+ $this->addElement('select', 'Country', array(
+ 'label' => 'Country:',
+ 'required' => false,
+ 'value' => Application_Model_Preference::GetStationCountry(),
+ 'multiOptions' => $country_list,
+ 'decorators' => array(
+ 'ViewHelper'
+ )
+ ));
+
+ // Station city
+ $this->addElement('text', 'City', array(
+ 'label' => 'City:',
+ 'required' => false,
+ 'class' => 'input_text',
+ 'value' => Application_Model_Preference::GetStationCity(),
+ 'decorators' => array(
+ 'ViewHelper'
+ )
+ ));
+
+ // Station Description
+ $description = new Zend_Form_Element_Textarea('Description');
+ $description->class = 'input_text_area';
+ $description->setLabel('Station Description:')
+ ->setRequired(false)
+ ->setValue(Application_Model_Preference::GetStationDescription())
+ ->setDecorators(array('ViewHelper'))
+ ->setAttrib('ROWS','2')
+ ->setAttrib('COLS','58');
+ $this->addElement($description);
+
+ // Station Logo
+ $upload = new Zend_Form_Element_File('Logo');
+ $upload->setLabel('Station Logo:')
+ ->setRequired(false)
+ ->setDecorators(array('File'))
+ ->addValidator('Count', false, 1)
+ ->addValidator('Extension', false, 'jpg,png,gif')
+ ->addValidator('ImageSize', false, array(
+ 'minwidth' => 200,
+ 'minheight' => 200,
+ 'maxwidth' => 600,
+ 'maxheight' => 600));
+ $this->addElement($upload);
+
+ //enable support feedback
+ $this->addElement('checkbox', 'SupportFeedback', array(
+ 'label' => 'Send support feedback',
+ 'required' => false,
+ 'value' => 1,
+ 'decorators' => array(
+ 'ViewHelper'
+ )
+ ));
+
+ // checkbox for publicise
+ $checkboxPublicise = new Zend_Form_Element_Checkbox("Publicise");
+ $checkboxPublicise->setLabel('Promote my station on Sourcefabric.org')
+ ->setRequired(false)
+ ->setDecorators(array('ViewHelper'))
+ ->setValue(Application_Model_Preference::GetPublicise());
+ $this->addElement($checkboxPublicise);
+
+ // text area for sending detail
+ $this->addElement('textarea', 'SendInfo', array(
+ 'class' => 'sending_textarea',
+ 'required' => false,
+ 'filters' => array('StringTrim'),
+ 'readonly' => true,
+ 'rows' => 5,
+ 'cols' => 61,
+ 'value' => Application_Model_Preference::GetSystemInfo(),
+ 'decorators' => array(
+ 'ViewHelper'
+ )
+ ));
+
+ // checkbox for privacy policy
+ $checkboxPrivacy = new Zend_Form_Element_Checkbox("Privacy");
+ $checkboxPrivacy->setLabel("By checking this box, I agree to Sourcefabric's privacy policy.")
+ ->setDecorators(array('ViewHelper'));
+ $this->addElement($checkboxPrivacy);
+ }
+}
+
diff --git a/airtime_mvc/application/forms/SupportPreferences.php b/airtime_mvc/application/forms/SupportPreferences.php
new file mode 100644
index 000000000..62c6496cf
--- /dev/null
+++ b/airtime_mvc/application/forms/SupportPreferences.php
@@ -0,0 +1,151 @@
+setDecorators(array(
+ array('ViewScript', array('viewScript' => 'form/preferences_support.phtml')),
+ array('File', array('viewScript' => 'form/preferences_support.phtml', 'placement' => false)))
+ );
+
+ // Phone number
+ $this->addElement('text', 'Phone', array(
+ 'class' => 'input_text',
+ 'label' => 'Phone:',
+ 'required' => false,
+ 'filters' => array('StringTrim'),
+ 'value' => Application_Model_Preference::GetPhone(),
+ 'decorators' => array(
+ 'ViewHelper'
+ )
+ ));
+
+ //Email
+ $this->addElement('text', 'Email', array(
+ 'class' => 'input_text',
+ 'label' => 'Email:',
+ 'required' => false,
+ 'filters' => array('StringTrim'),
+ 'value' => Application_Model_Preference::GetEmail(),
+ 'decorators' => array(
+ 'ViewHelper'
+ )
+ ));
+
+ // Station Web Site
+ $this->addElement('text', 'StationWebSite', array(
+ 'label' => 'Station Web Site:',
+ 'required' => false,
+ 'class' => 'input_text',
+ 'value' => Application_Model_Preference::GetStationWebSite(),
+ 'decorators' => array(
+ 'ViewHelper'
+ )
+ ));
+
+ // county list dropdown
+ $this->addElement('select', 'Country', array(
+ 'label' => 'Country:',
+ 'required' => false,
+ 'value' => Application_Model_Preference::GetStationCountry(),
+ 'multiOptions' => $country_list,
+ 'decorators' => array(
+ 'ViewHelper'
+ )
+ ));
+
+ // Station city
+ $this->addElement('text', 'City', array(
+ 'label' => 'City:',
+ 'required' => false,
+ 'class' => 'input_text',
+ 'value' => Application_Model_Preference::GetStationCity(),
+ 'decorators' => array(
+ 'ViewHelper'
+ )
+ ));
+
+ // Station Description
+ $description = new Zend_Form_Element_Textarea('Description');
+ $description->class = 'input_text_area';
+ $description->setLabel('Station Description:')
+ ->setRequired(false)
+ ->setValue(Application_Model_Preference::GetStationDescription())
+ ->setDecorators(array('ViewHelper'))
+ ->setAttrib('ROWS','2')
+ ->setAttrib('COLS','58');
+ $this->addElement($description);
+
+ // Station Logo
+ $upload = new Zend_Form_Element_File('Logo');
+ $upload->setLabel('Station Logo:')
+ ->setRequired(false)
+ ->setDecorators(array('File'))
+ ->addValidator('Count', false, 1)
+ ->addValidator('Extension', false, 'jpg,png,gif')
+ ->addValidator('ImageSize', false, array(
+ 'minwidth' => 200,
+ 'minheight' => 200,
+ 'maxwidth' => 600,
+ 'maxheight' => 600));
+ $this->addElement($upload);
+
+ //enable support feedback
+ $this->addElement('checkbox', 'SupportFeedback', array(
+ 'label' => 'Send support feedback',
+ 'required' => false,
+ 'value' => Application_Model_Preference::GetSupportFeedback(),
+ 'decorators' => array(
+ 'ViewHelper'
+ )
+ ));
+
+ // checkbox for publicise
+ $checkboxPublicise = new Zend_Form_Element_Checkbox("Publicise");
+ $checkboxPublicise->setLabel('Promote my station on Sourcefabric.org')
+ ->setRequired(false)
+ ->setDecorators(array('ViewHelper'))
+ ->setValue(Application_Model_Preference::GetPublicise());
+ if(Application_Model_Preference::GetSupportFeedback() == '0'){
+ $checkboxPublicise->setAttrib("disabled", "disabled");
+ }
+ $this->addElement($checkboxPublicise);
+
+ // text area for sending detail
+ $this->addElement('textarea', 'SendInfo', array(
+ 'class' => 'sending_textarea',
+ 'required' => false,
+ 'filters' => array('StringTrim'),
+ 'readonly' => true,
+ 'cols' => 61,
+ 'rows' => 5,
+ 'value' => Application_Model_Preference::GetSystemInfo(),
+ 'decorators' => array(
+ 'ViewHelper'
+ )
+ ));
+
+ // checkbox for privacy policy
+ $checkboxPrivacy = new Zend_Form_Element_Checkbox("Privacy");
+ $checkboxPrivacy->setLabel("By checking this box, I agree to Sourcefabric's privacy policy.")
+ ->setDecorators(array('ViewHelper'));
+ $this->addElement($checkboxPrivacy);
+ }
+
+ // overwriting isValid function
+ public function isValid ($data)
+ {
+ parent::isValid($data);
+ $checkPrivacy = $this->getElement('Privacy');
+ if($data["SupportFeedback"] == "1" && $data["Privacy"] != "1"){
+ $checkPrivacy->addError("You have to agree to privacy policy.");
+ return false;
+ }
+ return true;
+ }
+}
+
diff --git a/airtime_mvc/application/forms/WatchedDirPreferences.php b/airtime_mvc/application/forms/WatchedDirPreferences.php
new file mode 100644
index 000000000..6e443b0bc
--- /dev/null
+++ b/airtime_mvc/application/forms/WatchedDirPreferences.php
@@ -0,0 +1,51 @@
+setDecorators(array(
+ array('ViewScript', array('viewScript' => 'form/preferences_watched_dirs.phtml'))
+ ));
+
+ $this->addElement('text', 'storageFolder', array(
+ 'class' => 'input_text',
+ 'label' => 'Airtime\'s Storage Folder:',
+ 'required' => false,
+ 'filters' => array('StringTrim'),
+ 'value' => '',
+ 'decorators' => array(
+ 'ViewHelper'
+ )
+ ));
+
+ $this->addElement('text', 'watchedFolder', array(
+ 'class' => 'input_text',
+ 'label' => 'Choose a Folder to Watch:',
+ 'required' => false,
+ 'filters' => array('StringTrim'),
+ 'value' => '',
+ 'decorators' => array(
+ 'ViewHelper'
+ )
+ ));
+ }
+
+ public function verifyChosenFolder($p_form_element_id) {
+
+ $element = $this->getElement($p_form_element_id);
+
+ if (!is_dir($element->getValue())) {
+ $element->setErrors(array('Not a valid Directory'));
+ return false;
+ }
+ else {
+ $element->setValue("");
+ return true;
+ }
+
+ }
+
+}
+
diff --git a/airtime_mvc/application/layouts/scripts/library.phtml b/airtime_mvc/application/layouts/scripts/library.phtml
index 1ea03f7a8..cd55c2ec5 100644
--- a/airtime_mvc/application/layouts/scripts/library.phtml
+++ b/airtime_mvc/application/layouts/scripts/library.phtml
@@ -19,8 +19,8 @@
-
layout()->spl ?>
-
layout()->library ?>
+
layout()->library ?>
+
layout()->spl ?>