2020-11-25, 09:59 AM
Hello,
i'm want to add points per a user get a new award but i can't find this feature.
so i create a new function but i think i have some errors can any one help me ?
I use Newpoints and OUGC Awards Plugins
i'm want to add points per a user get a new award but i can't find this feature.
so i create a new function but i think i have some errors can any one help me ?
I use Newpoints and OUGC Awards Plugins
function newpoints_newaward()
{
global $db, $mybb, $user, $awards, $parser;
if (!$mybb->user['uid'])
return;
if ($mybb->settings['newpoints_main_enabled'] != 1)
return;
if ($mybb->settings['newpoints_income_award'] == 0)
return;
$categories = $cids = $thread_cache = $tids = array();
$query = $db->simple_select('ougc_awards_categories', '*', "visible='1'");
while($category = $db->fetch_array($query))
{
$cids[] = (int)$category['cid'];
$categories[] = $category;
};
$whereclause = "u.visible=1 AND u.uid='".(int)$user['uid']."' AND a.visible='1' AND a.type='2' AND a.cid IN ('".implode("','", array_values($cids))."')";
// Query our data.
if($awards->query_limit_profile == -1)
{
// Get awards
$query = $db->query('
SELECT u.*, a.*
FROM '.TABLE_PREFIX.'ougc_awards_users u
LEFT JOIN '.TABLE_PREFIX.'ougc_awards a ON (u.aid=a.aid)
WHERE '.$whereclause.'
');
}
else
{
// First we need to figure out the total amount of awards.
$query = $db->query('
SELECT COUNT(u.aid) AS awards
FROM '.TABLE_PREFIX.'ougc_awards_users u
LEFT JOIN '.TABLE_PREFIX.'ougc_awards a ON (u.aid=a.aid)
WHERE '.$whereclause.'
');
$awardscount = (int)$db->fetch_field($query, 'awards');
}
// check group rules - primary group check
$grouprules = newpoints_getrules('group', $mybb->user['usergroup']);
if (!$grouprules)
$grouprules['rate'] = 1; // no rule set so default income rate is 1
// if the group rate is 0, nothing is going to be added so let's just leave the function
if ($grouprules['rate'] == 0)
return;
// give points to the user of getting a award
newpoints_addpoints($mybb->user['uid'], $mybb->settings['newpoints_income_award'], $grouprules['rate']);
}