No display for in mypoints page

Points awaiting moderation: (Blank)

CommentFileSizeAuthor
#3 fix_unapproved.patch1.03 KBberdir

Comments

barrya’s picture

I too noticed this. If you look at line 1714(approx) - the bit that calculates the pending points you will see the following.

 //Grab the unmoderated point total
  $result = db_query("SELECT SUM(points) FROM {userpoints_txn} WHERE uid = %d AND status = 1", $uid);
  if (db_result($result, 0, 0)) {
    $args['unapproved_total'] = db_result($result, 0, 0);
  }
  else {
    $args['unapproved_total'] =0;
  }
  $args['overall_total'] = ($args['approved_total'] + $args['unapproved_total']);

Replace the above with the following and it will fix it.

  //Grab the unmoderated point total
  $result = db_query("SELECT SUM(points) FROM {userpoints_txn} WHERE uid = %d AND status = 1", $uid);
  $unapproved = db_result($result);

  if ($unapproved) {
    $args['unapproved_total'] = $unapproved;
  }
  else {
    $args['unapproved_total'] =0;
  }
  $args['overall_total'] = ($args['approved_total'] + $args['unapproved_total']);

The reason it was not working is that when you call db_result() it will set the pointer to the next entry in the mysql result object. Unlike the drupal 5 api, you are not able to specify the row to check on db_result().

berdir’s picture

Please provide that as a patch, thanks!

berdir’s picture

Status: Active » Needs review
StatusFileSize
new1.03 KB

Actually, the whole thing can be written in a single line...

berdir’s picture

Issue tags: +userpoints backport

Tagging to make it easier to find patches like this one.

berdir’s picture

Status: Needs review » Fixed

Commited.

berdir’s picture

Commited.

Status: Fixed » Closed (fixed)
Issue tags: -userpoints backport

Automatically closed -- issue fixed for 2 weeks with no activity.