Skip to content

Commit

Permalink
Merge pull request #1179 from BioKIC/master
Browse files Browse the repository at this point in the history
Hotfix 2024 08 07 (#1606)
  • Loading branch information
egbot authored Aug 12, 2024
2 parents 8a03036 + 49ec39d commit b9e54ce
Show file tree
Hide file tree
Showing 15 changed files with 141 additions and 78 deletions.
2 changes: 1 addition & 1 deletion classes/GlossaryManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand Down
11 changes: 7 additions & 4 deletions classes/OccurrenceCleaner.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function getDuplicateCatalogNumber($type, $start, $limit = 500){
}
$rs->free();

$retArr = array();
$stagingArr = array();
if($dupArr){
$sqlFrag = '';
if($type=='cat'){
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
Expand All @@ -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){
Expand Down
32 changes: 16 additions & 16 deletions classes/SpecUploadBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -896,9 +896,7 @@ protected function transferOccurrences(){
$this->outputMsg('<li>Transferring edits to versioning tables...</li>');
$this->versionExternalEdits();
}
elseif($this->collMetadataArr['managementtype'] == 'Live Data' && $this->uploadType != $this->RESTOREBACKUP){
$this->versionInternalEdits();
}
$this->versionInternalEdits();
$transactionInterval = 1000;
$this->outputMsg('<li>Updating existing records in batches of '.$transactionInterval.'... </li>');
//Grab specimen intervals for updating records in batches
Expand Down Expand Up @@ -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();
}
}

Expand Down
20 changes: 19 additions & 1 deletion classes/TaxonomyEditorManager.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php
include_once($SERVER_ROOT.'/classes/Manager.php');
include_once($SERVER_ROOT.'/content/lang/classes/TaxonomyEditorManager.'.$LANG_TAG.'.php');
if($LANG_TAG == 'en' || !file_exists($SERVER_ROOT . '/content/lang/classes/TaxonomyEditorManager.' . $LANG_TAG . '.php'))
include_once($SERVER_ROOT . '/content/lang/classes/TaxonomyEditorManager.en.php');
else include_once($SERVER_ROOT . '/content/lang/classes/TaxonomyEditorManager.' . $LANG_TAG . '.php');

class TaxonomyEditorManager extends Manager{

Expand Down Expand Up @@ -680,6 +682,14 @@ public function verifyDeleteTaxon(){
}
$rs->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);
Expand Down Expand Up @@ -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.')';
Expand Down Expand Up @@ -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.')';
Expand Down
14 changes: 8 additions & 6 deletions collections/admin/specuploadmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -627,13 +627,15 @@ function pkChanged(selObj){
</ul>
<?php
}
$versionCheckedStr = '';
if($isLiveData) $versionCheckedStr = 'checked';
if($isLiveData){
?>
<div style="margin:10px 0px;">
<input name="versiondata" type="checkbox" value="1">
<?php echo (isset($LANG['VERSION_DATA_CHANGES'])?$LANG['VERSION_DATA_CHANGES']:'Version data changes'); ?>
</div>
<?php
}
?>
<div style="margin:10px 0px;">
<input name="versiondata" type="checkbox" value="1" <?php echo $versionCheckedStr; ?> />
<?php echo (isset($LANG['VERSION_DATA_CHANGES'])?$LANG['VERSION_DATA_CHANGES']:'Version data changes'); ?>
</div>
<div style="margin:10px 0px;">
<input name="verifyimages" type="checkbox" value="1" />
<?php echo (isset($LANG['VER_LINKS_MEDIA'])?$LANG['VER_LINKS_MEDIA']:'Verify image links from associatedMedia field'); ?>
Expand Down
14 changes: 10 additions & 4 deletions collections/cleaning/duplicatesearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ function batchSwitchTargetSpecimens(cbElem){
</script>
</head>
<body style="margin-left:10px; width: 100%">
<?php
include($SERVER_ROOT . '/includes/header.php');
?>
<div class='navpath' style="margin:10px">
<a href="../../index.php"><?php echo $LANG['HOME']; ?></a> &gt;&gt;
<a href="../misc/collprofiles.php?collid=<?php echo $collid; ?>&emode=1"><?php echo $LANG['COL_MAN']; ?></a> &gt;&gt;
Expand All @@ -122,7 +125,7 @@ function batchSwitchTargetSpecimens(cbElem){
$href = 'duplicatesearch.php?collid='.$collid.'&action='.$action.'&start='.($start+$limit);
echo '<div style="float:right;"><a href="'.$href.'"><b>'.$LANG['NEXT'].' '.$limit.' '.$LANG['RECORDS'].' &gt;&gt;</b></a></div>';
}
echo '<div style="float:left;margin-bottom:4px;margin-left:15px;"><input name="action" type="submit" value="Merge Duplicate Records" /></div>';
echo '<div style="float:left;margin-bottom:4px;margin-left:15px;"><button name="action" type="submit" value="mergeDuplicates">' . $LANG['MERGE_DUPES'] . '</button></div>';
echo '<div style="float:left;margin-left:15px;"><b>'.($start+1).' '.$LANG['TO'].' '.($start+$recCnt).' '.$LANG['DUP_CLUSTERS'].' </b></div>';
?>
</div>
Expand Down Expand Up @@ -177,7 +180,7 @@ function batchSwitchTargetSpecimens(cbElem){
</table>
</div>
<div style="margin:15px;">
<button name="action" type="submit" value="Merge Duplicate Records"><?php echo $LANG['MERGE_DUPES']; ?></button>
<button name="action" type="submit" value="mergeDuplicates"><?php echo $LANG['MERGE_DUPES']; ?></button>
</div>
</form>
<?php
Expand All @@ -190,7 +193,7 @@ function batchSwitchTargetSpecimens(cbElem){
<?php
}
}
elseif($action == 'Merge Duplicate Records'){
elseif($action == 'mergeDuplicates'){
?>
<ul>
<li><?php echo $LANG['DUPE_MERGING_STARTED']; ?></li>
Expand All @@ -199,7 +202,7 @@ function batchSwitchTargetSpecimens(cbElem){
foreach($_POST['dupid'] as $v){
$vArr = explode('|',$v);
if(count($vArr) > 1){
$target = $_POST['dup'.str_replace(' ', '_', $vArr[0]).'target'];
$target = $_POST['dup' . $vArr[0] . 'target'];
if($target != $vArr[1]) $dupArr[$target][] = $vArr[1];
}
}
Expand Down Expand Up @@ -229,5 +232,8 @@ function batchSwitchTargetSpecimens(cbElem){
}
?>
</div>
<?php
include($SERVER_ROOT . '/includes/footer.php');
?>
</body>
</html>
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.33';
$CODE_VERSION = '3.0.34';

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
2 changes: 2 additions & 0 deletions content/lang/classes/TaxonomyEditorManager.en.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
$LANG['WARNING_UPDATE_IMAGES'] = 'WARNING: Taxon loaded into taxa, but occurrence images must be updated with matching name';
$LANG['ERROR_INSERT'] = 'ERROR inserting new taxon';
$LANG['ERROR_TRANSFER_IMGS'] = 'ERROR transferring image links';
$LANG['ERROR_TRANSFER_MAPS'] = 'ERROR transferring taxon map links';
$LANG['ERROR_TRANSFER_VERNACULARS'] = 'ERROR transferring vernaculars';
$LANG['ERROR_TRANSFER_TAXADESC'] = 'ERROR transferring taxadescblocks';
$LANG['ERROR_TRANSFER_CHECKLIST'] = 'ERROR transferring checklist links';
Expand All @@ -33,6 +34,7 @@
$LANG['ERROR_TRANSFER_SYN'] = 'ERROR transferring synonyms taxa';
$LANG['ERROR_TRANSFER_TAXENUMTREE'] = 'ERROR resetting taxaEnumTree index';
$LANG['ERROR_SETTING_NULL'] = 'ERROR setting tid to NULL for occurrence images in deleteTaxon method';
$LANG['ERROR_DEL_MAPS'] = 'ERROR deleting taxon maps wtihin deleteTaxon method';
$LANG['ERROR_DEL_VERNACULARS'] = 'ERROR deleting vernaculars in deleteTaxon method';
$LANG['ERROR_DEL_TAXDESC'] = 'ERROR deleting taxa description blocks in deleteTaxon method';
$LANG['ERROR_TIDINT_NULL'] = 'ERROR setting tidinterpreted to NULL in deleteTaxon method';
Expand Down
3 changes: 2 additions & 1 deletion content/lang/glossary/index.en.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
$LANG['KEYWORD'] = 'with keyword ';
$LANG['DISP_SRC'] = 'Display Sources';
$LANG['ADD_SRC'] = 'Add Sources';
$LANG['TAX_CONTR'] = 'Contributors for Taxonomic Group';
$LANG['TAX_CONTR'] = 'Contributors for Taxonomic Group(s)';
$LANG['SOURCE_SCINAME'] = 'Taxon';
$LANG['TERM_CONTR'] = 'Terms and Definitions contributed by';
$LANG['IMG_CONTR'] = 'Images contributed by';
$LANG['TRANS_BY'] = 'Translations by';
Expand Down
3 changes: 2 additions & 1 deletion content/lang/glossary/index.es.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
$LANG['KEYWORD'] = 'con palabra clave';
$LANG['DISP_SRC'] = 'Desplegar Fuentes';
$LANG['ADD_SRC'] = 'Añadir Fuentes';
$LANG['TAX_CONTR'] = 'Contribuyentes para Grupo Taxonómico';
$LANG['TAX_CONTR'] = 'Contribuyentes para Grupo(s) Taxonómico(s)';
$LANG['SOURCE_SCINAME'] = 'Taxon';
$LANG['TERM_CONTR'] = 'Términos y Definiciones contribuídas por';
$LANG['IMG_CONTR'] = 'Imágenes contribuídas por';
$LANG['TRANS_BY'] = 'Traducciones por';
Expand Down
2 changes: 2 additions & 0 deletions content/lang/taxa/taxonomy/taxonomydelete.en.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
$LANG['WARNING'] = 'Warning';
$LANG['IMGS_LINKED'] = 'images linked to this taxon';
$LANG['NO_IMGS'] = 'no images linked to this taxon';
$LANG['MAPS_LINKED'] = 'taxon maps linked to this taxon';
$LANG['NO_MAPS'] = 'no taxon maps linked to this taxon';
$LANG['VERNACULARS'] = 'Vernaculars';
$LANG['LINKED_VERNACULAR'] = 'Warning, linked vernacular names';
$LANG['NO_VERNACULAR'] = 'no vernacular names linked to this taxon';
Expand Down
2 changes: 2 additions & 0 deletions content/lang/taxa/taxonomy/taxonomydelete.es.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
$LANG['WARNING'] = 'Advertencia';
$LANG['IMGS_LINKED'] = 'imágenes vinculadas a este taxón';
$LANG['NO_IMGS'] = 'no hay imágenes vinculadas a este taxón';
$LANG['MAPS_LINKED'] = 'mapas vinculadas a este taxón';
$LANG['NO_MAPS'] = 'no hay mapas vinculadas a este taxón';
$LANG['VERNACULARS'] = 'Nombres comunes';
$LANG['LINKED_VERNACULAR'] = 'Advertencia, existen nombres comunes enlazados';
$LANG['NO_VERNACULAR'] = 'no existen nombres comunes enlazados con este taxón';
Expand Down
Loading

0 comments on commit b9e54ce

Please sign in to comment.