diff --git a/VIRTUAL_VACATION/vacation.pl b/VIRTUAL_VACATION/vacation.pl index 2df306a5..9bc87585 100644 --- a/VIRTUAL_VACATION/vacation.pl +++ b/VIRTUAL_VACATION/vacation.pl @@ -321,9 +321,14 @@ sub get_interval { sub already_notified { my ($to, $from) = @_; my $logger = get_logger(); + my $query; # delete old notifications - my $query = qq{DELETE vacation_notification.* FROM vacation_notification LEFT JOIN vacation ON vacation.email = vacation_notification.on_vacation WHERE on_vacation = ? AND notified = ? AND notified_at < vacation.activefrom}; + if ($db_type eq 'Pg') { + $query = qq{DELETE FROM vacation_notification USING vacation WHERE vacation.email = vacation_notification.on_vacation AND on_vacation = ? AND notified = ? AND notified_at < vacation.activefrom;}; + } else { # mysql + $query = qq{DELETE vacation_notification.* FROM vacation_notification LEFT JOIN vacation ON vacation.email = vacation_notification.on_vacation WHERE on_vacation = ? AND notified = ? AND notified_at < vacation.activefrom}; + } my $stm = $dbh->prepare($query); if (!$stm) { $logger->error("Could not prepare query (trying to delete old vacation notifications) :'$query' to: $to, from:$from"); @@ -353,7 +358,11 @@ sub already_notified { $interval = get_interval($to); if ($interval) { - $query = qq{SELECT NOW()-notified_at FROM vacation_notification WHERE on_vacation=? AND notified=?}; + if ($db_type eq 'Pg') { + $query = qq{SELECT extract( epoch from (NOW()-notified_at))::int FROM vacation_notification WHERE on_vacation=? AND notified=?}; + } else { # mysql + $query = qq{SELECT NOW()-notified_at FROM vacation_notification WHERE on_vacation=? AND notified=?}; + } $stm = $dbh->prepare($query) or panic_prepare($query); $stm->execute($to,$from) or panic_execute($query,"on_vacation='$to', notified='$from'"); my @row = $stm->fetchrow_array; diff --git a/edit.php b/edit.php index 1ee210f4..824abf33 100644 --- a/edit.php +++ b/edit.php @@ -45,7 +45,7 @@ $formconf = $handler->webformConfig(); authentication_require_role($formconf['required_role']); -if ($edit != '' || $formconf['early_init']) { +if ($new == 0 || $formconf['early_init']) { if (!$handler->init($edit)) { if (count($handler->errormsg) == 0) { # should never happen and indicates a bug in $handler->init() @@ -61,7 +61,7 @@ $form_fields = $handler->getStruct(); $id_field = $handler->getId_field(); if ($_SERVER['REQUEST_METHOD'] == "GET") { - if ($edit == '') { # new - prefill fields from URL parameters if allowed in $formconf['prefill'] + if ($new) { # new - prefill fields from URL parameters if allowed in $formconf['prefill'] if ( isset($formconf['prefill']) ) { foreach ($formconf['prefill'] as $field) { $prefillvalue = safeget($field, safesession("prefill:$table:$field")); @@ -116,7 +116,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { if (isset($formconf['hardcoded_edit']) && $formconf['hardcoded_edit']) { $values[$id_field] = $form_fields[$id_field]['default']; - } elseif ($edit != "") { + } elseif ($new == 0) { $values[$id_field] = $edit; } @@ -159,7 +159,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { } } - if ($edit != "") { + if ($new == 0) { header ("Location: " . $formconf['listview']); exit; } else { diff --git a/functions.inc.php b/functions.inc.php index 44e2aae4..f9a1144e 100644 --- a/functions.inc.php +++ b/functions.inc.php @@ -1282,6 +1282,7 @@ function db_connect ($ignore_errors = 0) { */ function db_get_boolean($bool) { if(! (is_bool($bool) || $bool == '0' || $bool == '1') ) { + error_log("Invalid usage of 'db_get_boolean($bool)'"); die("Invalid usage of 'db_get_boolean($bool)'"); } diff --git a/model/AliasHandler.php b/model/AliasHandler.php index f33b37ba..6275db9b 100644 --- a/model/AliasHandler.php +++ b/model/AliasHandler.php @@ -221,6 +221,10 @@ class AliasHandler extends PFAHandler { } else { $oldvalues = $old_ah->result(); + if (!isset($values['goto'])) { # no new value given? + $values['goto'] = $oldvalues['goto']; + } + if (!isset($values['on_vacation'])) { # no new value given? $values['on_vacation'] = $oldvalues['on_vacation']; } diff --git a/templates/list-virtual_mailbox.tpl b/templates/list-virtual_mailbox.tpl index 9042eb5e..9113dcc7 100644 --- a/templates/list-virtual_mailbox.tpl +++ b/templates/list-virtual_mailbox.tpl @@ -61,6 +61,8 @@