Add WrReportIntermapsValidDays configuration variable.
authorphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Sun, 22 Dec 2019 22:15:07 +0000 (22:15 +0000)
committerphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Sun, 22 Dec 2019 22:15:07 +0000 (22:15 +0000)
git-svn-id: http://www.winterrodeln.org/svn/servermediawiki/mediawiki_extensions/wrreport/trunk@2892 7aebc617-e5e2-0310-91dc-80fb5f6d2477

extension.json
wrreport_body.php

index 315a4fcbf4ca4c5870c99c8415d489d236b717b5..770c8bca01226b8722f491346f97c4cec0bc3027 100644 (file)
@@ -41,7 +41,8 @@
                "WrReportBlackListStrangers": [],
                "WrReportDeleteMode": "loggedin",
                "WrReportFeedRoot": "https://www.winterrodeln.org/feed",
-               "WrReportEnableIntermaps": true
+               "WrReportEnableIntermaps": true,
+               "WrReportIntermapsValidDays": 1
        },
        "ExtensionMessagesFiles": {
                "wrreportAlias": "wrreport.alias.php"
index 59443f94622f838473891a759c1dc5f03a55c6e8..e3d3e77cebb1af064c0bb475f785e6f2540cde33 100644 (file)
@@ -9,6 +9,7 @@
 //     $wgWrReportDeleteMode = 'loggedin'; // 'allow', 'loggedin', 'deny'
 //     $wgWrReportFeedRoot = 'https://www.winterrodeln.org/feed'; // root URL of the Winterrodeln feed without trailing slash
 //     $wgWrReportEnableIntermaps = true; // show Intermaps sledrun information column
+//     $wgWrReportIntermapsValidDays = 1; // number of days the last check of the Intermaps data may be in the past
 //
 //
 // The following tags are supported:
@@ -775,6 +776,7 @@ class WrReport {
                global $wgWrReportBlackListAll;
                global $wgWrReportBlackListStrangers;
                global $wgWrReportEnableIntermaps;
+               global $wgWrReportIntermapsValidDays;
 
                // Determine, whether the user is allowed to make a new report
                $userMayReport = ($wgWrReportMode == 'allow' || ($wgWrReportMode == 'loggedin' && $wgUser->isLoggedIn()));
@@ -799,6 +801,7 @@ class WrReport {
                $tr->appendElement('th')->appendText(wfMessage('wrreport-sledrun-length')->text());
 
                // Rows
+               $now = new DateTime();
                while ($row = $dbr->fetchObject($res)) {
                        $title = Title::newFromRow($row);
                        $tr = $table->appendElement('tr');
@@ -825,14 +828,17 @@ class WrReport {
                        if ($wgWrReportMode != 'summer' && $wgWrReportEnableIntermaps) {
                                $td = $tr->appendElement('td');
                                if ($row->show_status) {
-                                       if ($row->status == 'open') {
-                                               $msg = wfMessage('wrreport-icon-intermaps-open', $row->last_update)->text();
-                                               $td->appendElement('img', array('src' => '/vorlagen/s_open.png', 'alt' => $msg, 'title' => $msg));
-                                       } elseif ($row->status == 'closed') {
-                                               $msg = wfMessage('wrreport-icon-intermaps-closed', $row->last_update)->text();
-                                               $td->appendElement('img', array('src' => '/vorlagen/s_closed.png', 'alt' => $msg, 'title' => $msg));
-                                       } else {
-                                               $td->appendText($row->status);
+                                       $date_last_check = new DateTime($row->last_check);
+                                       if ($date_last_check->diff($now)->days <= $wgWrReportIntermapsValidDays) {
+                                               if ($row->status == 'open') {
+                                                       $msg = wfMessage('wrreport-icon-intermaps-open', $row->last_update)->text();
+                                                       $td->appendElement('img', array('src' => '/vorlagen/s_open.png', 'alt' => $msg, 'title' => $msg));
+                                               } elseif ($row->status == 'closed') {
+                                                       $msg = wfMessage('wrreport-icon-intermaps-closed', $row->last_update)->text();
+                                                       $td->appendElement('img', array('src' => '/vorlagen/s_closed.png', 'alt' => $msg, 'title' => $msg));
+                                               } else {
+                                                       $td->appendText($row->status);
+                                               }
                                        }
                                }
                        }