2020-11-21, 04:43 PM
Hello,
i'm want to add points per a user get a award but i can't find this feature.
i'm trying to create a new function but i think i have some error can any one help me what's wrong in this code
function newpoints_newaward()
{
global $db, $mybb, $aid;
if (!$mybb->user['uid'])
return;
if ($mybb->settings['newpoints_main_enabled'] != 1)
return;
if ($mybb->settings['newpoints_income_award'] == 0)
return;
$where = "u.uid='".(int)$user['uid']."'";
// 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 '.$where.'
');
$awards = $db->fetch_array($query);
$aid = $awards['aid'];
// check forum rules
$forumrules = newpoints_getrules('forum', $aid);
if (!$forumrules)
$forumrules['rate'] = 1; // no rule set so default income rate is 1
// if the forum rate is 0, nothing is going to be added so let's just leave the function
if ($forumrules['rate'] == 0)
return;
// 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
newpoints_addpoints($user['uid'], $mybb->settings['newpoints_income_award'], $forumrules['rate'], $grouprules['rate']);
}
i'm want to add points per a user get a award but i can't find this feature.
i'm trying to create a new function but i think i have some error can any one help me what's wrong in this code
function newpoints_newaward()
{
global $db, $mybb, $aid;
if (!$mybb->user['uid'])
return;
if ($mybb->settings['newpoints_main_enabled'] != 1)
return;
if ($mybb->settings['newpoints_income_award'] == 0)
return;
$where = "u.uid='".(int)$user['uid']."'";
// 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 '.$where.'
');
$awards = $db->fetch_array($query);
$aid = $awards['aid'];
// check forum rules
$forumrules = newpoints_getrules('forum', $aid);
if (!$forumrules)
$forumrules['rate'] = 1; // no rule set so default income rate is 1
// if the forum rate is 0, nothing is going to be added so let's just leave the function
if ($forumrules['rate'] == 0)
return;
// 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
newpoints_addpoints($user['uid'], $mybb->settings['newpoints_income_award'], $forumrules['rate'], $grouprules['rate']);
}