Make delete from channel library a configurable permission

This commit is contained in:
Calvin Montgomery 2017-01-23 21:16:39 -08:00
parent bec55bc3d1
commit b0ff4d5ef0
4 changed files with 9 additions and 10 deletions

View file

@ -2,7 +2,7 @@
"author": "Calvin Montgomery", "author": "Calvin Montgomery",
"name": "CyTube", "name": "CyTube",
"description": "Online media synchronizer and chat", "description": "Online media synchronizer and chat",
"version": "3.28.0", "version": "3.28.1",
"repository": { "repository": {
"url": "http://github.com/calzoneman/sync" "url": "http://github.com/calzoneman/sync"
}, },

View file

@ -41,7 +41,8 @@ const DEFAULT_PERMISSIONS = {
drink: 1.5, // Use the /d command drink: 1.5, // Use the /d command
chat: 0, // Send chat messages chat: 0, // Send chat messages
chatclear: 2, // Use the /clear command chatclear: 2, // Use the /clear command
exceedmaxitems: 2 // Exceed maximum items per user limit exceedmaxitems: 2, // Exceed maximum items per user limit
deletefromchannellib: 2 // Delete channel library items
}; };
function PermissionsModule(channel) { function PermissionsModule(channel) {
@ -336,11 +337,7 @@ PermissionsModule.prototype.canSetPermissions = function (actor) {
}; };
PermissionsModule.prototype.canUncache = function (actor) { PermissionsModule.prototype.canUncache = function (actor) {
if (actor instanceof User) { return this.hasPermission(actor, "deletefromchannellib");
actor = actor.account;
}
return actor.effectiveRank >= 2;
}; };
PermissionsModule.prototype.canExceedMaxItemsPerUser = function (actor) { PermissionsModule.prototype.canExceedMaxItemsPerUser = function (actor) {
@ -379,7 +376,8 @@ PermissionsModule.prototype.loadUnregistered = function () {
drink: 0, // Use the /d command drink: 0, // Use the /d command
chat: 0, // Send chat messages chat: 0, // Send chat messages
chatclear: 2, // Use the /clear command chatclear: 2, // Use the /clear command
exceedmaxitems: 2 // Exceed max items per user exceedmaxitems: 2, // Exceed max items per user
deletefromchannellib: 2
}; };
for (var key in perms) { for (var key in perms) {

View file

@ -893,7 +893,7 @@ Callbacks = {
generator: function (item, page, index) { generator: function (item, page, index) {
var li = makeSearchEntry(item, false); var li = makeSearchEntry(item, false);
if(hasPermission("playlistadd")) { if(hasPermission("playlistadd") || hasPermission("deletefromchannellib")) {
addLibraryButtons(li, item.id, data.source); addLibraryButtons(li, item.id, data.source);
} }
$(li).appendTo($("#library")); $(li).appendTo($("#library"));

View file

@ -1121,7 +1121,7 @@ function addLibraryButtons(li, id, source) {
}) })
.appendTo(btns); .appendTo(btns);
} }
if(CLIENT.rank >= 2 && source === "library") { if(hasPermission("deletefromchannellib") && source === "library") {
$("<button/>").addClass("btn btn-xs btn-danger") $("<button/>").addClass("btn btn-xs btn-danger")
.html("<span class='glyphicon glyphicon-trash'></span>") .html("<span class='glyphicon glyphicon-trash'></span>")
.click(function() { .click(function() {
@ -1992,6 +1992,7 @@ function genPermissionsEditor() {
makeOption("Lock/unlock playlist", "playlistlock", modleader, CHANNEL.perms.playlistlock+""); makeOption("Lock/unlock playlist", "playlistlock", modleader, CHANNEL.perms.playlistlock+"");
makeOption("Shuffle playlist", "playlistshuffle", standard, CHANNEL.perms.playlistshuffle+""); makeOption("Shuffle playlist", "playlistshuffle", standard, CHANNEL.perms.playlistshuffle+"");
makeOption("Clear playlist", "playlistclear", standard, CHANNEL.perms.playlistclear+""); makeOption("Clear playlist", "playlistclear", standard, CHANNEL.perms.playlistclear+"");
makeOption("Delete from channel library", "deletefromchannellib", standard, CHANNEL.perms.deletefromchannellib+"");
addDivider("Polls"); addDivider("Polls");
makeOption("Open/Close poll", "pollctl", modleader, CHANNEL.perms.pollctl+""); makeOption("Open/Close poll", "pollctl", modleader, CHANNEL.perms.pollctl+"");