Here is the full api documentation. The Details field seems to come from the 'information_data' parameter in step (d)
a) Use - Basic API
$api_AUP = JPATH_SITE.DS.'components'.DS.'com_alphauserpoints'.DS.'helper.php';
if ( file_exists($api_AUP))
{
require_once ($api_AUP);
AlphaUserPointsHelper::newpoints( 'function_name' );
}
function_name is the name of the rule that will be used to attribute points to the current user (if logged in). For each AlphaUserPoints integrated rule (system rules), names syntax is as follows:
example: sysplgaup_newregistered for new users points attribution
It is convinient to keep the same name syntax for third party components plugin as follows:
plgaup_functionname
Example: plgaup_newcomment or plgaup_newtopic for a comment system or forum API integration. To name a rule that would give points when adding a new topic in Fireboard: plgaup_newtopic_fb.
Keep in mind that this method only gives points to the current user. This is the Basic API.
b) Attribute points to another user:
To give points to anothe user than the one connected, only the user id is required. To get his AlphaUserPoints (AUPID) Identity, we just need to use the getAnyUserReferreID(). This method is the one used to give points to an article author when the article is being read by someone on the site.
$api_AUP = JPATH_SITE.DS.'components'.DS.'com_alphauserpoints'.DS.'helper.php';
if ( file_exists($api_AUP))
{
require_once ($api_AUP);
$aupid = AlphaUserPointsHelper::getAnyUserReferreID( $userID );
if ( $aupid ) AlphaUserPointsHelper::newpoints( 'function_name', $aupid );
}
c) Prevent from attributing points more than once for the same action:
To avoid that a user would get points many times for something allready done, we can add a reference key. When calling the AlphaUserPointsHelper::newpoints function, a pre check is done on this reference key. This method is used in the rule where a user reading an article would give points to the author.
$api_AUP = JPATH_SITE.DS.'components'.DS.'com_alphauserpoints'.DS.'helper.php';
if ( file_exists($api_AUP))
{
require_once ($api_AUP);
AlphaUserPointsHelper::newpoints( 'function_name', '', 'reference_key');
}
d) Adding information datas:
To add information datas to be displayed in the action details, just add a new parameter as follows:
$api_AUP = JPATH_SITE.DS.'components'.DS.'com_alphauserpoints'.DS.'helper.php';
if ( file_exists($api_AUP))
{
require_once ($api_AUP);
AlphaUserPointsHelper::newpoints( 'function_name', '', '', 'information_datas');
}
e) Using different amounts of points on the same rule:
A component might also need to add or to take points for different amounts. For example, when buying goods with points. Products have diferent prices, a fixed amount in the rule would'nt make it. The API $randompoints parameter comes instead of the amount of points set in the rule. It can be negative in case of purchases or penalities.
$api_AUP = JPATH_SITE.DS.'components'.DS.'com_alphauserpoints'.DS.'helper.php';
if ( file_exists($api_AUP))
{
require_once ($api_AUP);
AlphaUserPointsHelper::newpoints( 'function_name', '', '', '', -1450);
}
f) Get the result from a successfull operation:
In a more advanced code, if the component routine needs to know if the operation has been successfull or not, (enough amount of points for a purchase in a user account), we can add a 'feedback' parameter. It has a Boolean type value.
Code example:
$api_AUP = JPATH_SITE.DS.'components'.DS.'com_alphauserpoints'.DS.'helper.php';
if ( file_exists($api_AUP))
{
require_once ($api_AUP);
if (AlphaUserPointsHelper::newpoints( 'plgaup_purchasewithvirtuemart', '', 'payment ID: 20080831-YHMU', 'Product reference: AM-5245', -1290, true))
{
[... code continued ...]
}
}
g) Remove the constraint on the type of user:
In a customized code component, you can force and remove the constraint on a rule to the user level by adding the parameter force = 1. The existing rule will be available now for guest, registered and special.
h) API full implementation:
AlphaUserPointsHelper::newpoints( string$pluginfunction, [string$AUPIDotheruser = ''], [string$keyreference = ''], [string$data = ''], [integer$randompoints = 0], [boolean$feedback = false], [integer$force=0]);
Note: If a the operation is a points substraction, the account has to have at least the same amount of points. If not, a notice warns the user that he doe'snt have enough points to complete the action.