Skip to content
Permalink
Browse files

validate geocaches hide date; updates #898

  • Loading branch information...
following5 committed Sep 3, 2017
1 parent ffce1e2 commit 7238afeef441cd4a6be2ef7174021beaaf5543b6
@@ -94,6 +94,7 @@ function getWaypoints($cacheId)
`caches`.`name`,
`caches`.`type`,
`caches`.`size`,
`caches`.`date_created`,
`caches`.`date_hidden`,
`caches`.`date_activate`,
`caches`.`longitude`,
@@ -353,12 +354,44 @@ function getWaypoints($cacheId)
//check hidden_since
$hidden_date_not_ok = true;
$hidden_date_mismatch = false;
if (is_numeric($cache_hidden_day) && is_numeric($cache_hidden_month) &&
is_numeric($cache_hidden_year)
) {
$hidden_date_not_ok =
(checkdate($cache_hidden_month, $cache_hidden_day, $cache_hidden_year) == false);
}
if ($hidden_date_not_ok == false && $publish != 'notnow') {
$hidden_date = mktime(
0,
0,
0,
$cache_hidden_month,
$cache_hidden_day,
$cache_hidden_year
);
if ($status_old != 5) {
// the cache has already been published
$publish_date = strtotime(substr($cache_record['date_created'], 0, 10));
} elseif ($publish == 'later') {
// Activation hour can be ignored here. This simplifies checking event dates.
$publish_date = mktime(
0,
0,
0,
$cache_activate_month,
$cache_activate_day,
$cache_activate_year
);
} else {
// the cache is to be published now
$publish_date = time();
}
if (($cache_type == 6 && $hidden_date < $publish_date) ||
($cache_type != 6 && $hidden_date > $publish_date)) {
$hidden_date_mismatch = true;
}
}
//check date_activate
if ($status == 5) {
@@ -435,7 +468,8 @@ function getWaypoints($cacheId)
if (isset($_POST['submit'])) { // Ocprop
// all validations ok?
if (!(
$hidden_date_not_ok || $lat_not_ok || $lon_not_ok || $name_not_ok ||
$hidden_date_not_ok || $hidden_date_mismatch ||
$lat_not_ok || $lon_not_ok || $name_not_ok ||
$time_not_ok || $way_length_not_ok || $size_not_ok ||
$activate_date_not_ok || $status_not_ok || $diff_not_ok ||
$attribs_not_ok || $wpgc_not_ok
@@ -1074,7 +1108,15 @@ function getWaypoints($cacheId)
tpl_set_var('name_message', ($name_not_ok == true) ? $name_message : '');
tpl_set_var('lon_message', ($lon_not_ok == true) ? $coords_message : '');
tpl_set_var('lat_message', ($lat_not_ok == true) ? $coords_message : '');
tpl_set_var('date_message', ($hidden_date_not_ok == true) ? $date_message : '');
if ($hidden_date_mismatch == true) {
if ($cache_type == 6) {
tpl_set_var('date_message', $event_before_publish_message);
} else {
tpl_set_var('date_message', $hide_after_publish_message);
}
} else {
tpl_set_var('date_message', ($hidden_date_not_ok == true) ? $date_message : '');
}
tpl_set_var('size_message', ($size_not_ok == true) ? $sizemismatch_message : '');
tpl_set_var('wpgc_message', ($wpgc_not_ok == true) ? $bad_wpgc_message : '');
@@ -24,6 +24,8 @@
$error_general = "<tr><td class='error' colspan='2'><b>" . t('Some errors occurred, please check the marked fields.') . "</b></td></tr>";
$name_message = '&nbsp;<span class="errormsg">' . t('Cachename is invalid') . '</span>';
$date_message = '<span class="errormsg">' . t('date is invalid') . '</span>';
$hide_after_publish_message = '<span class="errormsg">' . t('The cache must be hidden before publish.') . '</span>';
$event_before_publish_message = '<span class="errormsg">' . t('The event must happen after publish.') . '</span>';
$coords_message = '<span class="errormsg">' . t('The used coordinates are invalid.') . '</span>';
$time_not_ok_message = '<span class="errormsg">' . t('The entered time is invalid.') . '</span>';
$way_length_not_ok_message = '<span class="errormsg">' . t('The distance you have entered is invalid. Format aa.aaa') . '</span>';
@@ -30,6 +30,8 @@
$time_not_ok_message = '<span class="errormsg">' . t('The entered time is invalid.') . '</span>';
$way_length_not_ok_message = '<span class="errormsg">' . t('The entered distance is invalid, Format: aa.aaa') . '</span>';
$date_not_ok_message = '<span class="errormsg">' . t('Invalid date, format:DD-MM-JJJJ') . '</span>';
$hide_after_publish_message = '<span class="errormsg">' . t('The cache must be hidden before publish.') . '</span>';
$event_before_publish_message = '<span class="errormsg">' . t('The event must happen after publish.') . '</span>';
$name_not_ok_message = '&nbsp;<span class="errormsg">' . t('Cachename is invalid') . '</span>';
$tos_not_ok_message = '<br/><span class="errormsg">' . t('The cache can only be adopted if you agree our terms of use.') . '</span>';
$type_not_ok_message = '&nbsp;<span class="errormsg">' . t('No cache-type is chosen.') . '</span>';
@@ -770,7 +770,6 @@
$error = true;
}
//check hidden_since
$hidden_date_not_ok = true;
if (is_numeric($hidden_day) && is_numeric($hidden_month) && is_numeric($hidden_year)) {
@@ -779,6 +778,23 @@
if ($hidden_date_not_ok) {
tpl_set_var('hidden_since_message', $date_not_ok_message);
$error = true;
} else if ($publish != 'notnow') {
$hidden_date = mktime(0, 0, 0, $hidden_month, $hidden_day, $hidden_year);
if ($publish == 'later') {
// Activation hour can be ignored here. This simplifies checking event dates.
$publish_date = mktime(0, 0, 0, $activate_month, $activate_day, $activate_year);
} else {
$publish_date = time();
}
if ($sel_type == 6 && $hidden_date < $publish_date) {
tpl_set_var('hidden_since_message', $event_before_publish_message);
$hidden_date_not_ok = true;
$error = true;
} elseif ($sel_type != 6 && $hidden_date > $publish_date) {
tpl_set_var('hidden_since_message', $hide_after_publish_message);
$hidden_date_not_ok = true;
$error = true;
}
}
//check GC waypoint
@@ -1953,3 +1953,5 @@ INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2656', 'as firs
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2657', 'after "%1"', '2017-08-20 19:30:00');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2658', 'as last picture', '2017-08-20 19:30:00');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2659', 'Recommendation', '2017-08-20 19:30:00');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2660', 'The cache must be hidden before publish.', '2017-08-20 19:30:00');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2661', 'The event must happen after publish.', '2017-08-20 19:30:00');
@@ -1951,3 +1951,5 @@ INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUE
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2657', 'DE', 'nach &bdquo;%1&ldquo;', '2017-08-20 19:30:00');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2658', 'DE', 'als letztes Bild', '2017-08-20 19:30:00');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2659', 'DE', 'Empfehlung', '2017-08-20 19:30:00');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2660', 'DE', 'Der Cache muss vor Veröffentlichung versteckt werden.', '2017-08-20 19:30:00');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2661', 'DE', 'Das Event muss nach der Cacheveröffentlichung stattfinden.', '2017-08-20 19:30:00');

0 comments on commit 7238afe

Please sign in to comment.
You can’t perform that action at this time.