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-size: cover;
background-position: center 15%; background-position: center 15%;
background-repeat: no-repeat; background-repeat: no-repeat;
height: 580px; height: 600px;
border-bottom: 1px solid #111; border-bottom: 1px solid #111;
position: relative; position: relative;
} }

View File

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

View File

@ -35,6 +35,30 @@
$('#editButtonContainer', page).hide(); $('#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") { if (item.LocationType == "Offline") {
@ -65,31 +89,6 @@
$('#missingIndicator', page).hide(); $('#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'); $(".autoNumeric").autoNumeric('init');
setPeopleHeader(page, item); setPeopleHeader(page, item);

View File

@ -2527,7 +2527,7 @@
var buttonCount = 0; var buttonCount = 0;
if (MediaPlayer.canPlay(item)) { if (MediaPlayer.canPlay(item, currentUser)) {
var resumePosition = (item.UserData || {}).PlaybackPositionTicks || 0; var resumePosition = (item.UserData || {}).PlaybackPositionTicks || 0;
var onPlayClick = 'LibraryBrowser.showPlayMenu(this, \'' + item.Id + '\', \'' + item.Type + '\', \'' + item.MediaType + '\', ' + resumePosition + ');return false;'; 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>'; 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++; buttonCount++;
} }

View File

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

View File

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

View File

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

View File

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

View File

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