Skip to content
This repository was archived by the owner on Mar 19, 2025. It is now read-only.

Commit eb0fb39

Browse files
committed
Adjustments to the state level protection of rare species
1 parent 2bb07be commit eb0fb39

File tree

3 files changed

+24
-10
lines changed

3 files changed

+24
-10
lines changed

classes/ChecklistAdmin.php

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
22
include_once($serverRoot.'/config/dbconnection.php');
3-
include_once($serverRoot.'/classes/OccurrenceUtilities.php');
43

54
class ChecklistAdmin {
65

@@ -85,7 +84,22 @@ public function editMetaData($postArr){
8584
}
8685
$sql = 'UPDATE fmchecklists SET '.substr($setSql,2).' WHERE (clid = '.$this->clid.')';
8786
//echo $sql; exit;
88-
if(!$this->conn->query($sql)){
87+
if($this->conn->query($sql)){
88+
if($postArr['type'] == 'rarespp'){
89+
if($postArr['locality']){
90+
$sql = 'UPDATE omoccurrences o INNER JOIN taxstatus ts1 ON o.tidinterpreted = ts1.tid '.
91+
'INNER JOIN taxstatus ts2 ON ts1.tidaccepted = ts2.tidaccepted '.
92+
'INNER JOIN fmchklsttaxalink cl ON ts2.tid = cl.tid '.
93+
'SET o.localitysecurity = 1 '.
94+
'WHERE (cl.clid = '.$this->clid.') AND (o.stateprovince = "'.$postArr['locality'].'") '.
95+
'AND (o.localitysecurity IS NULL OR o.localitysecurity = 0) AND (ts1.taxauthid = 1) AND (ts2.taxauthid = 1) ';
96+
if(!$this->conn->query($sql)){
97+
$statusStr = 'Error updating rare state species: '.$this->conn->error;
98+
}
99+
}
100+
}
101+
}
102+
else{
89103
$statusStr = 'Error: unable to update checklist metadata. SQL: '.$this->conn->error;
90104
}
91105
return $statusStr;
@@ -240,8 +254,8 @@ public function addNewSpecies($dataArr,$setRareSpp = false){
240254
$sqlRare = 'UPDATE omoccurrences o INNER JOIN taxstatus ts1 ON o.tidinterpreted = ts1.tid '.
241255
'INNER JOIN taxstatus ts2 ON ts1.tidaccepted = ts2.tidaccepted '.
242256
'SET o.localitysecurity = 1 '.
243-
'WHERE (o.localitysecurity IS NULL OR o.localitysecurity = 0) AND ts1.taxauthid = 1 AND ts2.taxauthid = 1 '.
244-
'AND o.stateprovince = "'.$state.'" AND ts2.tid = '.$dataArr['tid'];
257+
'WHERE (o.localitysecurity IS NULL OR o.localitysecurity = 0) AND (ts1.taxauthid = 1) AND (ts2.taxauthid = 1) '.
258+
'AND (o.stateprovince = "'.$state.'") AND (ts2.tid = '.$dataArr['tid'].')';
245259
//echo $sqlRare; exit;
246260
$this->conn->query($sqlRare);
247261
}

classes/OccurrenceUtilities.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -883,13 +883,13 @@ public function protectGloballyRareSpecies($collid = 0){
883883
//protect globally rare species
884884
if($this->verbose) $this->outputMsg('Protecting globally rare species... ',1);
885885
$sensitiveArr = array();
886-
$sql = 'SELECT DISTINCT t.tid, ts.tidaccepted '.
887-
'FROM taxa t INNER JOIN taxstatus ts ON t.tid = ts.tid '.
888-
'WHERE (ts.taxauthid = 1) AND (t.SecurityStatus > 0)';
886+
$sql = 'SELECT DISTINCT ts2.tid '.
887+
'FROM taxa t INNER JOIN taxstatus ts ON t.tid = ts.tid '.
888+
'INNER JOIN taxstatus ts2 ON ts.tidaccepted = ts2.tidaccepted '.
889+
'WHERE (ts.taxauthid = 1) AND (ts2.taxauthid = 1) AND (t.SecurityStatus > 0)';
889890
$rs = $this->conn->query($sql);
890891
while($r = $rs->fetch_object()){
891-
$sensitiveArr[$r->tid] = $r->tid;
892-
$sensitiveArr[$r->tidaccepted] = $r->tidaccepted;
892+
$sensitiveArr[] = $r->tid;
893893
}
894894
$rs->free();
895895

classes/VoucherManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public function deleteTaxon($rareLocality = ''){
190190
}
191191

192192
private function setStateRare($rareLocality){
193-
//Check to make sure name it's already on global list
193+
//Remove state based security protection only if name is not on global list
194194
$sql = 'SELECT IFNULL(securitystatus,0) as securitystatus FROM taxa WHERE tid = '.$this->tid;
195195
//echo $sql;
196196
$rs = $this->conn->query($sql);

0 commit comments

Comments
 (0)