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",
"name": "CyTube",
"description": "Online media synchronizer and chat",
"version": "3.28.0",
"version": "3.28.1",
"repository": {
"url": "http://github.com/calzoneman/sync"
},

View File

@ -41,7 +41,8 @@ const DEFAULT_PERMISSIONS = {
drink: 1.5, // Use the /d command
chat: 0, // Send chat messages
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) {
@ -336,11 +337,7 @@ PermissionsModule.prototype.canSetPermissions = function (actor) {
};
PermissionsModule.prototype.canUncache = function (actor) {
if (actor instanceof User) {
actor = actor.account;
}
return actor.effectiveRank >= 2;
return this.hasPermission(actor, "deletefromchannellib");
};
PermissionsModule.prototype.canExceedMaxItemsPerUser = function (actor) {
@ -379,7 +376,8 @@ PermissionsModule.prototype.loadUnregistered = function () {
drink: 0, // Use the /d command
chat: 0, // Send chat messages
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) {

View File

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

View File

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