From f66b2c3c218dcf6f6b771432ff3cc74cd299dbfd Mon Sep 17 00:00:00 2001
From: Sascha Grossenbacher <saschagros@gmail.com>
Date: Wed, 27 Apr 2011 01:49:51 +0200
Subject: [PATCH] Issue #1070134 by Berdir: Changed order of items in transaction list and view pages.

---
 userpoints.module    |   18 +++++++++---------
 userpoints.pages.inc |   44 ++++++++++++++++++++++----------------------
 2 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/userpoints.module b/userpoints.module
index d39f295..32a0759 100644
--- a/userpoints.module
+++ b/userpoints.module
@@ -1852,6 +1852,9 @@ function userpoints_get_transaction_header($settings) {
     'show_status' => TRUE,
   );
   $header = array();
+  if ($settings['show_user']) {
+    $header[] = array('data' => t('User'), 'field' => 'uid', 'class' => array('userpoints-transactions-header-status'));
+  }
   $header[] = array('data' => t('!Points', userpoints_translation()), 'field' => 'points', 'class' => array('userpoints-transactions-header-points'));
   // Only display category if there is more than one category. In contrast to
   // the filter, this is not specific for the categories. If there are
@@ -1860,9 +1863,6 @@ function userpoints_get_transaction_header($settings) {
   if ($settings['show_category']) {
     $header[] = array('data' => t('Category'), 'field' => 't.name', 'class' => array('userpoints-transactions-header-category'));
   }
-  if ($settings['show_user']) {
-    $header[] = array('data' => t('User'), 'field' => 'uid', 'class' => array('userpoints-transactions-header-status'));
-  }
   $header[] = array('data' => t('Date'), 'field' => 'time_stamp', 'sort' => 'desc', 'class' => array('userpoints-transactions-header-timestamp'));
   $header[] = array('data' => t('Reason'), 'class' => array('userpoints-transactions-header-reason'));
   if ($settings['show_status']) {
@@ -1902,6 +1902,12 @@ function userpoints_get_transaction_row($transaction, $settings = array()) {
     'userpoints-transaction-row-status-' . $css_stati[$transaction->status],
     'userpoints-transaction-row-category-' . $transaction->tid),
   );
+  if ($settings['show_user']) {
+    $row['data'][] = array(
+      'data' => theme('username', array('account' => user_load($transaction->uid))),
+      'class' => array('userpoints-transactions-field-user'),
+    );
+  }
   $row['data'][] = array(
     'data' => $transaction->points,
     'class' => array('userpoints-transactions-field-points', 'userpoints-transaction-points-' . ($transaction->points > 0 ? 'positive' : 'negative')),
@@ -1913,12 +1919,6 @@ function userpoints_get_transaction_row($transaction, $settings = array()) {
       'class' => array('userpoints-transactions-field-category'),
     );
   }
-  if ($settings['show_user']) {
-    $row['data'][] = array(
-      'data' => theme('username', array('account' => user_load($transaction->uid))),
-      'class' => array('userpoints-transactions-field-user'),
-    );
-  }
   $row['data'][] = array(
     'data' => format_date($transaction->time_stamp, 'small'),
     'class' => array('userpoints-transactions-field-timestamp'),
diff --git a/userpoints.pages.inc b/userpoints.pages.inc
index 53b3894..46bbd9f 100644
--- a/userpoints.pages.inc
+++ b/userpoints.pages.inc
@@ -221,11 +221,19 @@ function userpoints_view_transaction($transaction) {
     '#attributes' => array('class' => array('userpoints-group-details')),
   );
 
+  $content['details']['user'] = array(
+    '#theme' => 'userpoints_view_item',
+    '#title' => t('User'),
+    '#value' => theme('username', array('account' => $transaction->user)),
+    '#weight' => 0,
+    '#attributes' => array('class' => array('userpoints-item-user')),
+  );
+
   $content['details']['points'] = array(
     '#theme' => 'userpoints_view_item',
     '#title' => t('!Points', userpoints_translation()),
     '#value' => $transaction->points,
-    '#weight' => 0,
+    '#weight' => 10,
     '#attributes' => array('class' => array('userpoints-item-points')),
   );
 
@@ -233,31 +241,15 @@ function userpoints_view_transaction($transaction) {
     '#theme' => 'userpoints_view_item',
     '#title' => t('Category'),
     '#value' => $transaction->category,
-    '#weight' => 10,
-    '#attributes' => array('class' => array('userpoints-item-category')),
-  );
-
-  $content['details']['user'] = array(
-    '#theme' => 'userpoints_view_item',
-    '#title' => t('User'),
-    '#value' => theme('username', array('account' => $transaction->user)),
     '#weight' => 20,
-    '#attributes' => array('class' => array('userpoints-item-user')),
-  );
-
-  $content['details']['date'] = array(
-    '#theme' => 'userpoints_view_item',
-    '#title' => t('Date'),
-    '#value' => format_date($transaction->time_stamp),
-    '#weight' => 30,
-    '#attributes' => array('class' => array('userpoints-item-date')),
+    '#attributes' => array('class' => array('userpoints-item-category')),
   );
 
   $content['details']['reason'] = array(
     '#theme' => 'userpoints_view_item',
     '#title' => t('Reason'),
     '#value' => userpoints_create_description($transaction, array('truncate' => FALSE)),
-    '#weight' => 40,
+    '#weight' => 30,
     '#attributes' => array('class' => array('userpoints-item-reason')),
   );
 
@@ -265,7 +257,7 @@ function userpoints_view_transaction($transaction) {
     '#theme' => 'userpoints_view_item',
     '#title' => t('Transaction ID'),
     '#value' => $transaction->txn_id,
-    '#weight' => 50,
+    '#weight' => 40,
     '#attributes' => array('class' => array('userpoints-item-transaction')),
   );
 
@@ -285,11 +277,19 @@ function userpoints_view_transaction($transaction) {
     '#attributes' => array('class' => array('userpoints-item-status')),
   );
 
+  $content['status']['date'] = array(
+    '#theme' => 'userpoints_view_item',
+    '#title' => t('Transaction date'),
+    '#value' => format_date($transaction->time_stamp),
+    '#weight' => 10,
+    '#attributes' => array('class' => array('userpoints-item-date')),
+  );
+
   $content['status']['changed'] = array(
     '#theme' => 'userpoints_view_item',
     '#title' => t('Last modified'),
     '#value' => format_date($transaction->changed),
-    '#weight' => 10,
+    '#weight' => 20,
     '#attributes' => array('class' => array('userpoints-item-changed')),
   );
 
@@ -399,7 +399,7 @@ function userpoints_view_transaction($transaction) {
     if (!empty($transaction->reference)) {
       $content['admin']['reference'] = array(
         '#theme' => 'userpoints_view_item',
-        '#title' => t('Reference'),
+        '#title' => t('Internal reference'),
         '#value' => $transaction->reference,
         '#weight' => 40,
         '#attributes' => array('class' => array('userpoints-item-reference')),
-- 
1.7.4.1

