• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Batch Forum Creation

 
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1st of all, great forum!

Since there doesn't seem to be a JForum API, I'd like to approach remote category, forum, topic, and post creation by running DML statements directly against the database. When I create a new forum however, it doesn't show up in the forum index. Even if I go into the admin panel and resave permissions to both the Administration and General groups to set group-level permissions on the newly-created forum it doesn't show up. I've verified that the role values for my manually created forum match the role values for a similar forum created within the admin panel. Could this be a caching issue since I'm not calling any of the higher level jforum classes to construct the forum or am I missing an insert into an auxilary table?

Thanks!


[originally posted on jforum.net by Taboo]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I forgot to add that I'm working with version 2.1.4.

Thanks!
[originally posted on jforum.net by Taboo]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, it is caching. Take a look in the class net.jforum.repository.ForumRepository.

Rafael
[originally posted on jforum.net by Rafael Steil]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah ha! There it is: loadForums. Can you think of an easy way to setup a URL I can call to invoke that method on the currently running ForumModel. I'd hate to have to restart the forum everytime I wanted to create a new forum.

Thanks!
[originally posted on jforum.net by Taboo]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can use the methods addForum(Forum), as well addCategory(Category)

Rafael
[originally posted on jforum.net by Rafael Steil]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Great post!! Thanks for sharing with us!!!

Rafael
[originally posted on jforum.net by Rafael Steil]
 
I am going down to the lab. Do NOT let anyone in. Not even this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic