BadBehavior: Drupal 6 update

pobster - February 21, 2008 - 16:15
Project:Bad Behavior
Version:6.x-1.0-rc1
Component:Code
Category:support request
Priority:normal
Assigned:pobster
Status:closed
Description

Okay here's a working Badbehavior module for Drupal 6.x (using the current bad-behavior 2.0.13) based completely on the work done by Eaton and luperry upgrading the 4.7 version to 5.x (so thank them, not me - this port was easy!)

Don't bother trying to upgrade from the previous version, I didn't bother writing any upgrade code - I mean, why bother? The logs are of no interest particularly and that's all you'd be upgrading... Just start from scratch again.

...Install instructions are the same as usual, download Bad Behavior and unzip it. Then move the bad-behavior folder from the unzipped folder ('Bad-Behavior' if memory serves me correct) into the module/badbehavior folder so you end up with;

modules/badbehavior;

LICENSE.txt
README.txt
bad-behavior/ (folder)
badbehavior.info
badbehavior.install
badbehavior.module

modules/badbehavior/bad-behavior;

admin.inc.php
banned.inc.php
...etc...
...all the rest of the bad behavior files...

Pobster

AttachmentSize
badbehavior.zip3.27 KB

#1

pobster - February 25, 2008 - 13:04

edit: Use the release below instead. No sense in filling up this thread with old releases...

Pobster

#2

pobster - February 25, 2008 - 12:51

Also... If you're particularly bothered about uninstall hooks removing entries from your variable table, change the uninstall hook in badbehavior.install to;

function badbehavior_uninstall() {
  drupal_uninstall_schema('badbehavior');
  db_query("DELETE FROM {variable} WHERE name LIKE 'badbehavior_%'");
  cache_clear_all('variables', 'cache');
}

Apologies, didn't think to put it in the code before... Not that it really matters I guess! Just for neatness!

Pobster
PS. I've also included a nice hook_requirements to check that badbehavior/bad-behavior actually exists and that it contains at least core.inc.php and version.inc.php and removed the watchdog error message from hook_init (as the requirements hook negates it) and finally, I've removed the unnecessary admin/modules#description from hook_help.

AttachmentSize
badbehavior_1.zip3.59 KB

#3

pobster - March 10, 2008 - 09:40

Okay I changed the code from hook_init to hook_boot, so now badbahavior is called on *every* page request regardless of whether it's cached or not. Sorry didn't think about doing this before as I don't use page caching myself...

Tested and working...

Pobster

AttachmentSize
badbehavior.zip3.8 KB

#4

wilco - April 6, 2008 - 18:33

I'll review this module and then roll a release into the CVS.

#5

wilco - April 7, 2008 - 15:31
Version:HEAD» 6.x-1.0-rc1
Status:patch (code needs review)» closed

I've gone through it and created a RC for this patch.

Closing this ticket.

#6

pobster - April 7, 2008 - 15:47

Ah my bad, forgot about this http://drupal.org/node/140311

/**
  * Implementation of hook_menu().
  */
function badbehavior_menu() {
  $items = array();

  $items['admin/settings/badbehavior'] = array(
    'title' => 'Bad behavior',
    'description' => 'Configure automatic spam blocking for your site.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('badbehavior_settings'),
    'access arguments' => array('administer bad behavior')
  );
  $items['admin/reports/badbehavior'] = array(
    'title' => 'Bad behavior',
    'description' => 'Examine the spam blocking logs for your web site.',
    'page callback' => 'badbehavior_overview',
    'access arguments' => array('administer bad behavior')
  );
  $items['admin/reports/badbehavior/event'] = array(
    'title' => 'Details',
    'page callback' => 'badbehavior_event',
    'access arguments' => array('administer bad behavior'),
    'type' => MENU_CALLBACK);

  return $items;
}

Sorry!

Pobster
PS. Thanks for the credit in the README! ;o)

#7

wilco - April 8, 2008 - 21:30

Hey Pobster,

Glad to give props to our peeps!

I'm reviewing the code you posted versus what exists in the module. Am I missing something, I can't seem to see any difference between them. Can you help shed some light on this?

-wilco

#8

wilco - April 8, 2008 - 21:31
Status:closed» patch (code needs review)

#9

pobster - April 8, 2008 - 22:22

Hiya!

In Drupal 6.x the t() calls are unnecessary in title and description for hook_menu items. The items are automatically passed through t() now - that was the only change though! :o)

Thanks,

Pobster

#10

wilco - April 9, 2008 - 01:47

Wow! Can't believe I missed that one. Good one.

Thanks.

-wil

#11

wilco - April 9, 2008 - 01:55
Status:patch (code needs review)» closed

Rolled up a new release.

Enjoy.

This ticket is now closed.

 
 

Drupal is a registered trademark of Dries Buytaert.