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

Update logic for deciding if user can delete/edit entries

Local sysop can always deleted/edit entries (now).
Fixed checking of can_edit() return value (string or true), fixed issue #425
as reported by Craig Hendricks (thank you)
parent 8a9553f8
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
...@@ -1298,7 +1298,7 @@ function browse(list) ...@@ -1298,7 +1298,7 @@ function browse(list)
var prompt = ""; var prompt = "";
if(!options.add_ars || user.compare_ars(options.add_ars)) if(!options.add_ars || user.compare_ars(options.add_ars))
prompt += "~Add, "; prompt += "~Add, ";
if(list.length && can_edit(list[current])) if(list.length && can_edit(list[current]) === true)
prompt += "~Edit, ~Remove, "; prompt += "~Edit, ~Remove, ";
console.mnemonics(prompt + "~Download, ~Sort, ~Format, ~Quit, ~Help ~?"); console.mnemonics(prompt + "~Download, ~Sort, ~Format, ~Quit, ~Help ~?");
var key = console.getkey(K_UPPER); var key = console.getkey(K_UPPER);
...@@ -1310,7 +1310,7 @@ function browse(list) ...@@ -1310,7 +1310,7 @@ function browse(list)
list = orglist.slice(); list = orglist.slice();
continue; continue;
case 'E': case 'E':
if(!list[current] || !can_edit(list[current])) { if(!list[current] || can_edit(list[current]) !== true) {
console_beep(); console_beep();
continue; continue;
} }
...@@ -1328,7 +1328,7 @@ function browse(list) ...@@ -1328,7 +1328,7 @@ function browse(list)
continue; continue;
case KEY_DEL: case KEY_DEL:
case 'R': case 'R':
if(!list[current] || !can_edit(list[current])) { if(!list[current] || can_edit(list[current]) !== true) {
console_beep(); console_beep();
continue; continue;
} }
...@@ -1718,7 +1718,7 @@ function view(list, current) ...@@ -1718,7 +1718,7 @@ function view(list, current)
} }
prompt += ", "; prompt += ", ";
} }
if(can_edit(bbs)) if(can_edit(bbs) === true)
prompt += "~Edit, ~Remove, "; prompt += "~Edit, ~Remove, ";
if(user.is_sysop) if(user.is_sysop)
prompt += "~JSON, "; prompt += "~JSON, ";
...@@ -1808,7 +1808,7 @@ function view(list, current) ...@@ -1808,7 +1808,7 @@ function view(list, current)
break; break;
case KEY_DEL: case KEY_DEL:
case 'R': case 'R':
if(!can_edit(list[current])) { if(can_edit(list[current]) !== true) {
console_beep(); console_beep();
continue; continue;
} }
...@@ -1889,6 +1889,8 @@ function can_edit(bbs) ...@@ -1889,6 +1889,8 @@ function can_edit(bbs)
{ {
if(!bbs) if(!bbs)
return "not an entry"; return "not an entry";
if(user.is_sysop)
return true;
if(bbs.imported) { if(bbs.imported) {
return "Cannot edit imported entries"; return "Cannot edit imported entries";
} }
...@@ -1994,7 +1996,7 @@ function edit_array(title, arr, props, max_lens, prop_descs, max_array_len) ...@@ -1994,7 +1996,7 @@ function edit_array(title, arr, props, max_lens, prop_descs, max_array_len)
function edit(bbs) function edit(bbs)
{ {
var allowed = can_edit(bbs); var allowed = can_edit(bbs);
if(allowed != true) { if(allowed !== true) {
alert(allowed); alert(allowed);
return false; return false;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment