X-Git-Url: https://git.stricted.de/?p=GitHub%2FWoltLab%2Fwoltlab.github.io.git;a=blobdiff_plain;f=5.4%2Fphp%2Fapi%2Fuser_activity_points%2Findex.html;h=26d863de9774db2b18e04703fa292579c7e9e819;hp=e6ccbb9fd18eadb7c70dfa16e92303ad1df6e630;hb=704cbc4a08ba7a57c23e951255ffc41a21c31a7f;hpb=716a4ab6d247e50b770ecb39804a2d0a12e8e3bd diff --git a/5.4/php/api/user_activity_points/index.html b/5.4/php/api/user_activity_points/index.html index e6ccbb9f..26d863de 100644 --- a/5.4/php/api/user_activity_points/index.html +++ b/5.4/php/api/user_activity_points/index.html @@ -1957,26 +1957,43 @@

Users get activity points whenever they create content to award them for their contribution. Activity points are used to determine the rank of a user and can also be used for user conditions, for example for automatic user group assignments.

To integrate activity points into your package, you have to register an object type for the defintion com.woltlab.wcf.user.activityPointEvent and specify a default number of points:

-
<type>
+
1
+2
+3
+4
+5
<type>
     <name>com.example.foo.activityPointEvent.bar</name>
     <definitionname>com.woltlab.wcf.user.activityPointEvent</definitionname>
     <points>10</points>
 </type>
 
+

The number of points awarded for this type of activity point event can be changed by the administrator in the admin control panel. For this form and the user activity point list shown in the frontend, you have to provide the language item

-
wcf.user.activityPoint.objectType.com.example.foo.activityPointEvent.bar
+
1
wcf.user.activityPoint.objectType.com.example.foo.activityPointEvent.bar
 
+

that contains the name of the content for which the activity points are awarded.

If a relevant object is created, you have to use UserActivityPointHandler::fireEvent() which expects the name of the activity point event object type, the id of the object for which the points are awarded (though the object id is not used at the moment) and the user who gets the points:

-
UserActivityPointHandler::getInstance()->fireEvent(
+
1
+2
+3
+4
+5
UserActivityPointHandler::getInstance()->fireEvent(
         'com.example.foo.activityPointEvent.bar',
         $bar->barID,
         $bar->userID
 );
 
+

To remove activity points once objects are deleted, you have to use UserActivityPointHandler::removeEvents() which also expects the name of the activity point event object type and additionally an array mapping the id of the user whose activity points will be reduced to the number of objects that are removed for the relevant user:

-
UserActivityPointHandler::getInstance()->removeEvents(
+
1
+2
+3
+4
+5
+6
+7
UserActivityPointHandler::getInstance()->removeEvents(
         'com.example.foo.activityPointEvent.bar',
        [
                 1 => 1, // remove points for one object for user with id `1`
@@ -1984,6 +2001,7 @@ For this form and the user activity point list shown in the frontend, you have t
         ]
 );
 
+