';
+ if(isset($this->traitArr[$traitID]['states'])){
+ if($this->traitArr[$traitID]['type']=='TF'){
+ $innerStr .= '
';
+ }
+ else $innerStr .= '
';
+ $attrStateArr = $this->traitArr[$traitID]['states'];
+ foreach($attrStateArr as $sid => $sArr){
+ $isCoded = false;
+ if(array_key_exists('coded',$sArr)){
+ if(is_numeric($sArr['coded'])) $isCoded = $sArr['coded'];
+ else $isCoded = true;
+ $this->stateCodedArr[$sid] = $sid;
+ }
+ $depTraitIdArr = array();
+ if(isset($sArr['dependTraitID']) && $sArr['dependTraitID']) $depTraitIdArr = $sArr['dependTraitID'];
+ if($this->traitArr[$traitID]['type']=='NU'){
+ $innerStr .= '
';
+ }
+ $innerStr .= '
';
+ //Display if trait has been coded or is the first/base trait (e.g. $indend == 0)
+ $divClass = '';
+ if($classStr){
+ $classArr = explode(' ',$classStr);
+ $divClass = array_pop($classArr);
+ }
+ $outStr = '
';
+ if($controlType == 'select'){
+ $outStr .= '';
+ $outStr .= 'Select State ';
+ $outStr .= '------------------------------ ';
+ $outStr .= $innerStr;
+ $outStr .= ' ';
+ }
+ else{
+ $outStr .= $innerStr;
+ }
+ $outStr .= '
';
+ return $outStr;
+ }
+
+}
diff --git a/classes/OccurrenceAttributes.php b/classes/OccurrenceAttributes.php
index 2bf3235a03..59a6f9bc30 100644
--- a/classes/OccurrenceAttributes.php
+++ b/classes/OccurrenceAttributes.php
@@ -4,7 +4,7 @@
class OccurrenceAttributes extends Manager {
private $collidStr = 0;
- private $traitArr = array();
+ protected $traitArr = array();
private $stateCodedArr = array();
private $reviewSqlBase;
private $occid = 0;
@@ -297,7 +297,7 @@ private function setTraitArr($traitID){
return $this->traitArr;
}
- private function setDependentTraits($traitid){
+ protected function setDependentTraits($traitid){
$sql = 'SELECT DISTINCT s.traitid AS parenttraitid, d.parentstateid, d.traitid AS depTraitID '.
'FROM tmstates s INNER JOIN tmtraitdependencies d ON s.stateid = d.parentstateid '.
'WHERE (s.traitid = '.$traitid.')';
@@ -311,7 +311,7 @@ private function setDependentTraits($traitid){
$rs->free();
}
- private function setTraitStates(){
+ protected function setTraitStates(){
$sql = 'SELECT traitid, stateid, statename, description, notes, refurl FROM tmstates ';
if($this->traitArr) $sql .= 'WHERE traitid IN('.implode(',',array_keys($this->traitArr)).') ';
$sql .= 'ORDER BY traitid, sortseq, statecode ';
@@ -711,4 +711,4 @@ public function getSourceControlledArr($currentSetStr=''){
return $sourceControlArr;
}
}
-?>
\ No newline at end of file
+?>
diff --git a/classes/OccurrenceEditorManager.php b/classes/OccurrenceEditorManager.php
index 5b3ea381cb..bbe1daaf29 100644
--- a/classes/OccurrenceEditorManager.php
+++ b/classes/OccurrenceEditorManager.php
@@ -734,11 +734,11 @@ private function addTableJoins(&$sql){
}
//Edit functions
- public function editOccurrence($occArr, $editorStatus){
+ public function editOccurrence($postArr, $editorStatus){
global $USER_RIGHTS;
$status = '';
- $occid = $occArr['occid'];
+ $occid = $postArr['occid'];
if(is_numeric($occid) && $editorStatus){
$quickHostEntered = false;
$autoCommit = false;
@@ -761,7 +761,7 @@ public function editOccurrence($occArr, $editorStatus){
}
}
//Processing edit
- $editedFields = trim($occArr['editedfields']);
+ $editedFields = trim($postArr['editedfields']);
$editArr = array_unique(explode(';',$editedFields));
foreach($editArr as $k => $fName){
if(trim($fName) == 'host' || trim($fName) == 'hostassocid'){
@@ -779,15 +779,15 @@ public function editOccurrence($occArr, $editorStatus){
if($editArr || $quickHostEntered){
if($editArr){
//Deal with scientific name changes if the AJAX code fails
- if(in_array('sciname',$editArr) && $occArr['sciname'] && !$occArr['tidinterpreted']){
+ if(in_array('sciname',$editArr) && $postArr['sciname'] && !$postArr['tidinterpreted']){
$sql2 = 'SELECT t.tid, t.author, ts.family '.
'FROM taxa t INNER JOIN taxstatus ts ON t.tid = ts.tid '.
- 'WHERE ts.taxauthid = 1 AND sciname = "'.$this->cleanInStr($occArr['sciname']).'"';
+ 'WHERE ts.taxauthid = 1 AND sciname = "'.$this->cleanInStr($postArr['sciname']).'"';
$rs2 = $this->conn->query($sql2);
if($r2 = $rs2->fetch_object()){
- $occArr['tidinterpreted'] = $r2->tid;
- if(!$occArr['scientificnameauthorship']) $occArr['scientificnameauthorship'] = $r2->author;
- if(!$occArr['family']) $occArr['family'] = $r2->family;
+ $postArr['tidinterpreted'] = $r2->tid;
+ if(!$postArr['scientificnameauthorship']) $postArr['scientificnameauthorship'] = $r2->author;
+ if(!$postArr['family']) $postArr['family'] = $r2->family;
}
$rs2->free();
}
@@ -818,7 +818,7 @@ public function editOccurrence($occArr, $editorStatus){
//If processing status was "unprocessed" and recordEnteredBy is null, populate with user login
if($oldValues['recordenteredby'] == 'preprocessed' || (!$oldValues['recordenteredby'] && ($oldValues['processingstatus'] == 'unprocessed' || $oldValues['processingstatus'] == 'stage 1'))){
- $occArr['recordenteredby'] = $GLOBALS['USERNAME'];
+ $postArr['recordenteredby'] = $GLOBALS['USERNAME'];
$editArr[] = 'recordenteredby';
}
@@ -826,11 +826,11 @@ public function editOccurrence($occArr, $editorStatus){
$sqlEditsBase = 'INSERT INTO omoccuredits(occid,reviewstatus,appliedstatus,uid,fieldname,fieldvaluenew,fieldvalueold) '.
'VALUES ('.$occid.',1,'.($autoCommit?'1':'0').','.$GLOBALS['SYMB_UID'].',';
foreach($editArr as $fieldName){
- if(!array_key_exists($fieldName,$occArr)){
+ if(!array_key_exists($fieldName,$postArr)){
//Field is a checkbox that is unchecked: cultivationstatus, localitysecurity
- $occArr[$fieldName] = 0;
+ $postArr[$fieldName] = 0;
}
- $newValue = $this->cleanInStr($occArr[$fieldName]);
+ $newValue = $this->cleanInStr($postArr[$fieldName]);
$oldValue = $this->cleanInStr($oldValues[$fieldName]);
//Version edits only if value has changed
if($oldValue != $newValue){
@@ -838,14 +838,14 @@ public function editOccurrence($occArr, $editorStatus){
if($fieldName == 'ometid'){
//Exsiccati title has been changed, thus grab title string
$exsTitleStr = '';
- $sql = 'SELECT title FROM omexsiccatititles WHERE ometid = '.$occArr['ometid'];
+ $sql = 'SELECT title FROM omexsiccatititles WHERE ometid = '.$postArr['ometid'];
$rs = $this->conn->query($sql);
if($r = $rs->fetch_object()){
$exsTitleStr = $r->title;
}
$rs->free();
//Setup old and new strings
- if($newValue) $newValue = $exsTitleStr.' (ometid: '.$occArr['ometid'].')';
+ if($newValue) $newValue = $exsTitleStr.' (ometid: '.$postArr['ometid'].')';
if($oldValue) $oldValue = $oldValues['title'].' (ometid: '.$oldValues['ometid'].')';
}
$sqlEdit = $sqlEditsBase.'"'.$fieldName.'","'.$newValue.'","'.$oldValue.'")';
@@ -860,13 +860,13 @@ public function editOccurrence($occArr, $editorStatus){
$status = 'SUCCESS: edits submitted and activated ';
$sql = '';
//Apply autoprocessing status if set
- if(array_key_exists('autoprocessingstatus',$occArr) && $occArr['autoprocessingstatus']){
- $occArr['processingstatus'] = $occArr['autoprocessingstatus'];
+ if(array_key_exists('autoprocessingstatus',$postArr) && $postArr['autoprocessingstatus']){
+ $postArr['processingstatus'] = $postArr['autoprocessingstatus'];
}
- if(isset($occArr['institutioncode']) && $occArr['institutioncode'] == $this->collMap['institutioncode']) $occArr['institutioncode'] = '';
- if(isset($occArr['collectioncode']) && $occArr['collectioncode'] == $this->collMap['collectioncode']) $occArr['collectioncode'] = '';
- if(isset($occArr['ownerinstitutioncode']) && $occArr['ownerinstitutioncode'] == $this->collMap['institutioncode']) $occArr['ownerinstitutioncode'] = '';
- foreach($occArr as $oField => $ov){
+ if(isset($postArr['institutioncode']) && $postArr['institutioncode'] == $this->collMap['institutioncode']) $postArr['institutioncode'] = '';
+ if(isset($postArr['collectioncode']) && $postArr['collectioncode'] == $this->collMap['collectioncode']) $postArr['collectioncode'] = '';
+ if(isset($postArr['ownerinstitutioncode']) && $postArr['ownerinstitutioncode'] == $this->collMap['institutioncode']) $postArr['ownerinstitutioncode'] = '';
+ foreach($postArr as $oField => $ov){
if(in_array($oField,$this->occFieldArr) && $oField != 'observeruid'){
$vStr = $this->cleanInStr($ov);
$sql .= ','.$oField.' = '.($vStr!==''?'"'.$vStr.'"':'NULL');
@@ -879,28 +879,28 @@ public function editOccurrence($occArr, $editorStatus){
//If sciname was changed, update image tid link
if(in_array('tidinterpreted',$editArr)){
//Remap images
- $sqlImgTid = 'UPDATE images SET tid = '.(is_numeric($occArr['tidinterpreted'])?$occArr['tidinterpreted']:'NULL').' WHERE occid = ('.$occid.')';
+ $sqlImgTid = 'UPDATE images SET tid = '.(is_numeric($postArr['tidinterpreted'])?$postArr['tidinterpreted']:'NULL').' WHERE occid = ('.$occid.')';
$this->conn->query($sqlImgTid);
}
//If host was entered in quickhost field, update record
if($quickHostEntered){
- if($occArr['hostassocid']){
- if($occArr['host']){
- $sqlHost = 'UPDATE omoccurassociations SET verbatimsciname = "'.$occArr['host'].'" WHERE associd = '.$occArr['hostassocid'].' ';
+ if($postArr['hostassocid']){
+ if($postArr['host']){
+ $sqlHost = 'UPDATE omoccurassociations SET verbatimsciname = "'.$postArr['host'].'" WHERE associd = '.$postArr['hostassocid'].' ';
}
else{
- $sqlHost = 'DELETE FROM omoccurassociations WHERE associd = '.$occArr['hostassocid'].' ';
+ $sqlHost = 'DELETE FROM omoccurassociations WHERE associd = '.$postArr['hostassocid'].' ';
}
}
else{
- $sqlHost = 'INSERT INTO omoccurassociations(occid,relationship,verbatimsciname) VALUES('.$occid.',"host","'.$occArr['host'].'")';
+ $sqlHost = 'INSERT INTO omoccurassociations(occid,relationship,verbatimsciname) VALUES('.$occid.',"host","'.$postArr['host'].'")';
}
$this->conn->query($sqlHost);
}
//Update occurrence record
$sql = 'UPDATE omoccurrences SET '.substr($sql,1).' WHERE (occid = '.$occid.')';
if($this->conn->query($sql)){
- if(strtolower($occArr['processingstatus']) != 'unprocessed'){
+ if(strtolower($postArr['processingstatus']) != 'unprocessed'){
//UPDATE uid within omcrowdsourcequeue, only if not yet processed
$isVolunteer = true;
if(array_key_exists('CollAdmin',$USER_RIGHTS) && in_array($this->collId, $USER_RIGHTS['CollAdmin'])){
@@ -918,7 +918,7 @@ public function editOccurrence($occArr, $editorStatus){
}
}
//Deal with paleo fields
- if($this->paleoActivated && array_key_exists('eon',$occArr)){
+ if($this->paleoActivated && array_key_exists('eon',$postArr)){
//Check to see if paleo record already exists
$paleoRecordExist = false;
$paleoSql = 'SELECT paleoid FROM omoccurpaleo WHERE occid = '.$occid;
@@ -932,9 +932,9 @@ public function editOccurrence($occArr, $editorStatus){
$paleoHasValue = false;
$paleoFrag = '';
foreach($this->paleoFieldArr as $paleoField){
- if(array_key_exists($paleoField,$occArr)){
- $paleoFrag .= ','.$paleoField.' = '.($occArr[$paleoField]?'"'.$this->cleanInStr($occArr[$paleoField]).'"':'NULL');
- if($occArr[$paleoField]) $paleoHasValue = true;
+ if(array_key_exists($paleoField,$postArr)){
+ $paleoFrag .= ','.$paleoField.' = '.($postArr[$paleoField]?'"'.$this->cleanInStr($postArr[$paleoField]).'"':'NULL');
+ if($postArr[$paleoField]) $paleoHasValue = true;
}
}
$paleoSql = '';
@@ -956,9 +956,9 @@ public function editOccurrence($occArr, $editorStatus){
$paleoFrag1 = '';
$paleoFrag2 = '';
foreach($this->paleoFieldArr as $paleoField){
- if(array_key_exists($paleoField,$occArr) && $occArr[$paleoField]){
+ if(array_key_exists($paleoField,$postArr) && $postArr[$paleoField]){
$paleoFrag1 .= ','.$paleoField;
- $paleoFrag2 .= ',"'.$this->cleanInStr($occArr[$paleoField]).'" ';
+ $paleoFrag2 .= ',"'.$this->cleanInStr($postArr[$paleoField]).'" ';
}
}
if($paleoFrag1){
@@ -972,8 +972,8 @@ public function editOccurrence($occArr, $editorStatus){
//Deal with exsiccati
if(in_array('ometid',$editArr) || in_array('exsnumber',$editArr)){
- $ometid = $this->cleanInStr($occArr['ometid']);
- $exsNumber = $this->cleanInStr($occArr['exsnumber']);
+ $ometid = $this->cleanInStr($postArr['ometid']);
+ $exsNumber = $this->cleanInStr($postArr['exsnumber']);
if($ometid && $exsNumber){
//Values have been submitted, thus try to add ometid and omenid
//Get exsiccati number id
@@ -1011,9 +1011,9 @@ public function editOccurrence($occArr, $editorStatus){
}
}
//Deal with duplicate clusters
- if(isset($occArr['linkdupe']) && $occArr['linkdupe']){
- $dupTitle = $occArr['recordedby'].' '.$occArr['recordnumber'].' '.$occArr['eventdate'];
- $status .= $this->linkDuplicates($occArr['linkdupe'],$dupTitle);
+ if(isset($postArr['linkdupe']) && $postArr['linkdupe']){
+ $dupTitle = $postArr['recordedby'].' '.$postArr['recordnumber'].' '.$postArr['eventdate'];
+ $status .= $this->linkDuplicates($postArr['linkdupe'],$dupTitle);
}
}
else{
@@ -1031,9 +1031,9 @@ public function editOccurrence($occArr, $editorStatus){
return $status;
}
- public function addOccurrence($occArr){
- $status = "SUCCESS: new occurrence record submitted successfully ";
- if($occArr){
+ public function addOccurrence($postArr){
+ $status = 'SUCCESS: new occurrence record submitted successfully ';
+ if($postArr){
$fieldArr = array('basisOfRecord' => 's', 'catalogNumber' => 's', 'otherCatalogNumbers' => 's', 'occurrenceid' => 's',
'ownerInstitutionCode' => 's', 'institutionCode' => 's', 'collectionCode' => 's',
'family' => 's', 'sciname' => 's', 'tidinterpreted' => 'n', 'scientificNameAuthorship' => 's', 'identifiedBy' => 's', 'dateIdentified' => 's',
@@ -1047,36 +1047,27 @@ public function addOccurrence($occArr){
'footprintwkt' => 's', 'georeferencedBy' => 's', 'georeferenceProtocol' => 's', 'georeferenceSources' => 's', 'georeferenceVerificationStatus' => 's',
'georeferenceRemarks' => 's', 'minimumElevationInMeters' => 'n', 'maximumElevationInMeters' => 'n','verbatimElevation' => 's',
'minimumDepthInMeters' => 'n', 'maximumDepthInMeters' => 'n', 'verbatimDepth' => 's','disposition' => 's', 'language' => 's', 'duplicateQuantity' => 'n',
- 'labelProject' => 's','processingstatus' => 's', 'recordEnteredBy' => 's', 'observeruid' => 'n', 'dateentered' => 'd', 'genericcolumn2' => 's');
- $sql = 'INSERT INTO omoccurrences(collid, '.implode(array_keys($fieldArr),',').') VALUES ('.$occArr["collid"];
+ 'labelProject' => 's','processingStatus' => 's', 'recordEnteredBy' => 's', 'observeruid' => 'n', 'dateentered' => 'd', 'genericcolumn2' => 's');
+ $sql = 'INSERT INTO omoccurrences(collid, '.implode(array_keys($fieldArr),',').') VALUES ('.$postArr['collid'];
$fieldArr = array_change_key_case($fieldArr);
- //if(array_key_exists('cultivationstatus',$occArr) && $occArr['cultivationstatus']) $occArr['cultivationstatus'] = $occArr['cultivationstatus'];
- //if(array_key_exists('localitysecurity',$occArr) && $occArr['localitysecurity']) $occArr['localitysecurity'] = $occArr['localitysecurity'];
- if(!isset($occArr['dateentered']) || !$occArr['dateentered']) $occArr['dateentered'] = date('Y-m-d H:i:s');
- if(!isset($occArr['basisofrecord']) || !$occArr['basisofrecord']) $occArr['basisofrecord'] = (strpos($this->collMap['colltype'],'Observations') !== false?'HumanObservation':'PreservedSpecimen');
- if(isset($occArr['institutionCode']) && $occArr['institutionCode'] == $this->collMap['institutioncode']) $occArr['institutionCode'] = '';
- if(isset($occArr['collectionCode']) && $occArr['collectionCode'] == $this->collMap['collectioncode']) $occArr['collectionCode'] = '';
+ //if(array_key_exists('cultivationstatus',$postArr) && $postArr['cultivationstatus']) $postArr['cultivationstatus'] = $postArr['cultivationstatus'];
+ //if(array_key_exists('localitysecurity',$postArr) && $postArr['localitysecurity']) $postArr['localitysecurity'] = $postArr['localitysecurity'];
+ if(!isset($postArr['dateentered']) || !$postArr['dateentered']) $postArr['dateentered'] = date('Y-m-d H:i:s');
+ if(!isset($postArr['basisofrecord']) || !$postArr['basisofrecord']) $postArr['basisofrecord'] = (strpos($this->collMap['colltype'],'Observations') !== false?'HumanObservation':'PreservedSpecimen');
+ if(isset($postArr['institutioncode']) && $postArr['institutioncode'] == $this->collMap['institutioncode']) $postArr['institutionCode'] = '';
+ if(isset($postArr['collectioncode']) && $postArr['collectioncode'] == $this->collMap['collectioncode']) $postArr['collectionCode'] = '';
foreach($fieldArr as $fieldStr => $fieldType){
$fieldValue = '';
- if(array_key_exists($fieldStr,$occArr)) $fieldValue = $occArr[$fieldStr];
+ if(array_key_exists($fieldStr,$postArr)) $fieldValue = $postArr[$fieldStr];
if($fieldValue){
if($fieldType == 'n'){
- if(is_numeric($fieldValue)){
- $sql .= ', '.$fieldValue;
- }
- else{
- $sql .= ', NULL';
- }
+ if(is_numeric($fieldValue)) $sql .= ', '.$fieldValue;
+ else $sql .= ', NULL';
}
- else{
- //Is string or date
- $sql .= ', "'.$this->cleanInStr($fieldValue).'"';
- }
- }
- else{
- $sql .= ', NULL';
+ else $sql .= ', "'.$this->cleanInStr($fieldValue).'"'; //Is string or date
}
+ else $sql .= ', NULL';
}
$sql .= ')';
if($this->conn->query($sql)){
@@ -1090,14 +1081,14 @@ public function addOccurrence($occArr){
$status .= '(WARNING: Symbiota GUID mapping failed) ';
}
//Deal with paleo
- if($this->paleoActivated && array_key_exists('eon',$occArr)){
+ if($this->paleoActivated && array_key_exists('eon',$postArr)){
//Add new record
$paleoFrag1 = '';
$paleoFrag2 = '';
foreach($this->paleoFieldArr as $paleoField){
- if(array_key_exists($paleoField,$occArr)){
+ if(array_key_exists($paleoField,$postArr)){
$paleoFrag1 .= ','.$paleoField;
- $paleoFrag2 .= ','.($occArr[$paleoField]?'"'.$this->cleanInStr($occArr[$paleoField]).'"':'NULL');
+ $paleoFrag2 .= ','.($postArr[$paleoField]?'"'.$this->cleanInStr($postArr[$paleoField]).'"':'NULL');
}
}
if($paleoFrag1){
@@ -1106,10 +1097,10 @@ public function addOccurrence($occArr){
}
}
//Deal with Exsiccati
- if(isset($occArr['ometid']) && isset($occArr['exsnumber'])){
+ if(isset($postArr['ometid']) && isset($postArr['exsnumber'])){
//If exsiccati titie is submitted, trim off first character that was used to force Google Chrom to sort correctly
- $ometid = $this->cleanInStr($occArr['ometid']);
- $exsNumber = $this->cleanInStr($occArr['exsnumber']);
+ $ometid = $this->cleanInStr($postArr['ometid']);
+ $exsNumber = $this->cleanInStr($postArr['exsnumber']);
if($ometid && $exsNumber){
$exsNumberId = '';
$sql = 'SELECT omenid FROM omexsiccatinumbers WHERE ometid = '.$ometid.' AND exsnumber = "'.$exsNumber.'"';
@@ -1140,24 +1131,24 @@ public function addOccurrence($occArr){
}
}
//Deal with host data
- if(array_key_exists('host',$occArr)){
- $sql = 'INSERT INTO omoccurassociations(occid,relationship,verbatimsciname) VALUES('.$this->occid.',"host","'.$this->cleanInStr($occArr['host']).'")';
+ if(array_key_exists('host',$postArr)){
+ $sql = 'INSERT INTO omoccurassociations(occid,relationship,verbatimsciname) VALUES('.$this->occid.',"host","'.$this->cleanInStr($postArr['host']).'")';
if(!$this->conn->query($sql)){
$status .= '(WARNING adding host: '.$this->conn->error.') ';
}
}
- if(isset($occArr['confidenceranking']) && $occArr['confidenceranking']){
- $this->editIdentificationRanking($occArr['confidenceranking'],'');
+ if(isset($postArr['confidenceranking']) && $postArr['confidenceranking']){
+ $this->editIdentificationRanking($postArr['confidenceranking'],'');
}
//Deal with checklist voucher
- if(isset($occArr['clidvoucher']) && isset($occArr['tidinterpreted'])){
- $status .= $this->linkChecklistVoucher($occArr['clidvoucher'],$occArr['tidinterpreted']);
+ if(isset($postArr['clidvoucher']) && isset($postArr['tidinterpreted'])){
+ $status .= $this->linkChecklistVoucher($postArr['clidvoucher'],$postArr['tidinterpreted']);
}
//Deal with duplicate clustering
- if(isset($occArr['linkdupe']) && $occArr['linkdupe']){
- $dupTitle = $occArr['recordedby'].' '.$occArr['recordnumber'].' '.$occArr['eventdate'];
- $status .= $this->linkDuplicates($occArr['linkdupe'],$dupTitle);
+ if(isset($postArr['linkdupe']) && $postArr['linkdupe']){
+ $dupTitle = $postArr['recordedby'].' '.$postArr['recordnumber'].' '.$postArr['eventdate'];
+ $status .= $this->linkDuplicates($postArr['linkdupe'],$dupTitle);
}
}
else{
@@ -1294,8 +1285,45 @@ public function deleteOccurrence($delOccid){
return $status;
}
+ public function cloneOccurrence($postArr){
+ $retArr = array();
+ if(isset($postArr['clonecount']) && $postArr['clonecount']){
+ $postArr['recordenteredby'] = $GLOBALS['USERNAME'];
+ $sourceOccid = $this->occid;
+ $clearAllArr = array('catalognumber','othercatalognumbers','occurrenceid','individualcount','duplicatequantity','processingstatus','dateentered');
+ $postArr = array_diff_key($postArr,array_flip($clearAllArr));
+ if($postArr['targetcollid'] && $postArr['targetcollid'] != $this->collId){
+ $clearCollArr = array('basisofrecord','ownerinstitutioncode','institutioncode','collectioncode');
+ $postArr = array_diff_key($postArr,array_flip($clearCollArr));
+ $postArr['collid'] = $postArr['targetcollid'];
+ }
+ if(isset($postArr['carryover']) && $postArr['carryover'] == 1){
+ $clearEventArr = array('family','sciname','tidinterpreted','scientificnameauthorship','identifiedby','dateidentified','identificationreferences','identificationremarks',
+ 'taxonremarks','identificationqualifier','recordnumber','occurrenceremarks','verbatimattributes','dynamicproperties','lifestage','sex');
+ $postArr = array_diff_key($postArr,array_flip($clearEventArr));
+ }
+ $cloneCatNum = array();
+ if(isset($postArr['clonecatnum'])) $cloneCatNum = $postArr['clonecatnum'];
+ for($i=0; $i < $postArr['clonecount']; $i++){
+ if(isset($cloneCatNum[$i]) && $cloneCatNum[$i]) $postArr['catalognumber'] = $cloneCatNum[$i];
+ $this->addOccurrence($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, occidAssociate, relationship,createdUid) '.
+ 'values('.$this->occid.','.$sourceOccid.',"'.$postArr['assocrelation'].'",'.$GLOBALS['SYMB_UID'].') ';
+ if(!$this->conn->query($sql)){
+ $this->errorArr[] = 'ERROR adding relationship for cloned specimens: '.$this->conn->error;
+ }
+ }
+ }
+ }
+ $this->occid = $sourceOccid;
+ }
+ return $retArr;
+ }
+
public function mergeRecords($targetOccid,$sourceOccid){
- global $QUICK_HOST_ENTRY_IS_ACTIVE;
$status = true;
if(!$targetOccid || !$sourceOccid){
$this->errorArr[] = 'ERROR: target or source is null';
@@ -2182,6 +2210,19 @@ public function getQuickHost(){
return $retArr;
}
+ public function getAssociationControlVocab(){
+ $retArr = array();
+ $sql = 'SELECT t.cvTermID, t.term '.
+ 'FROM ctcontrolvocabterm t INNER JOIN ctcontrolvocab v ON t.cvID = v.cvID '.
+ 'WHERE v.tablename = "omoccurassociations" AND v.fieldName = "relationship" ORDER BY term';
+ $rs = $this->conn->query($sql);
+ while($r = $rs->fetch_object()){
+ $retArr[$r->cvTermID] = $r->term;
+ }
+ $rs->free();
+ return $retArr;
+ }
+
public function isCrowdsourceEditor(){
$isEditor = false;
$sql = 'SELECT reviewstatus, uidprocessor FROM omcrowdsourcequeue WHERE occid = '.$this->occid;
diff --git a/classes/OccurrenceExsiccatae.php b/classes/OccurrenceExsiccatae.php
index 3b0aa6b3e3..604ec8f6a5 100644
--- a/classes/OccurrenceExsiccatae.php
+++ b/classes/OccurrenceExsiccatae.php
@@ -77,16 +77,10 @@ public function getTitleArr($searchTerm, $specimenOnly, $imagesOnly, $collId, $s
//echo $sql;
if($rs = $this->conn->query($sql)){
while($r = $rs->fetch_object()){
- if($sortBy == 1) {
- if($r->abbreviation) $titleStr = (strlen($r->abbreviation)>100?substr($r->abbreviation,0,100).'...':$r->abbreviation);
- else {
- $titleStr = (strlen($r->title)>100?substr($r->title,0,100).'...':$r->title);
- $titleStr .= ', '.(strlen($r->editor)>50?substr($r->editor,0,50).'...':$r->editor);
- }
- } else {
- $titleStr = (strlen($r->title)>100?substr($r->title,0,100).'...':$r->title);
- if($r->editor) $titleStr .= ', '.(strlen($r->editor)>50?substr($r->editor,0,50).'...':$r->editor);
- }
+ $titleStr = $r->title;
+ if($sortBy == 1 && $r->abbreviation) $titleStr = $r->abbreviation;
+ if(strlen($titleStr)>100) $titleStr = substr($titleStr,0,100).'...';
+ $retArr[$r->ometid]['editor'] = $this->cleanOutStr($r->editor);
$retArr[$r->ometid]['exsrange'] = $this->cleanOutStr($r->exsrange);
$retArr[$r->ometid]['title'] = $this->cleanOutStr($titleStr);
}
diff --git a/classes/OccurrenceIndividual.php b/classes/OccurrenceIndividual.php
index 3e28e90a6a..26bcde9444 100644
--- a/classes/OccurrenceIndividual.php
+++ b/classes/OccurrenceIndividual.php
@@ -363,6 +363,65 @@ public function getDuplicateArr(){
return $retArr;
}
+ //Occurrence trait and attribute functions
+ public function getTraitArr(){
+ $retArr = array();
+ if($this->occid){
+ $sql = 'SELECT t.traitid, t.traitName, t.description AS t_desc, t.refUrl AS t_url, s.stateid, s.stateName, s.description AS s_desc, s.refUrl AS s_url, d.parentstateid '.
+ 'FROM tmattributes a INNER JOIN tmstates s ON a.stateid = s.stateid '.
+ 'INNER JOIN tmtraits t ON s.traitid = t.traitid '.
+ 'LEFT JOIN tmtraitdependencies d ON t.traitid = d.traitid '.
+ 'WHERE t.isPublic = 1 AND a.occid = '.$this->occid.' ORDER BY t.traitName, s.sortSeq';
+ $rs = $this->conn->query($sql);
+ if($rs){
+ while($r = $rs->fetch_object()){
+ $retArr[$r->traitid]['name'] = $r->traitName;
+ $retArr[$r->traitid]['desc'] = $r->t_desc;
+ $retArr[$r->traitid]['url'] = $r->t_url;
+ $retArr[$r->traitid]['depStateID'] = $r->parentstateid;
+ $retArr[$r->traitid]['state'][$r->stateid]['name'] = $r->stateName;
+ $retArr[$r->traitid]['state'][$r->stateid]['desc'] = $r->s_desc;
+ $retArr[$r->traitid]['state'][$r->stateid]['url'] = $r->s_url;
+ }
+ $rs->free();
+ }
+ if($retArr){
+ //Set dependent traits
+ $sql = 'SELECT DISTINCT s.traitid AS parentTraitID, d.parentStateID, d.traitid AS depTraitID '.
+ 'FROM tmstates s INNER JOIN tmtraitdependencies d ON s.stateid = d.parentstateid '.
+ 'WHERE s.traitid IN('.implode(',',array_keys($retArr)).')';
+ //echo $sql.'
';
+ $rs = $this->conn->query($sql);
+ while($r = $rs->fetch_object()){
+ $retArr[$r->parentTraitID]['state'][$r->parentStateID]['depTraitID'][] = $r->depTraitID;
+ }
+ $rs->free();
+ }
+ }
+ return $retArr;
+ }
+
+ public function echoTraitDiv($traitArr, $targetID, $ident = 15){
+ $tArr = $traitArr[$targetID];
+ foreach($tArr['state'] as $stateID => $sArr){
+ $this->echoTraitUnit($sArr,$ident);
+ if(array_key_exists('depTraitID',$sArr)){
+ foreach($sArr['depTraitID'] as $depTraitID){
+ $this->echoTraitDiv($traitArr, $depTraitID, $ident+15);
+ }
+ }
+ }
+ }
+
+ public function echoTraitUnit($outArr, $indent=0){
+ echo '
';
+ }
+
//Occurrence comment functions
public function getCommentArr($isEditor){
$retArr = array();
diff --git a/classes/OccurrenceLoans.php b/classes/OccurrenceLoans.php
index 54bb2e1985..9d42b04fe8 100644
--- a/classes/OccurrenceLoans.php
+++ b/classes/OccurrenceLoans.php
@@ -488,6 +488,31 @@ public function getSpecimenTotal($loanid){
return $retStr;
}
+ public function exportSpecimenList($loanid){
+ $fileName = 'loanSpecList_'.date('Ymd').'.csv';
+ header ('Cache-Control: must-revalidate, post-check=0, pre-check=0');
+ header ('Content-Type: text/csv');
+ header ('Content-Disposition: attachment; filename="'.$fileName.'"');
+ $sql = 'SELECT o.catalogNumber, o.otherCatalogNumbers, o.occurrenceID, o.family, o.sciname, o.recordedBy, o.recordNumber, o.eventDate, '.
+ 'o.country, o.stateProvince, o.county, o.locality, o.decimalLatitude, o.decimalLongitude, o.minimumElevationInMeters, o.dateEntered, o.dateLastModified '.
+ 'FROM omoccurrences o INNER JOIN omoccurloanslink l ON o.occid = l.occid '.
+ 'WHERE loanid = '.$loanid;
+ $rs = $this->conn->query($sql);
+ if($rs->num_rows){
+ $headerArr = array();
+ $fields = mysqli_fetch_fields($rs);
+ foreach($fields as $val) $headerArr[] = $val->name;
+ $out = fopen('php://output', 'w');
+ fputcsv($out, $headerArr);
+ while($r = $rs->fetch_assoc()){
+ fputcsv($out, $r);
+ }
+ $rs->free();
+ fclose($out);
+ }
+ else echo "Specimen recordset is empty.\n";
+ }
+
public function linkSpecimen($loanid, $catNum){
//This method is used by the ajax script insertLoanSpecimen.php
if(is_numeric($loanid)){
diff --git a/classes/OccurrenceManager.php b/classes/OccurrenceManager.php
index 8cae3c0ae7..3544573d1c 100644
--- a/classes/OccurrenceManager.php
+++ b/classes/OccurrenceManager.php
@@ -427,6 +427,27 @@ protected function setSqlWhere(){
$this->displaySearchArr[] = 'includes cultivated/captive occurrences';
}
}
+ $anyTraitsHere = false;
+ $stateids = array();
+ foreach($this->searchTermArr as $stkey => $stval){
+ if("traitid-" == substr($stkey, 0, 8) && is_numeric($stval)) {
+ $stateids[] = $stval;
+ $anyTraitsHere = true;
+ }
+ }
+ if($anyTraitsHere == true) {
+ $traitSql = implode(',', $stateids);
+ $traitNameSql = 'SELECT CONCAT_WS(": ", t.traitname, s.statename) AS traitName FROM tmtraits t JOIN tmstates s ON s.traitid = t.traitid WHERE s.stateid IN(' . $traitSql . ')';
+ $rs = $this->conn->query($traitNameSql);
+ if($rs){
+ while($r = $rs->fetch_object()) {
+ $this->displaySearchArr[] = $r->traitName;
+ }
+ $rs->free();
+ }
+ $sqlWhere .= 'AND (o.occid IN(SELECT occid FROM tmattributes WHERE stateid IN(' . $traitSql . ')))';
+ }
+
if($sqlWhere){
$this->sqlWhere = 'WHERE '.substr($sqlWhere,4);
}
@@ -844,6 +865,16 @@ protected function readRequestVariables(){
unset($this->searchTermArr["includecult"]);
}
}
+ // Traits search: loop over all "traitid-" fields
+ foreach ($_REQUEST as $reqkey => $reqval){
+ if("traitid-" == substr($reqkey, 0, 8)){
+ if($reqval){
+ $this->searchTermArr[$reqkey] = $reqval[0];
+ } else {
+ unset($this->searchTermArr[$reqkey]);
+ }
+ }
+ }
$llPattern = '-?\d+\.{0,1}\d*';
if(array_key_exists("upperlat",$_REQUEST)){
$upperLat = ''; $bottomlat = ''; $leftLong = ''; $rightlong = '';
diff --git a/classes/SpecUploadBase.php b/classes/SpecUploadBase.php
index d72c80e5fc..abfc2df56d 100644
--- a/classes/SpecUploadBase.php
+++ b/classes/SpecUploadBase.php
@@ -286,7 +286,8 @@ public function echoFieldMapTable($autoMap, $mode){
'elevationmeters'=>'minimumelevationinmeters','minelevationm'=>'minimumelevationinmeters','maxelevationm'=>'maximumelevationinmeters','verbatimelev'=>'verbatimelevation',
'field:associatedspecies'=>'associatedtaxa','associatedspecies'=>'associatedtaxa','assoctaxa'=>'associatedtaxa','specimennotes'=>'occurrenceremarks','notes'=>'occurrenceremarks',
'generalnotes'=>'occurrenceremarks','plantdescription'=>'verbatimattributes','description'=>'verbatimattributes','specimendescription'=>'verbatimattributes',
- 'phenology'=>'reproductivecondition','field:habitat'=>'habitat','habitatdescription'=>'habitat','sitedeschabitat'=>'habitat','ometid'=>'exsiccatiidentifier','exsnumber'=>'exsiccatinumber',
+ 'phenology'=>'reproductivecondition','field:habitat'=>'habitat','habitatdescription'=>'habitat','sitedeschabitat'=>'habitat',
+ 'ometid'=>'exsiccatiidentifier','exsiccataeidentifier'=>'exsiccatiidentifier','exsnumber'=>'exsiccatinumber','exsiccataenumber'=>'exsiccatinumber',
'group'=>'paleo-lithogroup','lithostratigraphicterms'=>'paleo-lithology','imageurl'=>'associatedmedia','subject_references'=>'tempfield01','subject_recordid'=>'tempfield02'
);
diff --git a/collections/editor/includes/queryform.php b/collections/editor/includes/queryform.php
index 90584f362a..41ae8294b6 100644
--- a/collections/editor/includes/queryform.php
+++ b/collections/editor/includes/queryform.php
@@ -36,7 +36,7 @@
else{
$processingStatusArr = array('unprocessed','unprocessed/NLP','stage 1','stage 2','stage 3','pending review-nfn','pending review','expert required','reviewed','closed');
}
-if(!isset($_REQUEST['q_catalognumber'])) $displayQuery = true;
+//if(!isset($_REQUEST['q_catalognumber'])) $displayQuery = true;
?>
Search returned 0 records
'."\n";
if($occArr || $goToMode == 1 || $goToMode == 2){ //$action == 'gotonew'
if($occId && $isLocked){
?>
@@ -763,7 +764,7 @@ function requestImage(){
?>
@@ -1259,13 +1260,8 @@ function requestImage(){
';
?>
-