* CtdlForEachMessage() now returns the number of messages processed. It also
authorArt Cancro <ajc@citadel.org>
Sun, 4 Jun 2000 02:30:59 +0000 (02:30 +0000)
committerArt Cancro <ajc@citadel.org>
Sun, 4 Jun 2000 02:30:59 +0000 (02:30 +0000)
  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)

citadel/ChangeLog
citadel/msgbase.c
citadel/msgbase.h
citadel/serv_moderate.c
citadel/techdoc/session.txt

index fd655c3597b58f91595cdc5647a0a1def3aa1b6f..6cd3344ddeb28a2b3f8a31de7de8588980d08268 100644 (file)
@@ -1,4 +1,11 @@
  $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()
@@ -1899,4 +1906,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
        * Initial CVS import 
-
index 1b819f8e833fcc05bb95fe08d4da7a61574864c0..8b3fac01db3de576cb7a2d8964caacddd3f78c09 100644 (file)
@@ -265,9 +265,9 @@ int CtdlMsgCmp(struct CtdlMessage *msg, struct CtdlMessage *template) {
 
 /*
  * 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,
@@ -279,6 +279,7 @@ void CtdlForEachMessage(int mode, long ref,
        struct cdbdata *cdbfr;
        long *msglist = NULL;
        int num_msgs = 0;
+       int num_processed = 0;
        long thismsg;
        struct SuppMsgInfo smi;
        struct CtdlMessage *msg;
@@ -296,7 +297,7 @@ void CtdlForEachMessage(int mode, long ref,
                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. */
        }
 
 
@@ -358,12 +359,15 @@ void CtdlForEachMessage(int mode, long ref,
                                       || ((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;
 }
 
 
index 90be1d3af37a4aa11f6cd79be67c45db6cb9302c..8daaaec721adfb8dcd349d9bbdf6441f5c93d621 100644 (file)
@@ -8,6 +8,7 @@
 #define MSGS_FIRST      3
 #define MSGS_LAST       4
 #define MSGS_GT         5
+#define MSGS_EQ                6
 
 /*
  * Flags which may be passed to CtdlSaveMsgPointerInRoom()
@@ -70,7 +71,7 @@ void PutSuppMsgInfo(struct SuppMsgInfo *);
 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,
index c9e08c7d2ea85dd24a22e33e54a02dd6df3dc71c..efa9b97ac92807c357383ac221229d9b177e0fce 100644 (file)
@@ -41,6 +41,8 @@
 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;
@@ -50,10 +52,23 @@ void cmd_mmod(char *argbuf) {
 
        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);
 }
 
 
index a0354843e8fb6dc4f1cc88128effbb0a9cbbeb71..fcecb3d82bf51991945fd066784f473fa65e5c20 100644 (file)
@@ -1803,4 +1803,16 @@ Any value other than 0 or 1 will not change the flag, only report its state.
 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.