<?php $options = array('type' => 'user', 'limit' => false); $all_users = new ElggBatch('elgg_get_entities', $options); foreach ($all_users as $user) { $options = array('guid' => $user->guid, 'metadata_name' => 'userpoints_points'); elgg_delete_metadata($options); $users_points = userpoints_get($user->guid); $users_approved_points = $users_points['approved']; $user->userpoints_points = (int) $users_approved_points; } system_message(elgg_echo("elggx_userpoints:restore_all:success")); forward(REFERER);
function hasUserPointsRequired($voucher_points) { if (elgg_is_active_plugin("elggx_userpoints")) { $userpoints = userpoints_get(elgg_get_logged_in_user_guid()); if ($userpoints[approved] >= $voucher_points) { return true; } } return false; }
/** * Elgg Gifts plugin * Send gifts to you friends * * @package Gifts * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 * @author Christian Heckelmann * @copyright Christian Heckelmann * @link http://www.heckelmann.info * * updated by iionly (iionly@gmx.de) */ elgg_require_js('gifts/gifts'); $useuserpoints = elgg_get_plugin_setting('useuserpoints', 'gifts'); if ($useuserpoints == 1 && function_exists('userpoints_get')) { $pTemp = userpoints_get(elgg_get_logged_in_user_guid()); $points = $pTemp['approved']; } if (!$points) { $points = 0; } $formBody = ''; if ($useuserpoints == 1) { $formBody .= "<div class='mbm'>" . elgg_echo("gifts:pointssum", array($points)) . "</div>"; } $send_to = get_input('send_to'); // Already send_to? if ($send_to) { //get the user object $user = get_user($send_to); //draw it
/** * Check for an existing pending invite for the given email address. * * @param string $email The amail address of the invited user * @return Bool Return true/false on pending record found or not */ function elggx_userpoints_registration_award($email) { $access = elgg_set_ignore_access(true); $guids = elggx_userpoints_invite_status(null, $email); if (!empty($guids)) { foreach ($guids as $guid) { $entity = get_entity($guid); $entity->meta_moderate = 'approved'; $user = get_user($entity->owner_guid); if (is_int($user->userpoints_points)) { $user->userpoints_points = (int) $user->userpoints_points + (int) $entity->meta_points; } else { $options = array('guid' => $user->guid, 'metadata_name' => 'userpoints_points'); elgg_delete_metadata($options); $users_points = userpoints_get($user->guid); $users_approved_points = $users_points['approved']; $user->userpoints_points = (int) $users_approved_points; } if (!elgg_trigger_plugin_hook('userpoints:update', 'object', array('entity' => $user), true)) { $user->userpoints_points = (int) $user->userpoints_points - (int) $entity->meta_points; } } } elgg_set_ignore_access($access); return; }
$gift_id = get_input('gift_id'); $body = get_input('body'); $cost = get_input('giftcost'); $access = get_input('access'); $receiver = get_entity($receiver_guid); $sender = elgg_get_logged_in_user_entity(); $sender_guid = $sender->getGUID(); // No Friend selected? if (!$receiver instanceof ElggUser || empty($gift_id)) { register_error(elgg_echo("gifts:blank")); forward("gifts/" . $sender->name . "/sendgift"); } // Userpoints $useuserpoints = elgg_get_plugin_setting('useuserpoints', 'gifts'); if ($useuserpoints == 1 && function_exists('userpoints_subtract')) { $pTemp = userpoints_get($sender_guid); $points = $pTemp['approved']; // Set new Point Value if (userpoints_subtract($sender_guid, $cost, 'gifts')) { system_message(elgg_echo('gifts:pointsuccess')); } else { system_message(elgg_echo('gifts:pointfail')); } } // create a gifts object $gift = new ElggObject(); $gift->description = $body; $gift->receiver = $receiver_guid; $gift->gift_id = $gift_id; $gift->subtype = "gift"; $gift->access_id = $access;