Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
johnvanbreda committed Jan 15, 2020
2 parents d0012e4 + dc75810 commit c752af9
Show file tree
Hide file tree
Showing 38 changed files with 1,069 additions and 301 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ before_script:
- .travis/postgres_setup.sh
# Enable the phpunit module in config.php (meaning initialise() is not tested)
- cp application/config/config.php.travis application/config/config.php
# Provide a config file for the rest_api and request_logging modules
# Provide a config file for the rest_api, spatial_index_builder and request_logging modules
- cp modules/rest_api/config/rest.php.travis modules/rest_api/config/rest.php
- cp modules/spatial_index_builder/config/spatial_index_builder.php.travis modules/spatial_index_builder/config/spatial_index_builder.php
- cp modules/request_logging/config/request_logging.example.php modules/request_logging/config/request_logging.php
# Downgrade to PHPUnit 5.7
- wget https://phar.phpunit.de/phpunit-5.7.phar
Expand Down
4 changes: 4 additions & 0 deletions application/config/sref_notations.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
'3109' => 'ETRS89 / Jersey Transverse Mercator',
'23030' => 'ED50 / UTM zone 30N',
'29902' => 'TM65 / Irish Grid',
'3006' => 'SWEREF99 TM / Swedish Transverse Mercator',
'3021' => 'RT90 2.5 gon v / Swedish Grid',
];

// Set the internally stored geoms to use spherical mercator projection.
Expand All @@ -45,6 +47,8 @@
'4326' => 5,
'4277' => 5,
'2169' => 0,
'3006' => 0,
'3021' => 0,
];

// provide a list of systems which translate x,y format into a proper Lat/Long format, and the default ouput format
Expand Down
4 changes: 2 additions & 2 deletions application/config/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@
*
* @var string
*/
$config['version'] = '3.0.1';
$config['version'] = '3.1.0';

/**
* Version release date.
*
* @var string
*/
$config['release_date'] = '2019-12-10';
$config['release_date'] = '2020-01-15';

/**
* Link to the code repository downloads page.
Expand Down
25 changes: 14 additions & 11 deletions application/helpers/spatial_ref.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,38 +27,41 @@ class spatial_ref {
/**
* Retrieves the metadata for all the supported spatial reference systems.
*
* @param boolean $refresh Set to true to force a full refresh, otherwise the result is cached.
* @param bool $refresh
* Set to true to force a full refresh, otherwise the result is cached.
*/
public static function system_metadata($refresh=false) {
public static function system_metadata($refresh = FALSE) {
$cacheId = 'spatial-ref-systems';
if ($refresh) {
$cache = Cache::instance();
$cache->delete($cacheId);
self::$system_metadata=false;
self::$system_metadata = FALSE;
}
if (self::$system_metadata === false) {
if (self::$system_metadata === FALSE) {
$latlong_systems = Kohana::config('sref_notations.lat_long_systems');
$cache = Cache::instance();
if ($cached = $cache->get($cacheId)) {
self::$system_metadata = $cached;
} else {
}
else {
self::$system_metadata = array();
// fetch any systems that are just declared as srids, with no notation module required
foreach (Kohana::config('sref_notations.sref_notations') as $code => $title) {
self::$system_metadata["EPSG:$code"] = array(
'title' => $title,
'srid' => $code,
// make a small assumption here, that a non-lat long system is going to be an x y grid of metres.
'treat_srid_as_x_y_metres' => !isset($latlong_systems[$code])
// make a small assumption here, that a non-lat long system is
// going to be an x y grid of metres.
'treat_srid_as_x_y_metres' => !isset($latlong_systems[$code]),
);
}
// Now look for any modules which extend the sref systems available
// Now look for any modules which extend the sref systems available.
foreach (Kohana::config('config.modules') as $path) {
$plugin = basename($path);
if (file_exists("$path/plugins/$plugin.php")) {
require_once("$path/plugins/$plugin.php");
if (function_exists($plugin.'_sref_systems')) {
$metadata = call_user_func($plugin.'_sref_systems');
require_once "$path/plugins/$plugin.php";
if (function_exists($plugin . '_sref_systems')) {
$metadata = call_user_func($plugin . '_sref_systems');
self::$system_metadata = array_merge(self::$system_metadata, $metadata);
}
}
Expand Down
28 changes: 16 additions & 12 deletions application/models/location.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,19 +238,23 @@ public function calcCentroid($boundary, $system = '4326') {
}

private static function getConvertedOptionValue($first, $second) {
return str_replace(array(',', ':'), array('&#44', '&#56'), $first) .
return str_replace(array(',', ':'), array('&#44', '&#58'), $first) .
":" .
str_replace(array(',', ':'), array('&#44', '&#56'), $second);
str_replace(array(',', ':'), array('&#44', '&#58'), $second);
}

/**
* Define a form that is used to capture a set of predetermined values that apply to every record during an import.
* Defines inputs required for values that apply to all imported records.
*
* Define a form that is used to capture a set of predetermined values that
* apply to every record during an import.
*/
public function fixed_values_form() {
$srefs = array();
$systems = spatial_ref::system_metadata();
foreach ($systems as $code => $metadata)
$srefs[] = self::getConvertedOptionValue($code, $metadata['title']);
public function fixedValuesForm() {
$srefs = [];
$systems = spatial_ref::system_list();
foreach ($systems as $code => $title) {
$srefs[] = self::getConvertedOptionValue($code, $title);
}

$location_types = array(":Defined in file");
$parent_location_types = array(":No filter");
Expand All @@ -265,28 +269,28 @@ public function fixed_values_form() {
'display' => 'Website',
'description' => 'Select the website to import records into.',
'datatype' => 'lookup',
'population_call' => 'direct:website:id:title'
'population_call' => 'direct:website:id:title',
),
'location:centroid_sref_system' => array(
'display' => 'Spatial Ref. System',
'description' => 'Select the spatial reference system used in this import file. Note, if you have a file with a mix of spatial reference systems then you need a ' .
'column in the import file which is mapped to the Location Spatial Reference System field containing the spatial reference system code.',
'datatype' => 'lookup',
'lookup_values'=>implode(',', $srefs)
'lookup_values' => implode(',', $srefs),
),
'location:location_type_id' => array(
'display' => 'Location Type',
'description' => 'Select the Location Type for all locations in this import file. Note, if you have a file with a mix of location type then you need a ' .
'column in the import file which is mapped to the Location Type field.',
'datatype' => 'lookup',
'lookup_values' => implode(',', $location_types)
'lookup_values' => implode(',', $location_types),
),
'fkFilter:location:location_type_id' => array(
'display' => 'Parent Location Type',
'description' => 'If this import file includes locations which reference parent locations records, you can restrict the type of parent locations looked ' .
'up by setting this location type. It is not currently possible to use a column in the file to do this on a location by location basis.',
'datatype' => 'lookup',
'lookup_values' => implode(',', $parent_location_types)
'lookup_values' => implode(',', $parent_location_types),
),
);
}
Expand Down
14 changes: 7 additions & 7 deletions application/models/occurrence.php
Original file line number Diff line number Diff line change
Expand Up @@ -570,32 +570,32 @@ private function _check_module_active($module) {
* * **occurrence_associations** - Set to 't' to enable occurrence associations options. The
* relevant warehouse module must also be enabled.
*/
public function fixed_values_form($options = array()) {
public function fixedValuesForm($options = array()) {
$srefs = array();
$systems = spatial_ref::system_list();
foreach ($systems as $code => $title) {
$srefs[] = str_replace(array(',', ':'), array('&#44', '&#56'), $code) .
$srefs[] = str_replace(array(',', ':'), array('&#44', '&#58'), $code) .
":" .
str_replace(array(',', ':'), array('&#44', '&#56'), $title);
str_replace(array(',', ':'), array('&#44', '&#58'), $title);
}

$sample_methods = array(":Defined in file");
$parent_sample_methods = array(":No filter");
$terms = $this->db->select('id, term')->from('list_termlists_terms')->where('termlist_external_key', 'indicia:sample_methods')->orderby('term', 'asc')->get()->result();
foreach ($terms as $term) {
$sample_method = str_replace(array(',', ':'), array('&#44', '&#56'), $term->id) .
$sample_method = str_replace(array(',', ':'), array('&#44', '&#58'), $term->id) .
":" .
str_replace(array(',', ':'), array('&#44', '&#56'), $term->term);
str_replace(array(',', ':'), array('&#44', '&#58'), $term->term);
$sample_methods[] = $sample_method;
$parent_sample_methods[] = $sample_method;
}

$locationTypes = array(":No filter");
$terms = $this->db->select('id, term')->from('list_termlists_terms')->where('termlist_external_key', 'indicia:location_types')->orderby('term', 'asc')->get()->result();
foreach ($terms as $term) {
$locationTypes[] = str_replace(array(',', ':'), array('&#44', '&#56'), $term->id) .
$locationTypes[] = str_replace(array(',', ':'), array('&#44', '&#58'), $term->id) .
":" .
str_replace(array(',', ':'), array('&#44', '&#56'), $term->term);
str_replace(array(',', ':'), array('&#44', '&#58'), $term->term);
}
$retVal = array(
'website_id' => array(
Expand Down
2 changes: 1 addition & 1 deletion application/models/sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ public function caption() {
/**
* Define a form that is used to capture a set of predetermined values that apply to every record during an import.
*/
public function fixed_values_form($options = array()) {
public function fixedValuesForm($options = array()) {
$srefs = array();
$systems = spatial_ref::system_list();
foreach ($systems as $code => $title)
Expand Down
2 changes: 1 addition & 1 deletion application/models/taxa_taxon_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ public function getDefaults() {
* Define a form that is used to capture a set of predetermined values that
* apply to every record during an import.
*/
public function fixed_values_form() {
public function fixedValuesForm() {
return array(
'taxa_taxon_list:taxon_list_id' => array(
'display' => 'Species List',
Expand Down
2 changes: 1 addition & 1 deletion application/models/termlists_term.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ public function getDefaults() {
/**
* Define a form that is used to capture a set of predetermined values that apply to every record during an import.
*/
public function fixed_values_form() {
public function fixedValuesForm() {
return array(
'termlists_term:termlist_id' => array(
'display' => 'Termlist',
Expand Down
3 changes: 2 additions & 1 deletion application/tests/helpers/vague_dateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ public function testVagueDateToString($from, $to, $type, $expected) {
public function provideStringToVagueDate() {
$year = date('Y');
$lastYear = $year - 1;
$lastDayInFeb = date('L') === '1' ? '29' : '28';
return [
'Date 1997-08-02' => ['1997-08-02', '1997-08-02', '1997-08-02', 'D'],
'Date 02/08/1997' => ['02/08/1997', '1997-08-02', '1997-08-02', 'D'],
Expand Down Expand Up @@ -269,7 +270,7 @@ public function provideStringToVagueDate() {
'Season Autumn 92' => ['Autumn 92', '1992-09-01', '1992-11-30', 'P'],
// Month only and season only years are always for the current year.
'Month only March' => ['March', "$year-03-01", "$year-03-31", 'M'],
'Season only Winter' => ['Winter', "$lastYear-12-01", "$year-02-28", 'S'],
'Season only Winter' => ['Winter', "$lastYear-12-01", "$year-02-$lastDayInFeb", 'S'],
'Season only Spring' => ['Spring', "$year-03-01", "$year-05-31", 'S'],
'Season only Summer' => ['Summer', "$year-06-01", "$year-08-31", 'S'],
'Season only Autumn' => ['Autumn', "$year-09-01", "$year-11-30", 'S'],
Expand Down
1 change: 0 additions & 1 deletion application/views/templates/template.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
);
echo html::script(
array(
'media/js/json2.js',
'media/js/jquery.js?v=3.2.1',
'media/js/jquery.url.js',
'media/js/fancybox/source/jquery.fancybox.pack.js',
Expand Down
50 changes: 49 additions & 1 deletion modules/attribute_sets/helpers/attribute_sets.php
Original file line number Diff line number Diff line change
Expand Up @@ -435,13 +435,61 @@ private static function deleteAttributesTaxonRestriction($db, $model) {
and aw.{$entity}_attribute_id=attla.{$entity}_attribute_id
and aw.deleted=false
where astr.deleted=false
and atr.{$entity}_attributes_website_id=atr.id
and atr.{$entity}_attributes_website_id=aw.id
and atr.restrict_to_taxon_meaning_id=astr.restrict_to_taxon_meaning_id
and coalesce(atr.restrict_to_stage_term_meaning_id, 0)=coalesce(astr.restrict_to_stage_term_meaning_id, 0)
);
SQL;
$db->query($qry);
}

// taxa_taxon_list_attributes do not use a website table so the above SQL does not work
// This code is a version of the above code for taxa_tax_list_attributes
$ttlQry = <<<SQL
update taxa_taxon_list_attribute_taxon_restrictions atr
set deleted=true, updated_on=now(), updated_by_id=$userId
from attribute_sets_taxon_restrictions astr
join attribute_sets_surveys ass
on ass.id=astr.attribute_sets_survey_id
join attribute_sets aset
on aset.id=ass.attribute_set_id
join attribute_sets_taxa_taxon_list_attributes asttla
on asttla.attribute_set_id=ass.attribute_set_id
join taxon_lists_taxa_taxon_list_attributes tlttla
on tlttla.taxon_list_id=aset.taxon_list_id
and tlttla.taxa_taxon_list_attribute_id=asttla.taxa_taxon_list_attribute_id
where (astr.deleted or ass.deleted or aset.deleted or asttla.deleted or tlttla.deleted)
and $alias.id=$model->id
and atr.taxon_lists_taxa_taxon_list_attribute_id=tlttla.id
and atr.restrict_to_taxon_meaning_id=astr.restrict_to_taxon_meaning_id
and coalesce(atr.restrict_to_stage_term_meaning_id, 0)=coalesce(astr.restrict_to_stage_term_meaning_id, 0)
and atr.deleted=false
and atr.id not in (
-- Exclude deletions for any restriction that is still valid because of
-- another attribute set.
select atr.id
from taxa_taxon_list_attribute_taxon_restrictions, attribute_sets_taxon_restrictions astr
join attribute_sets_surveys ass
on ass.id=astr.attribute_sets_survey_id
and ass.deleted=false
join attribute_sets aset
on aset.id=ass.attribute_set_id
and aset.deleted=false
join attribute_sets_taxa_taxon_list_attributes asttla
on asttla.attribute_set_id=ass.attribute_set_id
and asttla.deleted=false
join taxon_lists_taxa_taxon_list_attributes tlttla
on tlttla.taxon_list_id=aset.taxon_list_id
and tlttla.taxa_taxon_list_attribute_id=asttla.taxa_taxon_list_attribute_id
and tlttla.deleted=false
where astr.deleted=false
--AVB changed this in original code
and atr.taxon_lists_taxa_taxon_list_attribute_id=tlttla.id
and atr.restrict_to_taxon_meaning_id=astr.restrict_to_taxon_meaning_id
and coalesce(atr.restrict_to_stage_term_meaning_id, 0)=coalesce(astr.restrict_to_stage_term_meaning_id, 0)
);
SQL;
$db->query($ttlQry);
}

/**
Expand Down
23 changes: 12 additions & 11 deletions modules/auto_verify/config/auto_verify.php.example.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Indicia, the OPAL Online Recording Toolkit.
*
Expand All @@ -13,16 +14,16 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/gpl.html.
*
* @package Species Alerts
* @subpackage Config
* @author Indicia Team
* @license http://www.gnu.org/licenses/gpl.html GPL
* @link http://code.google.com/p/indicia/
* @author Indicia Team
* @license http://www.gnu.org/licenses/gpl.html GPL
* @link http://code.google.com/p/indicia/
*/

$config['auto_accept_occurrences_with_null_id_difficulty']='true';
// Note that -1 (or less) is unlimited, 0 processes nothing
$config['max_num_records_to_process_at_once']=0;
$config['oldest_record_created_date_to_process']='01/01/2000';
// 1 (or less) is effectively unlimited
$config['oldest_occurrence_id_to_process']=1;
$config['auto_accept_occurrences_with_null_id_difficulty'] = 'true';

// Note that -1 (or less) is unlimited, 0 processes nothing.
$config['max_num_records_to_process_at_once'] = 0;
$config['oldest_record_created_date_to_process'] = '01/01/2000';

// 1 (or less) is effectively unlimited.
$config['oldest_occurrence_id_to_process'] = 1;
Loading

0 comments on commit c752af9

Please sign in to comment.