Skip to content

Commit

Permalink
Merge pull request #16 from BioKIC/master
Browse files Browse the repository at this point in the history
Merge BioKIC/Symbiota developments
  • Loading branch information
egbot authored Jan 9, 2023
2 parents b10ef7d + a5ed5a5 commit c57cf0d
Show file tree
Hide file tree
Showing 40 changed files with 677 additions and 313 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
/index.php
content/lang/header.en.php
content/lang/header.es.php
content/lang/header.fr.php
content/lang/index.en.php
content/lang/index.es.php
content/lang/index.fr.php
includes/header.php
includes/footer.php
includes/head.php
Expand All @@ -20,5 +22,4 @@ includes/citationdataset.php
includes/citationportal.php
.project
.settings/org.eclipse.core.resources.prefs
content/lang/header.fr.php
.settings/org.eclipse.php.ui.prefs
59 changes: 47 additions & 12 deletions classes/DwcArchiverOccurrence.php
Original file line number Diff line number Diff line change
Expand Up @@ -414,13 +414,14 @@ public function getExsiccateArr($occid){
}

public function getAssociationStr($occid){
$retStr = '';
if(is_numeric($occid)){
$sql = 'SELECT assocID, occid, occidAssociate, relationship, subType, resourceUrl, identifier FROM omoccurassociations WHERE (occid = '.$occid.' OR occidAssociate = '.$occid.') AND verbatimSciname IS NULL ';
$relOccidArr = array();
$assocArr = array();
//Get associations defined within omoccurassociations
$sql = 'SELECT assocID, occid, occidAssociate, relationship, subType, resourceUrl, identifier FROM omoccurassociations
WHERE (occid = '.$occid.' OR occidAssociate = '.$occid.') AND verbatimSciname IS NULL ';
$rs = $this->conn->query($sql);
if($rs){
$relOccidArr = array();
$assocArr = array();
while($r = $rs->fetch_object()){
$relOccid = $r->occidAssociate;
$relationship = $r->relationship;
Expand All @@ -442,23 +443,57 @@ public function getAssociationStr($occid){
}
}
$rs->free();
}
//Append duplicate specimen duplicate associations
$sql = 'SELECT s.occid, l.occid as occidAssociate
FROM omoccurduplicatelink s INNER JOIN omoccurduplicates d ON s.duplicateid = d.duplicateid
INNER JOIN omoccurduplicatelink l ON d.duplicateid = l.duplicateid
WHERE s.occid IN('.$occid.') AND s.occid != l.occid ';
$rs = $this->conn->query($sql);
if($rs){
while($r = $rs->fetch_object()){
$assocKey = 'sd-'.$r->occidAssociate;
$assocArr[$assocKey]['occidassoc'] = $r->occidAssociate;
$assocArr[$assocKey]['relationship'] = 'herbariumSpecimenDuplicate';
$relOccidArr[$r->occidAssociate][] = $assocKey;
}
$rs->free();
}
//Append resource URLs to each output record
if($relOccidArr){
$this->setServerDomain();
//Replace GUID identifiers with occurrenceID values
$sql = 'SELECT occid, occurrenceid FROM omoccurrences WHERE occid IN('.implode(',',array_keys($relOccidArr)).') AND occurrenceid IS NOT NULL';
$rs = $this->conn->query($sql);
while($r = $rs->fetch_object()){
foreach($relOccidArr[$r->occid] as $k => $targetAssocID){
if($r->occurrenceid){
$url = $r->occurrenceid;
if(substr($url, 0, 4) != 'http') $url = $this->serverDomain.$GLOBALS['CLIENT_ROOT'].'/collections/individual/index.php?guid='.$r->occurrenceid;
$assocArr[$targetAssocID]['resourceurl'] = $url;
unset($relOccidArr[$r->occid][$k]);
}
}
}
$rs->free();
if($relOccidArr){
$this->setServerDomain();
$sql = 'SELECT o.occid, IFNULL(o.occurrenceid,g.guid) as guid FROM omoccurrences o INNER JOIN guidoccurrences g ON o.occid = g.occid WHERE o.occid IN('.implode(',',array_keys($relOccidArr)).')';
//Get recordID/occurrenceID guids for specimens live managed records
$sql = 'SELECT occid, guid FROM guidoccurrences WHERE occid IN('.implode(',',array_keys($relOccidArr)).')';
$rs = $this->conn->query($sql);
while($r = $rs->fetch_object()){
foreach($relOccidArr[$r->occid] as $targetAssocID){
$assocArr[$targetAssocID]['identifier'] = $r->guid;
$assocArr[$targetAssocID]['resourceurl'] = $this->serverDomain.$GLOBALS['CLIENT_ROOT'].'/collections/individual/index.php?guid='.$r->guid;
}
}
$rs->free();
}
foreach($assocArr as $assocateArr){
$retStr .= '|'.$assocateArr['relationship'];
if($assocateArr['subtype']) $retStr .= ' ('.$assocateArr['subtype'].')';
$retStr .= ': '.$assocateArr['resourceurl'];
}
}
//Create output strings
$retStr = '';
foreach($assocArr as $assocateArr){
$retStr .= ' | '.$assocateArr['relationship'];
if(!empty($assocateArr['subtype'])) $retStr .= ' ('.$assocateArr['subtype'].')';
$retStr .= ': '.$assocateArr['resourceurl'];
}
}
return trim($retStr,' |');
Expand Down
60 changes: 36 additions & 24 deletions classes/OccurrenceEditorDeterminations.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function getDetMap($identBy, $dateIdent, $sciName){
return $retArr;
}

public function addDetermination($detArr,$isEditor){
public function addDetermination($detArr, $isEditor){
global $LANG;
$status = $LANG['DET_SUCCESS'];
if(!$this->occid) return $LANG['ERROR_OCCID_NULL'];
Expand Down Expand Up @@ -170,7 +170,7 @@ public function addDetermination($detArr,$isEditor){
}
}
else{
$status = LANG['ERROR_FAILED_ADD'].': '.$this->conn->error;
$status = $LANG['ERROR_FAILED_ADD'].': '.$this->conn->error;
}
return $status;
}
Expand Down Expand Up @@ -350,51 +350,63 @@ public function makeDeterminationCurrent($detId){
}

public function addNomAdjustment($detArr,$isEditor){
$sql = 'SELECT identificationQualifier '.
'FROM omoccurrences '.
'WHERE occid = '.$this->occid;
//echo "<div>".$sql."</div>";
$sql = 'SELECT identificationQualifier FROM omoccurrences WHERE occid = '.$this->occid;
$rs = $this->conn->query($sql);
if($r = $rs->fetch_object()){
$detArr['identificationqualifier'] = $r->identificationQualifier;
}
$rs->free();
$detArr['identifiedby'] = 'Nomenclatural Adjustment';
$detArr['dateidentified'] = date('F').' '.date('j').', '.date('Y');
$this->addDetermination($detArr,$isEditor);
$this->addDetermination($detArr, $isEditor);
}

public function getNewDetItem($catNum,$sciName,$allCatNum=0){
public function getNewDetItem($catNum, $sciName, $allCatNum = 0){
$retArr = array();
if($catNum || $sciName){
$sql = 'SELECT occid, IFNULL(catalogNumber, othercatalognumbers) AS catalogNumber, sciname, CONCAT_WS(" ",recordedby,IFNULL(recordnumber,eventdate)) AS collector, '.
'CONCAT_WS(", ",country,stateprovince,county,locality) AS locality '.
'FROM omoccurrences '.
'WHERE collid = '.$this->collId.' ';
$sql = 'SELECT o.occid, o.catalogNumber, o.otherCatalogNumbers, o.sciname, CONCAT_WS(" ", o.recordedby, IFNULL(o.recordnumber, o.eventdate)) AS collector, '.
'CONCAT_WS(", ", o.country, o.stateprovince, o.county, o.locality) AS locality ';
$catNumArr = explode(',',$catNum);
if($catNum){
$catNumArr = explode(',',$catNum);
foreach($catNumArr as $k => $u){
$u = trim($u);
if($u) $catNumArr[$k] = $this->cleanInStr($u);
else unset($catNumArr[$k]);
}
$sql .= 'AND (catalogNumber IN("'.implode('","',$catNumArr).'") ';
if($allCatNum) $sql .= 'OR otherCatalogNumbers IN("'.implode('","',$catNumArr).'")';
if($allCatNum){
$sql .= ', i.identifierValue FROM omoccurrences o LEFT JOIN omoccuridentifiers i ON o.occid = i.occid ';
}
else{
$sql .= 'FROM omoccurrences o ';
}
$catNumStr = implode('","',$catNumArr);
$sql .= 'WHERE o.collid = '.$this->collId.' AND (o.catalogNumber IN("'.$catNumStr.'") ';
if($allCatNum){
$sql .= 'OR o.otherCatalogNumbers IN("'.$catNumStr.'") OR i.identifierValue IN("'.$catNumStr.'") ';
}
$sql .= ') ';
}
elseif($sciName){
$sql .= 'AND sciname = "'.$this->cleanInStr($sciName).'" ';
$sql .= 'FROM omoccurrences o WHERE o.collid = '.$this->collId.' AND o.sciname = "'.$this->cleanInStr($sciName).'" ';
}
$sql .= 'LIMIT 400 ';
//echo $sql;
$rs = $this->conn->query($sql);
while($r = $rs->fetch_object()){
$loc = $r->locality;
if(strlen($loc) > 500) $loc = substr($loc,400);
$retArr[$r->occid]['cn'] = $r->catalogNumber;
$retArr[$r->occid]['sn'] = $r->sciname;
$retArr[$r->occid]['coll'] = $r->collector;
$retArr[$r->occid]['loc'] = $loc;
if(!array_key_exists($r->occid, $retArr)){
$retArr[$r->occid]['sn'] = $r->sciname;
$retArr[$r->occid]['coll'] = $r->collector;
$loc = $r->locality;
if(strlen($loc) > 500) $loc = substr($loc,400);
$retArr[$r->occid]['loc'] = $loc;
$cn = $r->catalogNumber;
if($r->otherCatalogNumbers){
if(!$cn || in_array($r->otherCatalogNumbers, $catNumArr)) $cn = $r->otherCatalogNumbers;
}
$retArr[$r->occid]['cn'] = $cn;
}
if(!empty($r->identifierValue)){
if(!$retArr[$r->occid]['cn'] || in_array($r->identifierValue, $catNumArr)) $retArr[$r->occid]['cn'] = $r->identifierValue;
}
}
$rs->free();
}
Expand All @@ -405,4 +417,4 @@ public function getCollName(){
return $this->collMap['collectionname'].' ('.$this->collMap['institutioncode'].($this->collMap['collectioncode']?':'.$this->collMap['collectioncode']:'').')';
}
}
?>
?>
2 changes: 1 addition & 1 deletion classes/OccurrenceEditorManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -2450,7 +2450,7 @@ public function traitCodingActivated(){
//Setters and getters
public function setOccId($id){
if(is_numeric($id)){
$this->occid = $this->cleanInStr($id);
$this->occid = $id;
}
}

Expand Down
2 changes: 1 addition & 1 deletion collections/admin/specuploadmanagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $CHARSET; ?>">
<title><?php echo $DEFAULT_TITLE.(isset($LANG['UP_PROF_MAN'])?$LANG['UP_PROF_MAN']:'Specimen Upload Profile Manager'); ?></title>
<title><?php echo $DEFAULT_TITLE.' '.(isset($LANG['UP_PROF_MAN'])?$LANG['UP_PROF_MAN']:'Specimen Upload Profile Manager'); ?></title>
<?php
include_once($SERVER_ROOT.'/includes/head.php');
?>
Expand Down
Loading

0 comments on commit c57cf0d

Please sign in to comment.