What We Do
We provide top quality services and best solutions based on your requirements and needs.
Share

Introduction to Member Trigger


I was lucky to get involved in big scale project and gaining more knowledge. The new “Big-scale” project was proposed with clustered environment which involve with MySQL database clustering, Email clustering & Instant Messaging clustering. Beside that we also integrate open source application such as Dolphin from boonex.com, PrestaShop from prestashop.com.

ISSUE: From initial proposal we have included LDAP server as a central membership reference. We aware that not all of the applications that we proposed are support with LDAP integration interface. Beside that, during the project approval the budget has been cut-off and LDAP deployment has been discarded. But the requirement to having central authentication is still required since we have few 3rd party applications that require member integration and synchronization. The objective to achieve here is single-sign-on and central membership for multiple services running.

SOLUTION: We have proposed to our RND team to provide a solution for MXAE to integrate with 3rd party applications membership. Our request is something to hook during MXAE member data update so that we can customize accordingly to achieve the objective. This is when MXAE member trigger introduced.

Member Trigger conceptual diagram - Click to enlarge


Member trigger in nutshell

This function is basically returning the process type and object when member is doing something or administrator updating the membership at AMS. This sound a bit complicated for new comer, below is a conceptual diagram to illustrate the process flow from beginning of user input.

By having “Member trigger” facility, we also can achieve single sign-on at minimum requirement and configuration since this function also triggered when member login at website. Depending on development requirement, another option that can be useful is to set data mirroring for membership data between MXAE2 and another applications. During the triggering, we also able to initiate CURL request or network socket connection to establish to another third party application.

How-to

To start using MXAE2 member trigger function, we need to define the template code and function name for “website property” in AMS as per figure below.

Enabling Member Trigger - Click to enlarge


The format to define member trigger is (without double quote):

"Template code||Function name"
Example:

Member_trigger.tsl||doUpdateServices

Based on the above example, defining member trigger function is similar to “program trigger”, “callback” & “post_callback”.

function doUpdateServices($triggerType, $eventType, $member){...}

Based on the above “function”. Below is the parameter and descriptions.

Parameter Description Possible value to check
$triggerType This variable is to cater value pre trigger and post trigger, which mean before and after MXAE updating member data. 0 for before and 1 for after member data updated.
$eventType This variable will bring the value of event whether insert, update or delete 1 for insert, 2 for update and 4 for delete operation.
$member This parameter is an object for member Member object











Ok here is an example to integration MXAE member and limesurvey (http://www.limesurvey.org) member:
  1. PRE - Format member name.
  2. POST - Extend insert/update or delete to limesurvery membership table by using direct MySQL connection.

function mxMemberUpdate($triggerType, $eventType, $member){
    /*
     * MX_TRIGGER_PRE = 0
     * MX_TRIGGER_POST = 1
     *
     * MX_EVENT_INSERT = 1
     * MX_EVENT_UPDATE = 2
     * MX_EVENT_DELETE = 4
     */    
	$logger = new mxLog();
	
    	if ($triggerType == 0){ // PRE callback
if($eventType == 1 || $eventType == 2){ // If insert or update member then format the name
			$member->name = ucwords(strtolower($member->name));
		}
    }		
    // we only update other services for post callback
    if ($triggerType == 1){ // POST callback 
		mysql_connect('localhost', 'user', 'password');
		mysql_select_db('limesurvey');
        if($eventType == 1){ // create
$sql = "INSERT INTO lime_users (users_name, password, full_name, email, create_survey, create_user, delete_user, superadmin, configurator, manage_template, manage_label) VALUES ('".$member->username."','".hash('sha256',$member->getClearTextPassword())."', '".$member->name."', '".$member->email."', '0','0','0','0','0','0','0')";
        } elseif($eventType == 2){ // update
$sql = "UPDATE lime_users SET users_name = '".$member->username."', password = '".hash('sha256',$member->getClearTextPassword())."', full_name = '".$member->name."', email = '".$member->email."' WHERE users_name = '".$member->username."'" ;
        } elseif($eventType == 4){ // delete
$sql = "DELETE FROM lime_users WHERE users_name = '".$member->username."'";
        }		
		if(mysql_query($sql)) $logger->log('Query successful : '. $sql);
		else $logger->log('Query failed : '. $sql);
    }
}?>

Summary

As the name suggested, developer now have more control over member data and providing more flexibility to meet the business process requirement in the future. It’s recommended you to get updated with our news and FAQs published on our website.

MXAE Release News

MXAE 2.7.5 Released
We would like to announce the immediate availability of MXAE 2.7.5. This release focuses on...




Tips & Tricks

Remove duplicated search result items
When the searching some keyword is displaying double or duplicated in the result. As this...




MXAE Free Hosting

We are offering FREE hosting on MXAE platform with no string attached. You can use it as a development or demo hosting for your company. You can also use it to build your own website or host your client website.