Identical reports are checked and forbidden now. Closes ticket #31.
authorphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Wed, 3 Dec 2008 18:08:35 +0000 (18:08 +0000)
committerphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Wed, 3 Dec 2008 18:08:35 +0000 (18:08 +0000)
git-svn-id: http://www.winterrodeln.org/svn/servermediawiki/trunk/extensions/wrreport@337 7aebc617-e5e2-0310-91dc-80fb5f6d2477

wrreport.body.php

index c2994ede3ded4c7c3398dd5412ba8139ebe4800d..22d8d99b30b0c0bf8d9f162bf7e2705296bd8af4 100644 (file)
@@ -274,13 +274,21 @@ function wrReportConditionRender($page_title) {
        $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);
 }
 
@@ -553,6 +561,17 @@ class WrReport extends SpecialPage {
                                        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;