* applied Patrick Colemans patch
authorWilfried Göesgens <willi@citadel.org>
Mon, 3 Dec 2007 22:59:14 +0000 (22:59 +0000)
committerWilfried Göesgens <willi@citadel.org>
Mon, 3 Dec 2007 22:59:14 +0000 (22:59 +0000)
* patched CtdlDoIHavePermissionToPostInThisRoom to enable anonymous posting to non-aide-only post rooms
* first starts on bug 209 to get more versatile email interfaces.

citadel/ipcdef.h
citadel/modules/imap/imap_misc.c
citadel/msgbase.c
citadel/msgbase.h

index 438dc4dcb1dda323975cebb73afa4342b3bfdb19..2073589ee72e9f4ab1d485cb58cb8aca1c14e142 100644 (file)
@@ -58,6 +58,8 @@ extern "C" {
 #define QR2_SELFLIST   2               /* Self-service mailing list mgmt   */
 #define QR2_COLLABDEL  4               /* Anyone who can post can delete   */
 #define QR2_SUBJECTREQ 8               /* Subject strongly recommended */
+#define QR2_SUBSONLY   16              /* Listservice Subscribers may post */
+#define QR2_MODERATED  32              /* Listservice aide has to permit posts  */
 
 #define US_NEEDVALID   1               /* User needs to be validated       */
 #define US_EXTEDIT     2               /* Always use external editor       */
index 3b7d95834314ddbb8d60596ab4373e36b1eb0702..f0f93627ef3af50ed7d7ddebf4f31d1a57c771ab 100644 (file)
@@ -467,7 +467,7 @@ void imap_append(int num_parms, char *parms[]) {
        /* 
         * Can we post here?
         */
-       ret = CtdlDoIHavePermissionToPostInThisRoom(buf, sizeof buf);
+       ret = CtdlDoIHavePermissionToPostInThisRoom(buf, sizeof buf, POST_LOGGED_IN);
 
        if (ret) {
                /* Nope ... print an error message */
index c75cd1e26a134da1146fecc797e4cfa798edf559..15957eb24d18de53dd865a253b4a9a440b900b88 100644 (file)
@@ -3090,13 +3090,31 @@ struct CtdlMessage *CtdlMakeMessage(
  * room.  Returns a *CITADEL ERROR CODE* and puts a message in errmsgbuf, or
  * returns 0 on success.
  */
-int CtdlDoIHavePermissionToPostInThisRoom(char *errmsgbuf, size_t n) {
+int CtdlDoIHavePermissionToPostInThisRoom(char *errmsgbuf, size_t n, int PostPublic) {
        int ra;
 
-       if (!(CC->logged_in)) {
+       if (!(CC->logged_in) && 
+           (PostPublic == POST_LOGGED_IN)) {
                snprintf(errmsgbuf, n, "Not logged in.");
                return (ERROR + NOT_LOGGED_IN);
        }
+       else if (PostPublic == CHECK_EXISTANCE) {
+               return (0);
+       }
+       else if (!(CC->logged_in)) {
+               if ((CC->room.QRflags & QR_READONLY)) {
+                       snprintf(errmsgbuf, n, "Not logged in.");
+                       return (ERROR + NOT_LOGGED_IN);
+               }
+               else if (CC->room.QRflags2 & QR2_SUBSONLY){
+                       ////TODO: check if we're in that list...
+                       return (0);
+               }
+               else if (CC->room.QRflags2 & QR2_MODERATED) {
+                       return (0);
+               }
+
+       }
 
        if ((CC->user.axlevel < 2)
            && ((CC->room.QRflags & QR_MAILBOX) == 0)) {
@@ -3160,6 +3178,9 @@ struct recptypes *validate_recipients(char *supplied_recipients) {
        int invalid;
        struct ctdluser tempUS;
        struct ctdlroom tempQR;
+       struct ctdlroom tempQR2;
+       int err = 0;
+       char errmsg[SIZ];
        int in_quotes = 0;
 
        /* Initialize */
@@ -3268,11 +3289,31 @@ struct recptypes *validate_recipients(char *supplied_recipients) {
                                }
                                else if ( (!strncasecmp(this_recp, "room_", 5))
                                      && (!getroom(&tempQR, &this_recp_cooked[5])) ) {
-                                       ++ret->num_room;
-                                       if (!IsEmptyStr(ret->recp_room)) {
-                                               strcat(ret->recp_room, "|");
+
+                                       /* Save room so we can restore it later */
+                                       tempQR2 = CC->room;
+                                       CC->room = tempQR;
+                                       
+                                       /* Check permissions to send mail to this room */
+                                       err = CtdlDoIHavePermissionToPostInThisRoom(errmsg, sizeof errmsg, POST_EXTERNAL);
+                                       //// TODO: CHECK_EXISTANCE for dict_tcp
+                                       if (err)
+                                       {
+                                               cprintf("%d %s\n", err, errmsg);
+                                               ++ret->num_error;
+                                               invalid = 1;
+                                       } 
+                                       else {
+                                               ++ret->num_room;
+                                               if (!IsEmptyStr(ret->recp_room)) {
+                                                       strcat(ret->recp_room, "|");
+                                               }
+                                               strcat(ret->recp_room, &this_recp_cooked[5]);
                                        }
-                                       strcat(ret->recp_room, &this_recp_cooked[5]);
+                                       
+                                       /* Restore room in case something needs it */
+                                       CC->room = tempQR2;
+
                                }
                                else {
                                        ++ret->num_error;
@@ -3433,7 +3474,7 @@ void cmd_ent0(char *entargs)
 
        /* first check to make sure the request is valid. */
 
-       err = CtdlDoIHavePermissionToPostInThisRoom(errmsg, sizeof errmsg);
+       err = CtdlDoIHavePermissionToPostInThisRoom(errmsg, sizeof errmsg, POST_LOGGED_IN);
        if (err)
        {
                cprintf("%d %s\n", err, errmsg);
index ca0e6f0ac83129d4024955fb3a456a94ed0f4dd6..61800c76f9cabcdc9ad986a5105f2322a9865335 100644 (file)
@@ -148,7 +148,13 @@ int CtdlOutputPreLoadedMsg(struct CtdlMessage *,
 );
 int CtdlCopyMsgsToRoom(long *msgnum, int num_msgs, char *dest);
 int CtdlDoIHavePermissionToDeleteMessagesFromThisRoom(void);
-int CtdlDoIHavePermissionToPostInThisRoom(char *errmsgbuf, size_t n);
+
+enum {
+       POST_LOGGED_IN,
+       POST_EXTERNAL,
+       CHECK_EXISTANCE
+};
+int CtdlDoIHavePermissionToPostInThisRoom(char *errmsgbuf, size_t n, int PostPublic);
 
 
 /* values for which_set */