diff --git a/classes/GlossaryManager.php b/classes/GlossaryManager.php index 3b037a2f1f..fdc7ea11d6 100644 --- a/classes/GlossaryManager.php +++ b/classes/GlossaryManager.php @@ -578,7 +578,7 @@ public function getTaxonSources($tidStr = ''){ public function addSource($pArr){ $status = true; - if(is_numeric($pArr['tid'])){ + if($pArr['tid'] && is_numeric($pArr['tid'])){ $terms = $this->cleanInStr($pArr['contributorTerm']); $images = $this->cleanInStr($pArr['contributorImage']); $translator = $this->cleanInStr($pArr['translator']); diff --git a/classes/OccurrenceCleaner.php b/classes/OccurrenceCleaner.php index ac8c768a8c..15dd12614b 100644 --- a/classes/OccurrenceCleaner.php +++ b/classes/OccurrenceCleaner.php @@ -45,7 +45,7 @@ public function getDuplicateCatalogNumber($type, $start, $limit = 500){ } $rs->free(); - $retArr = array(); + $stagingArr = array(); if($dupArr){ $sqlFrag = ''; if($type=='cat'){ @@ -54,13 +54,15 @@ public function getDuplicateCatalogNumber($type, $start, $limit = 500){ else{ $sqlFrag = 'occid, otherCatalogNumbers, otherCatalogNumbers AS dupid FROM omoccurrences WHERE collid = '.$this->collid.' AND otherCatalogNumbers IN("'.implode('","', $dupArr).'") ORDER BY otherCatalogNumbers'; } - $retArr = $this->getDuplicates($sqlFrag); + $stagingArr = $this->getDuplicates($sqlFrag); } if($type=='other' && count($dupArr) < $limit){ - $retArr = array_merge($retArr, $this->setAdditionalIdentifiers($cnt, ($limit - count($dupArr)))); + $stagingArr = array_merge($stagingArr, $this->setAdditionalIdentifiers($cnt, ($limit - count($dupArr)))); } + //Replace catalog number keys with renumbered numeric keys, thus avoid unusual characters interferring with naming form target element + $retArr = array_values($stagingArr); return $retArr; } @@ -152,7 +154,7 @@ private function getDuplicates($sqlFragment){ $sqlFragment; $rs = $this->conn->query($sql); while($row = $rs->fetch_assoc()){ - $retArr[$row['dupid']][$row['occid']] = array_change_key_case($row); + $retArr[strtolower($row['dupid'])][$row['occid']] = array_change_key_case($row); } $rs->free(); return $retArr; @@ -162,6 +164,7 @@ public function mergeDupeArr($occidArr){ $status = true; $this->verboseMode = 2; $editorManager = new OccurrenceEditorManager($this->conn); + $editorManager->setCollId($this->collid); foreach($occidArr as $target => $occArr){ $mergeArr = array($target); foreach($occArr as $source){ diff --git a/classes/SpecUploadBase.php b/classes/SpecUploadBase.php index 20beffc31e..269bab7d7d 100644 --- a/classes/SpecUploadBase.php +++ b/classes/SpecUploadBase.php @@ -896,9 +896,7 @@ protected function transferOccurrences(){ $this->outputMsg('
  • Transferring edits to versioning tables...
  • '); $this->versionExternalEdits(); } - elseif($this->collMetadataArr['managementtype'] == 'Live Data' && $this->uploadType != $this->RESTOREBACKUP){ - $this->versionInternalEdits(); - } + $this->versionInternalEdits(); $transactionInterval = 1000; $this->outputMsg('
  • Updating existing records in batches of '.$transactionInterval.'...
  • '); //Grab specimen intervals for updating records in batches @@ -1003,23 +1001,25 @@ protected function transferOccurrences(){ private function versionInternalEdits(){ if($this->versionDataEdits){ - $sqlFrag = ''; - $excludedFieldArr = array('dateentered','observeruid'); - foreach($this->targetFieldArr as $field){ - if(!in_array($field, $excludedFieldArr)) $sqlFrag .= ',u.'.$field.',o.'.$field.' as old_'.$field; - } - $sql = 'SELECT o.occid'.$sqlFrag.' FROM omoccurrences o INNER JOIN uploadspectemp u ON o.occid = u.occid WHERE o.collid IN('.$this->collId.') AND u.collid IN('.$this->collId.')'; - $rs = $this->conn->query($sql); - while($r = $rs->fetch_assoc()){ + if($this->collMetadataArr['managementtype'] == 'Live Data' && $this->uploadType != $this->RESTOREBACKUP){ + $sqlFrag = ''; + $excludedFieldArr = array('dateentered','observeruid'); foreach($this->targetFieldArr as $field){ - if(in_array($field, $excludedFieldArr)) continue; - if($r[$field] != $r['old_'.$field]){ - if($this->uploadType == $this->SKELETAL && $r['old_'.$field]) continue; - $this->insertOccurEdit($r['occid'], $field, $r[$field], $r['old_'.$field]); + if(!in_array($field, $excludedFieldArr)) $sqlFrag .= ',u.'.$field.',o.'.$field.' as old_'.$field; + } + $sql = 'SELECT o.occid'.$sqlFrag.' FROM omoccurrences o INNER JOIN uploadspectemp u ON o.occid = u.occid WHERE o.collid IN('.$this->collId.') AND u.collid IN('.$this->collId.')'; + $rs = $this->conn->query($sql); + while($r = $rs->fetch_assoc()){ + foreach($this->targetFieldArr as $field){ + if(in_array($field, $excludedFieldArr)) continue; + if($r[$field] != $r['old_'.$field]){ + if($this->uploadType == $this->SKELETAL && $r['old_'.$field]) continue; + $this->insertOccurEdit($r['occid'], $field, $r[$field], $r['old_'.$field]); + } } } + $rs->free(); } - $rs->free(); } } diff --git a/classes/TaxonomyEditorManager.php b/classes/TaxonomyEditorManager.php index 2878147333..e392a438a3 100644 --- a/classes/TaxonomyEditorManager.php +++ b/classes/TaxonomyEditorManager.php @@ -1,6 +1,8 @@ free(); + //Taxon maps + $sql ='SELECT COUNT(mid) AS cnt FROM taxamaps WHERE tid = '.$this->tid; + $rs = $this->conn->query($sql); + while($r = $rs->fetch_object()){ + $retArr['map'] = $r->cnt; + } + $rs->free(); + //Vernaculars $sql ='SELECT vernacularname FROM taxavernaculars WHERE tid = '.$this->tid; $rs = $this->conn->query($sql); @@ -750,6 +760,10 @@ public function transferResources($targetTid){ $sql ='UPDATE IGNORE images SET tid = '.$targetTid.' WHERE occid IS NULL AND tid = '.$this->tid; if(!$this->conn->query($sql)) $this->warningArr[] = (isset($this->langArr['ERROR_TRANSFER_IMGS'])?$this->langArr['ERROR_TRANSFER_IMGS']:'ERROR transferring image links').' ('.$this->conn->error.')'; + //Taxon maps + $sql ='UPDATE IGNORE taxamaps SET mid = '.$targetTid.' WHERE tid = '.$this->tid; + if(!$this->conn->query($sql)) $this->warningArr[] = $this->langArr['ERROR_TRANSFER_MAPS'] . ' (' . $this->conn->error . ')'; + //Vernaculars $sql ='UPDATE IGNORE taxavernaculars SET tid = '.$targetTid.' WHERE tid = '.$this->tid; if(!$this->conn->query($sql)) $this->warningArr[] = (isset($this->langArr['ERROR_TRANSFER_VERNACULARS'])?$this->langArr['ERROR_TRANSFER_VERNACULARS']:'ERROR transferring vernaculars').' ('.$this->conn->error.')'; @@ -800,6 +814,10 @@ public function deleteTaxon(){ if(!$this->conn->query($sql)) $this->warningArr[] = 'ERROR deleting remaining links in deleteTaxon method ('.$this->conn->error.')'; */ + //Taxon maps + $sql ='DELETE FROM taxamaps WHERE tid = '.$this->tid; + if(!$this->conn->query($sql)) $this->warningArr[] = $this->langArr['ERROR_DEL_MAPS'] . ' (' . $this->conn->error . ')'; + //Vernaculars $sql ='DELETE FROM taxavernaculars WHERE tid = '.$this->tid; if(!$this->conn->query($sql)) $this->warningArr[] = (isset($this->langArr['ERROR_DEL_VERNACULARS'])?$this->langArr['ERROR_DEL_VERNACULARS']:'ERROR deleting vernaculars in deleteTaxon method').' ('.$this->conn->error.')'; diff --git a/collections/admin/specuploadmap.php b/collections/admin/specuploadmap.php index 7be5f4d8ee..b4652e8946 100644 --- a/collections/admin/specuploadmap.php +++ b/collections/admin/specuploadmap.php @@ -627,13 +627,15 @@ function pkChanged(selObj){ +
    + + +
    + -
    - /> - -
    diff --git a/collections/cleaning/duplicatesearch.php b/collections/cleaning/duplicatesearch.php index 0b0b5f0010..a0fbc7801d 100644 --- a/collections/cleaning/duplicatesearch.php +++ b/collections/cleaning/duplicatesearch.php @@ -96,6 +96,9 @@ function batchSwitchTargetSpecimens(cbElem){ + @@ -177,7 +180,7 @@ function batchSwitchTargetSpecimens(cbElem){
    - +