public function exportDataset($dsid)
 {
     //Get occurrence records
     $zip = array_key_exists('zip', $_POST) ? $_POST['zip'] : 0;
     $format = $_POST['format'];
     $extended = array_key_exists('extended', $_POST) ? $_POST['extended'] : 0;
     $redactLocalities = 1;
     $rareReaderArr = array();
     if ($IS_ADMIN || array_key_exists("CollAdmin", $userRights)) {
         $redactLocalities = 0;
     } elseif (array_key_exists("RareSppAdmin", $userRights) || array_key_exists("RareSppReadAll", $userRights)) {
         $redactLocalities = 0;
     } else {
         if (array_key_exists('CollEditor', $userRights)) {
             $rareReaderArr = $userRights['CollEditor'];
         }
         if (array_key_exists('RareSppReader', $userRights)) {
             $rareReaderArr = array_unique(array_merge($rareReaderArr, $userRights['RareSppReader']));
         }
     }
     $dwcaHandler = new DwcArchiverOccurrence();
     $dwcaHandler->setCharSetOut($cSet);
     $dwcaHandler->setSchemaType($schema);
     $dwcaHandler->setExtended($extended);
     $dwcaHandler->setDelimiter($format);
     $dwcaHandler->setVerbose(0);
     $dwcaHandler->setRedactLocalities($redactLocalities);
     if ($rareReaderArr) {
         $dwcaHandler->setRareReaderArr($rareReaderArr);
     }
     $occurManager = new OccurrenceManager();
     $dwcaHandler->setCustomWhereSql($occurManager->getSqlWhere());
     $outputFile = null;
     if ($zip) {
         //Ouput file is a zip file
         $includeIdent = array_key_exists('identifications', $_POST) ? 1 : 0;
         $dwcaHandler->setIncludeDets($includeIdent);
         $images = array_key_exists('images', $_POST) ? 1 : 0;
         $dwcaHandler->setIncludeImgs($images);
         $outputFile = $dwcaHandler->createDwcArchive('webreq');
     } else {
         //Output file is a flat occurrence file (not a zip file)
         $outputFile = $dwcaHandler->getOccurrenceFile();
     }
     //ob_start();
     $contentDesc = '';
     if ($schema == 'dwc') {
         $contentDesc = 'Darwin Core ';
     } else {
         $contentDesc = 'Symbiota ';
     }
     $contentDesc .= 'Occurrence ';
     if ($zip) {
         $contentDesc .= 'Archive ';
     }
     $contentDesc .= 'File';
     header('Content-Description: ' . $contentDesc);
     if ($zip) {
         header('Content-Type: application/zip');
     } elseif ($format == 'csv') {
         header('Content-Type: text/csv; charset=' . $charset);
     } else {
         header('Content-Type: text/html; charset=' . $charset);
     }
     header('Content-Disposition: attachment; filename=' . basename($outputFile));
     header('Content-Transfer-Encoding: binary');
     header('Expires: 0');
     header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
     header('Pragma: public');
     header('Content-Length: ' . filesize($outputFile));
     ob_clean();
     flush();
     //od_end_clean();
     readfile($outputFile);
     unlink($outputFile);
 }
Beispiel #2
0
             $dwcaHandler->addCondition('dbpk', 'NULL');
             $dwcaHandler->addCondition('catalognumber', 'NOTNULL');
         }
     }
 }
 $outputFile = null;
 if ($zip) {
     //Ouput file is a zip file
     $includeIdent = array_key_exists('identifications', $_POST) ? 1 : 0;
     $dwcaHandler->setIncludeDets($includeIdent);
     $images = array_key_exists('images', $_POST) ? 1 : 0;
     $dwcaHandler->setIncludeImgs($images);
     $outputFile = $dwcaHandler->createDwcArchive('webreq');
 } else {
     //Output file is a flat occurrence file (not a zip file)
     $outputFile = $dwcaHandler->getOccurrenceFile();
 }
 //ob_start();
 $contentDesc = '';
 if ($schema == 'dwc') {
     $contentDesc = 'Darwin Core ';
 } else {
     $contentDesc = 'Symbiota ';
 }
 $contentDesc .= 'Occurrence ';
 if ($zip) {
     $contentDesc .= 'Archive ';
 }
 $contentDesc .= 'File';
 header('Content-Description: ' . $contentDesc);
 if ($zip) {