### Eclipse Workspace Patch 1.0
#P moodle19
Index: mod/data/export.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/data/export.php,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 export.php
--- mod/data/export.php	12 Jun 2008 13:49:40 -0000	1.1.2.2
+++ mod/data/export.php	27 Dec 2009 05:24:24 -0000
@@ -49,6 +49,9 @@
 foreach ($fieldrecords as $fieldrecord) {
     $fields[]= data_get_field($fieldrecord, $data);
 }
+$otherfields['username'] = 'username'; 
+$otherfields['timemodified'] = 'timemodified';
+$otherfields['timeadded'] = 'timeadded';
 
 $mform = new mod_data_export_form('export.php?d='.$data->id, $fields);
 
@@ -82,6 +85,23 @@
     } else {
         $exportdata[0][] = $field->field->name;
     }
+    $maxfield = $field->field->id;
+}
+
+if (empty($formdata['username'])) {
+    unset($otherfields['username']);
+} else {
+    $exportdata[0][] = get_string('username');
+}
+if (empty($formdata['timeadded'])) {
+    unset($otherfields['timeadded']);
+} else {
+    $exportdata[0][] = get_string('timeadded','data');
+}
+if (empty($formdata['timemodified'])) {
+    unset($otherfields['timemodified']);
+} else {
+    $exportdata[0][] = get_string('timemodified','data');
 }
 
 $datarecords = get_records('data_records', 'dataid', $data->id);
@@ -89,6 +109,7 @@
 $line = 1;
 foreach($datarecords as $record) {
     // get content indexed by fieldid
+    $recorduser=get_record('user','id',$record->userid); 
     if( $content = get_records('data_content', 'recordid', $record->id, 'fieldid', 'fieldid, content, content1, content2, content3, content4') ) {
         foreach($fields as $field) {
             $contents = '';
@@ -97,6 +118,16 @@
             }
             $exportdata[$line][] = $contents;
         }
+        foreach($otherfields as $otherfield) {
+            
+            switch ($otherfield) {
+                
+                case ($otherfield=='username') : $contents = fullname($recorduser); break;
+                case ($otherfield=='timeadded') : $contents = userdate($record->timecreated, get_string('strftimedate'), 0); break;
+                case ($otherfield=='timemodified') : $contents = userdate($record->timemodified, get_string('strftimedate'), 0); break;
+            }
+            $exportdata[$line][] = $contents;
+        }
     }
     $line++;
 }
Index: mod/data/export_form.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/data/export_form.php,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 export_form.php
--- mod/data/export_form.php	31 May 2008 15:03:34 -0000	1.1.2.2
+++ mod/data/export_form.php	27 Dec 2009 05:24:24 -0000
@@ -48,7 +48,19 @@
                 $a->fieldtype = $field->name();
                 $mform->addElement('static', 'unsupported'.$field->field->id, $field->field->name, get_string('unsupportedexport', 'data', $a));
             }
+            $maxfield = $field->field->id;
         }
+        $strusername=get_string('username');
+        $strtimemodified=get_string('timemodified','data');
+        $strtimeadded=get_string('timeadded','data');
+        $mform->addElement('advcheckbox', 'username', '<div title="username">' . $strusername . '</div>', ' (' . $strusername . ')', array('group'=>1));
+        $mform->setDefault('username', 0);
+        $mform->addElement('advcheckbox', 'timemodified', '<div title="timemodified">' . $strtimemodified . '</div>', ' (' . $strtimemodified . ')', array('group'=>1));
+        $mform->setDefault('timemodified',0);
+        $mform->addElement('advcheckbox', 'timeadded', '<div title="timeadded">' . $strtimeadded . '</div>', ' (' . $strtimeadded . ')', array('group'=>1));
+        $mform->setDefault('timeadded', 0);
+        
+        
         $this->add_checkbox_controller(1, null, null, 1);
         $this->add_action_buttons(true, get_string('exportdatabaserecords', 'data'));
     }

