Index: profile_csv.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/profile_csv/profile_csv.module,v
retrieving revision 1.2.2.2
diff -u -r1.2.2.2 profile_csv.module
--- profile_csv.module	28 Aug 2006 02:55:34 -0000	1.2.2.2
+++ profile_csv.module	11 Sep 2006 22:11:43 -0000
@@ -1,5 +1,5 @@
 <?php
-
+/* $Id:$ */
 // Copyright 2006 http://2bits.com
 
 define('PROFILE_CSV_PARAM',     'profile_csv_param_');
@@ -72,7 +72,7 @@
     '#collapsed' => true,
   );
   
-  $result = db_query("SELECT pf.fid, pf.name, pf.title, pf.category FROM {profile_fields} pf ORDER BY pf.category, pf.title"); 
+  $result = db_query("SELECT pf.fid, pf.name, pf.title, pf.category FROM {profile_fields} pf ORDER BY pf.category, pf.weight, pf.title"); 
   while ($row = db_fetch_object($result)) {
     $fld = PROFILE_CSV_PARAM . 'profile_' . $row->fid;
     
@@ -112,7 +112,7 @@
   
   $data = _profile_csv_header();
   if (variable_get(PROFILE_CSV_ROLE . '2', 0)) {
-    $result = db_query("SELECT u.uid  FROM {users} u  WHERE u.uid > 1");
+    $result = db_query("SELECT u.uid  FROM {users} u  WHERE u.uid > 1 ORDER BY uid ASC");
     while ($row = db_fetch_object($result)) {
       $data .= _profile_csv_format_user($row->uid );
     }
@@ -120,7 +120,7 @@
   else{
     $result = db_query("SELECT u.uid , ur.rid  FROM {users} u
 	    INNER JOIN {users_roles} ur ON u.uid = ur.uid
-	    WHERE u.uid > 1");
+	    WHERE u.uid > 1 ORDER BY uid ASC");
     $prev_uid = 0;	    
     while ($row = db_fetch_object($result)) {
       if ((variable_get(PROFILE_CSV_ROLE . $row->rid, 0)) && ($row->uid != $prev_uid)) {
@@ -142,7 +142,7 @@
   
   if (!isset($fields)) {
     $fields = array();
-    $result = db_query('SELECT pf.fid, pf.name, pf.type FROM {profile_fields} pf');
+    $result = db_query('SELECT pf.fid, pf.name, pf.type, pf.visibility FROM {profile_fields} pf ORDER BY pf.category, pf.weight, pf.title');
     while ($row = db_fetch_object($result)) {
       if (variable_get(PROFILE_CSV_PARAM . 'profile_' . $row->fid, 0)) {
         $fields[$row->name] = $row->type;
@@ -171,7 +171,7 @@
 
 function _profile_csv_get_user($uid = 0) {
    $users = array();
-   $result = db_query('SELECT u.uid, u.name, u.mail FROM {users} u WHERE u.uid = %d', $uid);
+   $result = db_query('SELECT u.uid, u.name, u.mail, u.data FROM {users} u WHERE u.uid = %d', $uid);
    while ($row = db_fetch_object($result)) {
     if (variable_get(PROFILE_CSV_PARAM . 'uid', 0)) 
       $users[] = $row->uid;
