My users are looking at the /points screen and getting confused.

It has the number of points, approved, date, operation (that looks like this:karma:insert:up:author:6172 ), category, and description.

I don't think anyone understands what this is. How can I customize it to remove some columns and make the operations just have the node title and link rather than the code it has now. Thank you all so much.

Comments

kbahey’s picture

Status: Active » Fixed

There is a theme function that can override that. Look for theme_SOMETHING in userpoints.module, and copy them as phptemplate_SOMETHING to template.php and change it there.

Status: Fixed » Closed (fixed)

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

Flying Drupalist’s picture

Status: Closed (fixed) » Active

Hi, am I supposed to copy both

/*
 * Purpose: Allow my_userpoints to be themeable
 */
function theme_userpoints_list_my_userpoints($args, $header, $rows) {

and

/*
 * Purpose: Displays a detailed transaction report for an individual user
 * no URL argument returns current user otherwise accepts uid. 
 */
function userpoints_list_my_userpoints() {

The latter is what builds the table while the former only builds the stuff at the bottom. Just changing theme_userpoints_list_my_userpoints doesn't do anything.

Thanks.

matdab’s picture

Component: Code: userpoints API » Code: userpoints

Subscribing! Thats very important in order to use points to motivate users!!:)

matdab’s picture

Issue tags: +userpoints table

I've sponsored the table as a separate module - if anyone would like to use the code, don't hasitate, just the langauage is polish sometimes...


/**
 * implementation of hook_theme().
 */
function userpoints_akademia_theme() {
  return array(
    /*
    'userpoints_akademia_list_users' => array(
      'arguments' => array(
        'header' => null,
        'rows' => null,
        'tid' => null,
        'pager_limit' => null,
        )
      ),
    'userpoints_akademia_list_users_header' => array(
      'arguments' => array()
     ),
    'userpoints_akademia_list_users_row' => array(
      'arguments' => array(
        'row' => null,
         )
    ),
    */
    'userpoints_akademia_list_my_userpoints' => array(
      'arguments' => array(
        'args' => null,
        'header' => null,
        'rows' => null,
        ),
    ),
  ); //return array
}

/**
 * implementation of hook_menu().
 */
function userpoints_akademia_menu() {
  $items = array();
  $items['user/%user/points'] = array(
    'title'            => 'points',
    'page callback'    => 'userpoints_akademia_points',
    'page arguments'   => array(1),
    'access arguments' => array('access vote up/down statistics'),
    'type'             => menu_local_task,
  );
  return $items;
}

function userpoints_akademia_points($points_user) {
  $output = '';
  //$output .= '<pre>'.print_r($user,1).'</pre>';
  //return $output;

  
  //function userpoints_list_my_userpoints($points_user) {
  

  $overall_total = 0;
  $unapproved_total = 0;
  $approved_total = 0;

  $title = t( check_plain($points_user->name) . ': tabela plusów i minusów');
  drupal_set_title($title);

   //grab all tids for this user
  $sql = "select p.tid, t.name
    from {userpoints_txn} p
    left join {term_data} t on p.tid = t.tid
    where uid = %d
    group by p.tid, t.name";
  $results = db_query($sql, $points_user->uid);
  $grand_total = 0;
  while ($result = db_fetch_array($results)) {
    if ($result['name'] == null) {
      $result['name'] = t('!uncategorized', userpoints_translation());
    }
    //pull the sum from the caching table for resource reason and b/c the
    $result['total'] = userpoints_get_current_points($points_user->uid, $result['tid']);
    $args['subtotals'][$result['tid']] = $result;

    //maintain a grand total
    $grand_total += $result['total'];
  }
  $args['approved_total'] = $grand_total;

  //grab the unmoderated point total
  $args['unapproved_total'] = (int)db_result(db_query("select sum(points) from {userpoints_txn} where uid = %d and status = 1", $points_user->uid));
  $args['overall_total'] = ($args['approved_total'] + $args['unapproved_total']);

  $header = array(
    //array('data' => t('!points', userpoints_translation()), 'field' => 'points'),
    array('data' => t('Przyznane +/-'), 'field' => 'points'),
    //array('data' => t('approved?'), 'field' => 'status'),
    array('data' => t('Data'), 'field' => 'time_stamp', 'sort' => 'desc'),
    array('data' => t('Otrzymujesz ponieważ'), 'field' => 'operation'),
    array('data' => t('Tytuł treści'), 'field' => 'operation'),
    array('data' => t('Kto przyznał Ci +/-'), 'field' => 'operation'),
    array('data' => t('IP'), 'field' => 'operation'),
    //array('data' => t('moderacja'), 'field' => 'operation'),
    //array('data' => t('operation'), 'field' => 'operation'),
    //array('data' => t('category'), 'field' => 'cat'),
    //array('data' => t('description'), 'field' => 'description'),
  );
  
  $colspan = count($header);
  
  $sql  = "select p.txn_id, p.points, p.time_stamp, p.operation, p.description, p.status, p.tid, t.name as cat , p.entity_id, p.entity_type
           from {userpoints_txn} p
           left join {term_data} t on p.tid = t.tid
           where p.uid = %d and p.tid = 0";// and p.txn_id in (1140,1144)";
  $sql .= tablesort_sql($header);
  $pager_limit = 100;//variable_get(userpoints_report_limit, 10);
  $result = pager_query($sql, $pager_limit, 0, null, $points_user->uid);
  $stati = userpoints_txn_status();
  $num_rows = 0;
  $rows = array();
  while ($row = db_fetch_object($result)) {
    $num_rows++;
    $status = $stati[$row->status];
    if (!$row->cat) {
      $row->cat = t('!uncategorized', userpoints_translation());
    }
    if ($row->description) {
      $description = filter_xss($row->description);
    }
    else {
      $description = t('none');
    }
    //print "a<br/>";
    
    $title = '';
    $reason = 'powód: '.$row->entity_type;
    $ip = '';
    $who = '';
    $mod_url = '-';
      
    $operations = module_invoke_all('userpoints', 'entity_type', $row);
    //print 'operations:<pre>'. print_r($operations,1). "</pre><br/>";
    if (is_array($operations) && isset($operations[0])) {
      $operation = 'module_invoke_all: '. $operations[0];
      $reason = 'powód2';
      //print 'if:<pre>'. print_r($operations,1). "</pre><br/>";

    }
    else {
      //print 'else:<pre>'. print_r($operations,1). "</pre><br/>";

      
      switch ($row->entity_type) {
        case 'node' :
          $operation_type = preg_replace('/(:\d+)/i', '', $row->operation);
          $node = node_load($row->entity_id);
          if ($node) {
            $description = '';
            $node_types = array(
            	    'myblog' => 'Artykuł:',
            	    'audiobook_mp3' =>  'Audiobook:',
            	    'konkurs' => 'Konkurs:',
            	    'pytanie_do_eksperta' => 'Pytanie do Eksperta:',
            	    'strona' => 'Strona:',
            	    'forum' => 'Temat na forum:',
            	    'quiz' => 'Test:',
            	    'konkurs_element' => 'Zgłoszenie do konkursu:',
            );
            $reason = 'Opublikowałeś '.
              (isset($node_types[$node->type]) ? $node_types[$node->type] : $node->type);
            $title = l($node->title, 'node/'. $node->nid, array('attributes' => array('title' => $node->title)));
            $who = 'Akademia Rozwoju';
            $ip = '';
            
          }
          else {
            $operation = check_plain($row->operation);
          }
          break;
        case 'comment' :
          if (module_exists('comment')) {
            $operation_type = preg_replace('/(:\d+)/i', '', $row->operation);
            $vote_id = preg_replace('/(.*:)(\d+)/i', '$2', $row->operation);
            
            //we have to load the comment to get the nid for the comment
            $comment = _comment_load($row->entity_id);
            if ($comment) {
              if($vote_id) {
                $comment_add_info = _userpoints_akademia_get_add_info_votingapi_vote('votingapi_vote', 'comment', $comment->cid, $vote_id);
                if(isset($comment_add_info->vote_source)) {
                  $ip = $comment_add_info->vote_source;
                  $comment_add_user = user_load($comment_add_info->uid);
                  $who = l($comment_add_user->name,'user/'.$comment_add_user->uid);
                }
              }
              switch($operation_type) {
                case "delete":
                  $reason = 'Usunięto Twój komentarz: ';
                  break;
                case "Flag Comment Abuse":
                  $comment_add_info = _userpoints_akademia_get_add_info('flag_note', 'comment', $comment->cid);
                  if($comment_add_info->note) {
                //    $reason = 'Uzasadniając: "'. $comment_add_info->note .'" Użytkownik przyznał plusa Twojej treści:';
                //  }
                //  else {
                    $reason = 'Przyznałeś minusa treści:';
                  }
                  break;
                case "Flag Author Comment Abuse":
                  $comment_add_info = _userpoints_akademia_get_add_info('flag_note', 'comment', $comment->cid);
                  if($comment_add_info->note) {
                  	  $reason = 'Uzasadniając: "'. $comment_add_info->note .'" Użytkownik przyznał minusa Twojej treści:';
                  }
                  else {
                  	  $reason = 'Użytkownik przyznał minusa Twojej treści:';
                  }
                  break;
                case "insert":
                  $reason = 'Dodałeś komentarz: ';
                  $who = l($comment->name,'user/'.$comment->uid);
                  $ip = $comment->hostname;
                  break;
                case "karma:delete:down:author":
                  $reason = 'Użytkownik cofnął minusa Twojej treści: ';
                  $who = $who ? $who : "Gość";
                  break;
                case "karma:delete:up:author":
                  $reason = 'Użytkownik cofnął plusa Twojej treści: ';
                  $who = $who ? $who : "Gość";
                  break;
                case "karma:insert:down:author":
                  $reason = 'Użytkownik przyznał minusa Twojej treści: ';
                  $who = $who ? $who : "Gość";
                  break;
                case "karma:insert:up:author":
                  $reason = 'Użytkownik przyznał plusa Twojej treści: ';//.$comment->cid.','. $vote_id;
                  $who = $who ? $who : "Gość";
                  break;
                default:
                  $reason = 'default:'.$operation_type.'---'. check_plain($row->operation);
                  break;
              }
              
              $description = '';
              $title = l('Komentarz: '. $comment->subject, $comment->nid, array('attributes' => array('title' => $comment->subject), 'fragment' => 'comment-'. $comment->cid ));
              $operation = l($row->operation.' - '. 'komentarz: '. $comment->subject, 'node/'. $comment->nid, array('attributes' => array('title' => $comment->subject), 'fragment' => 'comment-'. $comment->cid ));
            }
            else {
              $operation = check_plain($row->operation);
            }
          }
          /*
          $title = $title. '$row->cat: ['. $row->cat. ']<br/>'.
          'status: ['. $status. ']<br/>'.
          'operation: ['. $operation. ']<br/>'.
          'description ['. $description. ']<br/>'.
          '<pre>'.print_r($row,1).'</pre>'.
          //'<pre>'.print_r($comment,1).'</pre>'.
          '<pre>'.print_r($comment_add_info,1).'</pre>'
          ;
          */
          break;
        case 'user':
            $operation_type = preg_replace('/( \d+)$/i', '', $row->operation);
            switch($operation_type) {
              case "invite invite":
                $reason = 'Wysłałeś zaproszenia do Akademii Rozwoju';
                $title = '-';
                break;
              case "invite register invited":
                $reason = 'Osoba, której wysłałeś zaproszenie, założyła konto.';
                preg_match('/(\d+)/i', $row->operation, $uid_invited);
                //$uid_invited = preg_replace('/.*(\d{1,})/', '$1,$2,${$1}, 123', $row->operation);
                if(isset($uid_invited[0])) {
                  $invited = user_load($uid_invited[0]);
                  if($invited) {
                    $title = l($invited->name,'user/'.$invited->uid);
                  }
                }
                /*
                $title2 = $title. 
                  //'$row->cat: ['. $row->cat. ']<br/>'.
                  //'status: ['. $status. ']<br/>'.
                  //'operation: ['. $operation. ']<br/>'.
                  //'description ['. $description. ']<br/>'.
                  '$row->operation ['. $row->operation. ']<br/>'.
                  'uid_invited ['. $uid_invited. ']<br/>'.
                  '<pre>'.print_r($row,1).'</pre>'.
                  '<pre>'.print_r($invited,1).'</pre>'.
                  '<pre>'.print_r($uid_invited,1).'</pre>'.
                  '';
                */
                break;
              default:
                $reason = $row->operation;
                $operation = l($row->operation, 'user/' . $row->entity_id);
                $title = $title. '$row->cat: ['. $row->cat. ']<br/>status: ['. $status. ']<br/>operation: ['. $operation. ']<br/> description ['. $description. ']<br/> <pre>'.print_r($row,1).'</pre>';
                break;
            }
            $who = 'Akademia Rozwoju';//l("Akademia rozwoju','user/3');
          break;
        default:
          $operation = check_plain($row->operation);
          $reason = $description;
          if($row->description == 'Przyznałeś plusa treści innego Użytkownika' || 'Za przyznanie punktu') {
            $title = '&nbsp;';
          }
          else {
            $title = '<pre>'.print_r($row,1).'</pre>'; 
            //$title. '$row->cat: ['. $row->cat. ']<br/>status: ['. $status. ']<br/>operation: ['. $operation. ']<br/> description ['. $description. ']<br/>
          } 
      }
      $operation = '';
    }
    $rows[] = array(
      array('data' => $row->points, 'align' => 'center'),
      array('data' => format_date($row->time_stamp, 'small'), 'align' => 'center'),
      array('data' => $reason),
      array('data' => $title),
      array('data' => $who),
      array('data' => $ip),
      //array('data' => $mod_url),
      //array('data' => $status, 'align' => 'center'),
      //array('data' => $operation),
      //array('data' => $row->cat),
      //array('data' => $description),
    );
    if ($num_rows <= 0) {
      $rows[] = array(
        array('data' => t('no !points earned', userpoints_translation()), 'colspan' => $colspan, 'align' => 'center')
      );
    }
  }
  //print '<pre>';
  //$node = node_load(192);
  //print_r($node);
  //print_r($args);
  //print_r($rows);
  //print '</pre>';
  return theme('userpoints_akademia_list_my_userpoints', $args, $header, $rows);
}


/*
 * purpose: allow my_userpoints to be themeable
 */
function theme_userpoints_akademia_list_my_userpoints($args, $header, $rows) {
  $table['class'] = 'tabela_punkty';
	$pager_limit = variable_get(userpoints_report_limit, 10);
   $output .= "<p>";
  if (isset($args) && isset($args['subtotals'][0])) {
    //foreach ($args['subtotals'] as $tid => $data) {
    //}
    $data = $args['subtotals'][0];
    $output .= '<strong>Suma plusów: </strong> '. $data['total'] .'<br />';
  }
  $output .= '<div class="tabela_punkty">';
  $output .= theme('table', $header, $rows);
 
  $output .= "</p>";
  $output .= "<p>";
  //$output .= '<strong>'. t('approved !points balance', userpoints_translation()) .':</strong> '. $args['approved_total'] .'<br />';
  //$output .= '<strong>'. t('!points awaiting moderation', userpoints_translation()) .':</strong> '. $args['unapproved_total'] .'<br />';
  //$output .= '<strong>'. t('net !points balance', userpoints_translation()) .':</strong> '. $args['overall_total'] .'<br />';
  $output .= "</p>";
  $output .= theme('pager', null, $pager_limit, 0);
  $output .= '</div>';
  return $output;
}

function _userpoints_akademia_get_add_info($table, $content_type, $content_id) {
  //$content_id = 202;        
  $sql  = "SELECT * FROM  {$table} WHERE content_type = '%s' and content_id = %d";
  return db_fetch_object(db_query($sql, $content_type, $content_id));
}


function _userpoints_akademia_get_add_info_votingapi_vote($table, $content_type, $content_id, $vote_id) {
  //$content_id = 202;        
  $sql  = "SELECT * FROM  {$table} WHERE content_type = '%s' and content_id = %d and vote_id = %d";
  if($content_id==183) {
    //printf($sql, $content_type, $content_id, $vote_id)."<br/>\n";
  }
  return db_fetch_object(db_query($sql, $content_type, $content_id, $vote_id));
}

// 

/*
select p.*
from userpoints_txn p
where p.uid = 3 and p.tid = 0
order by txn_id desc
           
*/

manuel.adan’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

Closing this as outdated, 6.x version is no longer maintained.