Skip to content

Commit

Permalink
Merge pull request #35 from BioKIC/Development
Browse files Browse the repository at this point in the history
Merge BioKIC/Symbiota Development branch developments
  • Loading branch information
egbot authored Sep 27, 2023
2 parents 297cf89 + e47ae11 commit 5f10daf
Show file tree
Hide file tree
Showing 27 changed files with 586 additions and 393 deletions.
113 changes: 55 additions & 58 deletions checklists/checklist.php

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion checklists/checklistadmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@
$statusStr = $clManager->deleteProject($_POST['pid']);
}
elseif($action == 'addPoint'){
$statusStr = $clManager->addPoint($_POST['pointtid'],$_POST['pointlat'],$_POST['pointlng'],$_POST['notes']);
if(!$clManager->addPoint($_POST['pointtid'], $_POST['pointlat'], $_POST['pointlng'], $_POST['notes'])){
$statusStr = $clManager->getErrorMessage();
}
}
elseif($action && array_key_exists('clidadd',$_POST)){
if(!$clManager->addChildChecklist($_POST['clidadd'])){
Expand Down
10 changes: 3 additions & 7 deletions checklists/checklistadminmeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@ function validateChecklistForm(f){
return false;
}
}
if(!isNumeric(f.pointradiusmeters.value)){
alert("<?php echo (isset($LANG['NUMERIC_RADIUS'])?$LANG['NUMERIC_RADIUS']:'Point radius must be a numeric value only'); ?>");
return false;
}
if(f.type){
if(f.type.value == "rarespp" && f.locality.value == ""){
alert("<?php echo (isset($LANG['NEED_STATE'])?$LANG['NEED_STATE']:'Rare species checklists must have a state value entered into the locality field'); ?>");
Expand Down Expand Up @@ -196,7 +192,7 @@ function enableDisableExtServiceFields() {
<select name="externalservice" id="externalservice" onchange="enableDisableExtServiceFields()">
<option value=""></option>
<option value="">-------------------------------</option>
<option value="inaturalist" <?php echo (($dynamPropsArr['externalservice']=='inaturalist')?'selected':''); ?>>iNaturalist</option>
<option value="inaturalist" <?php echo ((isset($dynamPropsArr['externalservice']) && $dynamPropsArr['externalservice']=='inaturalist')?'selected':''); ?>>iNaturalist</option>
</select>
</div>
<div style="width:100%;margin-top:5px">
Expand Down Expand Up @@ -251,7 +247,7 @@ function enableDisableExtServiceFields() {
</div>
<div style="float:left;margin-left:15px;">
<b><?php echo (isset($LANG['REFERENCE_CHECK'])?$LANG['POINTRAD']:'Point Radius (meters)');?></b><br/>
<input type="text" name="pointradiusmeters" style="width:110px;" value="<?php echo ($clArray?$clArray["pointradiusmeters"]:''); ?>" />
<input type="number" name="pointradiusmeters" style="width:110px;" value="<?php echo ($clArray?$clArray["pointradiusmeters"]:''); ?>" />
</div>
</div>
<div style="clear:both;margin-top:5px;">
Expand Down Expand Up @@ -324,7 +320,7 @@ function enableDisableExtServiceFields() {
</div>
<div id="sortSeqDiv" style="clear:both;margin-top:15px;">
<b><?php echo (isset($LANG['DEFAULT_SORT'])?$LANG['DEFAULT_SORT']:'Default Sorting Sequence'); ?>:</b>
<input name="sortsequence" type="text" value="<?php echo ($clArray?$clArray['sortsequence']:'50'); ?>" style="width:40px" />
<input name="sortsequence" type="number" value="<?php echo ($clArray?$clArray['sortsequence']:'50'); ?>" style="width:40px" />
</div>
<div id="accessDiv" style="clear:both;margin-top:15px;">
<b><?php echo (isset($LANG['ACCESS'])?$LANG['ACCESS']:'Access'); ?>:</b>
Expand Down
162 changes: 76 additions & 86 deletions checklists/externalvouchers.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

//--------------------------------------------------------------------
// This Symbiota enhancement was made possible with support from
// the United States Institute of Museum and Library Services grant
Expand All @@ -8,7 +7,6 @@
// omissions are his.
//--------------------------------------------------------------------


include_once('../config/symbini.php');
include_once($SERVER_ROOT.'/classes/ChecklistVoucherReport.php');
include_once($SERVER_ROOT.'/classes/ChecklistManager.php');
Expand Down Expand Up @@ -39,95 +37,82 @@
$isEditor = 1;
}
if($isEditor){
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
include_once($SERVER_ROOT.'/classes/ChecklistAdmin.php');
$clAdminer = new ChecklistAdmin();
$clAdminer->setClid($clid);
$postArr = $_POST;
foreach($postArr as $key => $value) {
if(substr($key,0,1) != 'i') {
if(urldecode($value) != '') {
$clAdminer->addExternalVouchers($key,urldecode($value));
}
}
}
header('Location: voucheradmin.php?clid='.$clid);
exit;
} else {
$taxaArray = $clManager->getTaxaList();
?>
<div id="externalServiceVoucherDiv">
?>
<div id="externalServiceVoucherDiv">
<div style="margin:10px;">
<div style="clear:both;">
<div style="margin:10px;">
<div style="clear:both;">
<div style="margin:10px;">
<?php echo $LANG['LISTEDBELOWEXTERNAL'];?>
</div>
<?php echo $LANG['LISTEDBELOWEXTERNAL'];?>
</div>
<?php
if($taxaArray = $clManager->getTaxaList()){
?>
<div style="margin:20px;">
<style type="text/css">
#extvoucher-taxalist-div {
margin-bottom: 10px;
}
.extvoucher-label {
display: inline-block;
width: 150px;
text-align: right;
}
</style>
<script src="../js/symb/checklists.externalserviceapi.js"></script></script>
<?php
echo '<div id="extvoucher-taxalist-div">';
echo '<form action="externalvouchers.php?clid='.$clid.'&pid='.$pid.'" method="post">';
echo '<button type="submit">'.$LANG['SAVEEXTVOUCH'].'</button>';
$prevGroup = '';
foreach($taxaArray as $tid => $sppArr){
$group = $sppArr['taxongroup'];
if($group != $prevGroup){
$famUrl = '../taxa/index.php?taxauthid=1&taxon='.strip_tags($group).'&clid='.$clid;
//Edit family name display style here
?>
<div class="family-div" id="<?php echo strip_tags($group);?>">
<a href="<?php echo $famUrl; ?>" target="_blank" style="color:black;"><?php echo $group;?></a>
</div>
<?php
$prevGroup = $group;
<style type="text/css">
#extvoucher-taxalist-div {
margin-bottom: 10px;
}
$taxonWithDashes = str_replace(' ', '-', $sppArr['sciname']);
echo '<div class="taxon-container">';
echo '<a href="#" target="_blank" id="a-' . $taxonWithDashes . '" style="pointer-events:none;">';
echo '<label class="extvoucher-label" id="l-' . $taxonWithDashes . '">'.$sppArr['sciname'].' '.$sppArr["author"].'</label></a>&nbsp;';
?>
<input type="text" name="i-<?php echo $tid; ?>" id="i-<?php echo $taxonWithDashes; ?>" style="background-color:#E3E7EB">
<input type="hidden" name="<?php echo $tid; ?>" id="v-<?php echo $taxonWithDashes; ?>">
<span class="view-specimen-span printoff">
<a style="text-decoration: none;" onclick="retrieveVoucherInfo('<?php echo $taxonWithDashes; ?>')">
<?php echo (isset($LANG['LOOKUPEXT'])?$LANG['LOOKUPEXT']:'Lookup external vouchers'); ?>
</a>
</span>
<span id="r-<?php echo $taxonWithDashes; ?>"></span>
<?php
echo "</div>\n";
$scinameasid = str_replace(" ", "-", $sppArr['sciname']);
if($arrforexternalserviceapi == '') {
$arrforexternalserviceapi .= "'" . $scinameasid . "'";
} else {
$arrforexternalserviceapi .= ",'" . $scinameasid . "'";
.extvoucher-label {
display: inline-block;
width: 150px;
text-align: right;
}
}
echo '<button type="submit">'.$LANG['SAVEEXTVOUCH'].'</button>';
echo '</form>';
echo '</div>';
</style>
<script src="../js/symb/checklists.externalserviceapi.js"></script>
<div id="extvoucher-taxalist-div">
<form name="externalVoucherForm" action="voucheradmin.php" method="post">
<button type="submit"><?= $LANG['SAVEEXTVOUCH'] ?></button>
<?php
$prevGroup = '';
$arrForExternalServiceApi = '';
foreach($taxaArray as $tid => $sppArr){
$group = $sppArr['taxongroup'];
if($group != $prevGroup){
$famUrl = '../taxa/index.php?taxauthid=1&taxon='.strip_tags($group).'&clid='.$clid;
//Edit family name display style here
?>
<div class="family-div" id="<?php echo strip_tags($group);?>">
<a href="<?php echo $famUrl; ?>" target="_blank" style="color:black;"><?php echo $group;?></a>
</div>
<?php
$prevGroup = $group;
}
$taxonWithDashes = str_replace(' ', '-', $sppArr['sciname']);
echo '<div class="taxon-container">';
echo '<a href="#" target="_blank" id="a-' . $taxonWithDashes . '" style="pointer-events:none;">';
echo '<label class="extvoucher-label" id="l-' . $taxonWithDashes . '">' . $sppArr['sciname'] . ' ' . (isset($sppArr['author']) ? $sppArr['author'] : '') . '</label></a>&nbsp;';
?>
<input type="text" name="i-<?php echo $tid; ?>" id="i-<?php echo $taxonWithDashes; ?>" style="background-color:#E3E7EB">
<input type="hidden" name="<?php echo $tid; ?>" id="v-<?php echo $taxonWithDashes; ?>">
<span class="view-specimen-span printoff">
<a style="text-decoration: none;" onclick="retrieveVoucherInfo('<?php echo $taxonWithDashes; ?>')">
<?php echo (isset($LANG['LOOKUPEXT'])?$LANG['LOOKUPEXT']:'Lookup external vouchers'); ?>
</a>
</span>
<span id="r-<?php echo $taxonWithDashes; ?>"></span>
<?php
echo "</div>\n";
$scinameasid = str_replace(' ', '-', $sppArr['sciname']);
$arrForExternalServiceApi .= ($arrForExternalServiceApi ? ',' : '') . "'" . $scinameasid . "'";
}
?>
<input name="pid" type="hidden" value="<?= $pid ?>" >
<input name="clid" type="hidden" value="<?= $clid ?>" >
<button name="submitaction" type="submit" value="linkExternalVouchers"><?= $LANG['SAVEEXTVOUCH'] ?></button>
</form>
</div>
<?php
if(isset($dynamPropsArr) && $dynamPropsArr['externalservice'] == 'inaturalist') {
?>
<script>
<?php
echo 'const checklisttaxa = [' . $arrforexternalserviceapi . '];';
<?php
echo 'const checklisttaxa = [' . $arrForExternalServiceApi . '];';
echo 'const externalProjID = "' . ($dynamPropsArr['externalserviceid']?$dynamPropsArr['externalserviceid']:'') . '";';
echo 'const iconictaxon = "' . ($dynamPropsArr['externalserviceiconictaxon']?$dynamPropsArr['externalserviceiconictaxon']:'') . '";';
?>

// iNaturalist Integration
// Note: the two part request (...Page1 vs ...AdditionalPages) is performed
// to allow for a variable number of total results. There will always be a
// to allow for a variable number of total results. There will always be a
// first page, but there may be 0 or more additional pages. The answer is
// extracted from the response to the first ("Page1") fetch request.
fetchiNatPage1(externalProjID, iconictaxon)
Expand All @@ -140,7 +125,7 @@
.then(pagestwoplus => {
const taxalist2 = pagestwoplus.map(page => extractiNatTaxaIdAndName(page.results))
taxalist = taxalist1.concat(taxalist2.flat());
checklisttaxa.forEach( taxon => {
checklisttaxa.forEach( taxon => {
let anchortag = document.getElementById('a-'+taxon);
let txtboxtag = document.getElementById('i-'+taxon);
let labeltag = document.getElementById('l-'+taxon);
Expand All @@ -159,12 +144,17 @@
})
})
</script>
<?php } ?>
<?php
}
?>
</div>
</div>
</div>
</div>
<?php
}
<?php
}
else echo '<h2>'.$LANG['EMPTY_LIST'].'</h2>';
?>
</div>
</div>
</div>
<?php
}
?>
44 changes: 32 additions & 12 deletions checklists/voucheradmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
$clid = array_key_exists('clid', $_REQUEST) ? filter_var($_REQUEST['clid'], FILTER_SANITIZE_NUMBER_INT) : 0;
$pid = array_key_exists('pid', $_REQUEST) ? filter_var($_REQUEST['pid'], FILTER_SANITIZE_NUMBER_INT) : '';
$startPos = array_key_exists('start', $_REQUEST) ? filter_var($_REQUEST['start'], FILTER_SANITIZE_NUMBER_INT) : 0;
$excludeVouchers = !empty($_POST['excludevouchers']) && $_POST['excludevouchers'] ? 1 : 0;
$tabIndex = array_key_exists('tabindex', $_REQUEST) ? filter_var($_REQUEST['tabindex'], FILTER_SANITIZE_NUMBER_INT) : 0;
$action = array_key_exists('submitaction', $_REQUEST) ? $_REQUEST['submitaction'] : '';
$displayMode = (array_key_exists('displaymode', $_REQUEST) ? filter_var($_REQUEST['displaymode'], FILTER_SANITIZE_NUMBER_INT) : 0);
Expand All @@ -32,13 +33,31 @@
elseif($action == 'submitVouchers'){
$useCurrentTaxonomy = false;
if(array_key_exists('usecurrent',$_POST) && $_POST['usecurrent']) $useCurrentTaxonomy = true;
$linkVouchers = true;
if(array_key_exists('excludevouchers',$_POST) && $_POST['excludevouchers']) $linkVouchers = false;
$clManager->linkTaxaVouchers($_POST['occids'], $useCurrentTaxonomy, $linkVouchers);
$clManager->linkTaxaVouchers($_POST['occids'], $useCurrentTaxonomy, $excludeVouchers);
}
elseif($action == 'resolveconflicts'){
$clManager->batchTransferConflicts($_POST['occid'], (array_key_exists('removetaxa',$_POST) ? true : false));
}
elseif($action == 'linkExternalVouchers'){
$clManager->setClid($clid);
$cnt = 0;
foreach($_POST as $key => $value) {
if(substr($key, 0, 2) == 'i-') {
$tid = substr($key, 2);
if(is_numeric($tid) && !empty($_POST[$tid])) {
if($clManager->addExternalVouchers($tid, urldecode($_POST[$tid]))){
$cnt++;
}
else{
$statusStr .= $clManager->getErrorMessage().'<br>';
}
}
}
}
if($cnt){
$statusStr = $cnt.' external vouchers have been linked to checklist';
}
}
}
$clManager->setCollectionVariables();
$clMetaArr = $clManager->getClMetadata();
Expand Down Expand Up @@ -88,10 +107,12 @@
</div>
<?php
if($statusStr){
$textColor = 'green';
if(stripos($statusStr, 'ERROR') !== false) $textColor = 'red';
?>
<hr />
<div style="margin:20px;font-weight:bold;color:red;">
<?php echo $statusStr; ?>
<div style="margin:20px; font-weight:bold; color: <?= $textColor ?>;">
<?= $statusStr; ?>
</div>
<hr />
<?php
Expand Down Expand Up @@ -233,15 +254,14 @@
<div id="tabs" style="margin-top:25px;">
<ul>

<li><a href="nonvoucheredtab.php?clid=<?php echo $clid.'&pid='.$pid.'&start='.$startPos.'&displaymode='.$displayMode; ?>"><span><?php echo $LANG['NON_VOUCHERED'];?></span></a></li>
<li><a href="vamissingtaxa.php?clid=<?php echo $clid.'&pid='.$pid.'&start='.$startPos.'&displaymode='.($tabIndex==1?$displayMode:0).'&excludevouchers='.(isset($_POST['excludevouchers'])?$_POST['excludevouchers']:''); ?>"><span><?php echo $LANG['MISSINGTAXA'];?></span></a></li>
<li><a href="vaconflicts.php?clid=<?php echo $clid.'&pid='.$pid.'&start='.$startPos; ?>"><span><?php echo $LANG['VOUCHCONF'];?></span></a></li>
<?php
if($clManager->getAssociatedExternalService()) echo '<li><a href="externalvouchers.php?clid='.$clid.'&pid='.$pid.'"><span>' . $LANG['EXTVOUCH'] . '</span></a></li>';
<li><a href="nonvoucheredtab.php?clid=<?= $clid.'&pid='.$pid.'&start='.$startPos.'&displaymode='.$displayMode; ?>"><span><?= $LANG['NON_VOUCHERED'];?></span></a></li>
<li><a href="vamissingtaxa.php?clid=<?= $clid.'&pid='.$pid.'&start='.$startPos.'&displaymode='.($tabIndex==1?$displayMode:0).'&excludevouchers='.$excludeVouchers; ?>"><span><?= $LANG['MISSINGTAXA'];?></span></a></li>
<li><a href="vaconflicts.php?clid=<?= $clid.'&pid='.$pid.'&start='.$startPos; ?>"><span><?= $LANG['VOUCHCONF'];?></span></a></li>
<?php
if($clManager->getAssociatedExternalService()) echo '<li><a href="externalvouchers.php?clid='.$clid.'&pid='.$pid.'"><span>' . $LANG['EXTERNALVOUCHERS'] . '</span></a></li>';
if($clManager->hasVoucherProjects()) echo '<li><a href="imgvouchertab.php?clid='.$clid.'">'.(isset($LANG['ADDIMGV'])?$LANG['ADDIMGV']:'Add Image Voucher').'</a></li>';

?>
<li><a href="#reportDiv"><span><?php echo htmlspecialchars($LANG['REPORTS'], HTML_SPECIAL_CHARS_FLAGS);?></span></a></li>
<li><a href="#reportDiv"><span><?= $LANG['REPORTS'] ?></span></a></li>
</ul>
<div id="reportDiv">
<div style="margin:25px;height:400px;">
Expand Down
Loading

0 comments on commit 5f10daf

Please sign in to comment.