The tag <bahnbewertung/> shows the link to the new report form now dependent on wheth...
authorphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Sat, 1 Nov 2008 09:52:05 +0000 (09:52 +0000)
committerphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Sat, 1 Nov 2008 09:52:05 +0000 (09:52 +0000)
git-svn-id: http://www.winterrodeln.org/svn/servermediawiki/trunk/extensions/wrreport@305 7aebc617-e5e2-0310-91dc-80fb5f6d2477

wrreport.body.php
wrreport.php

index dbe485f21aa286d79d49680e91b51a4cfff38983..18ddb945a7fa5ca36d890ae6fc3f7b1246fb6df5 100644 (file)
@@ -252,14 +252,35 @@ function bahnberichteParserHook($input, $args, &$parser) {
 /// * <bahnbewertung/>: The current page name is taken.
 /// * <bahnbewertung>page_name</bahnbewertung>: The given page name is taken.
 function bahnbewertungParserHook($input, $args, &$parser) {
 /// * <bahnbewertung/>: The current page name is taken.
 /// * <bahnbewertung>page_name</bahnbewertung>: The given page name is taken.
 function bahnbewertungParserHook($input, $args, &$parser) {
-       if (!$input) $input = $parser->getTitle()->getText();
-       list($condition, $date) = wrReportConditionRender($input);
+       $titleText = $input;
+       if (!$titleText) $titleText = $parser->getTitle()->getText();
+       list($condition, $date) = wrReportConditionRender($titleText);
        if ($date) $date = strftime('%d.%m.', $date);
        global $wrConditions;
        global $wrNewReportSection; //  = utf8_encode('Eintragen');
        global $wrShowReportsSection; //  = utf8_encode('Einträge');
        if ($date) $date = strftime('%d.%m.', $date);
        global $wrConditions;
        global $wrNewReportSection; //  = utf8_encode('Eintragen');
        global $wrShowReportsSection; //  = utf8_encode('Einträge');
-       if (isset($wrConditions[$condition])) return wrReportSandboxParse('[['. $input . '#' . $wrShowReportsSection . '|'. $wrConditions[$condition] . "]] <small>$date ''[[" . $input . '#' . $wrNewReportSection . "|Neu]]''</small>");
-       return wrReportSandboxParse("<small>''[[" . $input . '#' . $wrNewReportSection . "|Bitte eintragen]]''</small>");
+       global $wgUser;
+       global $wgWrReportMode; // e.g. 'summer'
+       global $wgWrReportBlackListAll;
+       global $wgWrReportBlackListStrangers;
+
+       // Determine, whether the user is allowed to make a new report
+       $userMayReport = ($wgWrReportMode == 'allow' || ($wgWrReportMode == 'loggedin' && $wgUser->isLoggedIn()));
+       if ($userMayReport) {
+               if (in_array($titleText, $wgWrReportBlackListAll)) $userMayReport = false;
+               if (!$wgUser->isLoggedIn() && in_array($titleText, $wgWrReportBlackListStrangers)) $userMayReport = false;
+       }
+
+       // Get the condition and create the response wiki text
+       if (isset($wrConditions[$condition])) {
+               $wikiText = '[['. $titleText . '#' . $wrShowReportsSection . '|'. $wrConditions[$condition] . "]] <small>$date";
+               if ($userMayReport) $wikiText .= " ''[[" . $titleText . '#' . $wrNewReportSection . "|Neu]]''";
+               $wikiText .= "</small>";
+       } else {
+               if ($userMayReport) $wikiText = "<small>''[[" . $titleText . '#' . $wrNewReportSection . "|Bitte eintragen]]''</small>";
+               else $wikiText = '--';
+       }
+       return wrReportSandboxParse($wikiText);
 }
 
 
 }
 
 
index 143c5a2ea325d8355f8bd05f8462a6198fc47103..87ed382b3a403d09db6b312a0ce1b9443e5f38b1 100644 (file)
@@ -31,7 +31,7 @@ function wrReportLocalizedPageName(&$specialPageArray, $code) {
 
 $wgExtensionCredits['parserhook'][] = array(
        'name' => 'Winterrodeln Report',
 
 $wgExtensionCredits['parserhook'][] = array(
        'name' => 'Winterrodeln Report',
-       'version' => '0.2 alpha',
+       'version' => '0.3',
        'author' =>'Philipp Spitzer', 
        'url' => 'http://www.winterrodeln.org', 
        'description' => 'This extension interprets the <report/> tag in sledding pages and creates report summaries'
        'author' =>'Philipp Spitzer', 
        'url' => 'http://www.winterrodeln.org', 
        'description' => 'This extension interprets the <report/> tag in sledding pages and creates report summaries'