When editing a group (adding or removing members from a group) on the /buddylist/UID/buddies/groups/edit page, form submission throws the following error:

    * warning: Invalid argument supplied for foreach() in .../drupal/modules/contrib/buddylist/buddylist.module on line 640.
    * warning: Invalid argument supplied for foreach() in .../drupal/modules/contrib/buddylist/buddylist.module on line 640.

This is becaue the form submission iterates through the submitted form, expecting only arrays of buddies, but it also gets the 'submit' button and the form ID string.

The fix is pretty simple, so I'm not going to form a patch. Just change the buddylist_edit_groups_table_submit function to be:

function buddylist_edit_groups_table_submit($form_id, $form_values) {

  $userid = $form_values['user'];

  unset($form_values['user']);

  unset($form_values['form_id']); // add this line
  unset($form_values['submit']); // add this line
  

  foreach ($form_values as $buddy => $groups) {

    foreach ($groups as $label_id => $checked) {

    	if ($checked == 0) {

    		buddylist_buddygroup_remove_buddy($userid, $buddy, $label_id);

    	}

    	else {

    		buddylist_buddygroup_add_buddy($userid, $buddy, $label_id);

    	}

    }

  }



  drupal_set_message(t('%buddy groups saved.', buddylist_translation()));

}

Comments

fago’s picture

Status: Needs review » Closed (duplicate)