Skip to content

Commit

Permalink
Hotfix 2023 06 19 (BioKIC#518)
Browse files Browse the repository at this point in the history
* Taxonomy Harvesting minor adjustments

- Check resources before interpretation and again after interpretation
- If name is matched within one recourse, skip the unnecessary step to check other resources
- Synchronize display text

* Refactor ImageLocalProcessor and resolve various bugs

- Provide support for input file to include medium and thumbnail image derivatives
- Expand Image Map processing to allow mapping file to include any images table field name
- Expand images insert function to handle any valid field found within images table
- Merge duplicate actions into shared private functions
- MD5 hash large version of image input file, but don't overwrite hash if supplied by source, unless image is not modified by upload scripts
- Handle BOM characters at start of csv file.
- Trim header elements for testing column names.
- Enforce default action of accepting derivative urls supplied within a csv image map file
- Improve uriExists function
- Make sure to remove staging images

* Occurrence Public Display page

- Allow occurrence archive (deleted occurrences) to be searchable by GUID (occurrenceID, recordID), thus reporting when a record is deleted

* Checklist multi-polygon map Issue

- Multipolygons defined within a checklist fail to map within both simple and dynamic maps

* Suppress geo ref index during stats update

* Occurrence Reviewer bug

- Fix for field name and start and end date filter variables failing to be carried forward when advancing to pages beyond 1000 records
BioKIC#335

* Collection metadata editor bug

- Reset contact array to ensure that JSON string is standardized as a non-associated array
Resolves issue: BioKIC#487

---------

Co-authored-by: Greg Post <[email protected]>
  • Loading branch information
egbot and GregoryPost authored Jun 22, 2023
1 parent f55bc39 commit deb6549
Show file tree
Hide file tree
Showing 13 changed files with 492 additions and 421 deletions.
45 changes: 23 additions & 22 deletions checklists/checklistmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,33 +67,34 @@ function initialize(){
}
}
}
//Check for and add checklist polygon
$clMeta = $clManager->getClMetaData();
if($clMeta['footprintwkt']){
?>
var polyPointArr = [];
<?php
$footPrintWkt = $clMeta['footprintwkt'];
if(substr($footPrintWkt, 0, 7) == 'POLYGON'){
$footPrintWkt = substr($footPrintWkt, 10, -2);
$pointArr = explode(',', $footPrintWkt);
foreach($pointArr as $pointStr){
$llArr = explode(' ', trim($pointStr));
if($llArr[0] > 90 || $llArr[0] < -90) break;
//Add checklist polygon
$wkt = $clMeta['footprintwkt'];
if(substr($wkt,0,7) == 'POLYGON') $wkt = substr($wkt,7);
else if(substr($wkt,0,12) == 'MULTIPOLYGON') $wkt = substr($wkt,12);
$coordArr = explode('),(', $wkt);
foreach($coordArr as $k => $polyFrag){
if($pointArr = explode(',', trim($polyFrag,' (),'))){
echo 'var polyPointArr'.$k.' = [];';
foreach($pointArr as $pointStr){
$llArr = explode(' ', trim($pointStr));
if($llArr[0] > 90 || $llArr[0] < -90) break;
?>
var polyPt = new google.maps.LatLng(<?php echo $llArr[0].','.$llArr[1]; ?>);
polyPointArr<?php echo $k; ?>.push(polyPt);
llBounds.extend(polyPt);
<?php
}
?>
var polyPt = new google.maps.LatLng(<?php echo $llArr[0].','.$llArr[1]; ?>);
polyPointArr.push(polyPt);
llBounds.extend(polyPt);
var footPoly<?php echo $k; ?> = new google.maps.Polygon({
paths: polyPointArr<?php echo $k; ?>,
strokeWeight: 2,
fillOpacity: 0.4,
map: map
});
<?php
}
?>
var footPoly = new google.maps.Polygon({
paths: polyPointArr,
strokeWeight: 2,
fillOpacity: 0.4,
map: map
});
<?php
}
}
?>
Expand Down
691 changes: 374 additions & 317 deletions classes/ImageLocalProcessor.php

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion classes/OccurrenceCollectionProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ public function updateStatistics($verbose = false){
ob_flush();
}
$occurMaintenance->generalOccurrenceCleaning();
$occurMaintenance->batchUpdateGeoreferenceIndex();
//$occurMaintenance->batchUpdateGeoreferenceIndex();
if($verbose){
echo '<li>Updating statistics...</li>';
flush();
Expand Down
34 changes: 24 additions & 10 deletions classes/OccurrenceIndividual.php
Original file line number Diff line number Diff line change
Expand Up @@ -968,21 +968,35 @@ public function getChecklists($clidExcludeArr){
return $returnArr;
}

public function checkArchive(){
public function checkArchive($guid){
$retArr = array();
$archiveObject = '';
$notes = '';
$sql = 'SELECT archiveobj, remarks FROM omoccurarchive ';
if($this->occid){
$sql = 'SELECT archiveobj, remarks FROM omoccurarchive WHERE occid = '.$this->occid;
if($rs = $this->conn->query($sql)){
if($r = $rs->fetch_object()){
$retArr['obj'] = json_decode($r->archiveobj, true);
$retArr['notes'] = $r->remarks;
}
$rs->free();
$sql .= 'WHERE occid = ?';
if($stmt = $this->conn->prepare($sql)){
$stmt->bind_param('i', $this->occid);
$stmt->execute();
$stmt->bind_result($archiveObject, $notes);
$stmt->fetch();
$stmt->close();
}
else{
trigger_error('ERROR checking archive: '.$this->conn->error,E_USER_WARNING);
}
if(!$retArr && $guid){
$sql .= 'WHERE (occurrenceid = ?) OR (recordID = ?) ';
if($stmt = $this->conn->prepare($sql)){
$stmt->bind_param('ss', $guid, $guid);
$stmt->execute();
$stmt->bind_result($archiveObject, $notes);
$stmt->fetch();
$stmt->close();
}
}
if($archiveObject){
$retArr['obj'] = json_decode($archiveObject, true);
$retArr['notes'] = $notes;
}
return $retArr;
}

Expand Down
51 changes: 24 additions & 27 deletions classes/OccurrenceMapManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,35 +294,32 @@ public function createShape(){
if($this->getSearchTerm('polycoords')){
$wkt = $this->getSearchTerm('polycoords');
if(substr($wkt,0,7) == 'POLYGON') $wkt = substr($wkt,7);
$wkt = trim($wkt,' (),');
$coordArr = explode(',',$wkt);
if($coordArr){
$shapeBounds = 'var queryShapeBounds = new google.maps.LatLngBounds();';
$queryShape = 'var queryPolygon = new google.maps.Polygon({';
$points = '';
foreach($coordArr as $k => $ptStr){
$ptArr = explode(' ',$ptStr);
$points .= ',new google.maps.LatLng('.$ptArr[0].', '.$ptArr[1].')';
$shapeBounds .= 'queryShapeBounds.extend(new google.maps.LatLng('.$ptArr[0].', '.$ptArr[1].'));';
else if(substr($wkt,0,12) == 'MULTIPOLYGON') $wkt = substr($wkt,12);
$coordArr = explode('),(', $wkt);
$shapeBounds = 'var queryShapeBounds = new google.maps.LatLngBounds();'."\n";
foreach($coordArr as $k => $polyFrag){
if($pointArr = explode(',', trim($polyFrag,' (),'))){
$queryShape .= 'var queryPolygon'.$k.' = new google.maps.Polygon({';
$points = '';
foreach($pointArr as $ptStr){
$ptArr = explode(' ',$ptStr);
$points .= ',new google.maps.LatLng('.$ptArr[0].', '.$ptArr[1].')';
$shapeBounds .= 'queryShapeBounds.extend(new google.maps.LatLng('.$ptArr[0].', '.$ptArr[1].'));'."\n";
}
$queryShape .= 'paths: ['.substr($points,1).'],';
$queryShape .= $properties;
$queryShape .= 'queryPolygon'.$k.'.type = "polygon";';
$queryShape .= 'google.maps.event.addListener(queryPolygon'.$k.', "click", function() { setSelection(queryPolygon'.$k.');});';
$queryShape .= 'google.maps.event.addListener(queryPolygon'.$k.', "dragend", function() { setSelection(queryPolygon'.$k.');});';
$queryShape .= 'google.maps.event.addListener(queryPolygon'.$k.'.getPath(), "insert_at", function() { setSelection(queryPolygon'.$k.');});';
$queryShape .= 'google.maps.event.addListener(queryPolygon'.$k.'.getPath(), "remove_at", function() { setSelection(queryPolygon'.$k.');});';
$queryShape .= 'google.maps.event.addListener(queryPolygon'.$k.'.getPath(), "set_at", function() { setSelection(queryPolygon'.$k.');});';
$queryShape .= 'setSelection(queryPolygon'.$k.');';
}
$queryShape .= 'paths: ['.substr($points,1).'],';
$queryShape .= $properties;
$queryShape .= "queryPolygon.type = 'polygon';";
$queryShape .= "google.maps.event.addListener(queryPolygon, 'click', function() {";
$queryShape .= 'setSelection(queryPolygon);});';
$queryShape .= "google.maps.event.addListener(queryPolygon, 'dragend', function() {";
$queryShape .= 'setSelection(queryPolygon);});';
$queryShape .= "google.maps.event.addListener(queryPolygon.getPath(), 'insert_at', function() {";
$queryShape .= 'setSelection(queryPolygon);});';
$queryShape .= "google.maps.event.addListener(queryPolygon.getPath(), 'remove_at', function() {";
$queryShape .= 'setSelection(queryPolygon);});';
$queryShape .= "google.maps.event.addListener(queryPolygon.getPath(), 'set_at', function() {";
$queryShape .= 'setSelection(queryPolygon);});';
$queryShape .= 'setSelection(queryPolygon);';
$queryShape .= $shapeBounds;
$queryShape .= 'map.fitBounds(queryShapeBounds);';
$queryShape .= 'map.panToBounds(queryShapeBounds);';
}
$queryShape .= $shapeBounds;
$queryShape .= 'map.fitBounds(queryShapeBounds);';
$queryShape .= 'map.panToBounds(queryShapeBounds);'."\n";
}
return $queryShape;
}
Expand Down
21 changes: 12 additions & 9 deletions classes/OmCollections.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,15 +214,19 @@ public function deleteContact($index){
}

private function updateContactJson($contactArr){
$status = false;
if($this->collid){
$sql = 'UPDATE omcollections SET contactJson = "'.$this->cleanInStr(json_encode($contactArr)).'" WHERE collid = '.$this->collid;
if(!$this->conn->query($sql)){
$this->errorMessage = 'ERROR updating contact: '.$this->conn->error;
return false;
$contactStr = json_encode(array_values($contactArr));
$sql = 'UPDATE omcollections SET contactJson = ? WHERE collid = '.$this->collid;
if($stmt = $this->conn->prepare($sql)){
$stmt->bind_param('s', $contactStr);
$stmt->execute();
if($stmt->affected_rows) $status = true;
elseif($stmt->error) $this->errorMessage = $stmt->error;
$stmt->close();
}
return true;
}
return false;
return $status;
}

private function getContactArr(){
Expand Down Expand Up @@ -288,9 +292,8 @@ public function linkAddress($addIID){
public function removeAddress($removeIID){
$status = false;
if($this->collid && is_numeric($removeIID)){
$con = MySQLiConnectionFactory::getCon("write");
$sql = 'UPDATE omcollections SET iid = NULL '.
'WHERE collid = '.$this->collid.' AND iid = '.$removeIID;
$con = MySQLiConnectionFactory::getCon('write');
$sql = 'UPDATE omcollections SET iid = NULL WHERE collid = '.$this->collid.' AND iid = '.$removeIID;
if($con->query($sql)){
$status = true;
}
Expand Down
38 changes: 19 additions & 19 deletions classes/TaxonomyCleaner.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,27 +94,27 @@ public function analyzeTaxa($taxResource, $startIndex, $limit = 50){
$sciname = $r->sciname;
$tid = 0;
$manualCheck = true;
$taxonArr = TaxonomyUtilities::parseScientificName($r->sciname,$this->conn,0,$this->targetKingdomName);
if(isset($taxonArr['sciname']) && $taxonArr['sciname']){
$sciname = $taxonArr['sciname'];
if($sciname != $r->sciname){
$this->logOrEcho('Interpreted base name: <b>'.$sciname.'</b>',1);
}
$tid = $taxonHarvester->getTid($taxonArr);
if($tid && $this->autoClean){
$this->remapOccurrenceTaxon($this->collid, $r->sciname, $tid, (isset($taxonArr['identificationqualifier'])?$taxonArr['identificationqualifier']:''));
$this->logOrEcho('Taxon remapped to <b>'.$sciname.'</b>',1);
if($tid = $taxonHarvester->processSciname($sciname)){
$taxaAdded= true;
if($taxonHarvester->isFullyResolved()){
$manualCheck = false;
}
else{
$this->logOrEcho('Taxon not fully resolved...',1);
}
}
if(!$tid){
if($taxonHarvester->processSciname($sciname)){
$taxaAdded= true;
if($taxonHarvester->isFullyResolved()){
$manualCheck = false;
$taxonArr = TaxonomyUtilities::parseScientificName($r->sciname,$this->conn,0,$this->targetKingdomName);
if(!$tid && $this->autoClean){
if(isset($taxonArr['sciname']) && $taxonArr['sciname']){
$sciname = $taxonArr['sciname'];
if($sciname != $r->sciname){
$this->logOrEcho('Interpreted base name: <b>'.$sciname.'</b>',1);
}
else{
$this->logOrEcho('Taxon not fully resolved...',1);
$tid = $taxonHarvester->getTid($taxonArr);
if($tid){
$this->remapOccurrenceTaxon($this->collid, $r->sciname, $tid, (isset($taxonArr['identificationqualifier'])?$taxonArr['identificationqualifier']:''));
$this->logOrEcho('Taxon remapped to <b>'.$sciname.'</b>',1);
$manualCheck = false;
}
}
}
Expand All @@ -129,14 +129,14 @@ public function analyzeTaxa($taxResource, $startIndex, $limit = 50){
for($x=1; $x <= 3; $x++){
if(isset($taxonArr['unitname'.$x]) && $taxonArr['unitname'.$x]) $strTestArr[] = $taxonArr['unitname'.$x];
}
foreach($matchArr as $tid => $scinameMatch){
foreach($matchArr as $tidMatch => $scinameMatch){
$snTokens = explode(' ',$scinameMatch);
foreach($snTokens as $k => $v){
if(in_array($v, $strTestArr)) $snTokens[$k] = '<b>'.$v.'</b>';
}
$idQual = (isset($taxonArr['identificationqualifier'])?str_replace("'", '', $taxonArr['identificationqualifier']):'');
$echoStr = '<i>'.implode(' ',$snTokens).'</i> =&gt; <span class="hideOnLoad">wait for page to finish loading...</span><span class="displayOnLoad" style="display:none">'.
'<a href="#" onclick="return remappTaxon(\''.urlencode($r->sciname).'\','.$tid.',\''.$idQual.'\','.$itemCnt.')" style="color:blue"> remap to this taxon</a>'.
'<a href="#" onclick="return remappTaxon(\''.urlencode($r->sciname).'\','.$tidMatch.',\''.$idQual.'\','.$itemCnt.')" style="color:blue"> remap to this taxon</a>'.
'<span id="remapSpan-'.$itemCnt.'"></span></span>';
$this->logOrEcho($echoStr,2);
$itemCnt++;
Expand Down
3 changes: 2 additions & 1 deletion classes/TaxonomyHarvester.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public function processSciname($term){
}
foreach($this->taxonomicResources as $authCode => $apiKey){
$newTid = $this->addSciname($taxonArr, $authCode);
if($newTid) break;
}
}
return $newTid;
Expand Down Expand Up @@ -228,7 +229,7 @@ private function addColTaxon($taxonArr){
}
else $this->logOrEcho('Targeted taxon return does not exist',2);
}
else $this->logOrEcho($sciName.' not found in CoL',2);
else $this->logOrEcho('Taxon not found',2);
}
else $this->logOrEcho('ERROR harvesting COL name: null input name',1);
return $tid;
Expand Down
5 changes: 3 additions & 2 deletions collections/editor/editreviewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
$displayMode = array_key_exists('display', $_REQUEST) ? filter_var($_REQUEST['display'], FILTER_SANITIZE_NUMBER_INT) : '1';
$faStatus = array_key_exists('fastatus', $_REQUEST) ? filter_var($_REQUEST['fastatus'], FILTER_SANITIZE_NUMBER_INT) : '';
$frStatus = array_key_exists('frstatus', $_REQUEST)? filter_var($_REQUEST['frstatus'], FILTER_SANITIZE_STRING) : '1,2';
$filterFieldName = array_key_exists('ffieldname', $_POST) ? filter_var($_POST['ffieldname'], FILTER_SANITIZE_STRING) : '';
$filterFieldName = array_key_exists('ffieldname', $_REQUEST) ? filter_var($_REQUEST['ffieldname'], FILTER_SANITIZE_STRING) : '';
$editor = array_key_exists('editor', $_REQUEST) ? filter_var($_REQUEST['editor'], FILTER_SANITIZE_STRING) : '';
$queryOccid = array_key_exists('occid', $_REQUEST) ? filter_var($_REQUEST['occid'], FILTER_SANITIZE_NUMBER_INT) : '';
$startDate = array_key_exists('startdate', $_REQUEST) ? filter_var($_REQUEST['startdate'], FILTER_SANITIZE_STRING) : '';
Expand Down Expand Up @@ -81,7 +81,8 @@

$subCnt = $limitCnt*($pageNum + 1);
if($subCnt > $recCnt) $subCnt = $recCnt;
$navPageBase = 'editreviewer.php?collid='.$collid.'&display='.$displayMode.'&fastatus='.$faStatus.'&frstatus='.$frStatus.'&editor='.$editor.'&reccnt='.$recCnt;
$navPageBase = 'editreviewer.php?collid='.$collid.'&display='.$displayMode.'&fastatus='.$faStatus.'&frstatus='.$frStatus.'&ffieldname='.$filterFieldName.
'&startdate='.$startDate.'&enddate='.$endDate.'&editor='.$editor.'&reccnt='.$recCnt;

$navStr = '<div class="navbarDiv" style="float:right;">';
if($pageNum) $navStr .= '<a href="'.$navPageBase.'&pagenum='.($pageNum-1).'&limitcnt='.$limitCnt.'" title="'.$LANG['PREVIOUS'].' '.$limitCnt.' '.$LANG['RECORDS1'].'">&lt;&lt;</a>';
Expand Down
2 changes: 1 addition & 1 deletion collections/individual/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -1395,7 +1395,7 @@ function initializeMap(){
<?php
ob_flush();
flush();
$rawArchArr = $indManager->checkArchive();
$rawArchArr = $indManager->checkArchive($guid);
if($rawArchArr && $rawArchArr['obj']){
$archArr = $rawArchArr['obj'];
if($isEditor){
Expand Down
10 changes: 5 additions & 5 deletions collections/specprocessor/processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
$specManager->setProjVariables($spprid);
if($action == 'Process Images'){
if($specManager->getProjectType() == 'iplant'){
$imageProcessor = new ImageProcessor($specManager->getConn());
$imageProcessor = new ImageProcessor();
echo '<ul>';
$imageProcessor->setLogMode(3);
$imageProcessor->setCollid($collid);
Expand Down Expand Up @@ -95,9 +95,9 @@
if($specManager->getLgMaxFileSize()) $imageProcessor->setLgFileSizeLimit($specManager->getLgMaxFileSize());
if($specManager->getJpgQuality()) $imageProcessor->setJpgQuality($specManager->getJpgQuality());
$imageProcessor->setUseImageMagick($specManager->getUseImageMagick());
$imageProcessor->setWebImg($_POST['webimg']);
$imageProcessor->setTnImg($_POST['createtnimg']);
$imageProcessor->setLgImg($_POST['createlgimg']);
$imageProcessor->setMedProcessingCode($_POST['webimg']);
$imageProcessor->setTnProcessingCode($_POST['createtnimg']);
$imageProcessor->setLgProcessingCode($_POST['createlgimg']);
$imageProcessor->setCreateNewRec($_POST['createnewrec']);
$imageProcessor->setImgExists($_POST['imgexists']);
$imageProcessor->setKeepOrig(0);
Expand All @@ -111,7 +111,7 @@
}
elseif($action == 'mapImageFile'){
//Process csv file with remote image urls
$imageProcessor = new ImageProcessor($specManager->getConn());
$imageProcessor = new ImageProcessor();
echo '<ul>';
$imageProcessor->setLogMode(3);
$imageProcessor->setCollid($collid);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,9 @@
if($lgFileSizeLimit) $imageProcessor->setLgFileSizeLimit($lgFileSizeLimit);
$imageProcessor->setJpgQuality($jpgQuality);

if(isset($webImg) && $webImg) $imageProcessor->setWebImg($webImg);
elseif(isset($createWebImg) && $createWebImg) $imageProcessor->setCreateWebImg($createWebImg);
if(isset($tnImg) && $tnImg) $imageProcessor->setTnImg($tnImg);
elseif(isset($createTnImg) && $createTnImg) $imageProcessor->setCreateTnImg($createTnImg);
if(isset($lgImg) && $lgImg) $imageProcessor->setLgImg($lgImg);
elseif(isset($createLgImg) && $createLgImg) $imageProcessor->setCreateLgImg($createLgImg);
if(isset($webImg) && $webImg) $imageProcessor->setMedProcessingCode($webImg);
if(isset($tnImg) && $tnImg) $imageProcessor->setTnProcessingCode($tnImg);
if(isset($lgImg) && $lgImg) $imageProcessor->setLgProcessingCode($lgImg);
$imageProcessor->setKeepOrig($keepOrig);
$imageProcessor->setCreateNewRec($createNewRec);
if(isset($imgExists)) $imageProcessor->setImgExists($imgExists);
Expand Down
2 changes: 1 addition & 1 deletion config/symbbase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
header('X-Frame-Options: DENY');
header('Cache-control: private'); // IE 6 FIX
date_default_timezone_set('America/Phoenix');
$CODE_VERSION = '3.0.9';
$CODE_VERSION = '3.0.10';

if(!isset($CLIENT_ROOT) && isset($clientRoot)) $CLIENT_ROOT = $clientRoot;
if(substr($CLIENT_ROOT,-1) == '/') $CLIENT_ROOT = substr($CLIENT_ROOT,0,strlen($CLIENT_ROOT)-1);
Expand Down

0 comments on commit deb6549

Please sign in to comment.