[Elgg 1.8-1.12 & 2.X - 4.X: Elggx Userpoints] v1.10.14

Release Notes

  • composer.json added.
  • Hello, iionly.

    Don't work function userpoints_delete($user_guid, $guid) if administrator, or group's owner deletes content/object that was created by another user.

    For an awarded user it's works when he deletes own content/object.

    But it don't work in situation when a site/group administrator deletes that content/object.

    How to fix it?

    Thanks.

  • @maxvin If I understand you correctly, the problem is only occuring if group content is deleted by another user (i.e. the group owner). It should only occur if the group owner isn't a site admin.

    Modifying the code of userpoints_delete() as follows should fix the issue (bold lines are new):

    function userpoints_delete($user_guid, $guid) {

        if (!elgg_get_plugin_setting('delete', 'elggx_userpoints')) {
            return(false);
        }

        $access = elgg_set_ignore_access(true);
        $access_status = access_get_show_hidden_status();
        access_show_hidden_entities(true);

        $points = 0;

        $entities = elgg_get_entities_from_metadata(array('metadata_name' => 'meta_guid', 'metadata_value' => $guid, 'type' => 'object', 'subtype' => 'userpoint', 'owner_guid' => $user_guid, 'limit' => false));
        foreach ($entities as $entity) {
            $points = $points + $entity->meta_points;
            $entity->delete();
        }

        $user = get_user($user_guid);

        // Decrement the users total points
        userpoints_update_user($user_guid, -$points);

        access_show_hidden_entities($access_status);
        elgg_set_ignore_access($access);

    }

    I'll include the fix in the next release of the Userpoints plugin.

  • Show it also transaction list for a user? Not admin but everybody see.Thank.

  • @inca "Transactions" in the sense of "actions a user got userpoints for"? If you mean this, the answer is yes but only for admins in the admin area of the Elgg site. A user will only get a system message (if this plugin option is enabled) when getting / losing points but a user won't see for what other users got points for. There's only a toppoints list with the Top 10 users (by total number of points).

  • @iionly Thank you very much!

Stats

  • Category: Misc
  • License: GNU General Public License (GPL) version 2
  • Updated: 2023-9-16
  • Downloads: 16452
  • Recommendations: 47

Other Projects

View iionly's plugins