Index: profile_csv.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/profile_csv/profile_csv.info,v
retrieving revision 1.1.2.2
diff -u -p -r1.1.2.2 profile_csv.info
--- profile_csv.info	18 Jun 2007 23:06:59 -0000	1.1.2.2
+++ profile_csv.info	17 Dec 2007 07:42:12 -0000
@@ -1,4 +1,3 @@
 name = Profile csv
 description = "Allows exporting profile data in comma separated variable format."
-
-package = 
+dependencies = profile
Index: profile_csv.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/profile_csv/profile_csv.module,v
retrieving revision 1.9.2.1
diff -u -p -r1.9.2.1 profile_csv.module
--- profile_csv.module	24 Mar 2007 04:02:14 -0000	1.9.2.1
+++ profile_csv.module	17 Dec 2007 07:42:12 -0000
@@ -10,25 +10,24 @@ define('PROFILE_CSV_PERM_DOWNLOAD',  'do
 
 function profile_csv_help($section='') {
   switch ($section) {
-    case "admin/modules#description":
-      $output = t("Allows exporting profile data in comma separated variable format.");
+    case 'admin/modules#description':
+      $output = t('Allows exporting profile data in comma separated variable format.');
       break;
   }
   return $output;
 }
         
 function profile_csv_admin_settings() {  
- 
   $set = 'roles';
   $form[$set] = array(
-  '#type' => 'fieldset',
-  '#title' => t('Roles'),
-  '#description' =>  t('Select one or more roles.'),
-  '#collapsible' => true,
-  '#collapsed' => true,
+    '#type' => 'fieldset',
+    '#title' => t('Roles'),
+    '#description' =>  t('Select one or more roles.'),
+    '#collapsible' => true,
+    '#collapsed' => true,
   );
   
-  $u_role = user_roles($membersonly = TRUE);
+  $u_role = user_roles($membersonly = true);
   foreach ( $u_role as $rid => $name) {
     $role = PROFILE_CSV_ROLE . $rid;
     $form[$set][PROFILE_CSV_ROLE . $rid] = array(
@@ -38,17 +37,18 @@ function profile_csv_admin_settings() { 
       '#default_value' => variable_get($role, 0),
     );
   }
+  
   $set = 'status';
   $form[$set] = array(
-  '#type' => 'fieldset',
-  '#title' => t('User status'),
-  '#description' =>  t('Select one status.'),
-  '#collapsible' => true,
-  '#collapsed' => true,
+    '#type' => 'fieldset',
+    '#title' => t('User status'),
+    '#description' =>  t('Select one status.'),
+    '#collapsible' => true,
+    '#collapsed' => true,
   );
-   $form[$set][PROFILE_CSV_STATUS] = array(
+  $form[$set][PROFILE_CSV_STATUS] = array(
     '#type' => 'select',
-    '#default_value' => variable_get(PROFILE_CSV_STATUS,2),
+    '#default_value' => variable_get(PROFILE_CSV_STATUS, 2),
     '#options' => array( 1 => t('active'), 0 => t('blocked'), 2 => t('both')),
     '#description' => t(''),
   );
@@ -61,25 +61,41 @@ function profile_csv_admin_settings() { 
     '#collapsible' => true,
     '#collapsed' => true,
   );
-  $form[$set][PROFILE_CSV_PARAM . 'uid'] = array(
+  $form[$set][PROFILE_CSV_PARAM .'uid'] = array(
     '#type' => 'checkbox',
     '#title' => t('User ID'),
     '#return_value' => 1,
-    '#default_value' => variable_get(PROFILE_CSV_PARAM . 'uid', 0),
+    '#default_value' => variable_get(PROFILE_CSV_PARAM .'uid', 0),
   );
-  $form[$set][PROFILE_CSV_PARAM . 'name'] = array(
+  $form[$set][PROFILE_CSV_PARAM .'name'] = array(
     '#type' => 'checkbox',
     '#title' => t('User Name'),
     '#return_value' => 1,
-    '#default_value' => variable_get(PROFILE_CSV_PARAM . 'name', 0),
+    '#default_value' => variable_get(PROFILE_CSV_PARAM .'name', 0),
   );
-  $form[$set][PROFILE_CSV_PARAM . 'mail'] = array(
+  $form[$set][PROFILE_CSV_PARAM .'mail'] = array(
     '#type' => 'checkbox',
     '#title' => t('User Email'),
     '#return_value' => 1,
-    '#default_value' => variable_get(PROFILE_CSV_PARAM . 'mail', 0),
+    '#default_value' => variable_get(PROFILE_CSV_PARAM .'mail', 0),
+  );
+  
+  $form[$set][PROFILE_CSV_PARAM .'created'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Account Created'),
+    '#return_value' => 1,
+    '#default_value' => variable_get(PROFILE_CSV_PARAM .'created', 0),
   );
   
+  $form[$set][PROFILE_CSV_PARAM .'access'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Site Last Accessed'),
+    '#return_value' => 1,
+    '#default_value' => variable_get(PROFILE_CSV_PARAM .'access', 0),
+  );
+
+
+  
   $set = 'profile';
   $form[$set] = array(
     '#type' => 'fieldset',
@@ -89,9 +105,9 @@ function profile_csv_admin_settings() { 
     '#collapsed' => true,
   );
   
-  $result = db_query("SELECT pf.fid, pf.name, pf.title, pf.category FROM {profile_fields} pf ORDER BY pf.category, pf.weight, 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;
+    $fld = PROFILE_CSV_PARAM .'profile_'. $row->fid;
     
     if (!isset($form[$set][$row->category])) {
       $form[$set][$row->category] = array(
@@ -101,18 +117,18 @@ function profile_csv_admin_settings() { 
       );
     }
     
-     $form[$set][$row->category][$fld] = array(
-        '#type' => 'checkbox',
-        '#title' => $row->title,
-        '#return_value' => 1,
-        '#default_value' => variable_get($fld, 0),
-      );
+    $form[$set][$row->category][$fld] = array(
+      '#type' => 'checkbox',
+      '#title' => $row->title,
+      '#return_value' => 1,
+      '#default_value' => variable_get($fld, 0),
+    );
   } 
-   return system_settings_form($form);
+  return system_settings_form($form);
 }
 
 function profile_csv_perm() {
-  return array (PROFILE_CSV_PERM_DOWNLOAD);
+  return array(PROFILE_CSV_PERM_DOWNLOAD);
 }
 
 function profile_csv_menu($may_cache) {
@@ -143,44 +159,40 @@ function profile_csv_menu($may_cache) {
 function profile_csv_page() {
   
   $data = _profile_csv_header();
-  $user_status = variable_get(PROFILE_CSV_STATUS,2);
-  if (variable_get(PROFILE_CSV_ROLE . '2', 0)) {
-    $result = db_query("SELECT u.uid, u.status FROM {users} u  WHERE u.uid > 1");
+  $user_status = variable_get(PROFILE_CSV_STATUS, 2);
+  if (variable_get(PROFILE_CSV_ROLE .'2', 0)) {
+    $result = db_query('SELECT u.uid, u.status FROM {users} u  WHERE u.uid > 1');
     while ($row = db_fetch_object($result)) {
-      if ($user_status == 2){
+      if ($user_status == 2) {
         $data .= _profile_csv_format_user($row->uid );
       }
-      else{      
-        if ($user_status == $row->status) {
-          $data .= _profile_csv_format_user($row->uid );
-        }
+      elseif ($user_status == $row->status) {
+        $data .= _profile_csv_format_user($row->uid );
       }
     }
   }
   else{
-    $result = db_query("SELECT u.uid, u.status, ur.rid  FROM {users} u
+    $result = db_query('SELECT u.uid, u.status, ur.rid  FROM {users} u
             INNER JOIN {users_roles} ur ON u.uid = ur.uid
-            WHERE u.uid > 1");
+            WHERE u.uid > 1');
     $prev_uid = 0;          
     while ($row = db_fetch_object($result)) {
       if ((variable_get(PROFILE_CSV_ROLE . $row->rid, 0)) && ($row->uid != $prev_uid)) {
-        if ($user_status == 2){
+        if ($user_status == 2) {
           $data .= _profile_csv_format_user($row->uid );
         }
-        else{      
-          if ($user_status == $row->status) {
-            $data .= _profile_csv_format_user($row->uid );
-          }
+        elseif ($user_status == $row->status) {
+            $data .= _profile_csv_format_user($row->uid );  
         }  
-       $prev_uid = $row->uid;
+      $prev_uid = $row->uid;
       } 
     }    
   }
-  header("Content-type: text/plain; charset=UTF-8");
-  header("Content-Disposition: attachment; filename=userlist.csv");
-  header("Pragma: no-cache");
-  header("Expires: 0");
-  print $data;
+  header('Content-type: text/plain; charset=UTF-8');
+  header('Content-Disposition: attachment; filename=userlist.csv');
+  header('Pragma: no-cache');
+  header('Expires: 0');
+  echo $data;
   exit();  
 }  
 
@@ -191,7 +203,7 @@ function _profile_csv_get_profile_fields
     $fields = array();
     $result = db_query('SELECT pf.fid, pf.name, pf.title, 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)) {
+      if (variable_get(PROFILE_CSV_PARAM .'profile_'. $row->fid, 0)) {
         $fields[] = array('name' => $row->name, 'title' => $row->title, 'type' => $row->type, 'visibility' => $row->visibility);
       }
     }
@@ -202,43 +214,50 @@ function _profile_csv_get_profile_fields
 
 function _profile_csv_format_user($uid = 0) { 
   $user_data = _profile_csv_get_user($uid);
-  $profile_data = _profile_csv_get_profile($uid,$user_data['data']);
+  $profile_data = _profile_csv_get_profile($uid, $user_data['data']);
   unset($user_data['data']);
   $info = array_merge($user_data, $profile_data);
   //all of the valid fields in ['data'] should have been picked out in _profile_csv_get_profile, so unset it  
     
-  foreach($info as $value) {
-    $new_info[] = '"' . str_replace('"', '""', $value) . '"';
+  foreach ($info as $value) {
+    $new_info[] = '"'. str_replace('"', '""', $value) .'"';
   }
   if (isset($new_info)) { 
-    $line = implode(",", $new_info);
+    $line = implode(',', $new_info);
   } 
-  $data .= trim($line) . "\n";
+  $data .= trim($line) ."\n";
   
- return $data;
+  return $data;
 }
 
 function _profile_csv_get_user($uid = 0) {
-   $users = array();
-   $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 = array();
+  $result = db_query('SELECT u.uid, u.name, u.mail, u.data, u.created, u.access 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;
- 
-    if (variable_get(PROFILE_CSV_PARAM . 'name', 0)) 
+    }
+    if (variable_get(PROFILE_CSV_PARAM .'name', 0)) {
       $users[] = $row->name;
-    
-    if (variable_get(PROFILE_CSV_PARAM . 'mail', 0)) 
+    }
+    if (variable_get(PROFILE_CSV_PARAM .'mail', 0)) {
       $users[] = $row->mail;
-      $users['data'] = unserialize($row->data);
-  } 
+    }
+    if (variable_get(PROFILE_CSV_PARAM .'created', 0)) {
+      $users[] = format_date($row->created, 'small');
+    }
+    if (variable_get(PROFILE_CSV_PARAM .'access', 0)) {
+      $users[] = format_date($row->access, 'small');
+    }
+    $users['data'] = unserialize($row->data);
+  }
   return $users;  
 }  
     
-function _profile_csv_get_profile($uid=0,$user_data=NULL) {
+function _profile_csv_get_profile($uid=0, $user_data=null) {
   $profile_fields = _profile_csv_get_profile_fields();  
   $profile_result = array();
-  foreach($profile_fields  as $profile_field) {
+  foreach ($profile_fields  as $profile_field) {
     if ($profile_field ['visibility'] == 4) {
       //$value = try to get it from the $user_data
       $value = $user_data[$profile_field['name']];
@@ -264,18 +283,24 @@ function _profile_csv_get_profile($uid=0
 function _profile_csv_header() {
   $row = array();
 
-  if (variable_get(PROFILE_CSV_PARAM . 'uid', 0)) 
+  if (variable_get(PROFILE_CSV_PARAM .'uid', 0)) {
     $row[] = '"uid"';
-
-  if (variable_get(PROFILE_CSV_PARAM . 'name', 0)) 
+  }
+  if (variable_get(PROFILE_CSV_PARAM .'name', 0)) {
     $row[] = '"name"';
-
-  if (variable_get(PROFILE_CSV_PARAM . 'mail', 0)) 
+  }
+  if (variable_get(PROFILE_CSV_PARAM .'mail', 0)) {
     $row[] = '"mail"';
-
-  foreach(_profile_csv_get_profile_fields() as $field) {
+  }
+  if (variable_get(PROFILE_CSV_PARAM .'created', 0)) {
+    $row[] = '"created"';
+  }
+  if (variable_get(PROFILE_CSV_PARAM .'access', 0)) {
+    $row[] = '"access"';
+  }
+  foreach (_profile_csv_get_profile_fields() as $field) {
     $row[] = '"'. $field['title'] .'"';
   }
 
-  return implode(",", $row) ."\n";
+  return implode(',', $row) ."\n";
 }
\ No newline at end of file
