Developer FAQ

How can I intergate YetAnotherForum (http://www.yetanotherforum.net) with Composite C1?

Answer:

Requirements:
1. Composite C1 1.2 SP1.1 or latest
2. YetAnotherForum (http://yetanotherforum.net/) version 1.9.3-FINAL or latest
3. MS SQL Server 2000 or latest

Important:
1. Please backup your C1 before start.
2. We are using YetAnotherForum version 1.9.3-FINAL as example in this article, this version have issue with creating new boards, please use SQL script below to fix it:

ALTER TABLE [dbo].[yaf_Forum] DROP CONSTRAINT [IX_yaf_Forum]
ALTER TABLE [dbo].[yaf_Forum] ADD CONSTRAINT [IX_yaf_Forum] UNIQUE NONCLUSTERED
(
[CategoryID] ASC,
[Name] ASC
)

How to make it work 
1. Download, install and configure latest YetAnotherForum using instructions from the install.txt
2. Create new folder "YAF" in the root of your C1 installation and copy all files from YetAnotherForum installation
3. Move YAF/App_Code files to the C1 App_Code folder, YAF/bin files to the C1 bin folder.
4. Move YAF/app.config, YAF/db.config, YAF/UrlRewriter.config, YAF/mail.config to the webroot.
5. Edit app.config and change "YAF.Root" (make sure it's not commented) to "/yaf" and "YAF.BaseUrl" to your custom value (normally parent page name).
6. Edit your C1 web.config and add section below to the <configuration><configSections> section:

 
<section name="rewriter" type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter" requirePermission="false" />

7. After </configSections> add:
 <connectionStrings configSource="db.config"/>
 <appSettings configSource="app.config"/>
 <rewriter configSource="URLRewriter.config" />
 
 <system.net>
 <mailSettings>
 <smtp configSource="mail.config"/>
 </mailSettings>
 </system.net>

8. Add new sections to the <system.web><pages><controls>:
 <add tagPrefix="ajaxToolkit" namespace ="AjaxControlToolkit"  assembly="AjaxControlToolkit"/>
 <add tagPrefix="YAF" namespace ="YAF.Classes.UI"  assembly="YAF.Classes.UI" />
 <add tagPrefix="YAF" namespace ="YAF.Classes.Utils"  assembly="YAF.Classes.Utils" />
 <add tagPrefix="YAF" namespace ="YAF.Classes.Data"  assembly="YAF.Classes.Data" />
 <add tagPrefix="YAF" namespace ="YAF.Controls"  assembly="YAF.Controls" />
 <add tagPrefix="YAF" namespace ="YAF.Controls.Statistics"  assembly="YAF.Controls" />
 <add tagPrefix="YAF" namespace ="YAF.Classes" />
 <add tagPrefix="YAF" namespace ="YAF"/>
 <add tagPrefix="editor" namespace ="YAF.Editor"/>

9. Just after <system.web><pages></controls>
 <namespaces>
 <add namespace ="YAF" />
 <add namespace ="YAF.Classes.UI" />
 <add namespace ="YAF.Classes.Utils" />
 <add namespace ="YAF.Controls" />
 <add namespace ="YAF.Classes.Data" />
 </namespaces>

10. After <system.web></pages>
 <roleManager enabled="true"  defaultProvider="YafRoleProvider">
 <providers>
 <clear/>
 <add connectionStringName="yafnet"  applicationName="YetAnotherForum"  name="YafRoleProvider"  type="YAF.Providers.Roles.YafRoleProvider"/>
 </providers>
 </roleManager>
 <membership defaultProvider="YafMembershipProvider"  hashAlgorithmType="SHA1">
 <providers>
 <clear/>
 <add connectionStringName="yafnet"  applicationName="YetAnotherForum"  name="YafMembershipProvider"  requiresUniqueEmail="true"  useSalt="true"  type="YAF.Providers.Membership.YafMembershipProvider"/>
 </providers>
 </membership>
 <profile enabled="true"  defaultProvider="YafProfileProvider"  inherits="YAF.Classes.Utils.YafUserProfile">
 <providers>
 <clear/>
 <add connectionStringName="yafnet"  applicationName="YetAnotherForum"  name="YafProfileProvider"  type="YAF.Providers.Profile.YafProfileProvider"/>
 </providers>
 </profile>

 <authentication mode="Forms">
 <forms name=".YAFNET_Authentication"  protection="All"  timeout="43200"  cookieless="UseCookies"/>
 </authentication>

11. New section to the <system.web><httpModules>:
 <add name="YafInitModule"  type="YAF.Classes.Base.YafInitModule, YAF.Classes.Base"/>
 <add name="UrlRewriter"  type="Intelligencia.UrlRewriter.RewriterHttpModule,Intelligencia.UrlRewriter" />

12. New section to the <system.webServer><modules>:
 <remove name="YafInitModule" />
 <remove name="UrlRewriter" />
 <add name="YafInitModule"  type="YAF.Classes.Base.YafInitModule, YAF.Classes.Base"/>
 <add name="UrlRewriter"  type="Intelligencia.UrlRewriter.RewriterHttpModule,Intelligencia.UrlRewriter"  preCondition="managedHandler"/>

13. Remove YAF/web.config
14. Add new property BaseURL to the App_Code/YAF/Forum.cs (just after BoardID, line 225):
public string BaseURL
 {
 get
 {
 return YafControlSettings.Current.BaseURL;
 }
 set
 {
 YafControlSettings.Current.BaseURL = value;
 }
 }

15. Install this package: Composite.Community.YetAnotherForum
16. Add code below to the page template or to the page in source mode. Please change BoardID parameter to display required boards:
 
<f:function name="Composite.Community.YetAnotherForum" xmlns:f="http://www.composite.net/ns/function/1.0"> 
  <f:param name="BoardID" value="1" /> 
</f:function>

17. Replace bin/YAF.Classes.Config.dll with this one and bin/YAF.Classes.Utils.dll with this one or follow steps described below to compule your own.
18. Replace "YafForumInfo.ForumRoot" to "YafForumInfo.ForumFileRoot" in yaf\pages\postmessage.ascx.cs (line 94, 141, 321).
19. Replace "YafForumInfo.ForumRoot" to "YafForumInfo.ForumFileRoot" in yaf\pages\pmessage.ascx.cs (line 97).
20. Replace "YafForumInfo.ForumRoot" to "YafForumInfo.ForumFileRoot" in yaf\controls\EditUsersSignature.ascx.cs (line 58).
21. Replace "YafForumInfo.ForumRoot" to "YafForumInfo.ForumFileRoot" in yaf\pages\avatar.ascx.cs (line 102).

Changes required to the source code
1. Change YAF.Classes\YAF.Classes.Config\Config.cs (BaseUrlFromWCM, line 151) from:
static public string BaseUrlFromWCM
 {
 get
 {
 return  GetConfigValueAsString( "YAF.BaseURL" , true );
 }
 }

to:
static public string BaseUrlFromWCM
 {
 get
 {
 return YafControlSettings.Current.BaseURL;
 }
 }

2. To YAF.Classes\YAF.Classes.Config\YafControlSettings.cs add (line 33):
private string _baseURL;

3. At same file add (line 76)
public string BaseURL
 {
 get
 {
 return _baseURL;
 }
 set
 {
 _baseURL = value;
 }
 }

4. Compile YAF.Classes.Config project and replace bin/YAF.Classes.Config.dll with compiled dll.
5. Replace "YafForumInfo.ForumRoot" to "YafForumInfo.ForumFileRoot" in YAF.Classes\YAF.Classes.Utils\Context.cs (line 1096).
6. Compile YAF.Classes.Utils project and replace bin/YAF.Classes.Utils.dll with compiled dll.