Skip to content

Commit

Permalink
Hotfix v.3.1.3 (#1821)
Browse files Browse the repository at this point in the history
* Hotfix v3.1.3 
- Adjusted hotfix merge instructions
- Inventory Management: Bug fix interfering with adding new editors to an inventory project
- Image migration modifications
-- Add option to copy over existing target files
-- Add checks and error handling for non-existent source files and already existing target files
-- Direct log files to be written to /content/logs/
- fix misspelled log directory name, with support still maintained for portals that already have the misspelled directory
- Fix jquery selector to be correct so button is enabled when trait is changed
- Misc language file and wording adjustments
  • Loading branch information
egbot authored Nov 4, 2024
1 parent db367a2 commit 258f4b9
Show file tree
Hide file tree
Showing 28 changed files with 183 additions and 52 deletions.
2 changes: 1 addition & 1 deletion checklists/checklist.php
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ function changeImageSource(elem){
foreach($clidArr as $id){
?>
<a href="#" onclick="return openPopup('clsppeditor.php?tid=<?php echo $tid . '&clid=' . $id; ?>','editorwindow');">
<img src='../images/edit.png' style='width:1.3em;' alt="<?php echo $LANG['IMG_EDIT_DETAILS']; ?>" title='<?php echo $LANG['EDIT_DETAILS']; ?>' />
<img src='../images/edit.png' style='width:1.3em;' alt="<?php echo $LANG['EDIT_DETAILS']; ?>" title='<?php echo $LANG['EDIT_DETAILS']; ?>' />
</a>
<?php
}
Expand Down
115 changes: 82 additions & 33 deletions classes/MediaResolutionTools.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class MediaResolutionTools extends Manager {
private $deleteOriginal = false;

//Image migration variables
private $collid;
private $collMetaArr;
private $transferThumbnail = false;
private $transferWeb = false;
Expand All @@ -23,14 +24,12 @@ class MediaResolutionTools extends Manager {
private $imgRootPath;
private $imgSubPath;
private $sourcePathPrefix;
private $copyOverExistingImages = false;

private $debugMode = false;

function __construct() {
parent::__construct(null,'write');
set_time_limit(600);
$this->verboseMode = 3;
$this->setLogFH('../../../temp/logs/imgMigration_'.date('Ym').'.log');
}

function __destruct(){
Expand All @@ -39,7 +38,12 @@ function __destruct(){

//Archiver functions
public function archiveImageFiles($imgidStart, $limit){
//Set stage
set_time_limit(1200);
$this->verboseMode = 3;
$logPath = $GLOBALS['SERVER_ROOT'] . '/content/logs/imageprocessing/';
if(!file_exists($logPath)) mkdir($logPath);
$logPath .= 'imgArchive_' . date('Ym') . '.log';
$this->setLogFH($logPath);
if(!$imgidStart) $imgidStart = 0;
if(!$this->imgidArr){
$this->logOrEcho('ABORTED: Image ids (imgid) not supplied');
Expand Down Expand Up @@ -165,8 +169,13 @@ private function archiveImage($imgFilePath, $imgid){

//Image migration functions
public function migrateFieldDerivatives($imgIdStart, $limit){
set_time_limit(1200);
$this->verboseMode = 3;
$logPath = $GLOBALS['SERVER_ROOT'] . '/content/logs/imageprocessing/';
if(!file_exists($logPath)) mkdir($logPath);
$logPath .= 'fieldDerivativeMigration_' . date('Ym') . '.log';
$this->setLogFH($logPath);
//Needs to be reworked
ini_set('max_execution_time', 3600);
$this->debugMode = true;
$imgId = 0;
if(is_numeric($limit) && is_numeric($this->collid) && $this->imgRootUrl && $this->imgRootPath){
Expand Down Expand Up @@ -249,7 +258,12 @@ public function migrateFieldDerivatives($imgIdStart, $limit){

public function migrateCollectionDerivatives($imgIdStart, $limit){
//Migrates images based on catalog number; NULL or weak catalogNumbers are skipped
ini_set('max_execution_time', 3600);
set_time_limit(1200);
$this->verboseMode = 3;
$logPath = $GLOBALS['SERVER_ROOT'] . '/content/logs/imageprocessing/';
if(!file_exists($logPath)) mkdir($logPath);
$logPath .= 'imgMigration_' . date('Ym') . '.log';
$this->setLogFH($logPath);
if($this->collid && is_numeric($limit) && $this->imgRootUrl && $this->imgRootPath){
if($this->transferThumbnail || $this->transferWeb || $this->transferLarge){
if($this->matchTermThumbnail || $this->matchTermWeb || $this->matchTermLarge){
Expand Down Expand Up @@ -294,53 +308,83 @@ public function migrateCollectionDerivatives($imgIdStart, $limit){
$targetPath = $this->imgRootPath.$pathFrag.$fileName;
$targetUrl = $this->imgRootUrl.$pathFrag.$fileName;
$thumbPath = $this->getLocalPath($r->thumbnailurl);
if(copy($thumbPath, $targetPath)){
$imgArr[$r->imgid]['tn'] = $targetUrl;
$this->logOrEcho('Copied: '.$thumbPath.' => '.$targetPath,1);
if($this->deleteSource){
if(unlink($thumbPath)){
$this->logOrEcho('Source deleted: '.$thumbPath,1);
}
else{
$this->logOrEcho('ERROR deleting source (file permissions?): '.$thumbPath,1);
if(file_exists($thumbPath)){
if($this->copyOverExistingImages || !file_exists($targetPath)){
if(copy($thumbPath, $targetPath)){
$imgArr[$r->imgid]['tn'] = $targetUrl;
$this->logOrEcho('Copied: '.$thumbPath.' => '.$targetPath,1);
if($this->deleteSource){
if(unlink($thumbPath)){
$this->logOrEcho('Source deleted: '.$thumbPath,1);
}
else{
$this->logOrEcho('ERROR deleting source (file permissions?): '.$thumbPath,1);
}
}
}
}
else{
$this->logOrEcho('Skipped: target file already exists (' . $targetPath . ')', 1);
}
}
else{
$this->logOrEcho('Skipped: source thumbnail does not exist (' . $thumbPath . ')', 1);
}
}
if($this->transferWeb && $r->url){
$fileName = basename($r->url);
$targetPath = $this->imgRootPath.$pathFrag.$fileName;
$targetUrl = $this->imgRootUrl.$pathFrag.$fileName;
$urlPath = $this->getLocalPath($r->url);
if(copy($urlPath, $targetPath)){
$imgArr[$r->imgid]['web'] = $targetUrl;
$this->logOrEcho('Copied: '.$urlPath.' => '.$targetPath,1);
if($this->deleteSource){
if(unlink($urlPath)){
$this->logOrEcho('Source delete: '.$urlPath,1);
}
else{
$this->logOrEcho('ERROR deleting source (file permissions?): '.$urlPath,1);
if(file_exists($urlPath)){
if($this->copyOverExistingImages || !file_exists($targetPath)){
if(copy($urlPath, $targetPath)){
$imgArr[$r->imgid]['web'] = $targetUrl;
$this->logOrEcho('Copied: '.$urlPath.' => '.$targetPath,1);
if($this->deleteSource){
if(unlink($urlPath)){
$this->logOrEcho('Source delete: '.$urlPath,1);
}
else{
$this->logOrEcho('ERROR deleting source (file permissions?): '.$urlPath,1);
}
}
}
}
else{
$this->logOrEcho('Skipped: target file already exists (' . $targetPath . ')', 1);
}
}
else{
$this->logOrEcho('Skipped: source file does not exist (' . $urlPath . ')', 1);
}
}
if($this->transferLarge && $r->originalurl){
$fileName = basename($r->originalurl);
$targetPath = $this->imgRootPath.$pathFrag.$fileName;
$targetUrl = $this->imgRootUrl.$pathFrag.$fileName;
$origPath = $this->getLocalPath($r->originalurl);
if(copy($origPath, $targetPath)){
$imgArr[$r->imgid]['lg'] = $targetUrl;
$this->logOrEcho('Copied: '.$origPath.' => '.$targetPath,1);
if($this->deleteSource){
if(unlink($origPath)){
$this->logOrEcho('Source deleted: '.$origPath,1);
}
else{
$this->logOrEcho('ERROR deleting source (file permissions?): '.$origPath,1);
if(file_exists($origPath)){
if($this->copyOverExistingImages || !file_exists($targetPath)){
if(copy($origPath, $targetPath)){
$imgArr[$r->imgid]['lg'] = $targetUrl;
$this->logOrEcho('Copied: '.$origPath.' => '.$targetPath,1);
if($this->deleteSource){
if(unlink($origPath)){
$this->logOrEcho('Source deleted: '.$origPath,1);
}
else{
$this->logOrEcho('ERROR deleting source (file permissions?): '.$origPath,1);
}
}
}
}
else{
$this->logOrEcho('Skipped: target file already exists (' . $targetPath . ')', 1);
}
}
else{
$this->logOrEcho('Skipped: source file does not exist (' . $origPath . ')', 1);
}
}
$processingCnt++;
Expand Down Expand Up @@ -567,5 +611,10 @@ public function setImgRootPath($url){
public function setImgSubPath($path){
$this->imgSubPath = $path;
}

public function setCopyOverExistingImages($bool){
if($bool) $this->copyOverExistingImages = true;
else $this->copyOverExistingImages = false;
}
}
?>
2 changes: 1 addition & 1 deletion classes/SpecProcessorManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ public function downloadReportData($target){
public function getLogListing(){
$retArr = array();
if($this->collid){
$dirArr = array('imgProccessing','cyverse','iplant','processing/imgmap');
$dirArr = array('imageprocessing','imgProccessing','cyverse','iplant','processing/imgmap');
foreach($dirArr as $dirPath){
if(file_exists($this->logPath.$dirPath)){
if($fh = opendir($this->logPath.$dirPath)){
Expand Down
2 changes: 1 addition & 1 deletion collections/admin/importextended.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ function importTypeChanged(selectElement){
<?= $LANG['INSTRUCTIONS'] ?>:
<ul>
<li><a href="https://biokic.github.io/symbiota-docs/coll_manager/upload/links" target="_blank"><?= $LANG['ASSOCIATIONS'] ?></a></li>
<?php if($IS_ADMIN) echo '<li><a href="https://biokic.github.io/symbiota-docs/coll_manager/upload/determinations" target="_blank">'.$LANG['DETERMINATIONS'].'</a></li>'; ?>
<?php if($IS_ADMIN) echo '<li><a href="https://biokic.github.io/symbiota-docs/portal_manager/determinations" target="_blank">'.$LANG['DETERMINATIONS'].'</a></li>'; ?>
<li><a href="https://biokic.github.io/symbiota-docs/coll_manager/images/url_upload" target="_blank"><?= $LANG['IMAGE_URLS'] ?></a></li>
</ul>
</div>
Expand Down
2 changes: 1 addition & 1 deletion collections/map/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ function buildTaxaLegend() {
taxaHtml += "<div style='display:table;'>";
prev_family = taxa.family;
}
const sn_link = `<a target="_blank" href="${taxa.origin}/taxa/index.php?tid=${taxa.tid}">${taxa.sn}</a>`;
const sn_link = `<a target="_blank" href="${taxa.origin? taxa.origin: '<?= $CLIENT_ROOT ?>'}/taxa/index.php?tid=${taxa.tid}">${taxa.sn}</a>`;
taxaHtml += legendRow(`taxa-${taxa.id_map.map(id => `${id.index}*${id.tid}`).join(",")}`, taxa.color, sn_link);
}

Expand Down
2 changes: 1 addition & 1 deletion collections/map/rpc/searchCollections.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

$host = false;
if(isset($SERVER_HOST)) {
$host = (str_contains($SERVER_HOST, '127.0.0.1') || str_contains($SERVER_HOST, 'localhost')? "http://": "https://") . $SERVER_HOST . $CLIENT_ROOT;
$host = ((str_contains($SERVER_HOST, '127.0.0.1') || str_contains($SERVER_HOST, 'localhost'))? "http://": "https://") . $SERVER_HOST . $CLIENT_ROOT;
}

foreach ($coordArr as $collName => $coll) {
Expand Down
2 changes: 1 addition & 1 deletion collections/search/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@
<input type="text" name="catnum" id="catnum" data-chip="<?php echo $LANG['CATALOG_NUMBER'] ?>" />
<span class="inset-input-label"><?php echo $LANG['CATALOG_NUMBER'] ?></span>
</label>
<span class="assistive-text"><?php echo $LANG['SEPARATE_MULTIPLE_W_COMMA'] ?></span>
<span class="assistive-text"><?php echo $LANG['SEPARATE_MULTIPLE_W_COMMA_DASH'] ?></span>
</div>
</div>
<div>
Expand Down
3 changes: 2 additions & 1 deletion collections/specprocessor/imageprocessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,8 @@ function validateFileUploadForm(f){
$logPath = '../../content/logs/';
foreach($logArr as $logCat => $logList){
echo '<div style="font-weight:bold;margin: 10px 0px 5px 0px">';
if($logCat=='imgProccessing') echo $LANG['GEN_PROCESSING'];
if($logCat=='imageprocessing') echo $LANG['GEN_PROCESSING'];
elseif($logCat=='imgProccessing') echo $LANG['GEN_PROCESSING'];
elseif($logCat=='iplant') echo $LANG['IPLANT'];
elseif($logCat=='cyverse') echo $LANG['CYVERSE'];
elseif($logCat=='processing/imgmap') echo $LANG['IMG_MAP_FILE'];
Expand Down
2 changes: 1 addition & 1 deletion collections/specprocessor/processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
$imageProcessor = new ImageLocalProcessor();

$imageProcessor->setLogMode(3);
$logPath = $SERVER_ROOT.(substr($SERVER_ROOT,-1) == '/'?'':'/').'content/logs/imgProccessing';
$logPath = $SERVER_ROOT . (substr($SERVER_ROOT, -1) == '/' ? '' : '/') . 'content/logs/imageprocessing';
if(!file_exists($logPath)) mkdir($logPath);
$imageProcessor->setLogPath($logPath);
$logFile = $collid.'_'.$specManager->getInstitutionCode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
$imgRootUrl = (array_key_exists('imgRootUrl', $_POST)?$_POST['imgRootUrl']:'');
$imgRootPath = (array_key_exists('imgRootPath', $_POST)?$_POST['imgRootPath']:'');
$imgSubPath = (array_key_exists('imgSubPath', $_POST)?$_POST['imgSubPath']:'');
$copyover = (!empty($_POST['copyover']) ? 1 : 0);
$submit = (array_key_exists('submitbutton', $_POST)?$_POST['submitbutton']:'');

//Sanitation
Expand Down Expand Up @@ -107,6 +108,7 @@ function verifyMigrationCode(f){
$toolManager->setImgRootUrl($imgRootUrl);
$toolManager->setImgRootPath($imgRootPath);
$toolManager->setImgSubPath($imgSubPath);
$toolManager->setCopyOverExistingImages($copyover);
if($collid) $imgIdStart = $toolManager->migrateCollectionDerivatives($imgIdStart, $limit);
else $imgIdStart = $toolManager->migrateFieldDerivatives($imgIdStart, $limit);
?>
Expand Down Expand Up @@ -287,6 +289,12 @@ function verifyMigrationCode(f){
</div>
</fieldset>
</div>
<div class="fieldRowDiv">
<div class="fieldDiv">
<input type="checkbox" name="copyover" value="1" <?= ($copyover ? 'checked' : '') ?>>
<span class="fieldLabel">copyover existing target images</span>
</div>
</div>
<div class="fieldRowDiv">
<div class="fieldDiv">
<span class="fieldLabel">imgId start:</span>
Expand Down
2 changes: 1 addition & 1 deletion config/symbbase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
header('X-Frame-Options: DENY');
header('Cache-control: private'); // IE 6 FIX
date_default_timezone_set('America/Phoenix');
$CODE_VERSION = '3.1.2';
$CODE_VERSION = '3.1.3';

set_include_path(get_include_path() . PATH_SEPARATOR . $SERVER_ROOT . PATH_SEPARATOR . $SERVER_ROOT.'/config/' . PATH_SEPARATOR . $SERVER_ROOT.'/classes/');

Expand Down
1 change: 1 addition & 0 deletions content/lang/collections/map/index.en.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
$LANG['RESET'] = 'Reset';
$LANG['SEARCH'] = 'Search';
$LANG['TAXA'] = 'Taxa';
$LANG['WITHIN'] = 'within';
$LANG['SHAPE_TOOLS'] = 'Use the shape tools on the map to select occurrences within a given shape';
$LANG['WITHIN_POLYGON'] = 'Within the selected polygon';
$LANG['WITHIN_CIRCLE'] = 'Within the selected circle';
Expand Down
3 changes: 3 additions & 0 deletions content/lang/collections/map/index.es.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
------------------
Language: Español (Spanish)
Translated by: Samanta Orellana
Edited by: Katie Pearson
Date Translated: 2021-06-23
Date Edited: 2024-10-22
------------------
*/
include_once($SERVER_ROOT.'/content/lang/collections/harvestparams.es.php');
Expand All @@ -16,6 +18,7 @@
$LANG['RESET'] = 'Reiniciar';
$LANG['SEARCH'] = 'Buscar';
$LANG['TAXA'] = 'Taxa';
$LANG['WITHIN'] = ''; //empty because correct phrasing is "a _ de mí"
$LANG['SHAPE_TOOLS'] = 'Use las herramientas de formas sobre el mapa para seleccionar los registros dentro de dicha forma';
$LANG['WITHIN_POLYGON'] = 'Dentro del polígono seleccionado';
$LANG['WITHIN_CIRCLE'] = 'Dentro del círculo seleccionado';
Expand Down
1 change: 1 addition & 0 deletions content/lang/collections/map/index.fr.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
$LANG['RESET'] = 'Réinitialiser';
$LANG['SEARCH'] = 'Recherche';
$LANG['TAXA'] = 'Taxa';
$LANG['WITHIN'] = 'à moins de';
$LANG['SHAPE_TOOLS'] = 'Utilisez les outils de forme sur la carte pour sélectionner des occurrences dans une forme donnée';
$LANG['WITHIN_POLYGON'] = 'Dans le polygone sélectionné';
$LANG['WITHIN_CIRCLE'] = 'Dans le cercle sélectionné';
Expand Down
2 changes: 2 additions & 0 deletions content/lang/collections/map/index.pt.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
------------------
*/
include_once($SERVER_ROOT.'/content/lang/collections/harvestparams.pt.php');
include_once('mapshared.pt.php');

$LANG['SEARCH_CRITERIA'] = 'Critérios de Pesquisa';
$LANG['CRITERIA'] = 'Critérios';
Expand All @@ -15,6 +16,7 @@
$LANG['RESET'] = 'Redefinir';
$LANG['SEARCH'] = 'Pesquisar';
$LANG['TAXA'] = 'Taxa';
$LANG['WITHIN'] = ''; //empty because correct phrasing is "a _ de mim"
$LANG['SHAPE_TOOLS'] = 'Use as ferramentas de forma no mapa para selecionar ocorrências dentro de uma determinada forma';
$LANG['WITHIN_POLYGON'] = 'Dentro do polígono selecionado';
$LANG['WITHIN_CIRCLE'] = 'Dentro do círculo selecionado';
Expand Down
17 changes: 17 additions & 0 deletions content/lang/collections/map/mapshared.pt.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
/*
------------------
Language: Português (Portuguese)
Translated by: Google Translate
Date Translated: 2024-10-22
------------------
*/
$LANG['LATITUDE'] = 'Latitude';
$LANG['LONGITUDE'] = 'Longitude';

$LANG['COLLECTION'] = 'Coleção';
$LANG['OBSERVATION'] = 'Observação';

$LANG['DECIMAL'] = 'Decimal';
$LANG['DEGREE'] = 'Grau';
?>
3 changes: 2 additions & 1 deletion content/lang/collections/search/index.en.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
$LANG['INCLUDE_CATA_NUM_GUIDs'] = 'Include other catalog numbers and GUIDs';
$LANG['CATALOG_NUMBER'] = 'Catalog Number';
$LANG['SEPARATE_MULTIPLE_W_COMMA'] = 'Separate multiple with commas.';
$LANG['SEPARATE_MULTIPLE_W_COMMA_DASH'] = 'Separate multiple with commas or provide ranges with a dash.';
$LANG['LIMIT_TO_SPECIMENS_W_IMAGES'] = 'Limit to specimens with images';
$LANG['LIMIT_TO_SPECIMENS_W_GENETIC_DATA'] = 'Limit to specimens with genetic data';
$LANG['LOCALITY'] = 'Locality';
Expand Down Expand Up @@ -87,7 +88,7 @@
$LANG['ONLY_WITH_IMAGES'] = 'Only with images';
$LANG['ONLY_WITH_GENETIC'] = 'Only with genetic';
$LANG['ONLY_WITH_COORDINATES'] = 'Only with coordinates';
$LANG['INCLUDE_CULTIVATED'] = 'Include cultivated';
$LANG['INCLUDE_CULTIVATED'] = 'Include cultivated/captive';
$LANG['MIN_ELEVATION'] = 'Min Elevation';
$LANG['MAX_ELEVATION'] = 'Max Elevation';
$LANG['UPPER_LAT'] = 'Upper Lat';
Expand Down
1 change: 1 addition & 0 deletions content/lang/collections/search/index.es.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
$LANG['INCLUDE_CATA_NUM_GUIDs'] = 'Incluir otros números de catálogo y GUID';
$LANG['CATALOG_NUMBER'] = 'Número de catálogo';
$LANG['SEPARATE_MULTIPLE_W_COMMA'] = 'Separar varios con comas.';
$LANG['SEPARATE_MULTIPLE_W_COMMA_DASH'] = 'Separe números múltiples con comas o proporcione rangos con un guión.';
$LANG['LIMIT_TO_SPECIMENS_W_IMAGES'] = 'Limitar a especímenes con imágenes';
$LANG['LIMIT_TO_SPECIMENS_W_GENETIC_DATA'] = 'Limitar a especímenes con datos genéticos';
$LANG['LOCALITY'] = 'Localidad';
Expand Down
Loading

0 comments on commit 258f4b9

Please sign in to comment.