betauserpoints:developer
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
betauserpoints:developer [2023/04/07 09:15] – admin | betauserpoints:developer [2023/04/07 09:32] (current) – admin | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | BetaUserPoints Developers API documentation | + | ====== |
- | =========================================== | + | |
Introduction BetaUserPoints - API integration in a Third party component (advanced) | Introduction BetaUserPoints - API integration in a Third party component (advanced) | ||
Line 7: | Line 7: | ||
Licence: BetaUserPoints is released under license GNU/GPL License. Author: Bernard Gilly – Adrien Roussel - Martin Brampton. This project started as AlphaUserPoints back in 2008. | Licence: BetaUserPoints is released under license GNU/GPL License. Author: Bernard Gilly – Adrien Roussel - Martin Brampton. This project started as AlphaUserPoints back in 2008. | ||
- | Plugin/Rule creation | + | ===== Plugin/Rule creation |
- | -------------------- | + | |
A plugin creation (new rule creation for a 3rd party component) is done in 2 steps | A plugin creation (new rule creation for a 3rd party component) is done in 2 steps | ||
- | ### Step1 - API insertion in a component | + | === Step1 - API insertion in a component |
Just insert the following API in the component code where needed. The best way is to make it follow a user action that could give the users some points or take some. For example : in a comment system component or in a forum, just add the API after the comment or topic INSERT query in the database. | Just insert the following API in the component code where needed. The best way is to make it follow a user action that could give the users some points or take some. For example : in a comment system component or in a forum, just add the API after the comment or topic INSERT query in the database. | ||
- | ### Basic API | + | === Basic API === |
Line 41: | Line 40: | ||
- | ### Attribute points to another user than the current user | + | === Attribute points to another user than the current user === |
To give points to anothe user than the one connected, only the user id is required. To get his BetaUserPoints (BUPID) 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. | To give points to anothe user than the one connected, only the user id is required. To get his BetaUserPoints (BUPID) 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. | ||
Line 55: | Line 54: | ||
</ | </ | ||
- | ### Avoid attributing points more than once for the same action | + | === Avoid attributing points more than once for the same action |
To avoid a user getting points many times for something already done, we can add a reference key. When calling the BetaUserPointsHelper:: | To avoid a user getting points many times for something already done, we can add a reference key. When calling the BetaUserPointsHelper:: | ||
Line 64: | Line 63: | ||
{ | { | ||
require_once $api_BUP; | require_once $api_BUP; | ||
- | $keyreference = BetaUserPointsHelper:: | + | $keyreference = BetaUserPointsHelper:: |
BetaUserPointsHelper:: | BetaUserPointsHelper:: | ||
} | } | ||
</ | </ | ||
- | ### Adding information datas | + | === Adding information datas === |
To add information datas to be displayed in the action details, just add a new parameter as follows: | To add information datas to be displayed in the action details, just add a new parameter as follows: | ||
Line 78: | Line 77: | ||
{ | { | ||
require_once $api_BUP; | require_once $api_BUP; | ||
- | $keyreference = BetaUserPointsHelper:: | + | $keyreference = BetaUserPointsHelper:: |
BetaUserPointsHelper:: | BetaUserPointsHelper:: | ||
} | } | ||
</ | </ | ||
- | ### Using different amounts of points on the same rule | + | === 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 different prices, a fixed amount in the rule would' | A component might also need to add or to take points for different amounts. For example, when buying goods with points. Products have different prices, a fixed amount in the rule would' | ||
Line 92: | Line 91: | ||
{ | { | ||
require_once $api_BUP; | require_once $api_BUP; | ||
- | $keyreference = BetaUserPointsHelper:: | + | $keyreference = BetaUserPointsHelper:: |
BetaUserPointsHelper:: | BetaUserPointsHelper:: | ||
} | } | ||
</ | </ | ||
- | ### Get the result from a successful operation | + | === Get the result from a successful operation |
In a more advanced code, if the component routine needs to know if the operation has been successful or not, (enough amount of points for a purchase in a user account), we can add a ' | In a more advanced code, if the component routine needs to know if the operation has been successful or not, (enough amount of points for a purchase in a user account), we can add a ' | ||
Line 114: | Line 113: | ||
</ | </ | ||
- | ### Remove the constraint on the type of user | + | === 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_. | 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_. | ||
- | ### Display an additional system message on frontend | + | === Display an additional system message on frontend |
you can display a specific message on frontend by adding the parameter frontmessage=”You custom message”. API full implementation | you can display a specific message on frontend by adding the parameter frontmessage=”You custom message”. API full implementation | ||
Line 137: | Line 136: | ||
Note: If the operation is a points substraction, | Note: If the operation is a points substraction, | ||
- | Step 2 - XML file creation | + | ==== Step 2 - XML file creation |
- | -------------------------- | + | |
Then developers have to create an xml file to make easier the installation process in the BetaUserPoints component. This xml file has to be utf-8 encoded (required). All developers of third party extensions for Joomla! can add directly at the root of their frontend component a unique xml file containing all the rules for a single component. Deveoper has to respect the ordering and tags: structure example: [betauserpoints_rule.xml](images/ | Then developers have to create an xml file to make easier the installation process in the BetaUserPoints component. This xml file has to be utf-8 encoded (required). All developers of third party extensions for Joomla! can add directly at the root of their frontend component a unique xml file containing all the rules for a single component. Deveoper has to respect the ordering and tags: structure example: [betauserpoints_rule.xml](images/ | ||
Line 144: | Line 142: | ||
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: betauserpoints_rule.xml | 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: betauserpoints_rule.xml | ||
- | ### Code list for categories : | + | === Code list for categories : === |
< | < | ||
Line 167: | Line 165: | ||
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 ' | 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 ' | ||
- | Plugin/Rule installation | + | ==== Plugin/Rule installation |
- | ------------------------ | + | |
- auto-detect xml file at the root of frontend component: | - auto-detect xml file at the root of frontend component: | ||
Click on the button “Auto-detect plugins” in the control panel of BetaUserPoints after installation of third component, plugin or module. Check regularly or periodically by clicking on this button. | Click on the button “Auto-detect plugins” in the control panel of BetaUserPoints after installation of third component, plugin or module. Check regularly or periodically by clicking on this button. | ||
- | Using BetaUserPoints | + | ==== Using BetaUserPoints |
- | ------------------------------------------------------------ | + | |
You can use easily the profil informations of a user directly in a third component. | You can use easily the profil informations of a user directly in a third component. | ||
Line 183: | Line 179: | ||
</ | </ | ||
- | ### Profil informations | + | === Profile information === |
To get the entire profil information, | To get the entire profil information, | ||
Line 243: | Line 239: | ||
</ | </ | ||
- | ### Get BUP avatar of user | + | === Get BUP avatar of user === |
Display the image of avatar from BetaUserPoints. | Display the image of avatar from BetaUserPoints. | ||
Line 254: | Line 250: | ||
- | ### Get link to BUP user profil | + | === Get link to BUP user profile === |
Get the url to show the profil of user. | Get the url to show the profil of user. | ||
Line 262: | Line 258: | ||
</ | </ | ||
- | ### Get link to BUP users list | + | === Get link to BUP users list === |
Get the url to show the list of users with points etc… | Get the url to show the list of users with points etc… | ||
Line 271: | Line 267: | ||
- | ### Get avatar Path of a user | + | === Get avatar Path of a user === |
Get the path avatar path of a specific user | Get the path avatar path of a specific user | ||
Line 280: | Line 276: | ||
- | ### Get avatar Live Path of a user | + | === Get avatar Live Path of a user === |
Get the live url avatar path of a specific user | Get the live url avatar path of a specific user | ||
Line 288: | Line 284: | ||
</ | </ | ||
- | ### Get the medals list of a user | + | === Get the medals list of a user === |
<code php> | <code php> | ||
Line 311: | Line 307: | ||
if(!defined(" | if(!defined(" | ||
{ | { | ||
- | define(' | + | define(' |
} | } | ||
if(!defined(" | if(!defined(" | ||
Line 324: | Line 320: | ||
</ | </ | ||
- | ### Get the ReferreID of any user | + | === Get the ReferreID of any user === |
<code php> | <code php> | ||
Line 333: | Line 329: | ||
- | ### Get the current total points of any user | + | === Get the current total points of any user === |
Use the first method with the referreid to get the total of points | Use the first method with the referreid to get the total of points | ||
Line 347: | Line 343: | ||
</ | </ | ||
- | ### Get the list of activities | + | === Get the list of activities |
<code php> | <code php> | ||
Line 383: | Line 379: | ||
</ | </ | ||
- | ### Get the next user rank | + | === Get the next user rank === |
<code php> | <code php> | ||
- | $nextrankinfo = BetaUserPointsHelper:: | + | $nextrankinfo = BetaUserPointsHelper:: |
</ | </ | ||
Line 399: | Line 395: | ||
</ | </ | ||
- | ### Get version of BUP | + | === Get version of BUP === |
<code php> | <code php> | ||
Line 405: | Line 401: | ||
</ | </ | ||
- | Returns the current version of BetaUserPoints like -> 1.0.0 | + | Returns the current version of BetaUserPoints like -> 4.0.0 |
- | BetaUserPoints is open for third component | + | ==== BetaUserPoints is open for third component |
- | ------------------------------------------ | + | |
Create your own plugin for BetaUserPoints ! | Create your own plugin for BetaUserPoints ! | ||
Line 437: | Line 432: | ||
* Created on 15 January 2016. | * Created on 15 January 2016. | ||
+ | |||
* Last updated on 05 April 2023. | * Last updated on 05 April 2023. | ||
betauserpoints/developer.1680858954.txt.gz · Last modified: 2023/04/07 09:15 by admin