Dangerous options subform on Preferences page and Delete all tracks button
This commit is contained in:
parent
fc36ff5797
commit
15bebc6267
8 changed files with 151 additions and 23 deletions
|
@ -454,4 +454,69 @@ class PreferenceController extends Zend_Controller_Action
|
||||||
}
|
}
|
||||||
$this->_helper->json->sendJson($out);
|
$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);
|
||||||
|
$storedFile->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* TODO: delete hard copies of files? */
|
||||||
|
|
||||||
|
$this->getResponse()
|
||||||
|
->setHttpResponseCode(200)
|
||||||
|
->appendBody("OK");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -24,6 +24,9 @@ class Application_Form_Preferences extends Zend_Form
|
||||||
$soundcloud_pref = new Application_Form_SoundcloudPreferences();
|
$soundcloud_pref = new Application_Form_SoundcloudPreferences();
|
||||||
$this->addSubForm($soundcloud_pref, 'preferences_soundcloud');
|
$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 = new Zend_Form_Element_Submit('submit');
|
||||||
$submit->setLabel(_('Save'));
|
$submit->setLabel(_('Save'));
|
||||||
//$submit->removeDecorator('Label');
|
//$submit->removeDecorator('Label');
|
||||||
|
|
|
@ -401,6 +401,7 @@ SQL;
|
||||||
//or from the cloud
|
//or from the cloud
|
||||||
if ($this->_file->getDbImportStatus() == CcFiles::IMPORT_STATUS_SUCCESS) {
|
if ($this->_file->getDbImportStatus() == CcFiles::IMPORT_STATUS_SUCCESS) {
|
||||||
try {
|
try {
|
||||||
|
Logging::info("DELETING PHYSICAL FILE " . $this->_file->getDbTrackTitle());
|
||||||
$this->_file->deletePhysicalFile();
|
$this->_file->deletePhysicalFile();
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (Exception $e)
|
||||||
|
|
|
@ -4,6 +4,18 @@
|
||||||
<?php echo $this->element->getSubform('preferences_general') ?>
|
<?php echo $this->element->getSubform('preferences_general') ?>
|
||||||
<?php //No soundcloud stuff on Airtime Pro -- Albert ?>
|
<?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() ?>
|
<?php echo $this->element->submit->render() ?>
|
||||||
|
|
||||||
</form>
|
</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>
|
|
@ -1788,7 +1788,7 @@ ul.errors {
|
||||||
width:278px;
|
width:278px;
|
||||||
}
|
}
|
||||||
|
|
||||||
ul.errors li {
|
ul.errors li, .warning {
|
||||||
color:#902d2d;
|
color:#902d2d;
|
||||||
font-size:11px;
|
font-size:11px;
|
||||||
padding:2px 4px;
|
padding:2px 4px;
|
||||||
|
@ -1798,6 +1798,11 @@ ul.errors li {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.warning-label {
|
||||||
|
font-size: medium;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
div.success{
|
div.success{
|
||||||
color:#3B5323;
|
color:#3B5323;
|
||||||
font-size:11px;
|
font-size:11px;
|
||||||
|
@ -2255,14 +2260,9 @@ dd.radio-inline-list, .preferences dd.radio-inline-list, .stream-config dd.radio
|
||||||
.radio-inline-list label {
|
.radio-inline-list label {
|
||||||
margin-right:12px;
|
margin-right:12px;
|
||||||
}
|
}
|
||||||
.preferences.simple-formblock dd.block-display {
|
.preferences.simple-formblock dd.block-display,
|
||||||
width: 100%;
|
.preferences.simple-formblock dd.block-display select, .stream-config.simple-formblock dd.block-display select,
|
||||||
}
|
.preferences dd.block-display .input_select, .stream-config dd.block-display .input_select {
|
||||||
|
|
||||||
.preferences.simple-formblock dd.block-display select, .stream-config.simple-formblock dd.block-display select {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
.preferences dd.block-display .input_select, .stream-config dd.block-display .input_select {
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
.preferences dd.block-display .input_text_area, .preferences dd.block-display .input_text
|
.preferences dd.block-display .input_text_area, .preferences dd.block-display .input_text
|
||||||
|
@ -2284,6 +2284,15 @@ dd.radio-inline-list, .preferences dd.radio-inline-list, .stream-config dd.radio
|
||||||
margin-bottom: 4px;
|
margin-bottom: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.preferences #Logo-img-container {
|
||||||
|
margin-top: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.centered {
|
||||||
|
margin: 0 auto;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
#show_time_info {
|
#show_time_info {
|
||||||
font-size:12px;
|
font-size:12px;
|
||||||
height:30px;
|
height:30px;
|
||||||
|
|
|
@ -1,18 +1,13 @@
|
||||||
function showErrorSections() {
|
function showErrorSections() {
|
||||||
if($("#soundcloud-settings .errors").length > 0) {
|
var selector = $("[id$=-settings]");
|
||||||
$("#soundcloud-settings").show();
|
selector.each(function(i) {
|
||||||
$(window).scrollTop($("#soundcloud-settings .errors").position().top);
|
var el = $(this);
|
||||||
}
|
var errors = el.find(".errors");
|
||||||
|
if (errors.length > 0) {
|
||||||
if($("#email-server-settings .errors").length > 0) {
|
el.show();
|
||||||
$("#email-server-settings").show();
|
$(window).scrollTop(errors.position().top);
|
||||||
$(window).scrollTop($("#email-server-settings .errors").position().top);
|
|
||||||
}
|
|
||||||
|
|
||||||
if($("#livestream-settings .errors").length > 0) {
|
|
||||||
$("#livestream-settings").show();
|
|
||||||
$(window).scrollTop($("#livestream-settings .errors").position().top);
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function setConfigureMailServerListener() {
|
function setConfigureMailServerListener() {
|
||||||
|
@ -120,6 +115,14 @@ function removeLogo() {
|
||||||
location.reload();
|
location.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function deleteAllFiles() {
|
||||||
|
var resp = confirm($.i18n._("Are you sure you want to delete all the tracks in your library?"))
|
||||||
|
if (resp) {
|
||||||
|
$.post(baseUrl+'Preference/delete-all-files', function(json){});
|
||||||
|
location.reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
$('.collapsible-header').live('click',function() {
|
$('.collapsible-header').live('click',function() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue