/// * <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 (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);
}
$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'