'Submission ID', 'submissiondate' => 'Submission Date', 'lastupdate' => 'Last Updated', 'accepted' => 'Acceptance', ); $authorFieldsAR = array(); foreach ($OC_submissionFieldSetAR as $fsKey => $fsAR) { if ($fsKey == 'fs_authors') { $fieldAR['skip' . $skip++] = ''; $fieldAR['name'] = 'Contact Author Full Name'; $authorFieldsAR['author_name'] = 'All Authors Full Name'; foreach ($fsAR['fields'] AS $fieldID) { $fieldAR[$fieldID] = 'Contact Author ' . $OC_submissionFieldAR[$fieldID]['name']; $authorFieldsAR['author_' . $fieldID] = 'All Authors ' . $OC_submissionFieldAR[$fieldID]['name']; } $fieldAR['skip' . $skip++] = ''; } else { foreach ($fsAR['fields'] AS $fieldID) { if (preg_match("/^password/i", $fieldID) || ($fieldID == 'file') || ($fieldID == 'topics') || empty($OC_submissionFieldAR[$fieldID]['name'])) { continue; } $fieldAR[$fieldID] = $OC_submissionFieldAR[$fieldID]['name']; } } } $fieldAR['_topics'] = 'Topics'; $fieldAR['skip' . $skip++] = ''; $fieldAR = array_merge($fieldAR, $authorFieldsAR); $fieldAR['skip' . $skip++] = ''; // Default list of checked fields $checkedFieldAR = array('paperid','title','name','email'); // Include extra fields if (oc_hookSet('chair-export-fields')) { foreach ($OC_hooksAR['chair-export-fields'] as $v) { require_once $v; } } if (isset($_POST['submit']) && ($_POST['submit'] == "Generate File") && isset($_POST['fields']) && !empty($_POST['fields'])) { // Check for valid submission if (!validToken('chair')) { warn('Invalid submission'); } // Verify Fields $fieldARkeys = array_keys($fieldAR); foreach ($_POST['fields'] as $f) { if (!in_array($f,$fieldARkeys)) { exporterr('Invalid field name selection'); } } // Init extra field AR $extraAR = array(); // List of fields to export $exportFieldsAR = $_POST['fields']; // All author data to display $incAuthorFieldsAR = array_intersect($_POST['fields'], array_keys($authorFieldsAR)); if (!empty($incAuthorFieldsAR)) { $maxPosition = 1; // tracks max number of authors per submission // Get all authors info $q = "SELECT `" . OCC_TABLE_AUTHOR . "`.*, CONCAT_WS(' ', `" . OCC_TABLE_AUTHOR . "`.`name_first`, `" . OCC_TABLE_AUTHOR . "`.`name_last`) AS `name` FROM `" . OCC_TABLE_AUTHOR . "`, `" . OCC_TABLE_PAPER . "` WHERE `" . OCC_TABLE_PAPER . "`.`paperid`=`" . OCC_TABLE_AUTHOR . "`.`paperid` " . $accSQL . " ORDER BY `paperid`, `position`"; $r = mysql_query($q) or exporterr("Unable to retrieve data for export (1)"); while ($l = mysql_fetch_assoc($r)) { foreach ($authorFieldsAR as $afKey => $afVal) { if (preg_match("/^author_(\w+)$/", $afKey, $matches)) { $extraAR[$l['paperid']]['_' . $afKey . $l['position']] = $l[$matches[1]]; } } if ($l['position'] > $maxPosition) { $maxPosition = $l['position']; } } $newAuthorFieldsAR = array(); for ($i=1; $i<=$maxPosition; $i++) { foreach($incAuthorFieldsAR as $f) { $newAuthorFieldsAR[] = '_' . $f . $i; } } reset($incAuthorFieldsAR); array_splice( $exportFieldsAR, array_search(current($incAuthorFieldsAR), $_POST['fields']), count($incAuthorFieldsAR), $newAuthorFieldsAR ); } // Topics if (in_array('_topics', $exportFieldsAR)) { $q = "SELECT `" . OCC_TABLE_PAPER . "`.`paperid`, `" . OCC_TABLE_TOPIC . "`.`topicname`, `" . OCC_TABLE_TOPIC . "`.`short` FROM `" . OCC_TABLE_PAPER . "`, `" . OCC_TABLE_TOPIC . "`, `" . OCC_TABLE_PAPERTOPIC . "` WHERE `" . OCC_TABLE_PAPER . "`.`paperid`=`" . OCC_TABLE_PAPERTOPIC . "`.`paperid` AND `" . OCC_TABLE_PAPERTOPIC . "`.`topicid`=`" . OCC_TABLE_TOPIC . "`.`topicid` " . $accSQL; $r = mysql_query($q) or exporterr("Unable to retrieve data for export (t)"); while ($l = mysql_fetch_assoc($r)) { if (isset($extraAR[$l['paperid']]['_topics'])) { $extraAR[$l['paperid']]['_topics'] .= ',' . useTopic($l['short'], $l['topicname']); } else { $extraAR[$l['paperid']]['_topics'] = useTopic($l['short'], $l['topicname']); } } } // Get extra fields data if (oc_hookSet('chair-export-data')) { foreach ($OC_hooksAR['chair-export-data'] as $v) { require_once $v; } } // Get sub. data & iterate through each $q = "SELECT `" . OCC_TABLE_PAPER . "`.*, `" . OCC_TABLE_PAPER . "`.`paperid` AS `id`, `" . OCC_TABLE_AUTHOR . "`.*, CONCAT_WS(' ',`" . OCC_TABLE_AUTHOR . "`.`name_first`,`" . OCC_TABLE_AUTHOR . "`.`name_last`) AS `name` FROM `" . OCC_TABLE_PAPER . "`, `" . OCC_TABLE_AUTHOR . "` WHERE `" . OCC_TABLE_PAPER . "`.`paperid`=`" . OCC_TABLE_AUTHOR . "`.`paperid` AND `" . OCC_TABLE_AUTHOR . "`.`position`=`" . OCC_TABLE_PAPER . "`.`contactid` ". $accSQL . " ORDER BY `" . OCC_TABLE_PAPER . "`.`paperid`"; $r = ocsql_query($q) or exporterr("Unable to retrieve data for export"); if (mysql_num_rows($r) == 0) { warn("There are no papers to export",'Export ' . $scope . ' Papers',1); exit; } else { // Export file require_once 'export.inc'; oc_export($scope, $exportFieldsAR, $fieldAR, $r, $extraAR, $OC_submissionFieldAR); exit; } } // Display form printHeader('Export ' . $scope, 1); print '

Export will generate one row/entry per submission. When selecting All Authors, each author\'s data will appear as separate fields.

'; foreach ($fieldAR as $fieldID => $fieldName) { if (preg_match("/^skip\d+$/", $fieldID)) { print '

'; continue; } print '
\n"; } print '

    Format:

Note: When opening up a CSV or Tab-delimited file in a spreadsheet, you may need to specify the character encoding: UTF-8.

'; printFooter(); ?>