Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
There's a code variable_get('comment_form_location_' . $node->type, COMMENT_FORM_BELOW) == COMMENT_FORM_BELOW
but no line in readme about this setting
A code in ajax_comments_reply() and ajax_comments_edit() depends on this and throws warnings about undefined $form
Suppose better remove a form with title Add new comment by changin'
// Delete any extra forms we've created
//$commands[] = ajax_command_invoke('[id^=comment-wrapper-] form.comment-form', 'remove');
$commands[] = ajax_command_invoke('.comment-form', 'remove');
Also ajax_comments_reply() does not check for $cid in line
// Add the new form
$commands[] = ajax_command_after('#comment-wrapper-' . $cid . ' >.comment', $form);
Comment | File | Size | Author |
---|---|---|---|
#19 | comment_form_separate_page_3.patch | 16.72 KB | inolen |
#20 | comment_form_separate_page_3_no_ws.patch | 7.56 KB | inolen |
#13 | comment_form_separate_page_2.patch | 5.9 KB | inolen |
#6 | 1278186-ajax-comment-form.patch | 15.97 KB | andypost |
#6 | 1278186-whitespace.patch | 13.1 KB | andypost |
Comments
Comment #1
inolen CreditAttribution: inolen commentedI'm not really sure about the variable_get() problem, I had rolled that in my patch originally from this patch:
http://drupal.org/node/1243412
As far as the change in ajax_comments_reply(), I'm not sure why you want to do that, that also gets rid of the main reply form at the bottom. Maybe that is desirable, but then you'd need to add a cancel button so you can have that form added back (otherwise once it's removed, it's gone until the user refreshes the page).
When you say check for $cid, do you mean that it's never validated to be an actual comment id?
Comment #2
andypostThe main problem with comment form is UX mess - you have to have the comment form at the bottom of comments list otherwise everything does not work! So there's no ability to use other values except COMMENT_FORM_BELOW
The proper ways to fix it is allow loading form for reply links and node link "Add new comment" and not depend of visibility of comment form. Also module should cares about existing comment form on the page but not the current way.
About $cid I mean that ajax_comments_reply() checks for reply in
but all other code ignores it, suppose, this $cid is always none-empty because this function is called for reply link so CID is always has value
Comment #3
inolen CreditAttribution: inolen commentedI'll look into it in just a minute.
I've never used the comment form location options.
Comment #4
inolen CreditAttribution: inolen commentedI think this should fix everything up for you.
Comment #5
andypostGreat!
last else should be
elsif (isset($form)) {
because we need sure that comments open or admin (UID=1)
Comment #6
andypost1278186-ajax-comment-form.patch
This patch fixes hook_menu to mimic more closely comment.module
Also optimizes loading entities by menu. Suppose ajax_comments_reply() should have more checks like http://dgo.to/a/comment_reply does
PS: sorry fro fuzz in patch, current code has a lot of trailing whitespace,
1278186-whitespace.patch cleans up a whitespace problems
1278186-interdiff.txt - contains only changes of code
Comment #7
inolen CreditAttribution: inolen commentedI agree with fixing up the hook_menu() calls for sure (I tried to rip that code out of the reply and delete callbacks), however, why do we need to check with isset($form)?
Should we perhaps just make it early out if $node->comment != COMMENT_NODE_OPEN? I.E. change:
to
We shouldn't need to validate the $form based on user permissions at that point.
I'll re-roll the original patch with the user access stuff tonight :)
Comment #8
inolen CreditAttribution: inolen commentedComment #9
andypostPlease take a look at
1278186-interdiff.txt
I think return nothing is not a good idea but it worksAlso what are you thinking about code-style? suppose module should pass Coder module review
Comment #10
inolen CreditAttribution: inolen commentedI'm not very familiar with what the standard approach is here.
Will attempting to generate a form like you're doing when the node is closed for comments generate something useful, i.e. an error saying "comments are closed" or will it just return an empty form?
Comment #11
andypostI think user should get access denied, probably standard message. Currently users are confused by no-reaction from clicking a link
Comment #12
inolen CreditAttribution: inolen commentedJust got home and tested, it looks like the buttons aren't displayed at all when the comments are closed and comment_form_submit() checks for the flag, so I don't think we even need to test for this.
Comment #13
inolen CreditAttribution: inolen commentedAfter quickly looking at the permissions, it looks like we do a lot less checking than the normal comments module, that'll have to be worked on in another patch.
Re-rolled the patch, removed the checks for COMMENT_NODE_OPEN because they don't seem to be needed as I said above, and removed some unused globals from the edit function.
We shouldn't add anything else to this patch, but does fix all the issues regarding COMMENT_FORM_BELOW/COMMENT_FORM_SEPARATE_PAGE?
Comment #14
andypostMake sense to split access thing into other issue except hook_menu()
1278186-interdiff.txt
This part should be in patch
Why not just use %comment as menu wildcard as core's comment module does?
Can you setup your editor to remove trailing whitespaces?
Comment #15
inolen CreditAttribution: inolen commentedAndypost,
I don't think changing just the edit menu item for this patch makes sense.
We can start a new issue and fix reply, edit and delete.
Edit: Doh on the trailing whitespace. New install, need to change that.
Comment #16
andypostOK, but a bit of clean-up should be done in this issue
This change should be reflected in ajax_comments_reply()
Comment #17
inolen CreditAttribution: inolen commentedWhat about that isn't reflected in ajax_comments_reply? Should we set a default value of NULL for $cid?
Comment #18
andypostThey should be $node (node object) and $pid = NULL (like core's comment)
Comment #19
inolen CreditAttribution: inolen commentedWent through and made the menus mimic comment's menus, then added the same permissions checks as comment. Also, I changed the 'delivery callback' of the menu items so we don't have to wrap our results in ajax_deliver anymore (was nice for returning error codes).
Downside is, I was an idiot and fixed my trailing whitespace in the middle of this work which turned the patch into an absolute mammoth.
To summarize what was done:
- AJAXify 'add new comment' button to insert comment form on pages where the comment form is not presented by default
- Made comment id in reply menu item optional (^^^)
- Don't add/replace default comment form on reply if one wasn't there by default
- Fixed permissions for reply/edit/delete callbacks
- Made page callbacks used ajax_deliver as the delivery callback
Comment #20
inolen CreditAttribution: inolen commentedFound the -w flag for git diff, this should be much easier to review :)
Comment #21
andypostGreat! It works and code is much cleaner for now!
let's commit this one (#20) and proceed with white-space clean-up at #1286126: Cleanup code and respect code-style
Comment #22
acouch CreditAttribution: acouch commentedthank to both of you for work and patience. i committed the patch at (#20).
Comment #23
andypostGreat! Now code looks more clean and sane, thanx for taking maintainership