Skip to content

Commit

Permalink
Merge pull request #312 from BioKIC/master
Browse files Browse the repository at this point in the history
Pull from biokic/Symbiota
  • Loading branch information
egbot authored Oct 10, 2022
2 parents fff2229 + 907c025 commit a286947
Show file tree
Hide file tree
Showing 60 changed files with 1,777 additions and 874 deletions.
96 changes: 69 additions & 27 deletions checklists/checklistadmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,25 @@
if(!$SYMB_UID) header('Location: ../profile/index.php?refurl=../checklists/checklistadmin.php?'.htmlspecialchars($_SERVER['QUERY_STRING'], ENT_QUOTES));

$clid = array_key_exists('clid',$_REQUEST)?$_REQUEST['clid']:0;
$pid = array_key_exists('pid',$_REQUEST)?$_REQUEST['pid']:'';
$pid = array_key_exists('pid',$_REQUEST)?$_REQUEST['pid']:0;
$targetClid = array_key_exists('targetclid',$_REQUEST)?$_REQUEST['targetclid']:0;
$transferMethod = array_key_exists('transmethod',$_POST)?$_POST['transmethod']:0;
$parentClid = array_key_exists('parentclid',$_REQUEST)?$_REQUEST['parentclid']:0;
$targetPid = array_key_exists('targetpid',$_REQUEST)?$_REQUEST['targetpid']:'';
$copyAttributes = array_key_exists('copyattributes',$_REQUEST)?$_REQUEST['copyattributes']:0;
$tabIndex = array_key_exists('tabindex',$_REQUEST)?$_REQUEST['tabindex']:0;
$action = array_key_exists('submitaction',$_REQUEST)?$_REQUEST['submitaction']:'';

//Sanitation
if(!is_numeric($clid)) $clid = 0;
if(!is_numeric($pid)) $pid = 0;
if(!is_numeric($targetClid)) $targetClid = 0;
if(!is_numeric($transferMethod)) $transferMethod = 0;
if(!is_numeric($parentClid)) $parentClid = '';
if(!is_numeric($targetPid)) $targetPid = 0;
if(!is_numeric($copyAttributes)) $copyAttributes = 0;
if(!is_numeric($tabIndex)) $tabIndex = 0;

$clManager = new ChecklistAdmin();
if(!$clid && isset($_POST['delclid'])) $clid = $_POST['delclid'];
$clManager->setClid($clid);
Expand All @@ -28,43 +43,66 @@
$isEditor = 0;
if($IS_ADMIN || (array_key_exists('ClAdmin',$USER_RIGHTS) && in_array($clid,$USER_RIGHTS['ClAdmin']))){
$isEditor = 1;

//Submit checklist MetaData edits
if($action == 'submitEdit'){
$clManager->editMetaData($_POST);
header('Location: checklist.php?clid='.$clid.'&pid='.$pid);
if($clManager->editChecklist($_POST)){
header('Location: checklist.php?clid='.$clid.'&pid='.$pid);
}
else{
$statusStr = $clManager->getErrorMessage();
}
}
elseif($action == 'DeleteCheck'){
$statusStr = $clManager->deleteChecklist($_POST['delclid']);
if($statusStr === true) header('Location: ../index.php');
elseif($action == 'deleteChecklist'){
$status = $clManager->deleteChecklist($_POST['delclid']);
if($status === true) header('Location: ../index.php');
echo $statusStr = $clManager->getErrorMessage();
}
elseif($action == 'Addeditor'){
elseif($action == 'addEditor'){
$statusStr = $clManager->addEditor($_POST['editoruid']);
}
elseif(array_key_exists('deleteuid',$_REQUEST)){
$statusStr = $clManager->deleteEditor($_REQUEST['deleteuid']);
}
elseif($action == 'AddToProject'){
elseif($action == 'addToProject'){
$statusStr = $clManager->addProject($_POST['pid']);
}
elseif($action == 'DeleteProject'){
elseif($action == 'deleteProject'){
$statusStr = $clManager->deleteProject($_POST['pid']);
}
elseif($action == 'Add Point'){
elseif($action == 'addPoint'){
$statusStr = $clManager->addPoint($_POST['pointtid'],$_POST['pointlat'],$_POST['pointlng'],$_POST['notes']);
}
elseif($action && array_key_exists('clidadd',$_POST)){
$statusStr = $clManager->addChildChecklist($_POST['clidadd']);
if(!$clManager->addChildChecklist($_POST['clidadd'])){
$statusStr = 'ERROR adding child checklist link';
}
}
elseif($action && array_key_exists('cliddel',$_GET)){
$statusStr = $clManager->deleteChildChecklist($_GET['cliddel']);
if(!$clManager->deleteChildChecklist($_GET['cliddel'])){
$statusStr = $clManager->getErrorMessage();
}
}
elseif($action == 'parseChecklist'){
$parseTid = 0;
if(array_key_exists('parsetid',$_POST) && is_numeric($_POST['parsetid'])) $parseTid = $_POST['parsetid'];
$taxon = '';
if(array_key_exists('taxon',$_POST)) $taxon = filter_var($_POST['taxon'], FILTER_SANITIZE_STRING);
$resultArr = $clManager->parseChecklist($parseTid, $taxon, $targetClid, $parentClid, $targetPid, $transferMethod, $copyAttributes);
if($resultArr){
$statusStr = '<div>Checklist parsed successfully!</div>';
if(isset($resultArr['targetPid'])){
$targetPid = $resultArr['targetPid'];
$statusStr .= '<div style="margin-left:15px"><a href="../projects/index.php?pid='.$targetPid.'" target="_blank">Target project</a></div>';
}
if(isset($resultArr['targetClid'])) $statusStr .= '<div style="margin-left:15px"><a href="checklist.php?clid='.$resultArr['targetClid'].'&pid='.$targetPid.'" target="_blank">Target checklist</a></div>';
if(isset($resultArr['parentClid'])){
$parentClid = $resultArr['parentClid'];
$statusStr .= '<div style="margin-left:15px"><a href="checklist.php?clid='.$resultArr['parentClid'].'&pid='.$targetPid.'" target="_blank">Parent checklist</a></div>';
}
}
}
}
$clArray = $clManager->getMetaData();
$defaultArr = array();
if(array_key_exists('defaultsettings',$clArray)){
$defaultArr = json_decode($clArray['defaultsettings'], true);
}
?>
<html>
<head>
Expand Down Expand Up @@ -137,23 +175,28 @@ function validateAddProjectForm(f){
</div>
<?php
if($statusStr){
$statusColor = 'green';
if(strpos($statusStr, 'ERROR') !== false) $statusColor = 'red';
?>
<hr />
<div style="margin:20px;font-weight:bold;color:red;">
<div style="margin:20px;font-weight:bold;color:<?php echo $statusColor;?>;">
<?php echo $statusStr; ?>
</div>
<hr />
<?php
}

if($clid && $isEditor){
$varBase = 'clid='.$clid.'&pid='.$pid;
$varChildren = $varBase.'&targetclid='.$targetClid.'&parentclid='.$parentClid.'&targetpid='.$targetPid.'&transmethod='.$transferMethod.'&copyattributes='.$copyAttributes;
?>
<div id="tabs" style="margin:10px;">
<ul>
<li><a href="#admintab"><span><?php echo $LANG['ADMIN'];?></span></a></li>
<li><a href="checklistadminmeta.php?clid=<?php echo $clid.'&pid='.$pid; ?>"><span><?php echo $LANG['DESCRIPTION'];?></span></a></li>
<!-- <li><a href="#pointtab"><span>Non-vouchered Points</span></a></li> -->
<li><a href="checklistadminchildren.php?clid=<?php echo $clid.'&pid='.$pid; ?>"><span><?php echo $LANG['RELATEDCHECK'];?></span></a></li>
<li><a href="checklistadminmeta.php?<?php echo $varBase; ?>"><span><?php echo $LANG['DESCRIPTION'];?></span></a></li>
<!-- <li><a href="#pointtab"><span>Non-vouchered Points</span></a></li> -->
<li><a href="checklistadminchildren.php?<?php echo $varChildren; ?>"><span><?php echo $LANG['RELATEDCHECK'];?></span></a></li>

<?php
if($clManager->hasVoucherProjects()) echo '<li><a href="imgvouchertab.php?clid='.$clid.'">'.(isset($LANG['ADDIMGVOUCHER'])?$LANG['ADDIMGVOUCHER']:'Add Image Voucher').'</a></li>';
?>
Expand Down Expand Up @@ -203,7 +246,7 @@ function validateAddProjectForm(f){
}
?>
</select>
<button name="submitaction" type="submit" value="Addeditor"><?php echo $LANG['ADDEDITOR'];?></button>
<button name="submitaction" type="submit" value="addEditor"><?php echo $LANG['ADDEDITOR'];?></button>
<input type="hidden" name="pid" value="<?php echo $pid; ?>" />
<input type="hidden" name="clid" value="<?php echo $clid; ?>" />
</div>
Expand All @@ -227,7 +270,7 @@ function validateAddProjectForm(f){
<form name="delProjectForm-<?php echo $pid; ?>" action="checklistadmin.php" method="post" onclick="return confirm(<?php echo $LANG['REMOVEPROJECTCONFIRM']; ?>);" title="<?php echo $LANG['REMOVEPROJECT'];?>" style="display:inline">
<input name="clid" type="hidden" value="<?php echo $clid; ?>" />
<input name="pid" type="hidden" value="<?php echo $pid; ?>" />
<input name="submitaction" type="hidden" value="DeleteProject" />
<input name="submitaction" type="hidden" value="deleteProject" />
<input name="submit" type="image" src="../images/drop.png" style="width:12px;" />
</form>
<?php
Expand Down Expand Up @@ -259,7 +302,7 @@ function validateAddProjectForm(f){
?>
</select>
<input name="clid" type="hidden" value="<?php echo $clid; ?>" />
<button name="submitaction" type="submit" value="AddToProject"><?php echo isset($LANG['SUBMIT'])?$LANG['SUBMIT']:'Submit';?></button>
<button name="submitaction" type="submit" value="addToProject"><?php echo isset($LANG['SUBMIT'])?$LANG['SUBMIT']:'Submit';?></button>
</form>
</fieldset>
<?php
Expand All @@ -278,8 +321,7 @@ function validateAddProjectForm(f){
<div style="margin:15px;">
<form name="deleteclform" action="checklistadmin.php" method="post" onsubmit="return window.confirm('<?php echo $LANG['CONFIRMDELETE'];?>')">
<input name="delclid" type="hidden" value="<?php echo $clid; ?>" />
<input name="submit" type="submit" value="<?php echo $LANG['DELETECHECK'];?>" <?php if($projArr || count($editorArr) > 1) echo 'DISABLED'; ?> />
<input type="hidden" name="submitaction" value="DeleteCheck" />
<button name="submitaction" type="submit" value="deleteChecklist" <?php if($projArr || count($editorArr) > 1) echo 'DISABLED'; ?>><?php echo $LANG['DELETECHECK'];?></button>
</form>
</div>
</div>
Expand Down Expand Up @@ -317,7 +359,7 @@ function validateAddProjectForm(f){
<input type="text" name="notes" style="width:95%" value="" />
</div>
<div>
<input name="submitaction" type="submit" value="Add Point" />
<button name="submitaction" type="submit" value="addPoint">Add Point</button>
<input type="hidden" name="tabindex" value="2" />
<input type="hidden" name="pid" value="<?php echo $pid; ?>" />
<input type="hidden" name="clid" value="<?php echo $clid; ?>" />
Expand Down
131 changes: 122 additions & 9 deletions checklists/checklistadminchildren.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,60 @@
include_once($SERVER_ROOT.'/classes/ChecklistAdmin.php');
@include_once($SERVER_ROOT.'/content/lang/checklists/checklistadminchildren.'.$LANG_TAG.'.php');

$clid = array_key_exists("clid",$_REQUEST)?$_REQUEST["clid"]:0;
$pid = array_key_exists("pid",$_REQUEST)?$_REQUEST["pid"]:"";
$clid = array_key_exists('clid',$_REQUEST)?$_REQUEST['clid']:0;
$pid = array_key_exists('pid',$_REQUEST)?$_REQUEST['pid']:'';
$targetClid = array_key_exists('targetclid',$_REQUEST)?$_REQUEST['targetclid']:'';
$transferMethod = array_key_exists('transmethod',$_REQUEST)?$_REQUEST['transmethod']:0;
$parentClid = array_key_exists('parentclid',$_REQUEST)?$_REQUEST['parentclid']:'';
$targetPid = array_key_exists('targetpid',$_REQUEST)?$_REQUEST['targetpid']:'';
$copyAttributes = array_key_exists('copyattributes',$_REQUEST)?$_REQUEST['copyattributes']:'';

//Sanitation
if(!is_numeric($clid)) $clid = 0;
if(!is_numeric($pid)) $pid = 0;
if(!is_numeric($targetClid)) $targetClid = 0;
if(!is_numeric($transferMethod)) $transferMethod = 0;
if(!is_numeric($parentClid)) $parentClid = '';
if(!is_numeric($targetPid)) $targetPid = 0;
if(!is_numeric($copyAttributes)) $copyAttributes = 0;

$clManager = new ChecklistAdmin();
$clManager->setClid($clid);

$clArr = $clManager->getUserChecklistArr();
$childArr = $clManager->getChildrenChecklist()
?>
<script src="../js/jquery-3.2.1.min.js?ver=3" type="text/javascript"></script>
<script src="../js/jquery-ui/jquery-ui.min.js?ver=3" type="text/javascript"></script>
<link href="../js/jquery-ui/jquery-ui.min.css" type="text/css" rel="Stylesheet" />
<script>
$("#taxon").autocomplete({
source: function( request, response ) {
$.getJSON( "<?php echo $CLIENT_ROOT; ?>/rpc/taxasuggest.php", { term: request.term }, response );
},
minLength: 3,
autoFocus: true,
select: function( event, ui ) {
if(ui.item){
$("#parsetid").val(ui.item.id);
}
}
});

function validateParseChecklistForm(){

}

function validateAddChildForm(f){

}
</script>
<style>
.section-div{ margin-bottom: 3px; }
#taxa{ width:400px }
#parsetid{ width:100px }
button{ margin:20px; }
</style>
<!-- inner text -->
<div id="innertext" style="background-color:white;">
<div style="float:right;">
Expand All @@ -33,15 +80,14 @@
<option value=""><?php echo (isset($LANG['SELECT_CHILD'])?$LANG['SELECT_CHILD']:'Select Child Checklist'); ?></option>
<option value="">-------------------------------</option>
<?php
$clArr = $clManager->getUserChecklistArr();
foreach($clArr as $k => $name){
echo '<option value="'.$k.'">'.$name.'</option>';
if(!isset($childArr[$k])) echo '<option value="'.$k.'">'.$name.'</option>';
}
?>
</select>
</div>
<div style="margin:10px;">
<button name="submitaction" type="submit" value="Add Child Checklist"><?php echo (isset($LANG['ADD_CHILD'])?$LANG['ADD_CHILD']:'Add Child Checklist'); ?></button>
<button name="submitaction" type="submit" value="addChildChecklist"><?php echo (isset($LANG['ADD_CHILD'])?$LANG['ADD_CHILD']:'Add Child Checklist'); ?></button>
<input name="clid" type="hidden" value="<?php echo $clid; ?>" />
<input name="pid" type="hidden" value="<?php echo $pid; ?>" />
<input name="tabindex" type="hidden" value="2" />
Expand All @@ -52,11 +98,11 @@
<div style="margin:15px;">
<ul>
<?php
if($childArr = $clManager->getChildrenChecklist()){
if($childArr){
foreach($childArr as $k => $cArr){
?>
<li>
<a href="checklist.php?clid=<?php echo $k; ?>"><?php echo $cArr['name']; ?></a>
<a href="checklist.php?clid=<?php echo $k; ?>" target="_blank"><?php echo $cArr['name']; ?></a>
<?php
if($cArr['pclid'] == $clid){
$confirmStr = (isset($LANG['SURE'])?$LANG['SURE']:'Are you sure you want to remove').$cArr['name'].(isset($LANG['AS_CHILD'])?$LANG['AS_CHILD']:'as a child checklist');
Expand All @@ -78,14 +124,13 @@
<div style="margin:30px 15px;font-weight:bold;font-size:120%;">
<u><?php echo (isset($LANG['PARENTS'])?$LANG['PARENTS']:'Parent Checklists'); ?></u>
</div>
<div style="margin:15px;">
<ul>
<?php
if($parentArr = $clManager->getParentChecklists()){
foreach($parentArr as $k => $name){
?>
<li>
<a href="checklist.php?clid=<?php echo $k; ?>"><?php echo $name; ?></a>
<a href="checklist.php?clid=<?php echo $k; ?>" target="_blank"><?php echo $name; ?></a>
</li>
<?php
}
Expand All @@ -96,4 +141,72 @@
?>
</ul>
</div>
<hr>
<div style="margin:20px 0px;">
<fieldset>
<legend>Batch Parse Species List</legend>
<div style="margin:10px 0px;">Use the following tool to parse a list into multiple children checklists based on taxonomic nodes (Liliopsida, Eudicots, Pinopsida, etc)</div>
<form name="parsechecklistform" target="checklistadmin.php" method="post" onsubmit="validateParseChecklistForm(this)">
<div class="section-div">
<label>Taxonomic node:</label>
<input id="taxon" name="taxon" type="text" required />
<input id="parsetid" name="parsetid" type="text" required >
</div>
<div class="section-div">
<label>Target checklist:</label>
<select name="targetclid" required>
<option value="">Select Target Checklist</option>
<option value="0">Create New Checklist</option>
<option value="">--------------------------</option>
<?php
foreach($clArr as $k => $name){
if(!isset($childArr[$k])) echo '<option value="'.$k.'" '.($targetClid == $k?'SELECTED':'').'>'.$name.'</option>';
}
?>
</select>
</div>
<div class="section-div">
<label>Transfer method:</label>
<input name="transmethod" type="radio" value="0" <?php if(!$transferMethod) echo 'checked'; ?>> transfer taxa
<input name="transmethod" type="radio" value="1" <?php if($transferMethod == 1) echo 'checked'; ?>> copy taxa
</div>
<div class="section-div">
<label>Link to parent checklist:</label>
<select name="parentclid">
<option value="">No Parent Checklist</option>
<option value="0" <?php if($parentClid === 0) echo 'SELECTED'; ?>>Create New Checklist</option>
<option value="">--------------------------</option>
<?php
foreach($clArr as $k => $name){
if(!isset($childArr[$k])) echo '<option value="'.$k.'" '.($parentClid == $k?'SELECTED':'').'>'.$name.'</option>';
}
?>
</select>
</div>
<div class="section-div">
<label>Add to project:</label>
<select name="targetpid">
<option value="">--no action--</option>
<option value="0">New Project</option>
<option value="">--------------------------</option>
<?php
$projArr = $clManager->getUserProjectArr();
foreach($projArr as $k => $name){
echo '<option value="'.$k.'" '.($targetPid == $k?'SELECTED':'').'>'.$name.'</option>';
}
?>
</select>
</div>
<div class="section-div">
<input name="copyattributes" type="checkbox" value="1" <?php if($copyAttributes) echo 'checked'; ?>>
<label>copy over permission and general attributes</label>
</div>
<div class="section-div">
<input name="tabindex" type="hidden" value="2" >
<button name="submitaction" type="submit" value="parseChecklist">Parse Checklist</button>
</div>
</form>
<div><a href="<?php echo $CLIENT_ROOT; ?>/taxa/taxonomy/taxonomydisplay.php" target="_blank">Open Taxonomic Thesaurus Explorer</a></div>
</fieldset>
</div>
</div>
Loading

0 comments on commit a286947

Please sign in to comment.