More misc fixes and rewrites (sorry, lame description)
[mailer.git] / inc / modules / admin / what-list_user.php
index 57630ce..d2a24f5 100644 (file)
@@ -224,10 +224,10 @@ LIMIT 1",
                        case "norefs": // Users w/o refs
                                if (!empty($whereStatement)) {
                                        // Add AND statement
                        case "norefs": // Users w/o refs
                                if (!empty($whereStatement)) {
                                        // Add AND statement
-                                       $whereStatement .= " AND refid=0";
+                                       $whereStatement .= " AND `refid`=0";
                                } else {
                                        // Add WHERE statement
                                } else {
                                        // Add WHERE statement
-                                       $whereStatement = " WHERE refid=0";
+                                       $whereStatement = " WHERE `refid`=0";
                                }
                                break;
 
                                }
                                break;
 
@@ -237,8 +237,12 @@ LIMIT 1",
                }
        } // END = if
 
                }
        } // END = if
 
+       // Generate master query string
+       $sql = sprintf("SELECT `userid`, `gender`, `surname`, `family`, `email`, `REMOTE_ADDR`, `refid`, `status`, `emails_sent`, `mails_confirmed`, `emails_received`".$MORE." FROM `{!_MYSQL_PREFIX!}_user_data`".$whereStatement." ORDER BY `%s` ASC",
+               REQUEST_GET('sortby')
+       );
+
        // Prepare SQL and run it
        // Prepare SQL and run it
-       $sql = "SELECT userid, gender, surname, family, email, REMOTE_ADDR, refid, status, emails_sent, mails_confirmed, emails_received".$MORE." FROM `{!_MYSQL_PREFIX!}_user_data`".$whereStatement." ORDER BY ".REQUEST_GET('sortby');
        $result_master = SQL_QUERY($sql, __FILE__, __LINE__);
 
        // Calculate page count (0.5 fixes a bug with page count)
        $result_master = SQL_QUERY($sql, __FILE__, __LINE__);
 
        // Calculate page count (0.5 fixes a bug with page count)
@@ -257,7 +261,7 @@ LIMIT 1",
        $sql .= " LIMIT ".(REQUEST_GET('offset') * REQUEST_GET('page') - REQUEST_GET('offset')).", ".REQUEST_GET('offset');
        $result = SQL_QUERY($sql, __FILE__, __LINE__);
 
        $sql .= " LIMIT ".(REQUEST_GET('offset') * REQUEST_GET('page') - REQUEST_GET('offset')).", ".REQUEST_GET('offset');
        $result = SQL_QUERY($sql, __FILE__, __LINE__);
 
-       $result_user = SQL_QUERY("SELECT emails_sent FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `status`='CONFIRMED'", __FILE__, __LINE__);
+       $result_user = SQL_QUERY("SELECT `emails_sent` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `status`='CONFIRMED'", __FILE__, __LINE__);
        $user_count = SQL_NUMROWS($result_user);
        SQL_FREERESULT($result_user);
 
        $user_count = SQL_NUMROWS($result_user);
        SQL_FREERESULT($result_user);
 
@@ -329,6 +333,11 @@ LIMIT 1",
                        $content['locked'] = translateComma(GET_TOTAL_DATA($content['userid'], 'user_points', 'locked_points'));
                        $content['lock_timestamp'] = generateDateTime($content['lock_timestamp'], '2');
                        $content['status'] = translateUserStatus($content['status']);
                        $content['locked'] = translateComma(GET_TOTAL_DATA($content['userid'], 'user_points', 'locked_points'));
                        $content['lock_timestamp'] = generateDateTime($content['lock_timestamp'], '2');
                        $content['status'] = translateUserStatus($content['status']);
+                       $content['refs']   = 0;
+
+                       // Get total refs
+                       $refs = GET_TOTAL_DATA($content['userid'], 'refsystem', 'counter');
+                       if ($refs > 0) $content['refs'] = $base."&amp;what=list_refs&amp;uid=".$content['userid']."\">".$refs."</a>]";
 
                        // Is the lock reason not set?
                        if (!isset($content['lock_reason'])) $content['lock_reason'] = '---';
 
                        // Is the lock reason not set?
                        if (!isset($content['lock_reason'])) $content['lock_reason'] = '---';
@@ -344,7 +353,7 @@ LIMIT 1",
                        }
 
                        // Load row template and switch colors
                        }
 
                        // Load row template and switch colors
-                       $OUT .= LOAD_TEMPLATE("admin_list_user_row", true, $content);
+                       $OUT .= LOAD_TEMPLATE('admin_list_user_row', true, $content);
                        $SW = 3 - $SW;
                } // END - while
 
                        $SW = 3 - $SW;
                } // END - while
 
@@ -354,7 +363,7 @@ LIMIT 1",
                define('__USER_ROWS', $OUT);
 
                // Load main template
                define('__USER_ROWS', $OUT);
 
                // Load main template
-               LOAD_TEMPLATE("admin_list_user");
+               LOAD_TEMPLATE('admin_list_user');
 
                // Free some memory
                SQL_FREERESULT($result_master);
 
                // Free some memory
                SQL_FREERESULT($result_master);
@@ -364,5 +373,5 @@ LIMIT 1",
        }
 }
 
        }
 }
 
-//
+// [EOF]
 ?>
 ?>