Panels has support for a comment form that has a different form_id than the normal comment form. This patch will allow (if you are using panels) Mollom to configure and control the spam that comes in on panels_comment_form.

CommentFileSizeAuthor
mollom_panels_comment.patch2 KBpopulist

Comments

creaoy’s picture

I tried this patch but it is not enough to get mollom work with comment panels form.

First I had problem with constantly invalid captcha.

I started to debug this function:
function mollom_expand_element($element, $edit, &$form_state, $form) {

As the result there is no $form_state['mollom'] data. Any data about mollom from panels_comment_form can be found here:
$form_state['clicked_button']['#post']['mollom']

I had to do such changes:

  if (!empty($form_state['mollom'])) {
    $mollom_state = $form_state['mollom'];
  }
  // ... or from data posted by the user. In that case we validate that the correct
  // form_id and user session ID is used...
  elseif (!empty($edit['session_id']) && ($cache = cache_get($edit['session_id'], 'cache_mollom')) 
    && $cache->data['#form_id'] === $form_state['values']['form_id'] && $cache->data['#user_session_id'] === session_id()) {
    $mollom_state = $cache->data;
  } elseif ($form_state['values']['form_id'] == 'panels_comment_form') {
    if (!empty($form_state['clicked_button']['#post']['mollom'])) {
      $mollom_state = $form_state['clicked_button']['#post']['mollom'];
    }
  }

But after that I had another problem. I could enter any CAPTCHA and it would be accepted.

If you look at elseif in the code above:

  elseif (!empty($edit['session_id']) && ($cache = cache_get($edit['session_id'], 'cache_mollom')) 
    && $cache->data['#form_id'] === $form_state['values']['form_id'] && $cache->data['#user_session_id'] === session_id()) {

You will see part of it "$cache->data['#user_session_id'] === session_id()".

For some reason session_id in cache and current session_id have different values.
Is this problem with caching? Or panels comment form makes session id regenerate?

I removed this condition and captcha works great but I understand this is not correct way. Any ideas how to solve this?

dave reid’s picture

Title: Panels Comment Form Support » Integrate with Panels comments
Status: Needs review » Postponed
dave reid’s picture

Status: Postponed » Closed (duplicate)

Marking as an official duplicate of #245682: Enable use of Mollom for any form. Keep posted to that issue for progress.