fixes #683 - Support disabling playback per user

This commit is contained in:
Luke Pulverenti 2014-01-22 21:19:04 -05:00
parent b6992659d1
commit 1fbbb143fe
9 changed files with 63 additions and 54 deletions

View File

@ -385,7 +385,7 @@ a.itemTag:hover {
background-size: cover;
background-position: center 15%;
background-repeat: no-repeat;
height: 580px;
height: 600px;
border-bottom: 1px solid #111;
position: relative;
}

View File

@ -79,14 +79,14 @@
ApiClient.sendWebSocketMessage("Context", vals.join('|'));
}
if (MediaPlayer.canPlay(item)) {
Dashboard.getCurrentUser().done(function (user) {
if (MediaPlayer.canPlay(item, user)) {
$('#playButtonContainer', page).show();
} else {
$('#playButtonContainer', page).hide();
}
Dashboard.getCurrentUser().done(function (user) {
var editImagesHref = user.Configuration.IsAdministrator ? 'edititemimages.html' + window.location.search : null;
$('#itemImage', page).html(LibraryBrowser.getDetailImageHtml(item, editImagesHref));

View File

@ -35,6 +35,30 @@
$('#editButtonContainer', page).hide();
}
if (MediaPlayer.canPlay(item, user) && item.LocationType !== "Offline" && item.LocationType !== "Virtual") {
var url = MediaPlayer.getPlayUrl(item);
if (url) {
$('#playExternalButtonContainer', page).show();
$('#playButtonContainer', page).hide();
} else {
$('#playButtonContainer', page).show();
$('#playExternalButtonContainer', page).hide();
}
$('#btnPlayExternal', page).attr('href', url || '#');
} else {
$('#playButtonContainer', page).hide();
$('#playExternalButtonContainer', page).hide();
}
if (item.LocalTrailerCount && item.LocationType !== "Offline" && user.Configuration.EnableMediaPlayback) {
$('#trailerButtonContainer', page).show();
} else {
$('#trailerButtonContainer', page).hide();
}
});
if (item.LocationType == "Offline") {
@ -65,31 +89,6 @@
$('#missingIndicator', page).hide();
}
if (MediaPlayer.canPlay(item) && item.LocationType !== "Offline" && item.LocationType !== "Virtual") {
var url = MediaPlayer.getPlayUrl(item);
if (url) {
$('#playExternalButtonContainer', page).show();
$('#playButtonContainer', page).hide();
} else {
$('#playButtonContainer', page).show();
$('#playExternalButtonContainer', page).hide();
}
$('#btnPlayExternal', page).attr('href', url || '#');
} else {
$('#playButtonContainer', page).hide();
$('#playExternalButtonContainer', page).hide();
}
if (item.LocalTrailerCount && item.LocationType !== "Offline") {
$('#trailerButtonContainer', page).show();
} else {
$('#trailerButtonContainer', page).hide();
}
$(".autoNumeric").autoNumeric('init');
setPeopleHeader(page, item);

View File

@ -2527,7 +2527,7 @@
var buttonCount = 0;
if (MediaPlayer.canPlay(item)) {
if (MediaPlayer.canPlay(item, currentUser)) {
var resumePosition = (item.UserData || {}).PlaybackPositionTicks || 0;
var onPlayClick = 'LibraryBrowser.showPlayMenu(this, \'' + item.Id + '\', \'' + item.Type + '\', \'' + item.MediaType + '\', ' + resumePosition + ');return false;';
@ -2541,7 +2541,7 @@
}
}
if (item.LocalTrailerCount) {
if (item.LocalTrailerCount && currentUser.Configuration.EnableMediaPlayback) {
html += '<button type="button" data-mini="true" data-inline="true" data-icon="video" data-iconpos="notext" class="btnPlayTrailer" data-itemid="' + item.Id + '" title="Play Trailer" style="' + buttonMargin + '">Play Trailer</button>';
buttonCount++;
}

View File

@ -144,14 +144,14 @@
ApiClient.sendWebSocketMessage("Context", vals.join('|'));
}
if (MediaPlayer.canPlay(item)) {
Dashboard.getCurrentUser().done(function (user) {
if (MediaPlayer.canPlay(item, user)) {
$('#playButtonContainer', page).show();
} else {
$('#playButtonContainer', page).hide();
}
Dashboard.getCurrentUser().done(function (user) {
if (user.Configuration.IsAdministrator && item.LocationType !== "Offline") {
$('#editButtonContainer', page).show();
} else {

View File

@ -64,16 +64,16 @@
ApiClient.sendWebSocketMessage("Context", vals.join('|'));
}
if (MediaPlayer.canPlay(item)) {
$('.status', page).html('Status:&nbsp;&nbsp;&nbsp;' + item.Status);
Dashboard.getCurrentUser().done(function (user) {
if (MediaPlayer.canPlay(item, user)) {
$('#playButtonContainer', page).show();
} else {
$('#playButtonContainer', page).hide();
}
$('.status', page).html('Status:&nbsp;&nbsp;&nbsp;' + item.Status);
Dashboard.getCurrentUser().done(function (user) {
if (user.Configuration.IsAdministrator && item.LocationType !== "Offline") {
$('#deleteButtonContainer', page).show();
} else {

View File

@ -999,7 +999,11 @@
}, 4000);
}
self.canPlay = function (item) {
self.canPlay = function (item, user) {
if (!user.Configuration.EnableMediaPlayback) {
return false;
}
if (item.LocationType == "Virtual") {
return false;

View File

@ -22,6 +22,7 @@
$('#chkDisabled', page).checked(user.Configuration.IsDisabled || false).checkboxradio("refresh");
$('#chkIsHidden', page).checked(user.Configuration.IsHidden || false).checkboxradio("refresh");
$('#chkEnableRemoteControlOtherUsers', page).checked(user.Configuration.EnableRemoteControlOfOtherUsers || false).checkboxradio("refresh");
$('#chkEnableMediaPlayback', page).checked(user.Configuration.EnableMediaPlayback || false).checkboxradio("refresh");
$('#chkManageLiveTv', page).checked(user.Configuration.EnableLiveTvManagement || false).checkboxradio("refresh");
@ -55,6 +56,7 @@
user.Configuration.IsDisabled = $('#chkDisabled', page).checked();
user.Configuration.EnableRemoteControlOfOtherUsers = $('#chkEnableRemoteControlOtherUsers', page).checked();
user.Configuration.EnableLiveTvManagement = $('#chkManageLiveTv', page).checked();
user.Configuration.EnableMediaPlayback = $('#chkEnableMediaPlayback', page).checked();
var userId = getParameterByName("userId");

View File

@ -29,24 +29,28 @@
<div id="featureAccessFields">
<h2>Feature Access</h2>
<div>
<input type="checkbox" id="chkEnableRemoteControlOtherUsers" name="chkEnableRemoteControlOtherUsers" />
<input type="checkbox" id="chkEnableMediaPlayback" name="chkEnableMediaPlayback" data-mini="true" />
<label for="chkEnableMediaPlayback">Allow media playback</label>
</div>
<div>
<input type="checkbox" id="chkEnableRemoteControlOtherUsers" name="chkEnableRemoteControlOtherUsers" data-mini="true" />
<label for="chkEnableRemoteControlOtherUsers">Allow this user to remote control other users</label>
</div>
<div>
<input type="checkbox" id="chkManageLiveTv" name="chkManageLiveTv" />
<label for="chkManageLiveTv">Manage live tv recordings</label>
<input type="checkbox" id="chkManageLiveTv" name="chkManageLiveTv" data-mini="true" />
<label for="chkManageLiveTv">Allow this user to schedule tv recordings</label>
</div>
<br />
</div>
<div id="accessControlDiv" style="display: none" data-role="collapsible">
<h2>Advanced Control</h2>
<div id="fldIsEnabled" style="margin: 1em 0 2em;">
<input type="checkbox" id="chkDisabled" name="chkDisabled" />
<input type="checkbox" id="chkDisabled" name="chkDisabled" data-mini="true" />
<label for="chkDisabled">Disable this user</label>
<div class="fieldDescription">If disabled the server will not allow any connections from this user. Existing connections will be abruptly terminated.</div>
</div>
<p id="fldIsHidden">
<input type="checkbox" id="chkIsHidden" name="chkIsHidden" />
<input type="checkbox" id="chkIsHidden" name="chkIsHidden" data-mini="true" />
<label for="chkIsHidden">Hide this user from login screens</label>
</p>
@ -54,10 +58,10 @@
<br />
<ul data-role="listview" class="ulForm">
<li>
<button type="submit" data-theme="b" data-icon="check">
<button type="submit" data-theme="b" data-icon="check" data-mini="true">
Save
</button>
<button type="button" onclick="history.back();" data-icon="delete">
<button type="button" onclick="history.back();" data-icon="delete" data-mini="true">
Cancel
</button>
</li>