Alphauserpoints Developer 2.x
Alphauserpoints Developer 2.x
English Version:
Page | 1 of 15
www.AlphaPlug.com
INTRODUCTION:
AlphaUserPoints - API integration in a Third party component (advanced)
This documentation was created for developers and, or anyone with a sufficient knowledge of
PHP language and Joomla component development.
Licence: AlphaUserPoints is released under license GNU/GPL License.
Author: Documentation written by Bernard Gilly for Pamper Me Network.
Index
AlphaUserPoints......................................................................................................................... 1
Manual For Developers .............................................................................................................. 1
INTRODUCTION:................................................................................................................. 2
Index ....................................................................................................................................... 2
Sales & Marketing Support For Developers .......................................................................... 4
Sample AlphaUserPoints Integration ..................................................................................... 5
Plugin/Rule creation ................................................................................................................... 6
Profil informations ............................................................................................................... 11
Get AUP avatar of user ....................................................................................................... 12
Get link to AUP user profil .................................................................................................. 12
Get link to AUP users list ..................................................................................................... 12
Get avatar Path of a user ...................................................................................................... 12
Get avatar Live Path of a user .............................................................................................. 12
Get the medals list of a user ................................................................................................. 12
Get the ReferreID of any user .............................................................................................. 13
Get the current total points of any user ................................................................................ 13
Get the list of activities......................................................................................................... 14
Get the next user rank........................................................................................................... 14
Get version of AUP .............................................................................................................. 15
Page | 2 of 15
www.AlphaPlug.com
Bernard Gilly spent almost ten (10) years perfecting AlphaUserPoints (AUP)
because he believed in a strong, dynamic Joomla community where all
developers give back as well as profit from their hardwork. In doing so, he
created the infrastructure necessary to transform the AUP component into a
powerful tool for social change powered by social rewards technology.
Upon retirement, Bernard passed the torch onto the Pamper Me Network to
grow his vision to distribute technology that enables software developers,
webmasters, crowd funders and related experts to reward their supporters for
sharing messages. We have embraced his vision and created the Joomla
Developer Partner Program to help developers to introduce their great
extensions, great ideas, crowd funding projects, events and special offers with a
global network of Joomla supporters.
So if you are a developer and share our vision we want to help you to grow your
Joomla business. Let's change the world together.
Page | 3 of 15
www.AlphaPlug.com
Page | 4 of 15
www.AlphaPlug.com
SAMPLE ALPHAUSERPOINTS
INTEGRATION
The list of Joomla applications supported by AlphaUserPoints is growing
constantly. Some of the integrations include Jomsocial, joobi jMarket, joobi
jSubscription, joobi jStore, Community Builder, CBE, JomWALL, Phoca
Gallery, VirtueMart, Joomunity, Jdownloads, JUDownloads, Jcomments, Awo
Rewards, Kuena, Jreview, ACYMailing, HikaSocial, UddeIM, JoomGallery,
JVLinkDirectory and Invitex to name a few.
For example, you can now use AlphaUserPoints to pay for Joobi jMarket, Joobi
jStore and Joobi jSubscription purchases.
You can review how jJoobi has chosen to enhance its components with
AlphaUserPoints by visiting
http://www.fanrewardsnetwork.com/index.php?option=com_k2&view=item&id
=501
If you have already built a AUP plugin we would like to share your project with
the community. Create a PMN account, add your articles, white papers, news
release or special offer announcements. Visit http://www.alphaplug.com to
login and submit.
Page | 5 of 15
www.AlphaPlug.com
API DOCUMENTATION
Plugin/Rule creation
A plugin creation (new rule creation for a 3rd party component) is done in 2 steps.
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 convenient 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 Kunena:
plgaup_kunena_topic_create.
Keep in mind that this method only gives points to the current user logged in. This is the
Basic API.
Page | 6 of 15
www.AlphaPlug.com
$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 );
}
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);
$keyreference = AlphaUserPointsHelper::buildKeyreference('function_name', item
id );
AlphaUserPointsHelper::newpoints( 'function_name', '', $keyreference);
}
Page | 7 of 15
www.AlphaPlug.com
$api_AUP = JPATH_SITE.DS.'components'.DS.'com_alphauserpoints'.DS.'helper.php';
if ( file_exists($api_AUP))
{
require_once ($api_AUP);
$keyreference = AlphaUserPointsHelper::buildKeyreference('function_name', item id );
AlphaUserPointsHelper::newpoints( 'function_name', '', $keyreference, '', -1450);
}
}
}
Note: If 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 (by default).
Page | 8 of 15
www.AlphaPlug.com
Tag component is the name of the third component like com_kunena or other. As it is the
same component, it is worth repeating for each rule in the tag rule
Administrator of the website which install a third component with this xml file can autodetect directly from the button auto-detect plugins in control panel of AlphaUserPoints.
Page | 9 of 15
www.AlphaPlug.com
This xml file has to be utf-8 encoded (required) but not be zipped! Just put this file at the root
of frontend component folder or plugin or module and include this file in your installer
extension. This file must be named exactly as follows: alphauserpoints_rule.xml
Code list for categories :
ar -> articles
cd -> coupons
co -> community
fo -> forums/comments
li -> links
mu -> music
ot -> other
ph -> photo
po -> polls
pu -> purchase
re -> recommend/send to a friend
sh -> shopping
su -> private
sy -> system rules
us -> users
vi -> video
NOTE :
Optionally, you can avoid this step manually by filling all the fields in the creation of a new
rule directly in the rule manager (button new in toolbar).
Plugin/Rule installation
- auto-detect xml file at the root of frontend component:
Click on the button Auto-detect plugins in the control panel of AlphaUserPoints after
installation of third component, plugin or module. Check regularly or periodically by clicking
on this button.
Page | 10 of 15
www.AlphaPlug.com
Profil informations
To get the entire profil information, just use the function getUserInfo() ;
Just use the referreid of AlphaUserPoints user or the joomla ID of the user (Id of Joomla
users table).
Use the first method with the referreid to get user Information profile like this :
AlphaUserPointsHelper::getUserInfo ( $referrerid ) ;
If you have not the referreid, you can use the ID of user in second parameter like this :
$user = & JFactory::getUser();
$userid = $user->id ;
$profil = AlphaUserPointsHelper::getUserInfo ( , $user->id ) ;
Then you can get the user informations.
$profil->name
$profil->username
$profil->registerDate
$profil->lastvisitDate
$profil->email
$profil->referreid
$profil->points
$profil->max_points
$profil->last_update
$profil->referraluser
$profil->referrees
$profil->blocked
$profil->birthdate
$profil->avatar
$profil->levelrank
$profil->leveldate
$profil->gender
$profil->aboutme
$profil->website
$profil->phonehome
$profil->phonemobile
$profil->address
$profil->zipcode
$profil->city
$profil->country
$profil->education
$profil->graduationyear
$profil->job
$profil->facebook
$profil->twitter
$profil->icq
$profil->aim
$profil->yim
$profil->msn
$profil->skype
$profil->gtalk
Page | 11 of 15
www.AlphaPlug.com
$profil->xfire
$profil->profileviews
Page | 12 of 15
www.AlphaPlug.com
Page | 13 of 15
www.AlphaPlug.com
Page | 14 of 15
www.AlphaPlug.com
onBeforeInsertUserActivityAlphaUserPoints
onUpdateAlphaUserPoints
onAfterUpdateAlphaUserPoints
onChangeLevelAlphaUserPoints
onUnlockMedalAlphaUserPoints
onGetNewRankAlphaUserPoints
onResetGeneralPointsAlphaUserPoints
onBeforeDeleteUserActivityAlphaUserPoints
onAfterDeleteUserActivityAlphaUserPoints
onBeforeDeleteAllUserActivitiesAlphaUserPoints
onAfterDeleteAllUserActivitiesAlphaUserPoints
onBeforeMakeRaffleAlphaUserPoints
onAfterMakeRaffleAlphaUserPoints
Page | 15 of 15
www.AlphaPlug.com