* Moved message deletion into the CtdlRoomAccess() API. The
authorArt Cancro <ajc@citadel.org>
Sat, 27 Jan 2007 04:30:39 +0000 (04:30 +0000)
committerArt Cancro <ajc@citadel.org>
Sat, 27 Jan 2007 04:30:39 +0000 (04:30 +0000)
  old function DoIHavePermissionToDeleteMessagesFromThisRoom() is now a
  simple wrapper around CtdlRoomAccess().
* This gives us the ability to query arbitrary room/user combinations, not
  just "this user, this room."  It also paves the way for the ability to
  grant "delete privileges" to any user for any room in the future.
* IMAP ACL now uses this feature to set or clear the "t" flag.  Observed
  that Thunderbird now activates or deactivates the Delete button for each
  folder based on the "t" flag.

citadel/imap_acl.c
citadel/ipcdef.h
citadel/msgbase.c
citadel/room_ops.c

index 8b3e465c27cafa4c7196434027325f0037aa9b53..cda6df09d37a13de4b9f332c73618aeb192fafd4 100644 (file)
@@ -109,6 +109,9 @@ void imap_acl_flags(char *rights, int ra)
                /* k - create mailboxes in this hierarchy */
 
                /* t - delete messages (set/clear \Deleted flag) */
+               if (ra & UA_DELETEALLOWED) {
+                       strcat(rights, "t");
+               }
 
                /* a - administer (perform SETACL/DELETEACL/GETACL/LISTRIGHTS) */
                /* x - delete mailbox (DELETE mailbox, old mailbox name in RENAME) */
index 5e3330c44a96a8f356a3415630b5ae66fe580f29..e3f8a374b2fc285516b357e2eb1cc670332545bf 100644 (file)
@@ -80,6 +80,7 @@ extern "C" {
 #define UA_ZAPPED               16
 #define UA_POSTALLOWED         32
 #define UA_ADMINALLOWED                64
+#define UA_DELETEALLOWED       128
 
 #ifdef __cplusplus
 }
index a5f2b89b064b53b1ba0e23113c4e988178990c3d..255672e97360fbdefbbf1c5989ea1f40af48ddf8 100644 (file)
@@ -3637,18 +3637,15 @@ int CtdlDeleteMessages(char *room_name,         /* which room */
  * the current room (returns 1 for yes, 0 for no)
  */
 int CtdlDoIHavePermissionToDeleteMessagesFromThisRoom(void) {
-       getuser(&CC->user, CC->curr_user);
-       if ((CC->user.axlevel < 6)
-           && (CC->user.usernum != CC->room.QRroomaide)
-           && ((CC->room.QRflags & QR_MAILBOX) == 0)
-           && (!(CC->internal_pgm))) {
-               return(0);
-       }
-       return(1);
+       int ra;
+       CtdlRoomAccess(&CC->room, &CC->user, &ra, NULL);
+       if (ra & UA_DELETEALLOWED) return(1);
+       return(0);
 }
 
 
 
+
 /*
  * Delete message from current room
  */
index 107cfc64b418a3bb4258c17887b55fa70af7b308..9a2a11ad039f37dd3bd84ccfe3cdc7c57a66899a 100644 (file)
@@ -65,7 +65,7 @@ void CtdlRoomAccess(struct ctdlroom *roombuf, struct ctdluser *userbuf,
        /* Force the properties of the Aide room */
        if (!strcasecmp(roombuf->QRname, config.c_aideroom)) {
                if (userbuf->axlevel >= 6) {
-                       retval = UA_KNOWN | UA_GOTOALLOWED | UA_POSTALLOWED;
+                       retval = UA_KNOWN | UA_GOTOALLOWED | UA_POSTALLOWED | UA_DELETEALLOWED;
                } else {
                        retval = 0;
                }
@@ -104,13 +104,14 @@ void CtdlRoomAccess(struct ctdlroom *roombuf, struct ctdluser *userbuf,
        }
 
        /* For mailbox rooms, also check the namespace */
+       /* Also, mailbox owners can delete their messages */
        if (roombuf->QRflags & QR_MAILBOX) {
                if (userbuf->usernum == atol(roombuf->QRname)) {
-                       retval = retval | UA_KNOWN | UA_GOTOALLOWED | UA_POSTALLOWED;
+                       retval = retval | UA_KNOWN | UA_GOTOALLOWED | UA_POSTALLOWED | UA_DELETEALLOWED;
                }
                /* An explicit match means the user belongs in this room */
                if (vbuf.v_flags & V_ACCESS) {
-                       retval = retval | UA_KNOWN | UA_GOTOALLOWED | UA_POSTALLOWED;
+                       retval = retval | UA_KNOWN | UA_GOTOALLOWED | UA_POSTALLOWED | UA_DELETEALLOWED;
                }
        }
 
@@ -170,7 +171,7 @@ void CtdlRoomAccess(struct ctdlroom *roombuf, struct ctdluser *userbuf,
        if ( (userbuf->axlevel >= 6)
           || (userbuf->usernum == roombuf->QRroomaide)
           ) {
-               retval = retval | UA_ADMINALLOWED;
+               retval = retval | UA_ADMINALLOWED | UA_DELETEALLOWED;
        }
 
 NEWMSG:        /* By the way, we also check for the presence of new messages */