}
+/// Forces a regeneration of region overview pages
+function wrRecacheRegions() {
+ // TODO: Better implementation - it's a "quick fix" now.
+ $title = Title::newFromText('Tirol');
+ $title->invalidateCache();
+
+ $title = Title::newFromText('Vorarlberg');
+ $title->invalidateCache();
+
+ $title = Title::newFromText('Steiermark');
+ $title->invalidateCache();
+}
+
+
// Render Functions
// ----------------
$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 (in_array($parser->getTitle()->getText(), $wgWrReportBlackListAll)) return wrReportSandboxParse(utf8_encode("''Bei dieser Rodelbahn dürfen derzeit leider keine Rodelbahnberichte abgegeben werden.''\n"));
if (!$wgUser->isLoggedIn() && in_array($parser->getTitle()->getText(), $wgWrReportBlackListStrangers)) return wrReportSandboxParse(utf8_encode("''Bei der angegebenen Rodelbahn dürfen derzeit nur angemeldete Benutzer Rodelbahnberichte abgebe.''\n\n"));
- // Ok, we can render the form :-)
- // To prevent cache problems (old prefilled user names shown or old dates in the date list), caching is disabled when showing the form:
- $title = $parser->getTitle();
- $title->invalidateCache(); // I don't know if this helps because the caching is done _after_ the call of this function...
+ // Calling "$title = $parser->getTitle(); $title->invalidateCache();" doesn't help here to force regeneration
+ // However, this would not be the best solution because the page has to be re-rendered only at midnight
+
return replaceByMarker(wrReportFormRender(TRUE, $parser->getTitle()->getText(), NULL, NULL, NULL, $author_name));
}
// Purge cache
$title->invalidateCache();
+ wrRecacheRegions();
+
// Show success message
global $wrShowReportsSection;
$wgOut->addWikiText(utf8_encode('<div class="successbox">Der Bahnbericht für [[') . $row['page_title'] . '#' . $wrShowReportsSection . '|' . $row['page_title'] . utf8_encode("]] wurde erfolgreich gelöscht.</div>\n"));
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;
// Purge cache
$title->invalidateCache();
+ wrRecacheRegions();
+
// Show success message
global $wrShowReportsSection;
$wgOut->addWikiText(utf8_encode('<div class="successbox">Der Bahnbericht für [[') . $page_title . '#' . $wrShowReportsSection . '|' . $page_title . utf8_encode("]] wurde erfolgreich gespeichert.</div>\n"));