You are here

README.txt in User Points 6

Same filename and directory in other branches
  1. 5.3 README.txt
  2. 5 README.txt
  3. 5.2 README.txt
  4. 7.2 README.txt
  5. 7 README.txt
Copyright 2005-2008 http://2bits.com

Description
-----------
The userpoints and userpoints_nc module provides the ability for users to gain
points with the do certain actions, such as:

- posting a node (different points can be awarded for different
  node types, e.g. page, story, forum, image, ...etc.)
- posting a comment
- moderating a comment

Upon deleting a node or a comment the number of points is subtracted.
If a node or comment author is changed points are transferred respectively

The number of points for each of the above actions is configurable by
the site adminsitrator.

A transaction log is created for each event. The log is viewable by
the admin.

Points can be moderated, i.e. approval can be done by the admin at a later
time.

A block displays the number of points the user gained. Another block 
displays the top 5 users who earned points.

----
Using modules from the project http://drupal.org/project/userpoints_contrib 
point can be awarded for other actions. 
including:
- voting on a node (requires the nodevote module)
- referring a person to the site (requires referral module)
- a visitor comes to the site via clicking on an affiliate link
  (requires the affiliates module)
- voting up or down a node (requires the vote_up_down module)
- inviting a person to register on the site (requires invite module)
- invited person actually registers on the site
- purchasing from your e-commerce store (reward points)

Using real money, users can purchase points from your ecommerce store
as well. Moreover, the points can be used as currency for ecommerce as well,
as in a form of payment


This module is useful in providing an incentive for users to participate
in the site, and be more active. The module is easily extended through use of 
the API (see below)


Initally sponsored by: http://artalyst.com

Installation
------------
To install this module, do the following:

1. Extract the tar ball that you downloaded from Drupal.org.

2. Upload the userpoints directory and all its contents to your
   modules directory.

Configuration
-------------
To enable this module do the following:

1. Go to Admin -> Modules, and enable userpoints.
   Check the messages to make sure that you did not get any errors
   on database creation.

2. Go to Admin -> Settings -> userpoints.

   Configure the options as per your requirements

3. Go to Admin -> Access Control and enable viewing for the roles you want.

For configuring with e-commerce, you have to have the ecommerce modules
installed and configured.

- User points can be used as a form of payment, with an admin defined
  multiplier

- Users gain points when purchasing items via e-commerce for every dollar
  they spend.

This is useful as a reward system.

This also allows purchasing of points for real money. You have to setup
a non-shippable product, and adjust the multiplier accordingly.

API
---
This modules provides an application programming interface (API), which is
callable and actionable by other modules.

The functions are:

userpoints_userpointsapi()

  Accepts an integer or an array. 
  If the parameter is an integer it is assumed to be points 
  for the currently logged in user (i.e. global $user; $user->uid) 

  If the parameter is an array the array can contain one or more of the
  following options. The only required parameters are 'points' or 'txn_id'
  If a parameter is not set the site settings will used. Setting a parameter 
  to NULL will cause the entry to be NULL, defaults are only used if the 
  parameter is not set

  Returns an array with a status (true/false) and a reason (string) if there
  is an error. example
  return array('status' => false, 'reasaon' => 'DB transaction failed');
  
  'uid'         => (int) User ID 
  'points'      => (int) # of points to award the user 
  'txn_id'      => (int) Transaction ID of a current points record. If
                         present an UPDATE occurs
  'moderate'    => (boolean) TRUE or FALSE. If NULL site settings are adhered to
  'description' => (string) fulltext Description presented to the user
  'expirydate'  => (timestamp) timestamp the date/time when the points will
                               be expired (depends on cron)
  'event'       => (string) varchar32 descriptive identifier administrative purposes
  'reference'   => (string) varchar32 indexed/searchable field on the DB
  'display'     => (boolean) Whether or not to display the "Points awarded"
                             message. If null, fall back to USERPOINTS_DISPLAY_MESSAGE
  'tid'         => (int) Taxonomy ID to place these points into; MUST BE in
                         the userpoints Vocabulary!

  Examples
    //Add 5 points to the currently logged in user
    userpoints_userpointsapi(5);  

    //Also add 5 points to the currently logged in user
    $params = array (
      'uid' => $user->uid,
      'points' => 5,
    );
    userpoints_userpointsapi($params); 

  
//---Hooks
hook_userpoints($op, $params = array()) 

  Use this hook to act upon certain operations. When other modules award
  points to a user, your hook will be called, among others.

  The arguments are:

  $op: The operation to be acted upon.
    'setting'
      Pass a field set and fields that would be displayed in the userpoints
      settings page. For example, this can be used for your program to ask
      the admin to set a number of points for certain actions your module
      performs. The function should return an array object conforming to
      FormsAPI structure.

    'points before'
      Calls your module, and others, before the points are processed. You can
      prevent points from being awarded by returning FALSE.

    'points after'
      Calls your module, and others, after points are processed. You can take
      certain actions if you so wish. Return value is ignored.

   The $params variable is the original $params array as sent to userpoints_userpointsapi
 
//---Other useful functions

userpoints_get_current_points($uid = NULL, $tid = NULL);
  Returns an integer of the sum of the user's point 
  If a tid is passed in that category's sum is returned otherwise
  the sites default category is used

userpoints_get_max_points($uid = NULL, $tid = NULL);
  Returns an integer of the sum of the user's max points achieved
  If a tid is passed in that category's sum is returned otherwise
  the sites default category is used

userpoints_get_vid()
  Returns an integer of the userpoints Vocabulary

userpoints_get_default_tid()
  Returns an integer for the userpoints default Taxonomy ID
  Note: this is the default when submitting points so you 
        DO NOT need to pass this into userpoints_userpointsapi

userpoints_get_categories()
  Returns an array of the possible categories including
  the special "Uncategorized" category (id=0). This is a keyed
  array that works perfectly with FAPI. If you're creating a 
  settings page wherein a user would select the category to 
  place points into, this will give you exactly what you need.
  See userpoints.module admin_settings function for an example.

userpoints_get_default_expiry_date()
  Returns a UNIX timestamp of the site's default expiration date.
  If an expiration date (or interval) it will be returned otherwise NULL

XML-RPC
-------

Using the userpoints_services module, and the services modules, you 
can allow external applications to query and update points on your
site.

Please refer to the services module documentation for further information.

Userpoints provides the follwing XML-RPC calls:

userpoints.get 

  string api_key (required)
    A valid API key.
  int uid (required)
    A valid Drupal User ID.
  int tid (optional)
    An optional Term ID for the category.

Example:

  $result = xmlrpc($server_url, 'userpoints.get', $key, $uid, $tid);
  // $result is an array
  // 'points' => 123

userpoints.points

  string api_key (required)
    A valid API key.
  int uid (required)
    A valid Drupal User ID.
  int points (required)
    Number of points to add/subtract.
  int tid (optional)
    An optional Term ID for the category.
  string event (optional)
    An optional event ID for this transaction.
  string description (optional)
    An optional description of this transaction.

Example:

  $result = xmlrpc($server_url, 'userpoints.points', $key, $uid, $points, $tid, $event, $description);
  // $result is an array
  // 'status'
  //   1 => Success
  //   0 => Fail
  // 'reason'
  //   Textual reason for failure, if status is 0

Bugs/Features/Patches:
----------------------
If you want to report bugs, feature requests, or submit a patch, please do so
at the project page on the Drupal web site.
http://drupal.org/project/userpoints

Author
------
Khalid Baheyeldin (http://baheyeldin.com/khalid and http://2bits.com)

If you use this module, find it useful, and want to send the author
a thank you note, then use the Feedback/Contact page at the URL above.

The author can also be contacted for paid customizations of this
and other modules.

File

README.txt
View source
  1. Copyright 2005-2008 http://2bits.com
  2. Description
  3. -----------
  4. The userpoints and userpoints_nc module provides the ability for users to gain
  5. points with the do certain actions, such as:
  6. - posting a node (different points can be awarded for different
  7. node types, e.g. page, story, forum, image, ...etc.)
  8. - posting a comment
  9. - moderating a comment
  10. Upon deleting a node or a comment the number of points is subtracted.
  11. If a node or comment author is changed points are transferred respectively
  12. The number of points for each of the above actions is configurable by
  13. the site adminsitrator.
  14. A transaction log is created for each event. The log is viewable by
  15. the admin.
  16. Points can be moderated, i.e. approval can be done by the admin at a later
  17. time.
  18. A block displays the number of points the user gained. Another block
  19. displays the top 5 users who earned points.
  20. ----
  21. Using modules from the project http://drupal.org/project/userpoints_contrib
  22. point can be awarded for other actions.
  23. including:
  24. - voting on a node (requires the nodevote module)
  25. - referring a person to the site (requires referral module)
  26. - a visitor comes to the site via clicking on an affiliate link
  27. (requires the affiliates module)
  28. - voting up or down a node (requires the vote_up_down module)
  29. - inviting a person to register on the site (requires invite module)
  30. - invited person actually registers on the site
  31. - purchasing from your e-commerce store (reward points)
  32. Using real money, users can purchase points from your ecommerce store
  33. as well. Moreover, the points can be used as currency for ecommerce as well,
  34. as in a form of payment
  35. This module is useful in providing an incentive for users to participate
  36. in the site, and be more active. The module is easily extended through use of
  37. the API (see below)
  38. Initally sponsored by: http://artalyst.com
  39. Installation
  40. ------------
  41. To install this module, do the following:
  42. 1. Extract the tar ball that you downloaded from Drupal.org.
  43. 2. Upload the userpoints directory and all its contents to your
  44. modules directory.
  45. Configuration
  46. -------------
  47. To enable this module do the following:
  48. 1. Go to Admin -> Modules, and enable userpoints.
  49. Check the messages to make sure that you did not get any errors
  50. on database creation.
  51. 2. Go to Admin -> Settings -> userpoints.
  52. Configure the options as per your requirements
  53. 3. Go to Admin -> Access Control and enable viewing for the roles you want.
  54. For configuring with e-commerce, you have to have the ecommerce modules
  55. installed and configured.
  56. - User points can be used as a form of payment, with an admin defined
  57. multiplier
  58. - Users gain points when purchasing items via e-commerce for every dollar
  59. they spend.
  60. This is useful as a reward system.
  61. This also allows purchasing of points for real money. You have to setup
  62. a non-shippable product, and adjust the multiplier accordingly.
  63. API
  64. ---
  65. This modules provides an application programming interface (API), which is
  66. callable and actionable by other modules.
  67. The functions are:
  68. userpoints_userpointsapi()
  69. Accepts an integer or an array.
  70. If the parameter is an integer it is assumed to be points
  71. for the currently logged in user (i.e. global $user; $user->uid)
  72. If the parameter is an array the array can contain one or more of the
  73. following options. The only required parameters are 'points' or 'txn_id'
  74. If a parameter is not set the site settings will used. Setting a parameter
  75. to NULL will cause the entry to be NULL, defaults are only used if the
  76. parameter is not set
  77. Returns an array with a status (true/false) and a reason (string) if there
  78. is an error. example
  79. return array('status' => false, 'reasaon' => 'DB transaction failed');
  80. 'uid' => (int) User ID
  81. 'points' => (int) # of points to award the user
  82. 'txn_id' => (int) Transaction ID of a current points record. If
  83. present an UPDATE occurs
  84. 'moderate' => (boolean) TRUE or FALSE. If NULL site settings are adhered to
  85. 'description' => (string) fulltext Description presented to the user
  86. 'expirydate' => (timestamp) timestamp the date/time when the points will
  87. be expired (depends on cron)
  88. 'event' => (string) varchar32 descriptive identifier administrative purposes
  89. 'reference' => (string) varchar32 indexed/searchable field on the DB
  90. 'display' => (boolean) Whether or not to display the "Points awarded"
  91. message. If null, fall back to USERPOINTS_DISPLAY_MESSAGE
  92. 'tid' => (int) Taxonomy ID to place these points into; MUST BE in
  93. the userpoints Vocabulary!
  94. Examples
  95. //Add 5 points to the currently logged in user
  96. userpoints_userpointsapi(5);
  97. //Also add 5 points to the currently logged in user
  98. $params = array (
  99. 'uid' => $user->uid,
  100. 'points' => 5,
  101. );
  102. userpoints_userpointsapi($params);
  103. //---Hooks
  104. hook_userpoints($op, $params = array())
  105. Use this hook to act upon certain operations. When other modules award
  106. points to a user, your hook will be called, among others.
  107. The arguments are:
  108. $op: The operation to be acted upon.
  109. 'setting'
  110. Pass a field set and fields that would be displayed in the userpoints
  111. settings page. For example, this can be used for your program to ask
  112. the admin to set a number of points for certain actions your module
  113. performs. The function should return an array object conforming to
  114. FormsAPI structure.
  115. 'points before'
  116. Calls your module, and others, before the points are processed. You can
  117. prevent points from being awarded by returning FALSE.
  118. 'points after'
  119. Calls your module, and others, after points are processed. You can take
  120. certain actions if you so wish. Return value is ignored.
  121. The $params variable is the original $params array as sent to userpoints_userpointsapi
  122. //---Other useful functions
  123. userpoints_get_current_points($uid = NULL, $tid = NULL);
  124. Returns an integer of the sum of the user's point
  125. If a tid is passed in that category's sum is returned otherwise
  126. the sites default category is used
  127. userpoints_get_max_points($uid = NULL, $tid = NULL);
  128. Returns an integer of the sum of the user's max points achieved
  129. If a tid is passed in that category's sum is returned otherwise
  130. the sites default category is used
  131. userpoints_get_vid()
  132. Returns an integer of the userpoints Vocabulary
  133. userpoints_get_default_tid()
  134. Returns an integer for the userpoints default Taxonomy ID
  135. Note: this is the default when submitting points so you
  136. DO NOT need to pass this into userpoints_userpointsapi
  137. userpoints_get_categories()
  138. Returns an array of the possible categories including
  139. the special "Uncategorized" category (id=0). This is a keyed
  140. array that works perfectly with FAPI. If you're creating a
  141. settings page wherein a user would select the category to
  142. place points into, this will give you exactly what you need.
  143. See userpoints.module admin_settings function for an example.
  144. userpoints_get_default_expiry_date()
  145. Returns a UNIX timestamp of the site's default expiration date.
  146. If an expiration date (or interval) it will be returned otherwise NULL
  147. XML-RPC
  148. -------
  149. Using the userpoints_services module, and the services modules, you
  150. can allow external applications to query and update points on your
  151. site.
  152. Please refer to the services module documentation for further information.
  153. Userpoints provides the follwing XML-RPC calls:
  154. userpoints.get
  155. string api_key (required)
  156. A valid API key.
  157. int uid (required)
  158. A valid Drupal User ID.
  159. int tid (optional)
  160. An optional Term ID for the category.
  161. Example:
  162. $result = xmlrpc($server_url, 'userpoints.get', $key, $uid, $tid);
  163. // $result is an array
  164. // 'points' => 123
  165. userpoints.points
  166. string api_key (required)
  167. A valid API key.
  168. int uid (required)
  169. A valid Drupal User ID.
  170. int points (required)
  171. Number of points to add/subtract.
  172. int tid (optional)
  173. An optional Term ID for the category.
  174. string event (optional)
  175. An optional event ID for this transaction.
  176. string description (optional)
  177. An optional description of this transaction.
  178. Example:
  179. $result = xmlrpc($server_url, 'userpoints.points', $key, $uid, $points, $tid, $event, $description);
  180. // $result is an array
  181. // 'status'
  182. // 1 => Success
  183. // 0 => Fail
  184. // 'reason'
  185. // Textual reason for failure, if status is 0
  186. Bugs/Features/Patches:
  187. ----------------------
  188. If you want to report bugs, feature requests, or submit a patch, please do so
  189. at the project page on the Drupal web site.
  190. http://drupal.org/project/userpoints
  191. Author
  192. ------
  193. Khalid Baheyeldin (http://baheyeldin.com/khalid and http://2bits.com)
  194. If you use this module, find it useful, and want to send the author
  195. a thank you note, then use the Feedback/Contact page at the URL above.
  196. The author can also be contacted for paid customizations of this
  197. and other modules.