Merge branch 'saas-dev' into saas-tunein
Conflicts: airtime_mvc/application/views/scripts/form/preferences.phtml
This commit is contained in:
commit
a2a9e54553
18 changed files with 238 additions and 76 deletions
|
@ -10,7 +10,7 @@ class ProvisioningHelper
|
|||
// Parameter values
|
||||
private $dbuser, $dbpass, $dbname, $dbhost, $dbowner, $apikey;
|
||||
private $instanceId;
|
||||
private $station_name, $description;
|
||||
private $stationName, $description;
|
||||
|
||||
public function __construct($apikey)
|
||||
{
|
||||
|
@ -40,18 +40,14 @@ class ProvisioningHelper
|
|||
if ($this->dbhost && !empty($this->dbhost)) {
|
||||
$this->setNewDatabaseConnection();
|
||||
|
||||
//if ($this->checkDatabaseExists()) {
|
||||
// throw new Exception("ERROR: Airtime database already exists");
|
||||
//}
|
||||
|
||||
if (!$this->checkDatabaseExists()) {
|
||||
throw new Exception("ERROR: $this->dbname database does not exist.");
|
||||
throw new DatabaseDoesNotExistException("ERROR: $this->dbname database does not exist.");
|
||||
}
|
||||
|
||||
//We really want to do this check because all the Propel-generated SQL starts with "DROP TABLE IF EXISTS".
|
||||
//If we don't check, then a second call to this API endpoint would wipe all the tables!
|
||||
if ($this->checkTablesExist()) {
|
||||
throw new Exception("ERROR: airtime tables already exists");
|
||||
throw new DatabaseAlreadyExistsException();
|
||||
}
|
||||
|
||||
$this->createDatabaseTables();
|
||||
|
@ -63,11 +59,19 @@ class ProvisioningHelper
|
|||
//All we need to do is create the database tables.
|
||||
|
||||
$this->initializePrefs();
|
||||
} catch (Exception $e) {
|
||||
} catch (DatabaseDoesNotExistException $e) {
|
||||
http_response_code(400);
|
||||
Logging::error($e->getMessage());
|
||||
echo $e->getMessage() . PHP_EOL;
|
||||
return;
|
||||
} catch (DatabaseAlreadyExistsException $e) {
|
||||
// When we recreate a terminated instance, the process will fail
|
||||
// if we return a 40x response here. In order to circumvent this,
|
||||
// just return a 200; we still avoid dropping the existing tables
|
||||
http_response_code(200);
|
||||
Logging::info($e->getMessage());
|
||||
echo $e->getMessage() . PHP_EOL;
|
||||
return;
|
||||
}
|
||||
|
||||
http_response_code(201);
|
||||
|
@ -108,7 +112,7 @@ class ProvisioningHelper
|
|||
$this->dbowner = $_POST['dbowner'];
|
||||
$this->instanceId = $_POST['instanceid'];
|
||||
|
||||
$this->station_name = $_POST['station_name'];
|
||||
$this->stationName = $_POST['station_name'];
|
||||
$this->description = $_POST['description'];
|
||||
}
|
||||
|
||||
|
@ -194,8 +198,8 @@ class ProvisioningHelper
|
|||
* Initialize preference values passed from the dashboard (if any exist)
|
||||
*/
|
||||
private function initializePrefs() {
|
||||
if ($this->station_name) {
|
||||
Application_Model_Preference::SetStationName($this->station_name);
|
||||
if ($this->stationName) {
|
||||
Application_Model_Preference::SetStationName($this->stationName);
|
||||
}
|
||||
if ($this->description) {
|
||||
Application_Model_Preference::SetStationDescription($this->description);
|
||||
|
@ -203,3 +207,14 @@ class ProvisioningHelper
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
class DatabaseAlreadyExistsException extends Exception {
|
||||
private static $_defaultMessage = "ERROR: airtime tables already exists";
|
||||
public function __construct($message = null, $code = 0, Exception $previous = null) {
|
||||
$message = _((is_null($message) ? self::$_defaultMessage : $message));
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
||||
|
||||
class DatabaseDoesNotExistException extends Exception {}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ define('COMPANY_SITE_URL' , 'http://sourcefabric.org/');
|
|||
define('WHOS_USING_URL' , 'http://sourcefabric.org/en/airtime/whosusing');
|
||||
define('TERMS_AND_CONDITIONS_URL' , 'http://www.sourcefabric.org/en/about/policy/');
|
||||
define('PRIVACY_POLICY_URL' , 'http://www.sourcefabric.org/en/about/policy/');
|
||||
define('USER_MANUAL_URL' , 'http://sourcefabric.booktype.pro/airtime-25-for-broadcasters/');
|
||||
define('USER_MANUAL_URL' , 'http://sourcefabric.booktype.pro/airtime-pro-for-broadcasters');
|
||||
|
||||
define('LICENSE_VERSION' , 'GNU AGPL v.3');
|
||||
define('LICENSE_URL' , 'http://www.gnu.org/licenses/agpl-3.0-standalone.html');
|
||||
|
|
|
@ -134,7 +134,7 @@ $pages = array(
|
|||
),
|
||||
array(
|
||||
'label' => _('User Manual'),
|
||||
'uri' => "http://sourcefabric.booktype.pro/airtime-25-for-broadcasters/",
|
||||
'uri' => "http://sourcefabric.booktype.pro/airtime-pro-for-broadcasters",
|
||||
'target' => "_blank"
|
||||
),
|
||||
array(
|
||||
|
|
|
@ -459,4 +459,69 @@ class PreferenceController extends Zend_Controller_Action
|
|||
}
|
||||
$this->_helper->json->sendJson($out);
|
||||
}
|
||||
|
||||
public function deleteAllFilesAction()
|
||||
{
|
||||
$this->view->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender(true);
|
||||
|
||||
// Only admin users should get here through ACL permissioning
|
||||
// Only allow POST requests
|
||||
$method = $_SERVER['REQUEST_METHOD'];
|
||||
if (!($method == 'POST')) {
|
||||
$this->getResponse()
|
||||
->setHttpResponseCode(405)
|
||||
->appendBody(_("Request method not accepted") . ": $method");
|
||||
return;
|
||||
}
|
||||
|
||||
$user = Application_Model_User::getCurrentUser();
|
||||
$playlists = $blocks = $streams = [];
|
||||
|
||||
$allPlaylists = CcPlaylistQuery::create()->find();
|
||||
foreach ($allPlaylists as $p) {
|
||||
$playlists[] = $p->getDbId();
|
||||
}
|
||||
|
||||
$allBlocks = CcBlockQuery::create()->find();
|
||||
foreach ($allBlocks as $b) {
|
||||
$blocks[] = $b->getDbId();
|
||||
}
|
||||
|
||||
$allStreams = CcWebstreamQuery::create()->find();
|
||||
foreach ($allStreams as $s) {
|
||||
$streams[] = $s->getDbId();
|
||||
}
|
||||
|
||||
// Delete all playlists, blocks, and streams
|
||||
Application_Model_Playlist::deletePlaylists($playlists, $user->getId());
|
||||
Application_Model_Block::deleteBlocks($blocks, $user->getId());
|
||||
Application_Model_Webstream::deleteStreams($streams, $user->getId());
|
||||
|
||||
try {
|
||||
// Delete all the cloud files
|
||||
$CC_CONFIG = Config::getConfig();
|
||||
|
||||
foreach ($CC_CONFIG["supportedStorageBackends"] as $storageBackend) {
|
||||
$proxyStorageBackend = new ProxyStorageBackend($storageBackend);
|
||||
$proxyStorageBackend->deleteAllCloudFileObjects();
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
Logging::info($e->getMessage());
|
||||
}
|
||||
|
||||
// Delete all files from the database
|
||||
$files = CcFilesQuery::create()->find();
|
||||
foreach ($files as $file) {
|
||||
$storedFile = new Application_Model_StoredFile($file, null);
|
||||
// Delete the files quietly to avoid getting Sentry errors for
|
||||
// every S3 file we delete.
|
||||
$storedFile->delete(true);
|
||||
}
|
||||
|
||||
$this->getResponse()
|
||||
->setHttpResponseCode(200)
|
||||
->appendBody("OK");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -57,13 +57,16 @@ class ProvisioningController extends Zend_Controller_Action
|
|||
|
||||
/**
|
||||
* Delete the Airtime Pro station's files from Amazon S3
|
||||
*
|
||||
* FIXME: When we deploy this next time, we should ensure that
|
||||
* this function can only be accessed with POST requests!
|
||||
*/
|
||||
public function terminateAction()
|
||||
{
|
||||
$this->view->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender(true);
|
||||
|
||||
if (!RestAuth::verifyAuth(true, true, $this)) {
|
||||
if (!RestAuth::verifyAuth(true, false, $this)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
21
airtime_mvc/application/forms/DangerousPreferences.php
Normal file
21
airtime_mvc/application/forms/DangerousPreferences.php
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
class Application_Form_DangerousPreferences extends Zend_Form_SubForm {
|
||||
|
||||
public function init() {
|
||||
|
||||
$this->setDecorators(array(
|
||||
array('ViewScript', array('viewScript' => 'form/preferences_danger.phtml'))
|
||||
));
|
||||
|
||||
$clearLibrary = new Zend_Form_Element_Button('clear_library');
|
||||
$clearLibrary->setLabel(_('Delete All Tracks in Library'));
|
||||
//$submit->removeDecorator('Label');
|
||||
$clearLibrary->setAttribs(array('class'=>'btn centered'));
|
||||
$clearLibrary->setAttrib('onclick', 'deleteAllFiles();');
|
||||
$clearLibrary->removeDecorator('DtDdWrapper');
|
||||
|
||||
$this->addElement($clearLibrary);
|
||||
}
|
||||
|
||||
}
|
|
@ -28,6 +28,9 @@ class Application_Form_Preferences extends Zend_Form
|
|||
$soundcloud_pref = new Application_Form_SoundcloudPreferences();
|
||||
$this->addSubForm($soundcloud_pref, 'preferences_soundcloud');
|
||||
|
||||
$danger_pref = new Application_Form_DangerousPreferences();
|
||||
$this->addSubForm($danger_pref, 'preferences_danger');
|
||||
|
||||
$submit = new Zend_Form_Element_Submit('submit');
|
||||
$submit->setLabel(_('Save'));
|
||||
//$submit->removeDecorator('Label');
|
||||
|
|
|
@ -375,7 +375,7 @@ SQL;
|
|||
* Deletes the physical file from the local file system or from the cloud
|
||||
*
|
||||
*/
|
||||
public function delete()
|
||||
public function delete($quiet=false)
|
||||
{
|
||||
// Check if the file is scheduled to be played in the future
|
||||
if (Application_Model_Schedule::IsFileScheduledInTheFuture($this->_file->getCcFileId())) {
|
||||
|
@ -405,8 +405,12 @@ SQL;
|
|||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
//Just log the exception and continue.
|
||||
Logging::error($e);
|
||||
if ($quiet) {
|
||||
Logging::info($e);
|
||||
} else {
|
||||
//Just log the exception and continue.
|
||||
Logging::error($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -150,23 +150,27 @@ class Application_Service_CalendarService
|
|||
$menu["edit"] = array(
|
||||
"name" => _("Edit This Instance"),
|
||||
"icon" => "edit",
|
||||
"url" => $baseUrl."Schedule/populate-repeating-show-instance-form");
|
||||
"url" => $baseUrl . "Schedule/populate-repeating-show-instance-form"
|
||||
);
|
||||
} else {
|
||||
$menu["edit"] = array(
|
||||
"name" => _("Edit"),
|
||||
"icon" => "edit",
|
||||
"items" => array());
|
||||
"items" => array()
|
||||
);
|
||||
|
||||
$menu["edit"]["items"]["all"] = array(
|
||||
"name" => _("Edit Show"),
|
||||
"icon" => "edit",
|
||||
"url" => $baseUrl."Schedule/populate-show-form");
|
||||
"url" => $baseUrl . "Schedule/populate-show-form"
|
||||
);
|
||||
|
||||
$menu["edit"]["items"]["instance"] = array(
|
||||
"name" => _("Edit This Instance"),
|
||||
"icon" => "edit",
|
||||
"url" => $baseUrl."Schedule/populate-repeating-show-instance-form");
|
||||
}
|
||||
"url" => $baseUrl . "Schedule/populate-repeating-show-instance-form"
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$menu["edit"] = array(
|
||||
"name"=> _("Edit Show"),
|
||||
|
|
|
@ -153,14 +153,19 @@ class Application_Service_ShowFormService
|
|||
if ($ccShowDay->isShowStartInPast()) {
|
||||
//for a non-repeating show, we should never allow user to change the start time.
|
||||
//for a repeating show, we should allow because the form works as repeating template form
|
||||
if (!$ccShowDay->isRepeating()) {
|
||||
$form->disableStartDateAndTime();
|
||||
|
||||
// Removing this - if there is no future instance, this will throw an error.
|
||||
// If there is a future instance, then we get a WHEN block representing the next instance
|
||||
// which may be confusing.
|
||||
/*if (!$ccShowDay->isRepeating()) {
|
||||
$form->disableStartDateAndTime();
|
||||
} else {
|
||||
list($showStart, $showEnd) = $this->getNextFutureRepeatShowTime();
|
||||
if ($this->hasShowStarted($showStart)) {
|
||||
$form->disableStartDateAndTime();
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
$form->populate(
|
||||
|
@ -410,9 +415,8 @@ class Application_Service_ShowFormService
|
|||
|
||||
//if the show is repeating, set the start date to the next
|
||||
//repeating instance in the future
|
||||
if ($this->ccShow->isRepeating()) {
|
||||
list($originalShowStartDateTime,) = $this->getNextFutureRepeatShowTime();
|
||||
} else {
|
||||
$originalShowStartDateTime = $this->getCurrentOrNextInstanceStartTime();
|
||||
if (!$originalShowStartDateTime) {
|
||||
$originalShowStartDateTime = $dt;
|
||||
}
|
||||
|
||||
|
@ -421,26 +425,30 @@ class Application_Service_ShowFormService
|
|||
|
||||
/**
|
||||
*
|
||||
* Returns 2 DateTime objects, in the user's local time,
|
||||
* of the next future repeat show instance start and end time
|
||||
* Returns a DateTime object, in the user's local time,
|
||||
* of the current or next show instance start time
|
||||
*
|
||||
* Returns null if there is no next future repeating show instance
|
||||
*/
|
||||
public function getNextFutureRepeatShowTime()
|
||||
public function getCurrentOrNextInstanceStartTime()
|
||||
{
|
||||
$ccShowInstance = CcShowInstancesQuery::create()
|
||||
->filterByDbShowId($this->ccShow->getDbId())
|
||||
->filterByDbModifiedInstance(false)
|
||||
->filterByDbStarts(gmdate("Y-m-d H:i:s"), Criteria::GREATER_THAN)
|
||||
->filterByDbStarts(gmdate("Y-m-d"), Criteria::GREATER_EQUAL)
|
||||
->orderByDbStarts()
|
||||
->findOne();
|
||||
|
||||
if (!$ccShowInstance) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$starts = new DateTime($ccShowInstance->getDbStarts(), new DateTimeZone("UTC"));
|
||||
$ends = new DateTime($ccShowInstance->getDbEnds(), new DateTimeZone("UTC"));
|
||||
$showTimezone = $this->ccShow->getFirstCcShowDay()->getDbTimezone();
|
||||
|
||||
$starts->setTimezone(new DateTimeZone($showTimezone));
|
||||
$ends->setTimezone(new DateTimeZone($showTimezone));
|
||||
|
||||
return array($starts, $ends);
|
||||
return $starts;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -252,8 +252,8 @@
|
|||
success: function(data) {
|
||||
|
||||
if (data.current === null) {
|
||||
if (data.currentShow != null) {
|
||||
//Master/show source have no current track but they do have a current show.
|
||||
if (data.currentShow != null && data.currentShow.length != 0) {
|
||||
// Master/show source have no current track but they do have a current show.
|
||||
$("p.now_playing").html(data.currentShow[0].name);
|
||||
} else {
|
||||
$("p.now_playing").html("Offline");
|
||||
|
|
|
@ -2,13 +2,27 @@
|
|||
<?php echo $this->element->getElement('csrf') ?>
|
||||
|
||||
<?php echo $this->element->getSubform('preferences_general') ?>
|
||||
<?php //No soundcloud stuff on Airtime Pro -- Albert ?>
|
||||
|
||||
<h3 class="collapsible-header" id="tunein-pref-heading"><span class="arrow-icon"></span><?php echo _("TuneIn Settings"); ?></h3>
|
||||
<div class="collapsible-content" id="tunein-settings">
|
||||
<?php echo $this->element->getSubform('preferences_tunein') ?>
|
||||
</div>
|
||||
|
||||
|
||||
<?php //No soundcloud stuff on Airtime Pro -- Albert ?>
|
||||
<h3 class="collapsible-header" id="soundcloud-heading"><span class="arrow-icon"></span><?php echo _("SoundCloud Settings") ?></h3>
|
||||
|
||||
<div class="collapsible-content" id="soundcloud-settings">
|
||||
<?php echo $this->element->getSubform('preferences_soundcloud') ?>
|
||||
</div>
|
||||
|
||||
<h3 class="collapsible-header" id="dangerous-heading"><span class="arrow-icon"></span><?php echo _("Dangerous Options") ?></h3>
|
||||
<div class="collapsible-content" id="dangerous-settings">
|
||||
<?php echo $this->element->getSubform('preferences_danger') ?>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
|
||||
<?php echo $this->element->submit->render() ?>
|
||||
|
||||
</form>
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
<fieldset class="padded">
|
||||
<dl class="zend_form">
|
||||
|
||||
<div class="warning" style="margin-bottom: 10px;">
|
||||
<p class="warning-label">
|
||||
<strong>Warning:</strong> These functions will have <strong>permanent and lasting effects</strong>
|
||||
on your Airtime station. Think carefully before using them!
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<?php echo $this->element->getElement('clear_library')->render() ?>
|
||||
|
||||
</dl>
|
||||
</fieldset>
|
|
@ -3,12 +3,11 @@
|
|||
font-size: 200px !important;
|
||||
}
|
||||
</style>
|
||||
<?php $upgradeLink = Application_Common_OsPath::getBaseDir() . "billing/upgrade"; ?>
|
||||
<?php if ($this->quotaLimitReached) { ?>
|
||||
<div class="errors quota-reached">
|
||||
Disk quota exceeded. You cannot upload files until you
|
||||
<a target="_parent" href=<?php $baseUrl = Application_Common_OsPath::getBaseDir(); echo $baseUrl . "billing/upgrade"?>>
|
||||
upgrade your storage
|
||||
</a>.
|
||||
<?php printf(_pro("Disk quota exceeded. You cannot upload files until you %s upgrade your storage"),
|
||||
"<a target=\"_parent\" href=$upgradeLink>");?></a>.
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue