CC-6122 - change library behaviour for guest users

This commit is contained in:
Duncan Sommerville 2015-09-01 13:53:59 -04:00
parent c7d926f8e8
commit 46e126145e
8 changed files with 165 additions and 224 deletions

View File

@ -24,95 +24,6 @@ class LibraryController extends Zend_Controller_Action
public function indexAction() public function indexAction()
{ {
$this->_redirect("showbuilder"); $this->_redirect("showbuilder");
// $CC_CONFIG = Config::getConfig();
//
// $request = $this->getRequest();
// $baseUrl = Application_Common_OsPath::getBaseDir();
//
// $this->view->headScript()->appendFile($baseUrl.'js/blockui/jquery.blockUI.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
// $this->view->headScript()->appendFile($baseUrl.'js/contextmenu/jquery.contextMenu.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
// $this->view->headScript()->appendFile($baseUrl.'js/datatables/js/jquery.dataTables.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
// $this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.pluginAPI.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
// $this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.fnSetFilteringDelay.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
// $this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.ColVis.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
// $this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.colReorder.min.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
// $this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.FixedColumns.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
// $this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.columnFilter.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
//
// $this->view->headScript()->appendFile($baseUrl.'js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
// $this->view->headScript()->appendFile($baseUrl.'js/airtime/utilities/utilities.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
// $this->view->headScript()->appendFile($baseUrl.'js/airtime/library/library.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
// $this->view->headScript()->appendFile($baseUrl.'js/airtime/library/events/library_playlistbuilder.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
//
// $this->view->headLink()->appendStylesheet($baseUrl.'css/media_library.css?'.$CC_CONFIG['airtime_version']);
// $this->view->headLink()->appendStylesheet($baseUrl.'css/jquery.contextMenu.css?'.$CC_CONFIG['airtime_version']);
// $this->view->headLink()->appendStylesheet($baseUrl.'css/datatables/css/ColVis.css?'.$CC_CONFIG['airtime_version']);
// $this->view->headLink()->appendStylesheet($baseUrl.'css/datatables/css/dataTables.colReorder.min.css?'.$CC_CONFIG['airtime_version']);
// $this->view->headLink()->appendStylesheet($baseUrl.'css/waveform.css?'.$CC_CONFIG['airtime_version']);
//
// $this->view->headScript()->appendFile($baseUrl.'js/airtime/library/spl.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
// $this->view->headScript()->appendFile($baseUrl.'js/airtime/playlist/smart_blockbuilder.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
//
// $this->view->headScript()->appendFile($baseUrl.'js/waveformplaylist/observer/observer.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
// $this->view->headScript()->appendFile($baseUrl.'js/waveformplaylist/config.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
// $this->view->headScript()->appendFile($baseUrl.'js/waveformplaylist/curves.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
// $this->view->headScript()->appendFile($baseUrl.'js/waveformplaylist/fades.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
// $this->view->headScript()->appendFile($baseUrl.'js/waveformplaylist/local_storage.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
// $this->view->headScript()->appendFile($baseUrl.'js/waveformplaylist/controls.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
// $this->view->headScript()->appendFile($baseUrl.'js/waveformplaylist/playout.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
// $this->view->headScript()->appendFile($baseUrl.'js/waveformplaylist/track_render.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
// $this->view->headScript()->appendFile($baseUrl.'js/waveformplaylist/track.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
// $this->view->headScript()->appendFile($baseUrl.'js/waveformplaylist/time_scale.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
// $this->view->headScript()->appendFile($baseUrl.'js/waveformplaylist/playlist.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
//
// //arbitrary attributes need to be allowed to set an id for the templates.
// $this->view->headScript()->setAllowArbitraryAttributes(true);
// //$this->view->headScript()->appendScript(file_get_contents(APPLICATION_PATH.'/../public/js/waveformplaylist/templates/bottombar.tpl'),
// // 'text/template', array('id' => 'tpl_playlist_cues', 'noescape' => true));
//
// $this->view->headLink()->appendStylesheet($baseUrl.'css/playlist_builder.css?'.$CC_CONFIG['airtime_version']);
//
// try {
//
// $obj_sess = new Zend_Session_Namespace(UI_PLAYLISTCONTROLLER_OBJ_SESSNAME);
// if (isset($obj_sess->id)) {
// $objInfo = Application_Model_Library::getObjInfo($obj_sess->type);
// $obj = new $objInfo['className']($obj_sess->id);
// $userInfo = Zend_Auth::getInstance()->getStorage()->read();
// $user = new Application_Model_User($userInfo->id);
// $isAdminOrPM = $user->isUserType(array(UTYPE_SUPERADMIN, UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
//
// if ($isAdminOrPM || $obj->getCreatorId() == $userInfo->id) {
// $this->view->obj = $obj;
// if ($obj_sess->type == "block") {
// $form = new Application_Form_SmartBlockCriteria();
// $form->startForm($obj_sess->id);
// $this->view->form = $form;
// }
// }
//
// $formatter = new LengthFormatter($obj->getLength());
// $this->view->length = $formatter->format();
// $this->view->type = $obj_sess->type;
// }
//
// //get user settings and determine if we need to hide
// // or show the playlist editor
// $showPlaylist = false;
// $data = Application_Model_Preference::getLibraryScreenSettings();
// if (!is_null($data)) {
// if ($data["playlist"] == "true") {
// $showPlaylist = true;
// }
// }
// $this->view->showPlaylist = $showPlaylist;
// } catch (PlaylistNotFoundException $e) {
// $this->playlistNotFound($obj_sess->type);
// } catch (Exception $e) {
// $this->playlistNotFound($obj_sess->type);
// Logging::info($e->getMessage());
// //$this->playlistUnknownError($e);
// }
} }
protected function playlistNotFound($p_type) protected function playlistNotFound($p_type)

View File

@ -51,8 +51,14 @@ class LocaleController extends Zend_Controller_Action
//library/events/library_showbuilder.js //library/events/library_showbuilder.js
//already in library/events/library_playlistbuilder.js //already in library/events/library_playlistbuilder.js
"Please select a cursor position on timeline." => _("Please select a cursor position on timeline."), "Please select a cursor position on timeline." => _("Please select a cursor position on timeline."),
"You haven't added any " => _("You haven't added any "), "You haven't added any tracks" => _("You haven't added any tracks"),
"Learn about " => _("Learn about "), "You haven't added any playlists" => _("You haven't added any playlists"),
"You haven't added any smart blocks" => _("You haven't added any smart blocks"),
"You haven't added any webstreams" => _("You haven't added any webstreams"),
"Learn about tracks" => _("Learn about tracks"),
"Learn about playlists" => _("Learn about playlists"),
"Learn about smart blocks" => _("Learn about smart blocks"),
"Learn about webstreams" => _("Learn about webstreams"),
"Click 'New' to create one." => _("Click 'New' to create one."), "Click 'New' to create one." => _("Click 'New' to create one."),
//"Adding 1 Item" => _("Adding 1 Item"), //"Adding 1 Item" => _("Adding 1 Item"),
//"Adding %s Items" => _("Adding %s Items"), //"Adding %s Items" => _("Adding %s Items"),

View File

@ -204,7 +204,11 @@ class Zend_Controller_Plugin_Acl extends Zend_Controller_Plugin_Abstract
$resourceName, $resourceName,
$request->getActionName())) { $request->getActionName())) {
/** Redirect to access denied page */ /** Redirect to access denied page */
$this->denyAccess(); $this->getResponse()
->setHttpResponseCode(403)
->appendBody("You don't have permission to access this resource.")
->sendResponse();
// $this->denyAccess(); /* This results in a 404! */
} }
} }
} }

View File

@ -78,7 +78,7 @@ class Application_Service_CalendarService
$menu["schedule"] = array( $menu["schedule"] = array(
// "name"=> _("Add / Remove Content"), // "name"=> _("Add / Remove Content"),
"name" => _("Schedule Show"), "name" => _("Schedule Tracks"),
"icon" => "add-remove-content", "icon" => "add-remove-content",
"url" => $baseUrl."showbuilder/builder-dialog/"); "url" => $baseUrl."showbuilder/builder-dialog/");
} }

View File

@ -0,0 +1,28 @@
{
"1": {
"media": "tracks",
"icon": "icon-music",
"subtext": "Click 'Upload' to add some now.",
"href": "http://sourcefabric.booktype.pro/airtime-pro-for-broadcasters/add-media/"
},
"2": {
"media": "playlists",
"icon": "icon-list",
"subtext": "Click 'New' to create one now.",
"href": "http://sourcefabric.booktype.pro/airtime-pro-for-broadcasters/library/"
},
"3": {
"media": "smart blocks",
"icon": "icon-time",
"subtext": "Click 'New' to create one now.",
"href": "http://sourcefabric.booktype.pro/airtime-pro-for-broadcasters/library/"
},
"4": {
"media": "webstreams",
"icon": "icon-random",
"subtext": "Click 'New' to create one now.",
"href": "http://sourcefabric.booktype.pro/airtime-pro-for-broadcasters/library/"
},
"unauthorized": "You don't have permission to view the library."
}

View File

@ -610,6 +610,7 @@ div.ColVis_collectionBackground {
.ColVis.TableTools > button { .ColVis.TableTools > button {
padding: 3px 9px; padding: 3px 9px;
margin: -1px -1px 5px 0;
} }
.ColVis_title { .ColVis_title {

View File

@ -79,47 +79,23 @@ var AIRTIME = (function(AIRTIME) {
if (emptyRow.length > 0) { if (emptyRow.length > 0) {
emptyRow.hide(); emptyRow.hide();
var opts = {}, var mediaType = parseInt($('.media_type_selector.selected').attr('data-selection-id')),
mediaType = parseInt($('.media_type_selector.selected').attr('data-selection-id')),
img = $('#library_empty_image'); img = $('#library_empty_image');
// TODO: once the new manual pages are added, change links!
if (mediaType > 1) {
opts.subtext = $.i18n._("Click 'New' to create one now.");
opts.href = "http://sourcefabric.booktype.pro/airtime-pro-for-broadcasters/library/";
} else {
opts.subtext = $.i18n._("Click 'Upload' to add some now.");
opts.href = "http://sourcefabric.booktype.pro/airtime-pro-for-broadcasters/add-media/";
}
switch(mediaType) {
case 1:
opts.media = $.i18n._('tracks');
opts.icon = 'icon-music';
break;
case 2:
opts.media = $.i18n._('playlists');
opts.icon = 'icon-list';
break;
case 3:
opts.media = $.i18n._('smart blocks');
opts.icon = 'icon-time';
break;
case 4:
opts.media = $.i18n._('webstreams');
opts.icon = 'icon-random';
break;
}
// Remove all classes for when we change between empty media types // Remove all classes for when we change between empty media types
img.removeClass(function() { img.removeClass(function() {
return $( this ).attr( "class" ); return $( this ).attr( "class" );
}); });
img.addClass("icon-white " + opts.icon); // TODO: once the new manual pages are added, change links!
$('#library_empty_text').html( $.getJSON( "ajax/library_placeholders.json", function( data ) {
$.i18n._("You haven't added any ") + opts.media + "." var opts = data[mediaType];
+ "<br/>" + opts.subtext img.addClass("icon-white " + opts.icon);
+ "<br/><a href='" + opts.href + "'>" + $.i18n._("Learn about ") + opts.media + "</a>" $('#library_empty_text').html(
); $.i18n._("You haven't added any " + opts.media + ".")
+ "<br/>" + $.i18n._(opts.subtext)
+ "<br/><a href='" + opts.href + "'>" + $.i18n._("Learn about " + opts.media) + "</a>"
);
}) ;
$('#library_empty').show(); $('#library_empty').show();
} else { } else {
$('#library_empty').hide(); $('#library_empty').hide();
@ -281,118 +257,119 @@ var AIRTIME = (function(AIRTIME) {
mod.createToolbarButtons(); mod.createToolbarButtons();
mod.moveSearchBarToHeader(); mod.moveSearchBarToHeader();
$toolbar.append($menu);
// add to timeline button
$toolbar
.find('#library-plus')
.click(
function() {
if (AIRTIME.button.isDisabled('btn-group #library-plus') === true) { if (localStorage.getItem('user-type') != 'G') {
return; $toolbar.append($menu);
} // add to timeline button
$toolbar
.find('#library-plus')
.click(
function () {
var selected = AIRTIME.library.getSelectedData(), data, i, length, temp, aMediaIds = [], aSchedIds = [], aData = []; if (AIRTIME.button.isDisabled('btn-group #library-plus') === true) {
return;
}
if ($("#show_builder_table").is(":visible")) { var selected = AIRTIME.library.getSelectedData(), data, i, length, temp, aMediaIds = [], aSchedIds = [], aData = [];
for (i = 0, length = selected.length; i < length; i++) {
data = selected[i];
aMediaIds.push( {
"id" : data.id,
"type" : data.ftype
});
}
// process selected files/playlists. if ($("#show_builder_table").is(":visible")) {
$("#show_builder_table tr.sb-selected").each(function(i, el) { for (i = 0, length = selected.length; i < length; i++) {
aData.push($(el).data("aData")); data = selected[i];
aMediaIds.push({
"id": data.id,
"type": data.ftype
}); });
}
// process selected schedule rows to add media // process selected files/playlists.
// after. $("#show_builder_table tr.sb-selected").each(function (i, el) {
for (i = 0, length = aData.length; i < length; i++) { aData.push($(el).data("aData"));
temp = aData[i]; });
aSchedIds.push( {
"id" : temp.id,
"instance" : temp.instance,
"timestamp" : temp.timestamp
});
}
if (aSchedIds.length == 0) { // process selected schedule rows to add media
if (!addToCurrentOrNext(aSchedIds)) { // after.
return; for (i = 0, length = aData.length; i < length; i++) {
} temp = aData[i];
} aSchedIds.push({
"id": temp.id,
"instance": temp.instance,
"timestamp": temp.timestamp
});
}
AIRTIME.showbuilder.fnAdd(aMediaIds, aSchedIds); if (aSchedIds.length == 0) {
} else { if (!addToCurrentOrNext(aSchedIds)) {
for (i = 0, length = selected.length; i < length; i++) { return;
data = selected[i];
aMediaIds.push([data.id, data.ftype]);
}
// check if a playlist/block is open before adding items
if ($('.active-tab .obj_type').val() == 'playlist'
|| $('.active-tab .obj_type').val() == 'block') {
AIRTIME.playlist.fnAddItems(aMediaIds, undefined, 'after');
} }
} }
});
// delete from library. AIRTIME.showbuilder.fnAdd(aMediaIds, aSchedIds);
$toolbar.find('.icon-trash').parent().click(function() { } else {
for (i = 0, length = selected.length; i < length; i++) {
data = selected[i];
aMediaIds.push([data.id, data.ftype]);
}
if (AIRTIME.button.isDisabled('icon-trash') === true) { // check if a playlist/block is open before adding items
return; if ($('.active-tab .obj_type').val() == 'playlist'
} || $('.active-tab .obj_type').val() == 'block') {
AIRTIME.playlist.fnAddItems(aMediaIds, undefined, 'after');
}
}
});
AIRTIME.library.fnDeleteSelectedItems(); // delete from library.
}); $toolbar.find('.icon-trash').parent().click(function () {
if (AIRTIME.button.isDisabled('icon-trash') === true) {
return;
}
$toolbar.find('#sb-new').click(function() { AIRTIME.library.fnDeleteSelectedItems();
if (AIRTIME.button.isDisabled('btn-group #sb-new') === true) { });
return;
}
var selection = $(".media_type_selector.selected").attr("data-selection-id"); $toolbar.find('#sb-new').click(function () {
if (AIRTIME.button.isDisabled('btn-group #sb-new') === true) {
return;
}
if (selection == 2) { var selection = $(".media_type_selector.selected").attr("data-selection-id");
AIRTIME.playlist.fnNew();
} else if (selection == 3) {
AIRTIME.playlist.fnNewBlock();
} else if (selection == 4) {
AIRTIME.playlist.fnWsNew();
}
});
if (selection == 2) {
$toolbar.find('#sb-edit').click(function() { AIRTIME.playlist.fnNew();
if (AIRTIME.button.isDisabled('btn-group #sb-edit') === true) { } else if (selection == 3) {
return; AIRTIME.playlist.fnNewBlock();
} } else if (selection == 4) {
AIRTIME.playlist.fnWsNew();
var selected = $(".lib-selected");
selected.each(function(i, el) {
var data = $(el).data("aData");
if (data.ftype === "audioclip") {
$.get(baseUrl + "library/edit-file-md/id/" + data.id, {format: "json"}, function(json){
AIRTIME.playlist.fileMdEdit(json);
//buildEditMetadataDialog(json);
});
} else if (data.ftype === "playlist" || data.ftype === "block") {
AIRTIME.playlist.fnEdit(data.id, data.ftype, baseUrl+'playlist/edit');
AIRTIME.playlist.validatePlaylistElements();
} else if (data.ftype === "stream") {
AIRTIME.playlist.fnEdit(data.id, data.ftype, baseUrl + 'webstream/edit');
} }
}); });
});
mod.createToolbarDropDown();
$toolbar.find('#sb-edit').click(function () {
if (AIRTIME.button.isDisabled('btn-group #sb-edit') === true) {
return;
}
var selected = $(".lib-selected");
selected.each(function (i, el) {
var data = $(el).data("aData");
if (data.ftype === "audioclip") {
$.get(baseUrl + "library/edit-file-md/id/" + data.id, {format: "json"}, function (json) {
AIRTIME.playlist.fileMdEdit(json);
//buildEditMetadataDialog(json);
});
} else if (data.ftype === "playlist" || data.ftype === "block") {
AIRTIME.playlist.fnEdit(data.id, data.ftype, baseUrl + 'playlist/edit');
AIRTIME.playlist.validatePlaylistElements();
} else if (data.ftype === "stream") {
AIRTIME.playlist.fnEdit(data.id, data.ftype, baseUrl + 'webstream/edit');
}
});
});
mod.createToolbarDropDown();
}
}; };
return AIRTIME; return AIRTIME;

View File

@ -558,6 +558,19 @@ var AIRTIME = (function(AIRTIME) {
} }
function handleAjaxError(r) {
// If the request was denied due to permissioning
if (r.status === 403) {
// Hide the processing div
$("#library_display_wrapper").find(".dt-process-rel").hide();
$.getJSON( "ajax/library_placeholders.json", function( data ) {
$('#library_empty_text').text($.i18n._(data.unauthorized));
}) ;
$('#library_empty').show();
}
}
oTable = $libTable.dataTable( { oTable = $libTable.dataTable( {
// put hidden columns at the top to insure they can never be visible // put hidden columns at the top to insure they can never be visible
@ -689,13 +702,14 @@ var AIRTIME = (function(AIRTIME) {
getUsabilityHint(); getUsabilityHint();
$.ajax( { $.ajax({
"dataType": 'json', "dataType": 'json',
"type": "POST", "type": "POST",
"url": sSource, "url": sSource,
"data": aoData, "data": aoData,
"success": fnCallback "success": fnCallback,
} ); "error": handleAjaxError,
});
}, },
"fnRowCallback": AIRTIME.library.fnRowCallback, "fnRowCallback": AIRTIME.library.fnRowCallback,
"fnCreatedRow": function( nRow, aData, iDataIndex ) { "fnCreatedRow": function( nRow, aData, iDataIndex ) {