diff --git a/airtime_mvc/application/common/Billing.php b/airtime_mvc/application/common/Billing.php index 137451172..2dbfafa9a 100644 --- a/airtime_mvc/application/common/Billing.php +++ b/airtime_mvc/application/common/Billing.php @@ -329,4 +329,49 @@ class Billing $result = Billing::makeRequest($credentials["url"], $query_string); } + public static function getInvoices() + { + Billing::ensureClientIdIsValid(); + $credentials = Billing::getAPICredentials(); + + $postfields = array(); + $postfields["username"] = $credentials["username"]; + $postfields["password"] = md5($credentials["password"]); + $postfields["action"] = "getinvoices"; + $postfields["responsetype"] = "json"; + $postfields["userid"] = Application_Model_Preference::GetClientId(); + + $query_string = ""; + foreach ($postfields AS $k=>$v) $query_string .= "$k=".urlencode($v)."&"; + + $result = Billing::makeRequest($credentials["url"], $query_string); + + $invoices = array(); + if ($result["invoices"]) { + $invoices = $result["invoices"]["invoice"]; + } + return $invoices; + } + + /** + * Checks if the customer has any unpaid invoices and if so, returns + * the ID of one of them. Returns 0 otherwise. + */ + public static function checkForUnpaidInvoice() { + $invoices = self::getInvoices(); + $unpaidInvoice = 0; + $unpaidInvoices = 0; + foreach ($invoices as $invoice) + { + if ($invoice['status'] == 'Unpaid') { + $unpaidInvoices += 1; + $unpaidInvoice = $invoice; + } + } + if ($unpaidInvoices > 0) { + return $unpaidInvoice; + } else { + return 0; + } + } } diff --git a/airtime_mvc/application/common/UsabilityHints.php b/airtime_mvc/application/common/UsabilityHints.php index fb52de7b6..04022a1a7 100644 --- a/airtime_mvc/application/common/UsabilityHints.php +++ b/airtime_mvc/application/common/UsabilityHints.php @@ -21,6 +21,8 @@ class Application_Common_UsabilityHints $userIsOnCalendarPage = false; $userIsOnAddMediaPage = false; + $userIsOnShowbuilderPage = false; + $userIsSuperAdmin = Application_Model_User::getCurrentUser()->isSuperAdmin(); // If $userPath is set the request came from AJAX so the user's // current location inside Airtime gets passed in to this function. @@ -36,6 +38,11 @@ class Application_Common_UsabilityHints if (strpos(strtolower($userPath), 'schedule') !== false) { $userIsOnCalendarPage = true; } + + if (strpos(strtolower($userPath), 'showbuilder') !== false) { + $userIsOnShowbuilderPage = true; + } + } else { // If $userPath is not set the request came from inside Airtime so // we can use Zend's Front Controller to get the user's current location. @@ -48,6 +55,10 @@ class Application_Common_UsabilityHints if ($currentController == "plupload") { $userIsOnAddMediaPage = true; } + + if ($currentController == 'showbuilder') { + $userIsOnShowbuilderPage = true; + } } if (self::zeroFilesUploaded()) { @@ -92,9 +103,15 @@ class Application_Common_UsabilityHints "", ""); } - } else { - return ""; + } else if ($userIsOnShowbuilderPage && $userIsSuperAdmin) { + $unpaidInvoice = Billing::checkForUnpaidInvoice(); + if ($unpaidInvoice != null) { + $invoiceUrl = "/billing/invoice?invoiceid=" . $unpaidInvoice['id']; + $amount = $unpaidInvoice['currencyprefix'] . $unpaidInvoice['total']; + return _pro(sprintf("You have an unpaid invoice for %s due soon. Please pay it to keep your station on the air.", $amount, $invoiceUrl));; + } } + return ""; } /** diff --git a/airtime_mvc/application/configs/navigation.php b/airtime_mvc/application/configs/navigation.php index 7dc0466a0..e61ad2986 100644 --- a/airtime_mvc/application/configs/navigation.php +++ b/airtime_mvc/application/configs/navigation.php @@ -110,7 +110,7 @@ $pages = array( ) ), array( - 'label' => ""._('Billing'), + 'label' => (Application_Model_Preference::GetPlanLevel()=="trial") ? ""._('Upgrade')."" : ""._('Billing'), 'controller' => 'billing', 'action' => 'upgrade', 'resource' => 'billing', diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index ca0d182ef..ed278a775 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -24,7 +24,8 @@ class ApiController extends Zend_Controller_Action "show-tracks", "show-schedules", "station-logo", - "show-logo" + "show-logo", + "stream-m3u" ); if (Zend_Session::isStarted()) { @@ -1501,5 +1502,23 @@ class ApiController extends Zend_Controller_Action $hint = Application_Common_UsabilityHints::getUsabilityHint($userPath); $this->_helper->json->sendJson($hint); } - + + public function streamM3uAction() + { + $this->view->layout()->disableLayout(); + $this->_helper->viewRenderer->setNoRender(true); + + header('Content-Type: application/x-mpegurl'); + header('Content-Disposition: attachment; filename=stream.m3u'); + $m3uFile = "#EXTM3U\r\n\r\n"; //Windows linebreaks eh + + $stationName = Application_Model_Preference::GetStationName(); + $streamData = Application_Model_StreamSetting::getEnabledStreamData(); + + foreach ($streamData as $stream) { + $m3uFile .= "#EXTINF,".$stationName." - " . strtoupper($stream['codec']) . "\r\n"; + $m3uFile .= $stream['url'] . "\r\n\r\n"; + } + echo $m3uFile; + } } diff --git a/airtime_mvc/application/controllers/BillingController.php b/airtime_mvc/application/controllers/BillingController.php index 4cfbd4f77..bf508036b 100644 --- a/airtime_mvc/application/controllers/BillingController.php +++ b/airtime_mvc/application/controllers/BillingController.php @@ -283,26 +283,7 @@ class BillingController extends Zend_Controller_Action { $baseUrl = Application_Common_OsPath::getBaseDir(); $this->view->headLink()->appendStylesheet($baseUrl.'css/billing.css?'.$CC_CONFIG['airtime_version']); - Billing::ensureClientIdIsValid(); - $credentials = Billing::getAPICredentials(); - - $postfields = array(); - $postfields["username"] = $credentials["username"]; - $postfields["password"] = md5($credentials["password"]); - $postfields["action"] = "getinvoices"; - $postfields["responsetype"] = "json"; - $postfields["userid"] = Application_Model_Preference::GetClientId(); - - $query_string = ""; - foreach ($postfields AS $k=>$v) $query_string .= "$k=".urlencode($v)."&"; - - $result = Billing::makeRequest($credentials["url"], $query_string); - - if ($result["invoices"]) { - $this->view->invoices = $result["invoices"]["invoice"];; - } else { - $this->view->invoices = array(); - } + $this->view->invoices = Billing::getInvoices(); } public function invoiceAction() @@ -312,6 +293,4 @@ class BillingController extends Zend_Controller_Action { $invoice_id = $request->getParam('invoiceid'); self::viewInvoice($invoice_id); } - - } diff --git a/airtime_mvc/application/controllers/EmbedController.php b/airtime_mvc/application/controllers/EmbedController.php index 51daf9301..37e4c5b01 100644 --- a/airtime_mvc/application/controllers/EmbedController.php +++ b/airtime_mvc/application/controllers/EmbedController.php @@ -29,6 +29,7 @@ class EmbedController extends Zend_Controller_Action $this->view->muses_swf = Application_Common_HTTPHelper::getStationUrl() . "js/airtime/player/muses.swf"; $this->view->metadata_api_url = Application_Common_HTTPHelper::getStationUrl() . "api/live-info"; $this->view->player_title = json_encode($this->view->escape($request->getParam('title'))); + $this->view->jquery_i18n = Application_Common_HTTPHelper::getStationUrl() . "js/i18n/jquery.i18n.js?"; $styleParam = $request->getParam('style'); $player_style = isset($styleParam) ? $styleParam : "basic"; diff --git a/airtime_mvc/application/controllers/LibraryController.php b/airtime_mvc/application/controllers/LibraryController.php index 63ccf4949..91cfb42e4 100644 --- a/airtime_mvc/application/controllers/LibraryController.php +++ b/airtime_mvc/application/controllers/LibraryController.php @@ -375,6 +375,9 @@ class LibraryController extends Zend_Controller_Action if ($form->isValid($serialized)) { $file->setDbColMetadata($serialized); + $this->view->status = true; + } else { + $this->view->status = false; } } diff --git a/airtime_mvc/application/controllers/LocaleController.php b/airtime_mvc/application/controllers/LocaleController.php index 5a51190fa..c63ecfec0 100644 --- a/airtime_mvc/application/controllers/LocaleController.php +++ b/airtime_mvc/application/controllers/LocaleController.php @@ -428,7 +428,12 @@ class LocaleController extends Zend_Controller_Action ": activate to sort column ascending", ": activate to sort column descending", //End of datatables - "Welcome to the new Airtime Pro!" => _("Welcome to the new Airtime Pro!") + "Welcome to the new Airtime Pro!" => _("Welcome to the new Airtime Pro!"), + //embed player + "On Air" => _("On Air"), + "Off Air" => _("Off Air"), + "Offline" => _("Offline"), + "Nothing scheduled" => _("Nothing scheduled") ); $this->view->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); diff --git a/airtime_mvc/application/forms/BillingClient.php b/airtime_mvc/application/forms/BillingClient.php index 098c004a4..60561b114 100644 --- a/airtime_mvc/application/forms/BillingClient.php +++ b/airtime_mvc/application/forms/BillingClient.php @@ -188,7 +188,7 @@ class Application_Form_BillingClient extends Zend_Form $passwordVerify->addValidator($notEmptyValidator); $this->addElement($passwordVerify); - $this->addElement('hash', 'csrf', array( + $this->addElement('hash', 'csrf_client', array( 'salt' => 'unique' )); diff --git a/airtime_mvc/application/forms/BillingUpgradeDowngrade.php b/airtime_mvc/application/forms/BillingUpgradeDowngrade.php index 5ff4ff4de..858f74ddd 100644 --- a/airtime_mvc/application/forms/BillingUpgradeDowngrade.php +++ b/airtime_mvc/application/forms/BillingUpgradeDowngrade.php @@ -3,12 +3,7 @@ class Application_Form_BillingUpgradeDowngrade extends Zend_Form { public function init() { - $csrf_namespace = new Zend_Session_Namespace('csrf_namespace'); - $csrf_element = new Zend_Form_Element_Hidden('csrf'); - $csrf_element->setValue($csrf_namespace->authtoken)->setRequired('true')->removeDecorator('HtmlTag')->removeDecorator('Label'); - $this->addElement($csrf_element); - - $this->addElement('hash', 'csrf', array( + $this->addElement('hash', 'csrf_upgrade', array( //Needs a unique ID (csrf_upgrade) so it doesn't conflict with other tokens in subforms 'salt' => 'unique' )); diff --git a/airtime_mvc/application/forms/EditAudioMD.php b/airtime_mvc/application/forms/EditAudioMD.php index 923c53ae8..7c9e40f8a 100644 --- a/airtime_mvc/application/forms/EditAudioMD.php +++ b/airtime_mvc/application/forms/EditAudioMD.php @@ -179,6 +179,26 @@ class Application_Form_EditAudioMD extends Zend_Form )); $this->addElement($language); + $validCuePattern = '/^(?:[0-9]{1,2}:)?(?:[0-9]{1,2}:)?[0-9]{1,6}(\.\d{1,6})?$/'; + + $cueIn = new Zend_Form_Element_Text('cuein'); + $cueIn->class = 'input_text'; + $cueIn->setLabel("Cue In:"); + $cueInValidator = Application_Form_Helper_ValidationTypes::overrideRegexValidator( + $validCuePattern, _(sprintf("Specify cue in time in the format %s", "(hh:mm:)ss(.dddddd)")) + ); + $cueIn->setValidators(array($cueInValidator)); + $this->addElement($cueIn); + + $cueOut = new Zend_Form_Element_Text('cueout'); + $cueOut->class = 'input_text'; + $cueOut->setLabel('Cue Out:'); + $cueOutValidator = Application_Form_Helper_ValidationTypes::overrideRegexValidator( + $validCuePattern, _(sprintf("Specify cue out time in the format %s", "(hh:mm:)ss(.dddddd)")) + ); + $cueOut->setValidators(array($cueOutValidator)); + $this->addElement($cueOut); + // Add the submit button $this->addElement('button', 'editmdsave', array( 'ignore' => true, diff --git a/airtime_mvc/application/layouts/scripts/layout.phtml b/airtime_mvc/application/layouts/scripts/layout.phtml index 454d6e3c7..810f56462 100644 --- a/airtime_mvc/application/layouts/scripts/layout.phtml +++ b/airtime_mvc/application/layouts/scripts/layout.phtml @@ -97,7 +97,7 @@ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
-
;">
+
;">