cheetahtech
2009-06-06T05:50:12Z
So I have the forum installed. Its a singular installation and I know I have the ability to create boards manually, but I wish to create boards dynamically. I need to know how to do this, so here is the scenario.

I have a website with over 17,000 users. The website is grouped into 25 users a piece. So I can say that I need about 680 forums created and I can't do that physically. I also need to store each boardID and attach it to the group of users. I have a group ID already so I can attach the group ID to a board ID, but I still don't know how to create a board dynamically.

On creating the board, I need a moderator to take control of the board as well. I know who the moderators will be already, but when creating it dynamically how do I assign moderators dynamically?

I see and understand this is a VERY unique situation, but is it possible and if so how do I do it? I know PHPBB can do it, but I want to use a C#/ASP.NET solution and this is the best board out there with that requirement. Please help me out!!!

I do appreciate all the help I am about to receive and if I get this up and working, I do not see a problem with a nice donation to YAF.
Sponsor
jshepler
2009-06-06T07:57:44Z
Everything you want to do can be done directly in the database and might be easier to just do it all in sql. Either way, I think the first step would be to start digging into yaf code, database tables and stored procedures to learn how yaf stores boards, forums, users, groups/roles and how moderators are specified.

Once you have "the lay of the land", you can better plan out what you need to do. For example, I believe that you don't assign specific people to be a moderator for a specific forum - you add them to the moderator group and give that group moderator access to the specific forum. So, if you want to have different moderators for different forums, you will need to make a different moderator group for each forum.

One approach you might take would be to create a table for the specs you need like:
ForumName   ModeratorUsername   ForumID     ModeratorUserID     ModeratorsGroupID
Forum1      Moderator1          NULL        NULL                NULL
Forum2      Moderator2          NULL        NULL                NULL
Forum3      Moderator3          NULL        NULL                NULL

Then you could write some queries to do the work for you like:
-- create forums
INSERT  INTO yaf_Forum (Name)
SELECT  ForumName
FROM    specTable

-- save the forum IDs for later user
UPDATE  st
SET     st.ForumID = yf.ForumID
FROM    specTable st
        INNER JOIN yaf_Forum yf ON yf.Name = st.ForumName



-- add moderator users
INSERT  INTO yaf_User (ProviderUserKey, Name)
SELECT  ProviderUserKey = u.UserId, Name = st.ModeratorUserName
FROM    specTable st
        INNER JOIN aspnet_Users u ON st.ModeratorUsername = u.UserName

-- save the user IDs for later use
UPDATE  st
SET     st.ModeratorUserID = yu.UserID
FROM    specTable st
        INNER JOIN yaf_User yu ON yu.Name = st.ModeratorUsername



-- create moderator groups
INSERT  INTO yaf_Group (Name)
SELECT  ForumName + 'Moderators'
FROM    specTable

-- save the group IDs for later use
UPDATE  st
SET     st.ModeratorsGroupID = yg.GroupID
FROM    specTable st
        INNER JOIN yaf_Group yg ON yg.Name = st.ForumName + 'Moderators'



-- add moderators to appropriate moderators group
INSERT  INTO yaf_UserGroup (UserID, GroupID)
SELECT  UserID = ModeratorUserID, GroupID = ModeratorGroupID

Note this is just theory and speculation, don't take the above code as anything other than illustrating the idea.

not jsheLPer
cheetahtech
2009-06-06T09:42:41Z
Thanks J.Shepler, I guess so what your telling me that there is no way to do this automatically in YAF. I will have to create my own way of doing it. Sad to see, because the code I create will have to be reimplemented with each code release.

Any other way of doing this?
jshepler
2009-06-06T09:48:46Z
Perhaps I misunderstood.

It sounded like this would be a one-time thing to do - setting up all the forums you need - not an ongoing thing.

What needs to happen after the initial 680 forums are setup?

not jsheLPer
cheetahtech
2009-06-06T09:58:49Z
Well, after the forums are completed, I will be upgrading YAF everytime a new update comes out. I will also never know how many real forums are out there unless I request it from the DB. Every 3 or 4 months, Existing boards will be used and new boards will also probably be created depending on the 25 users. It all depends on whether they would like to create new boards or not. So as I said before, creation of a new board needs to be in complete control of those 25 users and not the admin of the site.
jshepler
2009-06-06T10:16:48Z
Ok, so you're basically talking about 2 different things here. 1) setup the inital forums/moderators 2) create an interface for *someone* to create a new forum where *someone* is not the board admin.

#1 won't need to be redone - it's a one-time thing to get you "caught up".

When you say "creation of a new board needs to be in complete control of those 25 users", do you mean board or forum? I ask because you could create 1 board per group, have the group members be board admins for that board which would allow them to create/edit/delete the forums in that board. You would still be the host admin (site admin) with control over all boards. This would require no code changes or new code to be written.


Or am I still not getting it?

not jsheLPer
cheetahtech
2009-06-06T10:29:19Z
Alright, so your pretty close. The site will already know who the moderators are by a value I assigned to the user profiles. I don't want to create an interface to create a new board. I would like for it to be automatic. I already have an interface where someone can join a group and where someone can start a group. The groups will only consist of a MAX of 25 users and at max 25 users will be a moderator.

Each group gets a board. Not a forum. Each group will decide and have total control over their board and the forums in it. I will need to have complete control over ALL boards as the site admin.

Not to make this more confusing, but I must say that Boards (Not Forums) can be removed at any time. But most the time, The board will be moved with the 25 users over time instead, but when the users create a new group, they will need to automatically have a new board created with them.

Last note: I will need to keep records over which group has control over each board. I already have a group ID which is a GUID. I will need to attach this group ID to every Board ID that is created.
jshepler
2009-06-06T11:19:29Z
Yaf had caching problems running a multi-board site. I don't know if they've been fixed in the final release version or not. You're going to need to code a way to tell yaf which board to show. There are 2 ways to specify the board ID for yaf to use: in the web.config (YAF.BoardID appSetting) and the boardid property of the <yaf:forum> control. Since the boards are dynamic, you'll probably pass the board id in the querystring, so the code-behind of the page containing the <yaf:forum> control would then need to set the board id in Page_Init (might not be early enough, try it and see). This code won't need to change when yaf is updated since it's the page containing the forum control, not any of the yaf code itself.

Yaf will not automatically create boards. You will have to write code for that. It doesn't have to be a seperate interface, you already have that for creating a new group. Just add the board creation code to that.

Basically, this is the code you'll have to write (I'm sure I'm missing stuff):

Create Group:
- create new board
- create new roles in that board for the group (members, moderators, etc)
- add the current user to the yaf_user table for the new board ID (mark as board admin if needed)
- add the new user ID to appropriate roles
- track groupID and new boardID

Joining a Group:
- add user to yaf_user for the board (if not already there, yaf syncs this when user visits forum)
- add (new) user ID to appropriate roles

Removing a Group:
- delete all topics/posts/PMs/etc in board
- delete users from board's roles
- delete roles from board
- delete users from board
- delete forums in board
- delete board


If you don't want them having board admin access, then you'll need a way for them to create forums:

Adding a Forum:
- create new forum
- assign role access for all roles in board




I don't know what you mean by moving a board.

not jsheLPer
jshepler
2009-06-12T11:24:30Z
How's this goin for you?

I came across the code yaf does to delete a board which you can use. You can either call yaf's code (YAF.Classes.Data.DB.board_delete) or yaf's stored procedure (yaf_board_delete). That should save you some work when your users delete a group.

not jsheLPer
cheetahtech
2009-06-12T17:35:52Z
I was working on it, but because it became so MUCH work, I decided to put it off because my users wanted some other things before the forum system.

I did tho, build two more controls for the forum. A Top Post control and Last Viewed control I figured I would post them on the site, but there will be a little piece of code that will need to be looked at by the real Devs of YAF to fix it a little. Good controls, because I can put them anywhere on my site and they work...

About Us

The YAF.NET is an open source .NET forum project. YAF.NET is supported by an team of international developers who are build community by building community software.

Powered by Resharper Donate with PayPal button

Project Twitter Updates

Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved