For those of you who want to go hacking away at the db as a way of implementing a half-assed API for creating forums, here are some pointers:
I found it very easy to populate the jforum database with content from other systems (another forum, CMS, etc.) by using select statements to dynamically create insert statements and then wrapping them in a homemade eval function to execute them in sequence for each item in the source table. Also, I've created a jforum_forum_target_link which I've found handy as a means for to map the source data widgets to the jforum widgets. Why do this? Well, as you create forums and then topics and posts, you'll need to keep track of source data <-> forum relationships in order to pull the forum primary key to populate it as a foreign key in the forums' respective topics and posts. It's also handy as a bookmark for incremental updates from your source data to your forum so you're not duplicating content.
1st setup your eval procedure (I'm using postgreSQL... so milage may vary. Be sure to run createlang plpgsql <databasename> prior it issuing this command if you haven't already done so.)
Create forums using a source table containing names for the forums
This will create a forum for every name in your source table within category id 1 and marks the forum as moderated. Make sure the category exists before you run this statement. The key here is passing a blank
string ('''' in this example) to forum_desc. Without it, you are by default populating the forum description with a null which the FreeMarker template b0rks on. Also, if you don't care about a particular ordering for your forum list, hard coding a 1 into the forum_order will sort the forums alphabetically within the category.
Create topics and an initial post for each topic using a source table containing names, content and forum relations for the topics and posts
This creates the topics and an initial post (after all, what good is a topic without a post?) for the forums that were created in the previous step. My source data didn't differentiate between a topic and the 1st post. Also, notice the user_id is hard-coded as 1 and that once again the moderated flag is set. You'll probably want to change those particulars to something that reflects your source data.
Now that you have some content you have to set the permissions so that they're visible and useable. The easiest way to do this is through the admin area. If jforum is already running need to refresh the jforum repository. You can simply run
to restart the jforum and refresh the cache. If anyone has better way based upon Rafael's recommendation please share. Next go into the admin console and resave each of the group permissions.
You should be all set...
[originally posted on jforum.net by Taboo]