Requirement: Using Mango Blog as the base system, incorporate a forum. Logging into site should auto login to forum. All user management must be done via Mango Blog's user system.

Form: After some research (went for, Galleon Forums was chosen.

Solution: My first issue was.. How do I display Galleon forums in a Mango Blog page? Well.. this, as it turned out, was the easy part. I grabbed a plug-in called addcfcode. This plug-in allows for the inclusion of outside code into a Mango Blog page. With this I was then easily able to get Galleon forums to display in mango blog. Next up, figure out the user system.

First, I had to understand the workings of Mango blog's login and user system. I then had to take that knowledge and compare it to how Galleon Forums user security works. This was, for the most part, not that difficult. The data structure was pretty basic and straight forward. The part that tripped me up was how roles worked. That took a little more time to figure out. Now that I was able to map the security my next goal was to figure out user creation and updating. This was because I was handling all user management via Mango Blog. I looked into the Mango blog code to try and have it cross update users in both the Galleon tables and Mango tables at the same time. This would require me editing the Mango blog core code. I decided against this and took a different approach.

What I ended up doing for user management was database triggers. I added triggers to the base user tables for Mango blog so that any insert/update/ delete would also be reflected in the Galleon tables. This was a new experience for me as I had never written triggers for MySQL before. I have written them for SQL Server so I was familiar with the techniques. Once I got passed the nuances I was good to go. The main part in making this work was to have like roles in both Mango and Galleon. This made the security marry up perfectly from one to the next.

Here is an example of one of the triggers. This is for creating a new users. The insert into galleon_user_groups puts the user into a default group. The insert into the Mango Blog user group table will update this to be the correct group.

view plain print about
1CREATE TRIGGER `ins_galleon_users` BEFORE INSERT ON `mc_author` FOR EACH ROW begin
2        insert into galleon_users
3            (
4                id, username, password, emailaddress, signature, datecreated, confirmed
5            )
6        values
7            (
8      , NEW.username, NEW.password,, '', now(), 1
9            );
10        insert into galleon_users_groups
11        values
12        (, 'AD0F29B5-BEED-B8BD-CAA9379711EBF168');    

view plain print about
1CREATE TRIGGER `upd_galleon_user_groups` BEFORE UPDATE ON `mc_author_blog` FOR EACH ROW begin
3    /* trigger deletes then inserts new role in to galleon_user groups . Group names must match or trigger will fail */
5    declare ggid varchar(35);
8    delete from galleon_users_groups where useridfk = NEW.author_id;
10    set ggid = (select id from galleon_groups gg where = NEW.role);
12    insert into galleon_users_groups
13        (useridfk,    groupidfk)
14    values
15        (NEW.author_id, ggid);

Now that I had married the user systems now I had to add a login to Mango Blog to require a login to get to the forum. This was necessary as the forum is in a members only section of the site. I wanted to be able to secure different pages of the site with different security requirements. There was a Mango Blog plug-in that would allow me to secure sections for admins only. This was to restrictive as I need the security to be a little more granular. This is where the plug-in I created came from, roleSecure. This takes the custom fields on a page and uses them to secure a section.

I now had to blind login a user into Galleon Forums. This as actually pretty simple. With a couple lines of code in the Galleon forums application file I was able to pull this off. To keep the session working from Mango Blog to Galleon forums all I had to do was name the applications the same. However, in doing so I ran into a conflict. There was a conflict with a session var, session.users. Both Mango and Galleon used this but stored much different data in it. What I did to solve this conflict was to just rename the var in Galleon forums. Quick search and replace took care of that.

view plain print about
1<cfif ! isLoggedOn()>
2<!---added before login section in application.cfm--->
3    <cfquery name="getGalUser" datasource="xxxx" >
4        select username, password from galleon_users
5        where id = '#session.user.getID()#'
6    </cfquery>    
7    <cfset form.username = getGalUser.username>
8    <cfset form.password = getGalUser.password>
9    <cfset form.logon = 1>
11<!--- handle security --->

My last feat was to remove a bunch of the user management parts from Galleon Forums. I had to remove login, profile settings, and a few admin things. Nothing spectacular but it had to go since the database triggers were one way only from Mango to Galleon.

So there you have it... Mango Blog w / 2 plug-ins, Galleon Forums, and a few database triggers later and all is working harmoniously.

Till next time...