[Elgg 1.8-1.12 & 2.X: Elggx Userpoints] v1.8.1beta4

Release Notes

IMPORTANT: THIS IS A BETA RELEASE!!! Use on productive sites on your own risk !!! You have been warned!!!

Changelog:

  • A fix needed for the Gifts plugin to work (or all other plugins that want to use the functions userpoints_exists() and userpoints_get()).

TODO:

  • Thorough testing (also with 3rd party plugins as soon as they are available or I've managed to port them to Elgg 1.8)...
  • Which version of Elggx Userpoints are you using? You say you use Elgg 2.2.3 but are posting on the Elggx Userpoints page of version v1.8.1beta4. For Elgg 2.2.3 version 2.0.1 would be the currently recommended release.

    Does the error occur when trying to restore the userpoints of this specific user in the plugin settings page of Elggx Userpoints? Do you see any entries in the server log(s) that might explain what's goint wrong?

    Had this user gained many userpoints (less important is the number of points but rather the number of userpoint entities that were created by his actions - one entity per action that he got userpoints for)? If the number is high, the restoring might cause an out-of-memory error. I'd started working on a new release of the userpoints plugin in fall last year but never had the time to finish it up to now (and I can't finish it on short term either unfortunately). If the problem is caused by an oom error it might help you to replace the code of the userpoints_get() function in mod/elggx_userpoints/lib/userpoint.php (of version 2.0.1) with the following:

    function userpoints_get($user_guid) {
    
        $points = array('approved' => 0, 'pending' => 0);
    
        $entities = new ElggBatch('elgg_get_entities_from_metadata', array(
            'metadata_name' => 'meta_points',
            'type' => 'object',
            'subtype' => 'userpoint',
            'owner_guid' => $user_guid,
            'limit' => false
        ));
    
        foreach($entities as $obj) {
            if (isset($obj->meta_moderate)) {
                if ($obj->meta_moderate == 'approved') {
                    $points['approved'] += $obj->meta_points;
                } else if ($obj->meta_moderate == 'pending') {
                    $points['pending'] += $obj->meta_points;
                }
            } else {
                $points['approved'] += $obj->meta_points;
            }
        }
    
        return $points;
    }

    If it's only the re-calculation of the userpoints when restoring the points this hopefully fixes a possible memory issue. For any other changes it's too early (work-in-progress) to release any code at the moment.

Stats

  • Category: Misc
  • License: GNU General Public License (GPL) version 2
  • Updated: 2019-4-7
  • Downloads: 12399
  • Recommendations: 50

Other Projects

View iionly's plugins