- return; /* don't modify anything if we are read-only */
-
- switch (flag)
- {
- case M_DELETE:
-
-#ifdef USE_IMAP
- if (ctx && ctx->magic == M_IMAP)
- if (mutt_bit_isset (((IMAP_DATA *)ctx->data)->capabilities, ACL) \
- && !mutt_bit_isset(((IMAP_DATA *)ctx->data)->rights,IMAP_ACL_DELETE))
- return;
-#endif
-
- if (bf)
- {
- if (!h->deleted && !ctx->readonly)
- {
- h->deleted = 1;
- if (upd_ctx) ctx->deleted++;
-#ifdef USE_IMAP
- /* deleted messages aren't treated as changed elsewhere so that the
- * purge-on-sync option works correctly. This isn't applicable here */
- if (ctx && ctx->magic == M_IMAP)
- {
- h->changed = 1;
- if (upd_ctx) ctx->changed = 1;
- }
-#endif
- }
- }
- else if (h->deleted)
- {
- h->deleted = 0;
- if (upd_ctx)
- {
- ctx->deleted--;
- if (h->appended)
- ctx->appended--;
- }
- h->appended = 0; /* when undeleting, also reset the appended flag */
-#ifdef USE_IMAP
- /* see my comment above */
- if (ctx->magic == M_IMAP)
- {
- h->changed = 1;
- if (upd_ctx) ctx->changed = 1;
- }
-#endif
- /*
- * If the user undeletes a message which is marked as
- * "trash" in the maildir folder on disk, the folder has
- * been changed, and is marked accordingly. However, we do
- * _not_ mark the message itself changed, because trashing
- * is checked in specific code in the maildir folder
- * driver.
- */
- if (ctx->magic == M_MAILDIR && upd_ctx && h->trash)
- ctx->changed = 1;
- }
- break;
-
- case M_APPENDED:
- if (bf)
- {
- if (!h->appended)
- {
- h->appended = 1;
- if (upd_ctx) ctx->appended++;
- }
- }
- break;
-
- case M_PURGED:
- if (bf)
- {
- if (!h->purged)
- h->purged = 1;
- }
- else if (h->purged)
- h->purged = 0;
- break;
-
- case M_NEW:
-
-#ifdef USE_IMAP
- if (ctx && ctx->magic == M_IMAP)
- if (mutt_bit_isset (((IMAP_DATA *)ctx->data)->capabilities, ACL) \
- && !mutt_bit_isset(((IMAP_DATA *)ctx->data)->rights,IMAP_ACL_SEEN))
- return;
-#endif
-
- if (bf)
- {
- if (h->read || h->old)
- {
- h->old = 0;
- if (upd_ctx) ctx->new++;
- if (h->read)
- {
- h->read = 0;
- if (upd_ctx) ctx->unread++;
- }
- h->changed = 1;
- if (upd_ctx) ctx->changed = 1;
- }
- }
- else if (!h->read)
- {
- if (!h->old)
- if (upd_ctx) ctx->new--;
- h->read = 1;
- if (upd_ctx) ctx->unread--;
- h->changed = 1;
- if (upd_ctx) ctx->changed = 1;
+ return; /* don't modify anything if we are read-only */
+
+ switch (flag) {
+ case M_DELETE:
+
+ if (!mx_acl_check (ctx, ACL_DELETE))
+ return;
+
+ if (bf) {
+ if (!h->deleted && !ctx->readonly) {
+ h->deleted = 1;
+ if (upd_ctx)
+ ctx->deleted++;
+ /* deleted messages aren't treated as changed elsewhere so that the
+ * purge-on-sync option works correctly. This isn't applicable here */
+ if (ctx && ctx->magic == M_IMAP) {
+ h->changed = 1;
+ if (upd_ctx)
+ ctx->changed = 1;
+ }