If you have multiple pending invitations (when using approval required) displayed at buddylist/[uid]/buddies/requests you always accept/decline the first user in the table regardless of which accept/decline submit button you click. In otherwords, the form always gets submitted with the requester/requestee hidden values of the first form on the page. I tried this in FireFox 1.5 and IE7 with same behavior. I changed the code to give each form a unqiue id thinking that might be the problem and that had no effect. Looking at the forms in the table it appears that they are correct with each having th correct hidden values but the submit is always the first forms values.

Any ideas?

Thx.

Comments

dldege’s picture

StatusFileSize
new63.69 KB

Actually looking at it again I think it has to do with the hidden form token values which are the same for both all the forms. I assume this means on the server side that drupal will get some cached version of this form (the first on on the page) that matches the token and use that which has the wrong hidden values.

I'll test this and see.

dldege’s picture

Couldn't get it working - but I did mess up the tokens enough to get validation errors.

dldege’s picture

I'm still stuck with this - can anyone help or shed some insight?

p_palmer’s picture

I can confirm this...

The error in the buddylist.module code is at these functions....

  • buddylist_pending_requester_list(&$account)
  • buddylist_pending_requested_list(&$account)
  • buddylist_pending_requester_list(&$account)
  • buddylist_pending_requested_list(&$account)

It seems to be around this repeated snippet of code...

    while ($row = db_fetch_object($result)) {
      $html_row = array();
      $html_row[] = theme('username', $row);
      $html_row[] = drupal_get_form('buddylist_request_cancel_', buddylist_request_cancel_form($row->uid, $account->uid));
      $html_rows[] = $html_row;
      $rownum++;
    }

Looking at the above, the drupal_get_form() is called to create a form for each user in the list, but passes EXACTLY the same $form_id for each iteration.

Form.inc expects unique $form_ids per page.

When form.inc handles the submit, as all of the forms are the same name, we always get back the first form, or in other words user on the list.

Therefore, this section of the code is probably invalid and requires rework to stop this 'feature' happening for all the above functions !!!

Can anyone else help further this on?

dldege’s picture

You are right with the duplicate forms. I'm running out of time to get a solution so I'm going to do something that is not form based similar to buddy list add and remove. In other words the pending list table will have a link for each user to 'cancel' which will then display a confirm_form() with the correct values. This should be pretty easy and I can reuse the existing form submit handler for cancel operation.

I'll post the code when it works - I won't be able to make it a patch at this time since I have so many other modifications to buddylist but I'll revisit all my changes and submit patches after my project is completed.

dldege’s picture

StatusFileSize
new66.39 KB

Got it all working. The forms are gone and replaced with links for accept/deny/cancel. Those links go to pages with appropriate confirm_form() forms.

Here is my buddylist.module with this change and all of my other modifications - use at your own risk :)

p_palmer’s picture

i have been using buddylist.module,v 1.48.2.40 2007/01/05 18:49:23 fago Exp $

thanks but your version throws a wobbly under 4.7.5, i can see it is for dru 5.0 only (e.g. drupal_mail calls)

unfortunately, there are too many changes for me to decypher what is what, maybe someone can backport?

anymore for anymore ?

nodestroy’s picture

StatusFileSize
new8.19 KB

this solution is near to dldege´s but the rest of the module is untouched...

fago’s picture

Version: master » 5.x-1.x-dev
Status: Active » Needs work

thanks for your work.

But could you clean it up a bit more, before it goes in please:

  • I wasn't able to apply your patch. If you use eclipse for generating patches please select the project as patch root
  • remove unwanted changes from the patch, like new lines (@@ -453,6 +473,7 @@) and commented out code
  • there are some tabs in the code, e.g. before $items[]
  • also each array key should have its own line -> callback arguments
  • there is also no weight needed for callbacks, as they aren't visible
  • buddylist_approval_form()'s name is a bit misleading now, isn't it more a part of the confirm_form now?
  • also the $requestee_uid is duplicated in its signature, as the uid is in the account object too
  • there shouldn't be a drupal_goto() in a form api submit function, use its return value. furthermore I think the best default return value would be the buddylist of the user
  • if you load the requester_account only on submit, you could load it only if the mail has to be sent too
  • you forgot to use t() inside the l() functions
  • language! please stay with the official buddylist language, there is no invitation and network but a request and a buddylist ;)

Furthermore I wondered if this issue applies to the cancel buttons to?

nodestroy’s picture

Status: Needs work » Needs review
StatusFileSize
new12.37 KB

here with the favoured changes, also including the cancel buttons ;)

fago’s picture

Title: Error accepting when there are multiple invitations » Error accepting when there are multiple requests
Status: Needs review » Needs work

thanks, this will fix a lot of bugs. however there are still some invite-phrases in there - buddylist does requests, but no invites.

dldege’s picture

The invite/invitation is what I was using in my project so when I made the original change for this bug I just used that language. I think we should introduce a mapping for request, requests, requested, etc. into buddylist_translation() so that this can be a user option.

Then the menu handlers could set their titles, etc. in the buddylist way using t('xxxxx', buddylist_translation()).

fago’s picture

yep, I agree, however this is another issue. Feel free to open one.. I'd be happy about a patch.

nodestroy’s picture

Status: Needs work » Needs review
StatusFileSize
new17.69 KB

one more, with - i hope so - correct phrases

fago’s picture

Status: Needs review » Needs work

damn, now it doesn't apply any more!
could you please reroll it against the latest code?
(there was a commit recently: http://drupal.org/cvs?commit=60462)

nodestroy’s picture

Status: Needs work » Needs review
StatusFileSize
new10.93 KB

now it should work ;)

fago’s picture

Status: Needs review » Fixed

thanks!!
Committed to 5.x and HEAD.

rbburton’s picture

Version: 5.x-1.x-dev » 4.7.x-1.x-dev
Category: bug » support
Priority: Critical » Normal

Has this been backported to 4.7?

fago’s picture

no, feel free to provide a patch..

Personally I'm concentrating on 5.x now, as I'd prefer one stable branch to two buggy branches.. However, of course any backports of fixes are welcome!

Anonymous’s picture

Status: Fixed » Closed (fixed)