$Log$
+ Revision 572.4 2000/06/04 02:30:56 ajc
+ * CtdlForEachMessage() now returns the number of messages processed. It also
+ accepts the MSGS_EQ mode, for targeting a specific message number (useful for
+ determining whether the specified message actually exists in a room).
+ * Completed the server side of the moderation system (serv_moderate.c module
+ which implements the MMOD command)
+
Revision 572.3 2000/06/03 05:47:57 ajc
* Replaced most of the very repetitive and very redundant access level checks
in most commands with a single API call: CtdlAccessLevelCheck()
Fri Jul 10 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
* Initial CVS import
-
/*
* API function to perform an operation for each qualifying message in the
- * current room.
+ * current room. (Returns the number of messages processed.)
*/
-void CtdlForEachMessage(int mode, long ref,
+int CtdlForEachMessage(int mode, long ref,
int moderation_level,
char *content_type,
struct CtdlMessage *compare,
struct cdbdata *cdbfr;
long *msglist = NULL;
int num_msgs = 0;
+ int num_processed = 0;
long thismsg;
struct SuppMsgInfo smi;
struct CtdlMessage *msg;
num_msgs = cdbfr->len / sizeof(long);
cdb_free(cdbfr);
} else {
- return; /* No messages at all? No further action. */
+ return 0; /* No messages at all? No further action. */
}
|| ((mode == MSGS_LAST) && (a >= (num_msgs - ref)))
|| ((mode == MSGS_FIRST) && (a < ref))
|| ((mode == MSGS_GT) && (thismsg > ref))
+ || ((mode == MSGS_EQ) && (thismsg == ref))
)
) {
- CallBack(thismsg);
+ if (CallBack) CallBack(thismsg);
+ ++num_processed;
}
}
phree(msglist); /* Clean up */
+ return num_processed;
}
#define MSGS_FIRST 3
#define MSGS_LAST 4
#define MSGS_GT 5
+#define MSGS_EQ 6
/*
* Flags which may be passed to CtdlSaveMsgPointerInRoom()
void AdjRefCount(long, int);
void simple_listing(long);
int CtdlMsgCmp(struct CtdlMessage *msg, struct CtdlMessage *template);
-void CtdlForEachMessage(int mode, long ref,
+int CtdlForEachMessage(int mode, long ref,
int moderation_level,
char *content_type,
struct CtdlMessage *compare,
void cmd_mmod(char *argbuf) {
long msgnum;
int newlevel;
+ struct SuppMsgInfo smi;
+ int is_message_in_room;
/* user must be at least a Room Aide to moderate */
if (CtdlAccessCheck(ac_room_aide)) return;
if ( (newlevel < (-63)) || (newlevel > (+63)) ) {
cprintf("%d %d is not a valid moderation level.\n",
- newlevel, ERROR+ILLEGAL_VALUE);
+ ERROR+ILLEGAL_VALUE, newlevel);
+ return;
}
- cprintf("%d FIXME ... actually do this!!!!!!!!\n", OK);
+ is_message_in_room = CtdlForEachMessage(MSGS_EQ, msgnum, (-127),
+ NULL, NULL, NULL);
+ if (!is_message_in_room) {
+ cprintf("%d Message %ld is not in this room.\n",
+ ERROR+ILLEGAL_VALUE, msgnum);
+ return;
+ }
+
+ GetSuppMsgInfo(&smi, msgnum);
+ smi.smi_mod = newlevel;
+ PutSuppMsgInfo(&smi);
+
+ cprintf("%d Message %ld is moderated to %d\n", OK, msgnum, newlevel);
}
The command returns ERROR if it fails; otherwise, it returns OK followed by a
number representing the current state of the flag.
+
+ MMOD (MODerate a Message)
+
+ Set or change the moderation level of a message. The two parameters passed
+to this command should be the message number and the desired moderation level.
+Please refer to the "moderation.txt" document for a description of some
+commonly used moderation levels.
+ If the command succeeds, OK is returned. If the specified message does not
+exist in the current room, or if the specified moderation level is not within
+acceptable limits, ERROR+ILLEGAL_VALUE is returned. This command requires at
+least Room Aide access; if the calling user is not an Aide, or a Room Aide for
+the current room, ERROR+HIGHER_ACCESS_REQUIRED is returned.