Moving from phpBB to the Drupal forum

Background

I took over development of a community-based website which was using phpBB for the forum.  The rest of the site was rather plain, but the forum was the important aspect of the site and had some decent use.  I initially installed Joomla! to handle the content of the site, but left the forum unaltered (excepting to change the theme to blend in with the rest of the site.)  Occasionally, I would attempt to tie the login for the forum with the login for Joomla!, but this just created more problems, so I had to revert back to the old way of doing things.

Eventually, I got around to using Drupal more and more and found it to be exceptional!  It has a significantly steeper learning curve, and it's not really for everyone, but once I learned my way around in it, I really enjoyed using it.  I installed a module that would allow people to login using their forum accounts (phpBBforum).  However, people being what they are, combined with Murphy's Law, this wasn't getting much use...

Then we had a new request.  Apparently facebook used to have has a 5000 friend limit (I don't use or care to use facebook at this time...)  They had lifted the 5000 limit on friends, but when posting comments, it apparently didn't allow friends 5001 and up to post (or something like that.)  The request was to allow the discussion to continue on the site.  I felt that having the discussion take place in the forum would be the ideal location (as opposed to a blog) as it would allow neater archiving an people should already be used to it.  The Facebook Connect API seemed ideal, as the facebook members could login with their facebook accounts and we could simplfy the process as much as possible (face it; every extra step you add is going to frustrate some people.)  Unfortunately, the Facebook Connect mod for phpBB isn't complete (and not recommended for production sites.)  In addition, we were having people who couldn't get into the forum (don't you love the old "I can't get in, what's wrong" comment?  I mean, it's just sooooooooo helpful in debugging!)  Since Drupal has a Facebook Connect module that, while not complete, at least is ok for production sites, I began to ponder this route.

Back when I was looking into bridging Drupal with phpBB, I became frustrated with the stance of the Drupal developers to develop their own forum rather than bridge to existing solutions.  I still question whether it should really be a part of the CMS, but then we take for granted that a blog is...  Anyway, I started looking into porting our phpBB forum to Drupal, using the phpBB2Drupal module.  While the migration wasn't completely smooth (hence the reason for this tutorial), I was impressed with the results.  It didn't take long for me to find that Drupal may actually provide a superior forum to phpBB (with the right modules installed.)

I will point out, however, that as of this writing, I have not had other members examine the Drupal forum.  It may end up getting stopped before it goes live, but I still wanted to document the procedure for the migration and getting the forum set up.

 

Beginning migration

Getting Started

The Drupal installation isn't really any different than other uses, so I won't detail that here.  You DO need to make sure you enabled the forum module in the Drupal core (and any other modules that you might need, such as upload, profile, search, poll, tracker, etc.)

Gather Required Modules

Please note that not all of these modules may be necessary for your site.  In fact, you can just enable the forum module and go with that!  I'm attempting to detail my process here to help others (and to help myself if I ever need to reinstall.)

The following is a list of modules that I added to get the forum working the way I needed:

The following improve the forum experience:

Migrating phpBB

Migrating the phpBB forum

Activate Forum Module

You will need to activate the Forum module in Drupal core.  There may be other modules you will want to activate (ie. upload, poll, profile) but Forum is required.

Once you have activated the Forum module, you will have a new content type: Forum Topic.  I would recommend going to Administer -> Content Management -> Content Types and editing the Forum Topic type.  Make sure attachments are enabled, and adjust the comment settings as follows:

Create Forum Moderator Role (Optional)

While this is optional, and could be done later, I recommend going to Administer -> User Management -> Roles and creating a role named Forum Moderator (or something along those lines.)  Be sure to give this role any appropriate permissions for moderating the forum (more permissions will be added as we progress.)

Install Initial Modules

With your Drupal installation ready, install the following modules:

and while you're at it, go ahead and install Better Formats.

Update permissions for Privatemsg (give moderators access.)

  1. Go to Administer -> Site Configuration -> Input Formats and create a new input format named something like Forum Input Format and allow it to use the BBCode filter (and any others you want) and make sure all roles have access to it.
  2. Go to Administer -> Site Configuration -> Input Formats and click the Settings tab.  Check the 'Control formats per node type' box and save.
  3. Go to Administer -> Content Management -> Content Types and edit the Forum Topic type.  Expand the Input format settings and make the default type for this node "Forum input format" or whatever you created above in step 1.

Set Migration Settings

Go to Administer -> Site Configuration -> phpBB2Drupal Settings.  This will bring up a number of settings that must be set in order to import and migrate the phpBB data.

  1. This is a very risky operation.  Your Drupal database WILL be altered, making it possible the entire site could go down.  Be sure you back things up (definitely backup your database before trying ANYTHING like this!!!)  Because of the risk, you have to set the checkbox agreeing that this is either a demo site or you are confident enough to continue.
  2. Specify the location of the phpBB database.  By default, phpBB2Drupal assumes the phpBB data is in the same database as Drupal.  I prefer using separate databases as it is cleaner, and if something goes wrong, it is less likely to damage something else.  While the phpBB database should be safe during the migration, I strongly recommend making a backup.  I also recommend importing this backup into a temporary database, if possible, to use for the migration.  This will prevent anything bad from happening to the existing forum.  Anyway, to use the separate database, uncheck the 'phpbb is on the same database as drupal' box and save the configuration.  Enter the correct path of the phpBB database, including the username and password, and save the configuration again.  If you mis-type the database path, you will receive the Site Off-line error page.  See notes below for how to fix this.
  3. You may want to edit the import time limit or user import settings (I leave them alone.)
  4. Set the Input Format settings to Forum Input Format (or whatever you named it.)
  5. You can leave the BBCode as is, since you'll be using the BBCode module.
  6. Check the 'import attachments' box and save the configuration.
  7. You may now click the 'proceed with migration' link

NOTES:

If you mistyped the phpBB database path in step 2 above and are getting the Site Off-line error page, you can't fix this through the settings.php file like you would if there was a problem with Drupal's database.  The only way I have found to fix this is to go into phpMyAdmin and edit Drupal's database.  Look for the 'variable' table (I use 'drupal_' as a prefix for the tables, so mine is drupal_variable.)  Delete the entry named phpbb2drupal_db_url and edit phpbb2drupal_same_db to set it back to true (change the 0 to a 1.)  Clear Drupal's cache and go back into the phpBB2Drupal settings.  Now make sure to type it correctly!!!

Proceed With Migration

With all of the settings correct, you may click the 'proceed with migration' link from the phpBB2Drupal Settings page.  The migration is done in steps where you select what you want to migrate, then click the Import button.  I would often get an error about a table 'system' not existing.  If you get a white page with just the error message, try going back and importing again.  If you get the long error message but you have the drop-down box and import button below it, you're actually probably ok...  Just go through the following steps:

  1. Import Users
  2. Import Categories
  3. Import Topics
  4. Import Posts
  5. Transform URLs

The import process can take quite some time, depending on how big your forum was.

Post Migration

After you have finished the migration steps, you will be given a link to the post migration configuration.  This can also be access through Administer -> phpBB to Drupal -> Post Migration Configuration.  This tells you what to do in order to finalize the migration process.  Basically:

  1. Go to Administer -> User Management -> User Settings.  Enable signatures and pictures and adjust any other settings (i.e. max picture size, default picture, etc.)
  2. Go to Administer -> Site Building -> Themes and enable 'User pictures in posts' and 'User pictures in comments' under general settings.
  3. If allowing polls in the forum, go to Administer -> Content Management -> Taxonomy.  Edit the Forum vocabulary by checking the 'Polls' box.

If you don't have your phpBB installation in <Drupal_path>/forums, you can go to path_to_drupal/forum to view your imported forum.  In the next section, we'll take care of fixing things up.

Cleaning up the import

Clean Up

Install Advanced Forum

If you look at your forum now, it really doesn't look all that impressive.  If you have users who are used to your phpBB forum, they are going to start emailing you nasty messages about how they hate the new look and all that.  Let's try to make things a bit easier for us all.

First up, let's install the following modules:

Upon installation of the Flat Comments module, you will be able to flatten existing comments for any and all types.  I prefer flat comments, but suit yourself.  I do think forums look better with flat comments as it is easier to find the most recent post.

Go to Administer -> Site Configuration -> Advanced Forum.  I don't like the 'naked' forum style, so change it to something else (blue_lagoon_stacked is nice.)  The rest can be left alone unless you really want to change it.

Now if you look at your imported forum, it is starting to look like a forum!  You may notice that the user avatars and smilies are not showing and the signatures aren't quite right.  We'll get to that, but first let's tackle...

Private Forums

It is pretty common for a forum to be accessible only to moderators or those with sufficiently high enough status.  Drupal currently doesn't support this behavior natively, but is expected to in D7.  In the meantime, we need the following modules installed:

You will need to rebuild the content permissions.  Now to set a forum for a special group of members, go to Administer -> Content Management -> Forums.  Select 'edit forum' next to the forum you wish to make private and select the appropriate permissions at the bottom.  For example, make the moderator the only one who can view a forum.  You might want to adjust the other permissions as well so that the appropriate individuals may edit or delete posts.

Smilies

In order to convert ASCII emoticons to graphical smilies, you need to install the Smileys module.  You may import smilies from other applications, such as phpBB or Yahoo!  In order to have them work with your Forum input format, go to Administer -> Site Configuration -> Input Formats and configure the forum format by enabling the Smileys filter.  Also, go to Administer -> Site Configuration -> Smileys and under Settings, enable smileys for nodes and comments and all desired format types (at least your forum type.)  You might want to go ahead and enable this for other formats as well.  If you look at your forum posts, you should have smilies working!

Signatures

By default, Drupal appends the signature to the end of the post.  In order handle this properly (meaning, like other forums), install the Signatures for Forums module.  Go to Administer -> Site Configuration -> Signatures for Forums and adjust the settings (show the signatures for the desired format types, I use the forum input format...)  Next, Drupal's signature functionality must be turned on, so go to Administer -> User Management -> User Settings and make sure signature support is enabled (we did this earlier.)  Since we are also using Advanced Forum, go to Administer -> Site Configuration -> Signatures for Forums and expand 'Other Options' and disable 'Automatically add signatures to content.'

Fix User Avatars

Users created in Drupal should have no problem with their avatars showing up.  However, I was going crazy trying to get the avatars for users imported from phpBB to show up.  After some digging through the databases and looking at the files in the phpBB images/avatar/upload directory, I figured it out.  Say you have a file in the directory named 63f0ff6ffa05cdd65149165723a8afd8_10.jpg.  The 63f0ff6ffa05cdd65149165723a8afd8_ is some sort of hash used by phpBB for reasons I can't understand.  If you dig into the database, you will find that the user with the avatar has the filename as simply 10.jpg in the database.  I used Bulk Rename Utility to remove everything up to and including the underscore in the files.  This worked for the majority of the avatars, but there were some still not showing.  More digging in the database showed that after this initial rename process, I had some files with names like 4_234576465234.jpeg in the database which should be associated with a file named 4.jpeg.  You can find these files by searching the drupal_users table for where the picture value is "like" '%\_%' (notice the escaped underscore and wildcards).  Since there were only a few, I manually editted the database to remove the underscore and gibberish after.  I have no idea why phpBB did this, but it did.  However, we still aren't finished, as the forum still won't show the avatars!  Again, looking at the path for the avatar, we can see that phpBB2Drupal has them in the database as being in the directory 'files/' when they should be in 'sites/default/files/'.  Use the following SQL command on the users table (in my case, drupal_users) by going to that table in phpMyAdmin and clicking the SQL tab.

UPDATE drupal_users SET picture = REPLACE(picture, "files/", "sites/default/files/")

followed by

UPDATE drupal_users SET picture = REPLACE(picture, "sites/default/sites/default/", "sites/default/")

in order to remove any duplications.

(see this issue for how I figured this one out: http://drupal.org/node/689852).

At this point, you should be able to see the avatars in the forum!!!!

(By the way, the avatars from phpBB need to be copied to 'sites/default/files/pictures/'.  I then used IrfanView to resize them to the size used by the site/forum.)  In order to get the pictures to show at an appropriate size without physically resizing them (in other words, to have smaller pictures in the forum posts and larger pictures in the profile), use the ImageCache Profiles module.  Details can be found in the 'Miscellaneous Additions' part of this tutorial.

Moderation

Unless you want your forum to become full of spam, you are going to want moderators.  The following modules will assist with the moderation process.

Fasttoggle

By default, moderating posts can be a bit involved.  Without Fasttoggle, you would have to click the edit tab for the post, then make your selections here and save it, which I don't think many non-techie moderators would really like (heck, I don't like it either.)  This module places links in the post to perform most of the administrative tasks directly from the post view, saving page loads!  Allows changing post status (published/unpublished), comment status (read/write, read-only (ie. "locked"), or disabled (shows first post only.)), sticky setting, and whether the post is promoted to the front page.  Also allows for toggling the status of the comments and the users' activation state.

Links to edit or delete a post directly on the post

This one isn't a module and requires modifying your theme's template.php file.  My feeling is that many of the moderators on our forum would find the way to go about deleting a post fairly non-intuitive (click the edit tab, scroll down, click delete, confirm.)  If it was possible to put a delete button right on the post, as is done with the comments, then that would greatly simplify matters.  After a bit of searching, I came across this article: http://11heavens.com/quick-edit-and-delete-links-for-the-Administrator which basically explains how to go about doing this.  The code in the article only places the links on the teaser, so I modified that in order to have them placed on the nodes.

First, open your theme's template.php file and look for the function THEME_preprocess_node(&$vars, $hook).  You will want to uncomment this and then replace the default code ($vars['sample_variable'] = t('Lorem ipsum.');) with the following:

  // If we're in teaser view and have right to update(edit) the node
  if (($vars['teaser'] || $vars['node']) && node_access('update', $vars['node'])) {
    // get the human-readable name for the content type of the node
    $content_type_name = node_get_types('name', $vars['node']);
    // making a back-up of the old node links...
    $links = $vars['node']->links;
    // and adding the quick edit link
    $links['quick-edit'] = array(
      'title' => 'Edit ' . $content_type_name,
      'href' => 'node/' . $vars['nid'] . '/edit',
    );
    // and then adding the quick delete link
    // if we have the right to delete the node
    if (node_access('delete', $vars['node'])) {
      $links['quick-delete'] = array(
        'title' => 'Delete ' . $content_type_name,
        'href' => 'node/' . $vars['nid'] . '/delete',
      );
    }
    // overwriting the $links variable with our new links THEMED
    $vars['links'] = theme('links', $links, array('class' => 'links inline'));
  }

Note that I have

($vars['teaser'] || $vars['node'])

in that first if statement. The teaser check is probably unnecessary since teasers are nodes, but I left it there from the original code. By making sure it is a node, the links will be placed on the actual post, which is what I wanted for the forum.

Modr8

The Modr8 module creates a queue of posts for moderation.  This is mostly to have a moderator preview posts before they are published.  These posts are placed in a queue so that when a moderator logs in, they can view them easily.  Since I don't make use moderator previews, this module is of little use to me...

Abuse

The Abuse module puts links on the content to report abusive posts to a moderator.  You can define reasons for reporting abuse (foul language, derogatory comments, etc.)  Once installed, go to Administer -> Site Configuration -> Abuse Moderation Settings to adjust the settings for the module, then go to Administer -> Site Configuration -> Abuse Moderation Settings -> Abuse Moderation Reasons to customize the reasons for reporting abuse.

Under Administer -> Site Configuration -> Input Formats, configure the forum input format, and select the Bad Words Filter.

Under Administer -> Content Management -> Content Types, edit Forum Topic by expanding the Abuse Moderation Settings and check the desired boxes (at least check 'Allow flagging for Forum topic nodes'.)

 

Miscellaneous Additions

The following are things that can enhance your Drupal Forum.  What has been discussed so far will make the forum seem a lot like phpBB, but still have some things missing.  Here, we'll try to fill in the gaps.

More enhancements may be found here: http://drupal.org/node/227121.  I don't plan on implementing everything, so you may want to browse this list to see what, if anything, suits your needs.

CKEditor

This is the wysiwyg editor that I use.  There are others available, so take your pick.

UPDATE: I have switched to using the WYSIWYG editor in combination with WYSIWYG Image Upload.  WYSIWYG is great, and allows you to easily install various editors.  WYSIWYG Image Upload is nice, if it works.  Unfortunately, it doesn't work in conjunction with Facebook Connect, so until this gets fixed (the problem is probably in Facebook Connect) I'd recommend using this at your own risk (though, it is the most intuitive image upload tool I have found for Drupal.)

User Stats

The User Stats module allows for showing user information, such as join date, post count, etc.  Install as usual, then go to Administer -> Site Configuration -> User Stats settings to edit according to you needs (you might want to include the forum topic in the post count.)  This will expose the statistics to the theme developer to place in the post.

ImageCache Profiles

The user image in the forum posts will typically be fairly small (say, 100x100 pixels.)  When you go to the user's profile, it would be nice to have a larger picture so we can better see who this person is.  This is where ImageCache Profiles comes in.

Install the module and its prerequisites (ImageCache).  The Readme file contains a good overview of how to implement this, but here's the basics:

  1. Go to Administer -> Site Building -> ImageCache.
  2. Click the 'Add new preset' tab.
    1. Enter the name for the images to use in the posts (user_image_default) and save.
    2. Apply the desired actions.  The readme says to use 'Add scale and crop', but I don't like the idea that the image may have important parts cut off, so I just use 'Add scale'.  Enter the dimensions for the image (ie. 100).
    3. Create the action and save the profile.
  3. Go back to the ImageCache settings and add another preset.
    1. Enter the name for the images in the user profile (user_image_large) and save.
    2. Apply the desired actions.  Again, I use 'Add scale' with a size of 200.
    3. Create the action and save the profile.
  4. Make sure that user pictures are enabled in Administer -> User Management -> User Settings.
    1. Specify a default user picture if desired.
    2. Enter the maximum image dimensions of 1600x1400 (the displayed pictures will be resized by ImageCache.)
    3. Set the maximum file size to 1024.
    4. Enter picture guidelines.  It would be good to have users upload a picture that is at least 200x200 pixels, since we will be downsizing to that.
    5. Select the ImageCache preset for the user's profile page (user_image_large).
    6. Select the ImageCache preset for the user's comments (user_image_default).
    7. Select the ImageCache preset for the default user's image size (user_image_default).
    8. Set the minimum and maximum image dimensions to 200 pixels, since that is the size we specified for user_image_large.  If you have an ImageCache preset using larger images, you may want to adjust this value.

Ignore User

Maybe some members have a tendency to ramble on about pointless nonsense.  Install the Ignore User module and members can choose to ignore the posts of others.

Quote

Installing the Quote module will place a 'quote' button so that users may include the original post in replies.  Install the module, then go to Administer -> Site Configuration -> Input Formats.  Configure the Forum input format to include the Quote filter.  You will also probably need to rearrange the filters (click the rearrange tab at the top) so that Quote comes before line-breaking filters and BBCode.  Next, go to Administer -> Site Configuration -> Quote and check the forum topic.  Make sure 'Display the quote link for nodes' is checked.