Add unregistration for channel admins
This commit is contained in:
parent
27cfbcb61a
commit
4620fb2d56
|
@ -229,6 +229,14 @@ Channel.prototype.tryRegister = function(user) {
|
|||
}
|
||||
}
|
||||
|
||||
Channel.prototype.unregister = function() {
|
||||
if(Database.unregisterChannel(this.name)) {
|
||||
this.registered = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Channel.prototype.getRank = function(name) {
|
||||
var global = Auth.getGlobalRank(name);
|
||||
if(!this.registered) {
|
||||
|
|
21
database.js
21
database.js
|
@ -260,6 +260,27 @@ exports.registerChannel = function(chan) {
|
|||
return results;
|
||||
}
|
||||
|
||||
exports.unregisterChannel = function(channame) {
|
||||
var db = exports.getConnection();
|
||||
if(!db) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var query = "DROP TABLE `chan_{}_bans`, `chan_{}_ranks`, `chan_{}_library`"
|
||||
.replace(/\{\}/g, sqlEscape(channame));
|
||||
|
||||
var results = db.querySync(query);
|
||||
if(!results) {
|
||||
return false;
|
||||
}
|
||||
|
||||
query = "DELETE FROM channels WHERE name='{}'"
|
||||
.replace("{}", sqlEscape(channame));
|
||||
results = db.querySync(query);
|
||||
db.closeSync();
|
||||
return results;
|
||||
}
|
||||
|
||||
exports.lookupChannelRank = function(channame, username) {
|
||||
var db = exports.getConnection();
|
||||
if(!db) {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"author": "Calvin Montgomery",
|
||||
"name": "CyTube",
|
||||
"description": "Online media synchronizer and chat",
|
||||
"version": "1.7.1",
|
||||
"version": "1.7.2",
|
||||
"repository": {
|
||||
"url": "http://github.com/calzoneman/sync"
|
||||
},
|
||||
|
|
|
@ -9,7 +9,7 @@ The above copyright notice and this permission notice shall be included in all c
|
|||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
const VERSION = "1.7.1";
|
||||
const VERSION = "1.7.2";
|
||||
|
||||
var fs = require("fs");
|
||||
var Logger = require("./logger.js");
|
||||
|
|
29
user.js
29
user.js
|
@ -272,6 +272,35 @@ User.prototype.initCallbacks = function() {
|
|||
}
|
||||
}.bind(this));
|
||||
|
||||
this.socket.on("unregisterChannel", function() {
|
||||
if(this.channel == null) {
|
||||
return;
|
||||
}
|
||||
if(!this.channel.registered) {
|
||||
this.socket.emit("unregisterChannel", {
|
||||
success: false,
|
||||
error: "This channel is already unregistered"
|
||||
});
|
||||
}
|
||||
else if(this.rank < 10) {
|
||||
this.socket.emit("unregisterChannel", {
|
||||
success: false,
|
||||
error: "You don't have permission to unregister"
|
||||
});
|
||||
}
|
||||
else if(this.channel.unregister()) {
|
||||
this.socket.emit("unregisterChannel", {
|
||||
success: true
|
||||
});
|
||||
}
|
||||
else {
|
||||
this.socket.emit("unregisterChannel", {
|
||||
success: false,
|
||||
error: "Unregistration failed. Please see a site admin if this continues."
|
||||
});
|
||||
}
|
||||
}.bind(this));
|
||||
|
||||
this.socket.on("adm", function(data) {
|
||||
if(Rank.hasPermission(this, "acp")) {
|
||||
this.handleAdm(data);
|
||||
|
|
|
@ -75,6 +75,15 @@ Callbacks = {
|
|||
}
|
||||
},
|
||||
|
||||
unregisterChannel: function(data) {
|
||||
if(data.success) {
|
||||
alert("Channel unregistered");
|
||||
}
|
||||
else {
|
||||
alert(data.error);
|
||||
}
|
||||
},
|
||||
|
||||
updateMotd: function(data) {
|
||||
$("#motdtext").val(data.motd);
|
||||
if(data.motd != "")
|
||||
|
|
|
@ -456,6 +456,13 @@ $("#show_acl").click(function() {
|
|||
}
|
||||
});
|
||||
|
||||
$("#drop_channel").click(function() {
|
||||
var res = confirm("You are about to unregister your channel. This will PERMANENTLY delete your channel data, including ranks, bans, and library videos. This cannot be undone. Are you sure you want to continue?");
|
||||
if(res) {
|
||||
socket.emit("unregisterChannel");
|
||||
}
|
||||
});
|
||||
|
||||
function splitreEntry(str) {
|
||||
var split = [];
|
||||
var current = [];
|
||||
|
|
|
@ -644,6 +644,9 @@ function handleRankChange() {
|
|||
$("#clearplaylist").css("display", "none");
|
||||
$("#shuffleplaylist").css("display", "none");
|
||||
}
|
||||
if(RANK >= 10) {
|
||||
$("#drop_channel").parent().css("display", "");
|
||||
}
|
||||
}
|
||||
|
||||
function onWindowFocus() {
|
||||
|
|
|
@ -140,6 +140,9 @@
|
|||
<li>
|
||||
<a href="javascript:void(0)" id="show_acl">Channel Ranks</a>
|
||||
</li>
|
||||
<li style="display: none">
|
||||
<a href="javascript:void(0)" id="drop_channel">Unregister Channel</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue