At "Administer >> Site configuration >> Spam" if you try to configure "Content to filter" your changes aren't saved. For example, you can't enable filtering of "story", "page" or "users" content. Thus, the spam filter is only able to filter comments.

Comments

coreyp_1’s picture

Status: Active » Needs review
StatusFileSize
new1.16 KB

gotta love the form api...

coltrane’s picture

Title: Unable to filter "story", "page", or "users" content » Only able to filter comments

Patch corrects problem but another solution that lets system_settings_form_submit() do the variable set and delete work is to alter the content filters to use the spam namespace prefix.

foreach ($content_types as $content_type) {
        $name = $content_type['name'];
        $form['content']["spam_filter_$name"] = array( // <-- added spam_filter_
          '#type' => 'checkbox',
          '#title' => t($content_type['title']),
          '#description' => $content_type['description'],
          '#default_value' => variable_get("spam_filter_$name", (int)$content_type['default_value']),
        );
      }

This has the added value of making spam_admin_settings_form_submit() obsolete. However, the filter_types variable becomes a serialized array when using system_settings_form_submit() instead of just a comma-separated string. But, I don't see any use of filter_types anyways ... and it should really be namespaced like the rest of Spam modules variables.

Thoughts?

coltrane’s picture

luti’s picture

coltrane, what is the code in #2? I mean, where to put (use) it?

coltrane’s picture

Approach in #2 rolled into a patch. Need feedback whether filter_types is used.

luti’s picture

coltrane, it doesn't seem to work for me - whatever I select or deselect doesn't remain like that, but I always get the selections as before the update of this module.

Are you sure the whole spam_admin_settings_form_submit() function declaration shall be removed?! It was not so in your post above (#2)...

I have noticed in your patch that I have 1 more line between (lines 904 and 905 in my file):

    }
  }

and (lines 907 and 908 in my file):

  variable_set('filter_types', implode(',', $filter_types));
/* TODO The 'op' element in the form values is deprecated.

which is (line 906 in my file):
$filter_types = is_array($filter_types) ? implode(',', $filter_types) : $filter_types;

and it seems the content type selection works for me (at least, it remains selected as I do it, checking and unchecking certain types...).

gnassar’s picture

Status: Needs review » Fixed

Patch in #5 confirmed. Nice job!

As for filter_types, a grep through the module tree finds nothing outside of those occurrences in spam.module, so seems safe to delete for now.

Committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.