| | @@ -543,13 +543,13 @@ |
| 543 | 543 | int modPending; /* True if awaiting moderation */ |
| 544 | 544 | const char *zModAction; /* Moderation action or NULL */ |
| 545 | 545 | int isModerator; /* TRUE if user is the moderator */ |
| 546 | 546 | const char *zMime; /* MIME Type */ |
| 547 | 547 | Blob attach; /* Content of the attachment */ |
| 548 | | - int fShowContent = 0; |
| 548 | + int fShowContent = 0; /* True to emit the content */ |
| 549 | 549 | int bUserIsOwner = 0; /* True if pAttach->zUser is login_name() */ |
| 550 | | - int showDelMenu = 0; |
| 550 | + int showDelMenu = 0; /* True to enable delete option */ |
| 551 | 551 | const char *zLn = P("ln"); |
| 552 | 552 | |
| 553 | 553 | login_check_credentials(); |
| 554 | 554 | if( !g.perm.RdTkt && !g.perm.RdWiki ){ |
| 555 | 555 | login_needed(g.anon.RdTkt || g.anon.RdWiki); |
| | @@ -592,11 +592,12 @@ |
| 592 | 592 | } |
| 593 | 593 | zDate = db_text(0, "SELECT datetime(%.12f)", pAttach->rDate); |
| 594 | 594 | |
| 595 | 595 | if( P("confirm") && |
| 596 | 596 | ((zForumPost |
| 597 | | - && (g.perm.Admin || (g.perm.AttachForum && bUserIsOwner))) || |
| 597 | + && ((bUserIsOwner && g.perm.AttachForum) || |
| 598 | + forumpost_may_close())) || |
| 598 | 599 | (zTktUuid && g.perm.WrTkt) || |
| 599 | 600 | (zWikiName && g.perm.WrWiki) || |
| 600 | 601 | (zTNUuid && g.perm.Write && g.perm.WrWiki)) |
| 601 | 602 | ){ |
| 602 | 603 | /* Delete attachment. */ |
| | @@ -604,13 +605,14 @@ |
| 604 | 605 | char *zNewDate; |
| 605 | 606 | Blob manifest; |
| 606 | 607 | Blob cksum; |
| 607 | 608 | const char *zFile = zName; |
| 608 | 609 | |
| 609 | | - if( !g.perm.Admin && !bUserIsOwner ){ |
| 610 | | - webpage_error("Only admins can delete other users' attachments from " |
| 611 | | - "forum posts."); |
| 610 | + if( !bUserIsOwner ){ |
| 611 | + if( zForumPost ? !forumpost_may_close() : !g.perm.Admin ){ |
| 612 | + webpage_error("Only admins can delete other users' attachments."); |
| 613 | + } |
| 612 | 614 | } |
| 613 | 615 | db_begin_transaction(); |
| 614 | 616 | blob_zero(&manifest); |
| 615 | 617 | for(i=n=0; zFile[i]; i++){ |
| 616 | 618 | if( zFile[i]=='/' || zFile[i]=='\\' ) n = i; |
| 617 | 619 | |