Skip to content

Commit b9a9482

Browse files
committed
Merge pull request #142 from dgets/roominfo-tidying
Roominfo tidying; added timestamps & fixed extra line in text blobs
2 parents 69243b7 + 2da33a4 commit b9a9482

3 files changed

Lines changed: 61 additions & 9 deletions

File tree

load/dexpress.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ wholist = {
8686
* NOTE: This needs to be less of a monolith
8787
*/
8888
list_long : function(ul) {
89-
var timeon;
90-
9189
//time to do this the right way
9290
bbs.log_key("w");
9391

load/dperroom.js

Lines changed: 58 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,38 @@ roomData = {
8181
console.putmsg(green + high_intensity + "\nStaying the same for " +
8282
"now . . .\n");
8383
}
84+
},
85+
/*
86+
* summary:
87+
* If the current user is the sysop/cosysop, allows editing of the
88+
* room's info to set a moderator
89+
*/
90+
changeRoomModerator : function() {
91+
var newMod = new String();
92+
93+
if (user.security.level >= 80) {
94+
//go ahead and set the moderator for this room/sub
95+
console.putmsg(yellow + high_intensity + "Changing moderator for " +
96+
user.cursub + "\nNew Moderator: " + green);
97+
newMod = console.getstr("New Moderator: ", 40); //max user alias len
98+
99+
while (system.matchuser(newMod) == 0) {
100+
console.putmsg(yellow + newMod + " not found.\n");
101+
newMod = console.getstr("New Moderator: ", 40);
102+
}
103+
104+
roomSettings[bbs.cursub_code].moderator = newMod;
105+
} else {
106+
//add some error logging here at some point, as well; this could be
107+
//a security concern at some point
108+
console.putmsg(red + high_intensity + "Your security level is not" +
109+
" high enough to change room moderator.\nMust we log this?\n");
110+
throw new dDocException("changeRoomModerator() Exception",
111+
"Not high enough security to change room moderator", 1);
112+
}
113+
114+
roomData.fileIO.saveRoomInfo();
115+
84116
},
85117
/*
86118
* summary:
@@ -90,6 +122,28 @@ roomData = {
90122
changeRoomInfo : function() {
91123
var infoTxt = new Array();
92124

125+
if (roomSettings[bbs.cursub_code].moderator != user.alias) {
126+
try {
127+
this.changeRoomModerator();
128+
} catch (e) {
129+
if (userSettings.debug.misc) {
130+
console.putmsg(yellow + "Unable to change room mod!\n" +
131+
"Msg: " + red + high_intensity + e.message + "\n");
132+
}
133+
134+
throw new dDocException("changeRoomInfo() Exception",
135+
"Exception in changeRoomModerator()", 1);
136+
//that should keep anyone from getting beyond here that
137+
//shouldn't be
138+
}
139+
}
140+
141+
var nao = new Date();
142+
roomSettings[bbs.cursub_code].infoCreationDate =
143+
nao.getDate() + nao.toUTCString();
144+
145+
this.displayRoomInfoHdr();
146+
93147
if ((infoTxt = poast.getTextBlob(this.maxInfoLines)) != null) {
94148
//save the new room info
95149
/* try {
@@ -101,10 +155,12 @@ roomData = {
101155
"\n");
102156
}*/
103157
roomSettings[bbs.cursub_code].info = infoTxt;
104-
roomSettings[bbs.cursub_code].moderator = user.alias;
158+
//this will be set in a separate method handling moderators
159+
//roomSettings[bbs.cursub_code].moderator = user.alias;
105160
//of course this will have to be replaced with better code to
106161
//make sure the person is authorized, sysop modification of it,
107162
//etc etc etc (re: above)
163+
108164
//roomSettings[bbs.cursub_code].infoCreationDate =
109165
roomData.fileIO.saveRoomInfo();
110166
}
@@ -117,12 +173,7 @@ roomData = {
117173
displayRoomInfo : function() {
118174
this.displayRoomInfoHdr();
119175

120-
try {
121-
roomSettings[bbs.cursub_code] = snagRoomInfoBlob();
122-
} catch (e) {
123-
console.putmsg("Unable to snagRoomInfoBlob(): " + e.name +
124-
"\nMsg: " + e.message + "\n");
125-
}
176+
roomSettings[bbs.cursub_code] = roomData.fileIO.snagRoomInfoBlob();
126177

127178
if (roomSettings[bbs.cursub_code].info.length == 0) {
128179
//or should we be looking for null here?

load/dpoast.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ poast = {
138138
"\nlength: " + mTxt.length + "\nBeing returned\n");
139139
}
140140

141+
//this is an ugly hack fix, but whatever; it's quick and
142+
//works for now (issue #136 on github)
143+
mTxt.pop();
141144
return mTxt;
142145
break;
143146
/* case 'X':

0 commit comments

Comments
 (0)