Skip to content
Snippets Groups Projects
Commit 22eeb410 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Merge branch 'dd_msg_reader_permission_check_optimizations' into 'master'

DD Msg Reader: Permission check optimizations

See merge request !346
parents 41540513 ec8712f1
Branches
Tags
2 merge requests!463MRC mods by Codefenix (2024-10-20),!346DD Msg Reader: Permission check optimizations
...@@ -172,11 +172,6 @@ ...@@ -172,11 +172,6 @@
   
"use strict"; "use strict";
   
// TODO: To make the new-to-you scan faster, Digital Man said checking messagebase.last_msg against the user's new
// scan pointer for that sub is the optimization to do
// TODO: In the message list, add the ability to search with / similar to my area chooser.
   
/* Command-line arguments (in -arg=val format, or -arg format to enable an /* Command-line arguments (in -arg=val format, or -arg format to enable an
option): option):
...@@ -8877,7 +8872,11 @@ function DigDistMsgReader_EditExistingMessageOldWay(pMsgbase, pOrigMsgHdr, pMsgI ...@@ -8877,7 +8872,11 @@ function DigDistMsgReader_EditExistingMessageOldWay(pMsgbase, pOrigMsgHdr, pMsgI
// their last message). // their last message).
function DigDistMsgReader_CanDelete() function DigDistMsgReader_CanDelete()
{ {
// Deleting messages is allowed if the user is the sysop or reading personal email.
// If not, check the sub-board configuration.
var canDelete = user.is_sysop || this.readingPersonalEmail; var canDelete = user.is_sysop || this.readingPersonalEmail;
if (!canDelete)
{
var msgbase = new MsgBase(this.subBoardCode); var msgbase = new MsgBase(this.subBoardCode);
if (msgbase.open()) if (msgbase.open())
{ {
...@@ -8885,13 +8884,17 @@ function DigDistMsgReader_CanDelete() ...@@ -8885,13 +8884,17 @@ function DigDistMsgReader_CanDelete()
canDelete = canDelete || ((msgbase.cfg.settings & SUB_DEL) == SUB_DEL); canDelete = canDelete || ((msgbase.cfg.settings & SUB_DEL) == SUB_DEL);
msgbase.close(); msgbase.close();
} }
}
return canDelete; return canDelete;
} }
// For the DigDistMsgReader Class: Returns whether or not the user can delete // For the DigDistMsgReader Class: Returns whether or not the user can delete
// the last message they posted in the sub-board. // the last message they posted in the sub-board.
function DigDistMsgReader_CanDeleteLastMsg() function DigDistMsgReader_CanDeleteLastMsg()
{ {
// Sysops can delete the last message by default. If not, check the sub-board configuration.
var canDelete = user.is_sysop; var canDelete = user.is_sysop;
if (!canDelete)
{
var msgbase = new MsgBase(this.subBoardCode); var msgbase = new MsgBase(this.subBoardCode);
if (msgbase.open()) if (msgbase.open())
{ {
...@@ -8899,13 +8902,17 @@ function DigDistMsgReader_CanDeleteLastMsg() ...@@ -8899,13 +8902,17 @@ function DigDistMsgReader_CanDeleteLastMsg()
canDelete = canDelete || ((msgbase.cfg.settings & SUB_DELLAST) == SUB_DELLAST); canDelete = canDelete || ((msgbase.cfg.settings & SUB_DELLAST) == SUB_DELLAST);
msgbase.close(); msgbase.close();
} }
}
return canDelete; return canDelete;
} }
// For the DigDistMsgReader Class: Returns whether or not the user can edit // For the DigDistMsgReader Class: Returns whether or not the user can edit
// messages. // messages.
function DigDistMsgReader_CanEdit() function DigDistMsgReader_CanEdit()
{ {
// Sysops can edit by default. If not, check the sub-board configuration.
var canEdit = user.is_sysop; var canEdit = user.is_sysop;
if (!canEdit)
{
var msgbase = new MsgBase(this.subBoardCode); var msgbase = new MsgBase(this.subBoardCode);
if (msgbase.open()) if (msgbase.open())
{ {
...@@ -8913,13 +8920,18 @@ function DigDistMsgReader_CanEdit() ...@@ -8913,13 +8920,18 @@ function DigDistMsgReader_CanEdit()
canEdit = canEdit || ((msgbase.cfg.settings & SUB_EDIT) == SUB_EDIT); canEdit = canEdit || ((msgbase.cfg.settings & SUB_EDIT) == SUB_EDIT);
msgbase.close(); msgbase.close();
} }
}
return canEdit; return canEdit;
} }
// For the DigDistMsgReader Class: Returns whether or not message quoting // For the DigDistMsgReader Class: Returns whether or not message quoting
// is enabled. // is enabled.
function DigDistMsgReader_CanQuote() function DigDistMsgReader_CanQuote()
{ {
// Sysops and users reading personal email can quote by default.
// If not, check the sub-board configuration.
var canQuote = this.readingPersonalEmail || user.is_sysop; var canQuote = this.readingPersonalEmail || user.is_sysop;
if (!canQuote)
{
var msgbase = new MsgBase(this.subBoardCode); var msgbase = new MsgBase(this.subBoardCode);
if (msgbase.open()) if (msgbase.open())
{ {
...@@ -8927,6 +8939,7 @@ function DigDistMsgReader_CanQuote() ...@@ -8927,6 +8939,7 @@ function DigDistMsgReader_CanQuote()
canQuote = canQuote || ((msgbase.cfg.settings & SUB_QUOTE) == SUB_QUOTE); canQuote = canQuote || ((msgbase.cfg.settings & SUB_QUOTE) == SUB_QUOTE);
msgbase.close(); msgbase.close();
} }
}
return canQuote; return canQuote;
} }
   
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment