Help me get started - Expanding the admin interface

Vote:
 

This is a "big one" Cool

I am starting a part of my project that needs to expand the admin functionality. I have a forum, and for a Forum (instance) I have to make an attribute called "Moderated" (do I?) which will stop all forum entries from being published to the public site. All items that are created by the users must end up in a "tab" in the admin interface where moderators/admins will se a list of items not yet accepted for publishing. The reason for this is some concerns around child safety and legal/medical reasons. So I really need some/a lot of help getting started here.

Issues:
1. Forum must have attribue "Moderated" that is easy to switch on/off, preferably in the Forum tab in admin - need help here.
2. All Topics/Replys must have an attribute called "Published" that is default "false" - this i think i can handle, hehe.
3. All non-published items must be listed in some way in the admin interface, preferably in an own meny item, next for Forum for example. In this list there needs only be a view of the Topic/Reply text and a checkbox to approve "publish", and some method of possibly editing the Topic/Reply.

I think that covers most of it. Any takers? Suggestions to other solutions are also most welcome. I will of course post my solution as I progress Innocent

No need to say I'm completely n00bish on expanding the admin interface and in desperate need of help, hehe.

</marius>

#25245
Oct 16, 2008 11:05
Vote:
 
*bump*
#25332
Oct 21, 2008 10:06
Vote:
 

Hi Marius,

 Because you say that suggestions for other solutions are welcome here's one alternate solution that might work for you.

The idea is to save any replies to the forum in a separate list of replies that are not yet moderated. This would have the effect that the threads in the forum would not be filled with "invisible" replies, which would make paging difficult to handle.

This list should, according to you specification, be able to store both new topics and replies, so a pointer to the forum room would be necessary for topics, and a pointer to the topic would be needed for replies. This pointer is used so that the moderator api, when accepting the post, would know where to post the new topic/reply (which room or topic in which to place the topic or reply).

In the admin, you would create a new user control (.ascx) that lists the not-yet-accepted entries and allows for the moderator to accept them. You could then change the Menu.ascx to include a link to your control, next to the one for forum.

As for the Moderated property, I would suggest you create an attribute to store this value. Currently there's no GUI to change these attributes for forum rooms, but the moderator API could easily be extended to list the forum rooms and a checkbox next to them that updates the corresponding attribute.


Regards,

Kristoffer

 

#25407
Oct 23, 2008 15:00
Vote:
 

Ok, thanks Kristoffer. I think I get some of your points. But HOW do I do this? I need code man! :) 

How do I save replies on a separate list? Do I add an attribute to the Forum class that sets a Forum to "moderated" ? Some forums need this possibility, others are regular forums. 

Where would I put this admin asxc control? I'm thinking in the /Netstar/StarCommunity/Modules/New Module path?

 

#25429
Oct 24, 2008 13:56
Vote:
 

 

I've finished up my admin module and this is what I had to do:

First off I created a table in the db to hold my forum entries. This was managed by a custom database access class that handles all CRUD actions. I also implemented a custom class simply clalled ModeratedItem which holds all values for a topic or reply. I created an enum ForumObjectType { topic, reply } to identify the type of object.

I added an Attribute on the StarCommunity.Core.Modules.Forum.Forum object which is a boolean. This allows me to control all forums and their moderation level (on/off).

In my frontend codebase I simply do a check when I post to a forum to check if the forum is moderated or not by a forum.GetAttributeValue("bModerated") check. In the methods that post either a new topic or a new reply i do some checking and in stead of creating a Topic or Reply object, I create a ModeratedItem object and ship it to my custom table.


if(ForumHandler.GetForum(topic.Room.Forum.ID).GetAttributeValue("bForumIsModerated"))
{
//save reply to extern list
ModeratedItem item = new ModeratedItem();
item.ParentID = topic.ID;
item.AuthorID = userAuthor.User.ID;
item.DateCreated = reply.CreateDate;
item.Subject = reply.Subject;
item.Text = reply.Text;
item.Type = ModeratedItem.ForumObjectType.Reply;
DataAccess.Write(item);
pnlModerationInformation.Visible = true;
}
else { ForumHandler.AddReply(reply); }


This sends nothing to the Forum, and no empty Topic or Replies items are present. That's pretty much the frontend code.

In Admin i did some more complex work to moderate the Items. The whole idea is that the moderators need some control on special forums where information may be sensitive.

I added my ModeratedForum.ascx control in the /netstar/starcommunity/Modules/ForumModerated folder, and edited the Menu.ascx to include my usercontrol.

My control has two functions. First it sets the moderation of any forum to on/off. Simple button list that changes the bModerated attribute of the Forum. I'll post the code here, because there was a simple issue that got me debugging a lot before it all worked, and that is Clone() and UpdateForum() that must be called.

(button click)
int _forumId = Int32.Parse(e.CommandArgument.ToString());
bool _isModerated = ForumHandler.GetForum(_forumId).GetAttributeValue("bForumIsModerated");
_isModerated = !_isModerated;
global::StarCommunity.Modules.Forum.Forum f = (global::StarCommunity.Modules.Forum.Forum)ForumHandler.GetForum(_forumId).Clone();
f.SetAttributeValue("bForumIsModerated", _isModerated);
ForumHandler.UpdateForum(f);

 

This works great, and in the ascx frontend I set the button colour according to status, red means moderated - so that admins can easily see what forums are moderated.

For the moderation I made a DataList that gets all items in the custom table and lists them out. There Admins can edit, post or delete items. For example, if an admin need to edit a post, click the edit button, Edit the item and publish. Code:

  protected void btnUpdateAndPublishItem(object sender, DataListCommandEventArgs e)
  {
  ModeratedItem item = DataAccess.ReadItem(Int32.Parse(e.CommandArgument.ToString()));
  MessageItem message = new MessageItem();

  item.Text = ((FCKeditor)e.Item.FindControl("tbEditPost")).Value;
   
  //create a message to the user
  message.Message = ((FCKeditor) e.Item.FindControl("tbEditPostComment")).Value;
  message.UserID = item.AuthorID;
  message.DateCreated = DateTime.Now;

  DataAccess.WriteMessage(message);
  DataAccess.Update(item);
  DataAccess.Approve(item);
  dlModerateItems.SelectedIndex = -1;
  SwitchView(ViewMode.ModerationList);
  }

Note I have a MessageItem class; I made another custom table that allows admins to send a message/comment to the user that has had a post edited or deleted. I show these messages on a custom page attached to the users MyPage. Pretty cool, huh? :)

 

This is what I have time to post now. Any comments are welcome!  

 

 

 

 

#25883
Edited, Nov 11, 2008 10:45
This thread is locked and should be used for reference only. Please use the Legacy add-ons forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.