From: Art Cancro Date: Sat, 27 Jan 2007 04:30:39 +0000 (+0000) Subject: * Moved message deletion into the CtdlRoomAccess() API. The X-Git-Tag: v7.86~3610 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=a875445bc9a575f2d429ad9ab09f81d47298e851;p=citadel.git * Moved message deletion into the CtdlRoomAccess() API. The 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. --- diff --git a/citadel/imap_acl.c b/citadel/imap_acl.c index 8b3e465c2..cda6df09d 100644 --- a/citadel/imap_acl.c +++ b/citadel/imap_acl.c @@ -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) */ diff --git a/citadel/ipcdef.h b/citadel/ipcdef.h index 5e3330c44..e3f8a374b 100644 --- a/citadel/ipcdef.h +++ b/citadel/ipcdef.h @@ -80,6 +80,7 @@ extern "C" { #define UA_ZAPPED 16 #define UA_POSTALLOWED 32 #define UA_ADMINALLOWED 64 +#define UA_DELETEALLOWED 128 #ifdef __cplusplus } diff --git a/citadel/msgbase.c b/citadel/msgbase.c index a5f2b89b0..255672e97 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -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 */ diff --git a/citadel/room_ops.c b/citadel/room_ops.c index 107cfc64b..9a2a11ad0 100644 --- a/citadel/room_ops.c +++ b/citadel/room_ops.c @@ -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 */