$dbr = wfGetDB(DB_SLAVE);
$res = $dbr->select('wrreport', array('max(wrreport.id) as max'), array('page_title' => $page_title, 'condition is not null', 'date_invalid > now()'));
// select condition, date_report from wrreport where id = (select max(wrreport.id) as max from wrreport where page_title='Birgitzer Alm (vom Adelshof)' and date_invalid > now() and condition is not null);
- if ($res->numRows() <= 0) return array(NULL, NULL);
+ if ($res->numRows() <= 0) {
+ $dbr->freeResult($res);
+ return array(NULL, NULL);
+ }
$row = $dbr->fetchObject($res);
+ $dbr->freeResult($res);
$res = $dbr->select('wrreport', array('condition', 'date_report'), array('id' => $row->max));
- if ($res->numRows() <= 0) return array(NULL, NULL);
+ if ($res->numRows() <= 0) {
+ $dbr->freeResult($res);
+ return array(NULL, NULL);
+ }
$row = $dbr->fetchObject($res);
$date = $row->date_report;
if ($date) $date = strtotime($date);
+ $dbr->freeResult($res);
return array($row->condition, $date);
}
if (!$description) $errorMsg = utf8_encode('Bitte bei der Beschreibung eine kurze Begründung für die Bewertung abgeben.');
elseif (!(stripos($description, 'http') === FALSE)) $errorMsg = utf8_encode('Der Text "http" ist leider für nicht-angemeldete Benutzer nicht erlaubt, weil wir in der Vergangenheit Fälle hatten, bei denen externe Werbelinks automatisiert eingetragen wurden.');
}
+
+ // Chech whether identical reports are present
+ if (!$errorMsg) {
+ $dbr = wfGetDB(DB_SLAVE);
+ $sqlConditions = array('page_id' => $page_id, 'date_report' => $date_report, 'condition' => $condition, 'description' => $description, 'author_name' => $author_name);
+ $res = $dbr->select('wrreport', 'id', $sqlConditions);
+ if ($res->numRows() == 1) $errorMsg = utf8_encode('Der Rodelbahnbericht wurde bereits früher gespeichert.');
+ $dbr->freeResult($res);
+ }
+
+ // Show error if any
if ($errorMsg) {
$this->execute($par, 'preview', $errorMsg);
return;