- // Set mode depending on how many mails the member has to confirm
- $locked = false;
- if (($ref_payout > 0) && ($CONFIG['allow_direct_pay'] == "N")) $locked = true;
-
- // Is begging rallye active?
- if ($CONFIG['beg_rallye'] == "Y")
- {
- // Add points to rallye account
- $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET beg_points=beg_points+%s WHERE userid=%d LIMIT 1",
- array($POINTS, $uid), __FILE__, __LINE__);
- }
- else
- {
- // Add points to account
- ADD_POINTS_REFSYSTEM($uid, $POINTS, false, "0", $locked, strtolower($CONFIG['beg_mode']));
- }
-
- // Subtract begged points from member account if the admin has selected one
- if ($CONFIG['beg_uid'] > 0)
- {
- // Subtract from this account
- $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET used_points=used_points+%s WHERE userid=%d LIMIT 1",
- array($POINTS, bigintval($CONFIG['beg_uid'])), __FILE__, __LINE__);
-
- // Update mediadata as well
- if (GET_EXT_VERSION("mediadata") >= "0.0.4")
- {
- // Update database
- MEDIA_UPDATE_ENTRY(array("total_points"), "sub", $POINTS);
+ // Pay points?
+ if ($pay === true) {
+ // Add points to user or begging rallye account
+ if (BEG_ADD_POINTS($uid, $points)) {
+ // Set "done" message
+ define('__BEG_MSG', LOAD_TEMPLATE("beg_done", true));
+ } else {
+ // Error!
+ define('__BEG_MSG', LOAD_TEMPLATE("beg_failed", true));