-
- Downloads
Merge branch 'dd_msg_reader_permission_check_optimizations' into 'master'
DD Msg Reader: Permission check optimizations See merge request !346
No related branches found
No related tags found
... | @@ -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,13 +8872,18 @@ function DigDistMsgReader_EditExistingMessageOldWay(pMsgbase, pOrigMsgHdr, pMsgI | ... | @@ -8877,13 +8872,18 @@ 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; | ||
var msgbase = new MsgBase(this.subBoardCode); | if (!canDelete) | ||
if (msgbase.open()) | |||
{ | { | ||
if (msgbase.cfg != null) | var msgbase = new MsgBase(this.subBoardCode); | ||
canDelete = canDelete || ((msgbase.cfg.settings & SUB_DEL) == SUB_DEL); | if (msgbase.open()) | ||
msgbase.close(); | { | ||
if (msgbase.cfg != null) | |||
canDelete = canDelete || ((msgbase.cfg.settings & SUB_DEL) == SUB_DEL); | |||
|
|||
msgbase.close(); | |||
} | |||
} | } | ||
return canDelete; | return canDelete; | ||
} | } | ||
... | @@ -8891,13 +8891,17 @@ function DigDistMsgReader_CanDelete() | ... | @@ -8891,13 +8891,17 @@ function DigDistMsgReader_CanDelete() |
// 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; | ||
var msgbase = new MsgBase(this.subBoardCode); | if (!canDelete) | ||
if (msgbase.open()) | |||
{ | { | ||
if (msgbase.cfg != null) | var msgbase = new MsgBase(this.subBoardCode); | ||
canDelete = canDelete || ((msgbase.cfg.settings & SUB_DELLAST) == SUB_DELLAST); | if (msgbase.open()) | ||
msgbase.close(); | { | ||
if (msgbase.cfg != null) | |||
canDelete = canDelete || ((msgbase.cfg.settings & SUB_DELLAST) == SUB_DELLAST); | |||
msgbase.close(); | |||
} | |||
} | } | ||
return canDelete; | return canDelete; | ||
} | } | ||
... | @@ -8905,13 +8909,17 @@ function DigDistMsgReader_CanDeleteLastMsg() | ... | @@ -8905,13 +8909,17 @@ function DigDistMsgReader_CanDeleteLastMsg() |
// 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; | ||
var msgbase = new MsgBase(this.subBoardCode); | if (!canEdit) | ||
if (msgbase.open()) | |||
{ | { | ||
if (msgbase.cfg != null) | var msgbase = new MsgBase(this.subBoardCode); | ||
canEdit = canEdit || ((msgbase.cfg.settings & SUB_EDIT) == SUB_EDIT); | if (msgbase.open()) | ||
msgbase.close(); | { | ||
if (msgbase.cfg != null) | |||
canEdit = canEdit || ((msgbase.cfg.settings & SUB_EDIT) == SUB_EDIT); | |||
msgbase.close(); | |||
} | |||
} | } | ||
return canEdit; | return canEdit; | ||
} | } | ||
... | @@ -8919,13 +8927,18 @@ function DigDistMsgReader_CanEdit() | ... | @@ -8919,13 +8927,18 @@ function DigDistMsgReader_CanEdit() |
// 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; | ||
var msgbase = new MsgBase(this.subBoardCode); | if (!canQuote) | ||
if (msgbase.open()) | |||
{ | { | ||
if (msgbase.cfg != null) | var msgbase = new MsgBase(this.subBoardCode); | ||
canQuote = canQuote || ((msgbase.cfg.settings & SUB_QUOTE) == SUB_QUOTE); | if (msgbase.open()) | ||
msgbase.close(); | { | ||
if (msgbase.cfg != null) | |||
canQuote = canQuote || ((msgbase.cfg.settings & SUB_QUOTE) == SUB_QUOTE); | |||
msgbase.close(); | |||
} | |||
} | } | ||
return canQuote; | return canQuote; | ||
} | } | ||
... | @@ -21869,14 +21882,14 @@ function getExternalEditorQuoteWrapCfgFromSCFG(pEditorCode) | ... | @@ -21869,14 +21882,14 @@ function getExternalEditorQuoteWrapCfgFromSCFG(pEditorCode) |
// Return value: The new string | // Return value: The new string | ||
function chgCharInStr(pStr, pCharIndex, pNewText) | function chgCharInStr(pStr, pCharIndex, pNewText) | ||
{ | { | ||
if (typeof(pStr) != "string") | if (typeof(pStr) != "string") | ||
return ""; | return ""; | ||
if ((pCharIndex < 0) || (pCharIndex >= pStr.length)) | if ((pCharIndex < 0) || (pCharIndex >= pStr.length)) | ||
return pStr; | return pStr; | ||
if (typeof(pNewText) != "string") | if (typeof(pNewText) != "string") | ||
return pStr; | return pStr; | ||
return (pStr.substr(0, pCharIndex) + pNewText + pStr.substr(pCharIndex+1)); | return (pStr.substr(0, pCharIndex) + pNewText + pStr.substr(pCharIndex+1)); | ||
} | } | ||
// Given a string of attribute characters, this function inserts the control code | // Given a string of attribute characters, this function inserts the control code | ||
... | ... |