forked from mybb/mybb
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes several bugs with attachments at once (mybb#3926)
* This commit fixes several bugs with attachments at once: 1. When the "Post Thread" or "Post Reply" button was clicked after an attachment had been selected with the "Choose Files" button, the attachment was not saved. 2. When "Add Attachment" was clicked after a previous attachment had been removed via AJAX and a new attachment had been selected with the "Choose Files" button, the new attachment was not saved. I reported this issue here: https://community.mybb.com/thread-227178.html 3. When Javascript was disabled and "Remove", "Unapprove", or "Approve" was clicked, the corresponding action was not performed. This bug was reported in issue mybb#3675. These problems were caused by: 1. Various typos. Correcting the typos resolves the problem: 1.1. A typo - already noted in issue mybb#3886 - in the conditionals in editpost.php, newreply.php, and newthread.php (singular should be plural): `$_FILES['attachment']` should be `$_FILES['attachments']` 1.2. A typo in two conditionals in editpost.php (as noted in issue mybb#3675): `$mybb->input['submit']` should be `$mybb->input['submitbutton']` 2. The setting in jscripts/post.js of the `attachmentaid` input when removing an attachment, which, when the new attachment was submitted, caused those same conditionals as in 1.1 to fail due to the test: `!$mybb->get_input('attachmentaid', MyBB::INPUT_INT)` Removing that test resolves the problem without any side-effects. An alternative was to unset `attachmentaid` in post.js after the removal operation completed, however, it seems better to delete code than to add it. 3. The lack of a value for the `attachmentaid` and `attachmentact` inputs. This is fixed in this commit by: 3.1. Adjusting the `name` property of the remove, approve, and unapprove submit buttons such that the attachment ID is appended after an underscore. 3.2. Adding a function `detect_attachmentact()` which detects when an input with such a name is present, extracts the attachment ID from it, and then sets the missing values for `attachmentaid` and `attachmentact`. * Apply suggestions from code review Co-Authored-By: Euan <[email protected]> * Unset attachment[aid/act] in post.js after removing an attachment. In the first commit in this PR, I wrote: An alternative was to unset `attachmentaid` in post.js after the removal operation completed, however, it seems better to delete code than to add it. In hindsight, it seems best to make this change on top of the previous one, and to in addition unset `attachmentact`, to prevent incorrect signalling to server-side code. * Enhances "Remove" attachment support. * Provides support for existing themes which have not yet changed their templates to mirror the changes we've just made to the 'post_attachments_attachment_remove' template. * Provides support for fading out the removed attachment with Javascript when it is unapproved. * Simplified the support in post.js for 3rd-party themes. * Updated template 'post_attachments_attachment_unapproved'. It had hard-coded HTML for the "Remove" button, such that the recent changes we've made to that button's "name" attribute in the 'post_attachments_attachment_remove' template weren't being reflected. * Also regenerate header in editpost.php when removing an attachment. As caught by @yuliu here: mybb#3926 (comment) * Save attachments on "Preview Post" and "Save as Draft". * Replace mod queue in $header rather than regen $header. In editpost.php, when an attachment is removed or (un)approved and Javascript is not enabled. * Removes header regen from editpost.php. Instead, blanks the header's moderation queue in global.php when the current page is editpost.php. * Removes a redundant line in global.php. Co-authored-by: Euan <[email protected]>
- Loading branch information
1 parent
465419b
commit 80cba4a
Showing
7 changed files
with
63 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters