r76380 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76379‎ | r76380 | r76381 >
Date:06:24, 9 November 2010
Author:werdna
Status:deferred
Tags:
Comment:
Do not allow users to read threads on talkpages that they cannot read.
Modified paths:
  • /trunk/extensions/LiquidThreads/LiquidThreads.php (modified) (history)
  • /trunk/extensions/LiquidThreads/classes/Hooks.php (modified) (history)
  • /trunk/extensions/LiquidThreads/i18n/Lqt.i18n.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LiquidThreads/i18n/Lqt.i18n.php
@@ -316,7 +316,6 @@
317317 // Tabs in skins
318318 'nstab-thread' => 'Thread',
319319 'nstab-summary' => 'Summary',
320 -
321320 );
322321
323322 /** Message documentation (Message documentation)
Index: trunk/extensions/LiquidThreads/LiquidThreads.php
@@ -128,6 +128,9 @@
129129 $wgHooks['OutputPageParserOutput'][] = 'LqtParserFunctions::onAddParserOutput';
130130 $wgHooks['OutputPageBeforeHTML'][] = 'LqtParserFunctions::onAddHTML';
131131
 132+// Permissions
 133+$wgHooks['userCan'][] = 'LqtHooks::onGetUserPermissionsErrors';
 134+
132135 // Classes
133136 $wgAutoloadClasses['LqtDispatch'] = $dir . 'classes/Dispatch.php';
134137 $wgAutoloadClasses['LqtView'] = $dir . 'classes/View.php';
Index: trunk/extensions/LiquidThreads/classes/Hooks.php
@@ -760,4 +760,26 @@
761761
762762 $array[$title][] = $entry;
763763 }
 764+
 765+ // Do not allow users to read threads on talkpages that they cannot read.
 766+ public static function onGetUserPermissionsErrors( $title, $user, $action, &$result ) {
 767+ if ( $title->getNamespace() != NS_LQT_THREAD || $action != 'read' )
 768+ return true;
 769+
 770+ $thread = Threads::withRoot( new Article($title) );
 771+
 772+ if ( ! $thread )
 773+ return true;
 774+
 775+ $talkpage = $thread->article();
 776+
 777+ $canRead = $talkpage->getTitle()->userCan( 'read', false );
 778+
 779+ if ( $canRead ) {
 780+ return true;
 781+ } else {
 782+ $result = false;
 783+ return false;
 784+ }
 785+ }
764786 }

Status & tagging log