diff --git a/classes/ChecklistVoucherAdmin.php b/classes/ChecklistVoucherAdmin.php index 583fc20454..9a3e188b4f 100644 --- a/classes/ChecklistVoucherAdmin.php +++ b/classes/ChecklistVoucherAdmin.php @@ -498,16 +498,18 @@ public function addExternalVouchers($tid, $dataAsJson){ //Data mod functions protected function insertChecklistTaxaLink($tid, $clid = null, $morpho = ''){ - $status = false; + $clTaxaID = false; if(!$clid) $clid = $this->clid; if(is_numeric($tid) && is_numeric($clid)){ $inventoryManager = new ImInventories(); $inputArr = array('tid' => $tid, 'clid' => $clid); if($morpho) $inputArr['morphoSpecies'] = $morpho; - $status = $inventoryManager->insertChecklistTaxaLink($inputArr); - if(!$status) $this->errorMessage = $inventoryManager->getErrorMessage(); + if($inventoryManager->insertChecklistTaxaLink($inputArr)){ + $clTaxaID = $inventoryManager->getPrimaryKey(); + } + else $this->errorMessage = $inventoryManager->getErrorMessage(); } - return $status; + return $clTaxaID; } protected function insertVoucher($clTaxaID, $occid, $editorNotes = null, $notes = null){ diff --git a/classes/GlossaryManager.php b/classes/GlossaryManager.php index d2f1e496f6..8963e6a46f 100644 --- a/classes/GlossaryManager.php +++ b/classes/GlossaryManager.php @@ -1056,9 +1056,9 @@ public function getExportArr($language, $tid, $keyword, $deepSearch=0, $images=0 if($r->source && !in_array($r->source, $referencesArr)) $referencesArr[] = $r->source; if($r->translator && !in_array($r->translator, $contributorsArr)) $contributorsArr[] = $r->translator; if($r->author && !in_array($r->author, $contributorsArr)) $contributorsArr[] = $r->author; - $retArr[$r->glossid]['term'] = strip_tags($r->term); - $retArr[$r->glossid]['searchTerm'] = strip_tags($r->searchterm); - if(!$definitions || $definitions != 'nodef') $retArr[$r->glossid]['definition'] = strip_tags($r->definition); + $retArr[$r->glossid]['term'] = strip_tags($r->term ?? ''); + $retArr[$r->glossid]['searchTerm'] = strip_tags($r->searchterm ?? ''); + if(!$definitions || $definitions != 'nodef') $retArr[$r->glossid]['definition'] = strip_tags($r->definition ?? ''); if($r->glossgrpid && $r->glossgrpid != $r->glossid) $groupMap[$r->glossgrpid][] = $r->glossid; } $rs->free(); diff --git a/classes/OccurrenceEditorManager.php b/classes/OccurrenceEditorManager.php index b8dde554d6..ee8ffff83e 100644 --- a/classes/OccurrenceEditorManager.php +++ b/classes/OccurrenceEditorManager.php @@ -1621,9 +1621,10 @@ public function cloneOccurrence($postArr){ if($sourceOccid != $this->occid && !in_array($this->occid,$retArr)){ $retArr[$this->occid] = $this->occid; if(isset($postArr['assocrelation']) && $postArr['assocrelation']){ - $sql = 'INSERT INTO omoccurassociations(occid, associationType, occidAssociate, relationship,createdUid) VALUES(?, "internalOccurrence", ?, ?, ?) '; + $sql = 'INSERT INTO omoccurassociations(occid, associationType, occidAssociate, relationship, createdUid, RecordID) VALUES(?, "internalOccurrence", ?, ?, ?, ? ) '; if($stmt = $this->conn->prepare($sql)){ - $stmt->bind_param('iisi', $this->occid, $sourceOccid, $postArr['assocrelation'], $GLOBALS['SYMB_UID']); + $guid = UuidFactory::getUuidV4(); + $stmt->bind_param('iisis', $this->occid, $sourceOccid, $postArr['assocrelation'], $GLOBALS['SYMB_UID'], $guid); $stmt->execute(); if($stmt->error){ $this->errorArr[] = $LANG['ERROR_ADDING_REL'].': '.$this->conn->error; diff --git a/classes/OccurrenceExsiccatae.php b/classes/OccurrenceExsiccatae.php index 397dfb3f5f..4fecfdf1bc 100644 --- a/classes/OccurrenceExsiccatae.php +++ b/classes/OccurrenceExsiccatae.php @@ -775,6 +775,7 @@ public function getExsTableRow($occid,$oArr,$omenid,$targetCollid){ } private function cleanOutStr($str){ + if(!isset($str)) return null; $newStr = str_replace('"',""",$str); $newStr = str_replace("'","'",$newStr); //$newStr = $this->conn->real_escape_string($newStr); @@ -788,4 +789,4 @@ private function cleanInStr($str){ return $newStr; } } -?> \ No newline at end of file +?> diff --git a/classes/OccurrenceIndividual.php b/classes/OccurrenceIndividual.php index 81db408692..4042ba18d6 100644 --- a/classes/OccurrenceIndividual.php +++ b/classes/OccurrenceIndividual.php @@ -2,6 +2,7 @@ include_once('Manager.php'); include_once('OccurrenceAccessStats.php'); include_once('ChecklistVoucherAdmin.php'); +include_once($SERVER_ROOT . '/utilities/SymbUtil.php'); class OccurrenceIndividual extends Manager{ @@ -75,31 +76,31 @@ public function setGuid($guid){ if(!$this->occid){ //Check occurrence recordID $sql = 'SELECT occid FROM omoccurrences WHERE (occurrenceid = ?) OR (recordID = ?)'; - if($stmt = $this->conn->prepare($sql)){ - $stmt->bind_param('ss', $guid, $guid); - $stmt->execute(); - $stmt->bind_result($this->occid); - $stmt->close(); + if($result = SymbUtil::execute_query($this->conn, $sql, [$guid, $guid])){ + if($row = $result->fetch_assoc()) { + $this->occid = $row['occid']; + } + $result->free(); } } if(!$this->occid){ //Check image recordID $sql = 'SELECT occid FROM images WHERE recordID = ?'; - if($stmt = $this->conn->prepare($sql)){ - $stmt->bind_param('s', $guid); - $stmt->execute(); - $stmt->bind_result($this->occid); - $stmt->close(); + if($result = SymbUtil::execute_query($this->conn, $sql, [$guid])){ + if($row = $result->fetch_assoc()) { + $this->occid = $row['occid']; + } + $result->free(); } } if(!$this->occid){ //Check identification recordID $sql = 'SELECT occid FROM omoccurdeterminations WHERE recordID = ?'; - if($stmt = $this->conn->prepare($sql)){ - $stmt->bind_param('s', $guid); - $stmt->execute(); - $stmt->bind_result($this->occid); - $stmt->close(); + if($result = SymbUtil::execute_query($this->conn, $sql, [$guid])){ + if($row = $result->fetch_assoc()) { + $this->occid = $row['occid']; + } + $result->free(); } } return $this->occid; @@ -422,7 +423,7 @@ private function setOccurrenceRelationships(){ $objectID = $r->catalogNumber; if($objectID) { if(strpos($objectID, $r->instCode) === false){ - //Append institution and collection code to catalogNumber, but only if it is not already included + //Append institution and collection code to catalogNumber, but only if it is not already included $collCode = $r->instCode; if($r->collCode) $collCode .= '-' . $r->collCode; $objectID = $collCode . ':' . $r->catalogNumber; diff --git a/classes/OccurrenceLabel.php b/classes/OccurrenceLabel.php index 0b27517a59..08b1eb18d7 100644 --- a/classes/OccurrenceLabel.php +++ b/classes/OccurrenceLabel.php @@ -172,7 +172,6 @@ public function getLabelArray($occidArr, $speciesAuthors = false){ 'INNER JOIN taxa t2 ON ts.parenttid = t2.tid '. $sqlWhere.' AND t.rankid > 220 AND ts.taxauthid = 1 '; if(!$speciesAuthors) $sql1 .= 'AND t.unitname2 = t.unitname3 '; - //echo $sql1; exit; if($rs1 = $this->conn->query($sql1)){ while($row1 = $rs1->fetch_object()){ $authorArr[$row1->occid] = $row1->author ?? ''; @@ -182,12 +181,15 @@ public function getLabelArray($occidArr, $speciesAuthors = false){ //Get occurrence records $this->setLabelFieldArr(); $sql2 = 'SELECT '.implode(',',$this->labelFieldArr).' FROM omoccurrences o LEFT JOIN taxa t ON o.tidinterpreted = t.tid '.$sqlWhere; - //echo 'SQL: '.$sql2; if($rs2 = $this->conn->query($sql2)){ while($row2 = $rs2->fetch_assoc()){ - $row2 = array_change_key_case($row2); - if(array_key_exists($row2['occid'],$authorArr)) $row2['parentauthor'] = $authorArr[$row2['occid']]; - $retArr[$row2['occid']] = $row2; + $occid = $row2['occid']; + foreach($row2 as $fieldName => $fieldValue){ + $retArr[$occid][strtolower($fieldName)] = $fieldValue ?? ''; + } + if(array_key_exists($occid, $authorArr)){ + $retArr[$occid]['parentauthor'] = $authorArr[$occid]; + } } $rs2->free(); } diff --git a/classes/TaxonomyUpload.php b/classes/TaxonomyUpload.php index 93cc7ceeee..6fe03b336b 100644 --- a/classes/TaxonomyUpload.php +++ b/classes/TaxonomyUpload.php @@ -217,7 +217,7 @@ public function loadFile($fieldMap){ if($k == 'author') $sql2 .= ',"'.($inValue?$inValue:'').'"'; else $sql2 .= ','.($inValue?'"'.$inValue.'"':'NULL'); } - $sql = 'INSERT INTO uploadtaxa('.substr($sql1,1).') VALUES('.substr($sql2,1).')'; + $sql = 'INSERT IGNORE INTO uploadtaxa('.substr($sql1,1).') VALUES('.substr($sql2,1).')'; //echo '