Active Forums integration with the Active Social Journal has been limited to activity that takes place within the context of a social group. Since we implemented journal item security in Active Social 1.8, we can now secure journal items in a couple different ways. In this post I'm going to show how I used the Active Social Journal API within Active Forums 4.3. Everything that I'm going to cover should useful to anyone that has a need to integrate with the Active Social Journal API.
Changes to Active Forums
We need to configure a few settings before we can send data to the Active Social Journal. Active Forums allows you to store your journal access keys for topics and replies under the community tab in the control panel. The input options are present for all versions of Active Forums except for Lite. The ability to store the access keys and the informational message are configured based upon the installation status of Active Social.
Forum Configuration Options
Active Forums already handles journal entries that belong to a group. I didn't want to do anything that would change this behavior. I thought it made the most sense to give you a few integration options at the forum level. You can enable or disable the Active Social Integration under the features tab of any forum or group. You can also choose to only send new topics to the journal. The last option controls how you want to handle security. You can select Everyone, Community, Friends Only or Read Roles. You would select Read Roles if you want the forum journal items to match the forum security for who can read the topic. One big caveat, security for the journal item is stored with the actual journal item. This means that if your forum security changes, the security for the journal item will NOT change. If that is a concern for you then you may want to consider using social groups in addition to forums.
Journal API Sample Code
Now that we have all of our settings stored in the application we are ready to add some code to send data to the journal. For Active Forums, I created three functions for working with the Journal API. I wanted a function that would make it easy for me to determine the current state of Active Social within the portal. I also use the function to assist with the availability of my configuration options in the control panel. I created a function called GetActiveSocialStatus that would return a value that I could use within my other functions.
Public Function GetActiveSocialStatus(ByVal PortalId As Integer) As Integer
If IO.File.Exists(HttpContext.Current.Server.MapPath("~/bin/active.modules.social.dll")) Then
Dim mc As New DotNetNuke.Entities.Modules.ModuleController
Dim tc As New DotNetNuke.Entities.Tabs.TabController
Dim ti As DotNetNuke.Entities.Tabs.TabInfo = Nothing
For Each mi As DotNetNuke.Entities.Modules.ModuleInfo In mc.GetModules(PortalId)
If mi.ModuleName.Contains("Active Social") And mi.IsDeleted = False Then
ti = tc.GetTab(mi.TabID, PortalId, False)
If Not ti Is Nothing Then
If ti.IsDeleted = False Then
'Installed and ready
Return 1
End If
End If
End If
Next
'Not installed on portal
Return 0
Else
'Not Installed
Return -1
End If
End Function
The two other functions would be used for sending data to the journal. The functions are identical, but one is for sending topics and the other is for sending replies. In most you will only need one. Below is the code for AddTopicToJournal
Public Sub AddTopicToJournal(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal ForumId As Integer, ByVal UserId As Integer, ByVal URL As String, ByVal Subject As String, ByVal Summary As String, ByVal Body As String, ByVal SecurityOption As Integer, ByVal ReadRoles As String)
If GetActiveSocialStatus(PortalId) < 1 Then
Exit Sub
End If
Dim ai As Object = Nothing
Dim asm As System.Reflection.Assembly
asm = System.Reflection.Assembly.Load("Active.Modules.Social")
Dim ac As Object = Nothing
ac = asm.CreateInstance("Active.Modules.Social.API.Journal")
Dim MainSettings As SettingsInfo = DataCache.MainSettings(ModuleId)
Dim roles As String = String.Empty
If Not String.IsNullOrEmpty(ReadRoles) Then
If ReadRoles.Contains("|") Then
roles = ReadRoles.Substring(0, ReadRoles.IndexOf("|") - 1)
End If
End If
ac.AddProfileItem(New Guid(MainSettings.ActiveSocialReplyKey), UserId, URL, Subject, Summary, Body, SecurityOption, roles)
End Sub
Summary
If everything works like I described then you should see this topic appear on my
profile. You do have to be logged in to view profiles on this site, but you should also see it in the social summary on our
community page. I will also be posting more details about the actual content that can be sent to the journal very shortly.