Index: trunk/extensions/LiquidThreads/i18n/Lqt.i18n.php |
— | — | @@ -316,7 +316,6 @@ |
317 | 317 | // Tabs in skins |
318 | 318 | 'nstab-thread' => 'Thread', |
319 | 319 | 'nstab-summary' => 'Summary', |
320 | | - |
321 | 320 | ); |
322 | 321 | |
323 | 322 | /** Message documentation (Message documentation) |
Index: trunk/extensions/LiquidThreads/LiquidThreads.php |
— | — | @@ -128,6 +128,9 @@ |
129 | 129 | $wgHooks['OutputPageParserOutput'][] = 'LqtParserFunctions::onAddParserOutput'; |
130 | 130 | $wgHooks['OutputPageBeforeHTML'][] = 'LqtParserFunctions::onAddHTML'; |
131 | 131 | |
| 132 | +// Permissions |
| 133 | +$wgHooks['userCan'][] = 'LqtHooks::onGetUserPermissionsErrors'; |
| 134 | + |
132 | 135 | // Classes |
133 | 136 | $wgAutoloadClasses['LqtDispatch'] = $dir . 'classes/Dispatch.php'; |
134 | 137 | $wgAutoloadClasses['LqtView'] = $dir . 'classes/View.php'; |
Index: trunk/extensions/LiquidThreads/classes/Hooks.php |
— | — | @@ -760,4 +760,26 @@ |
761 | 761 | |
762 | 762 | $array[$title][] = $entry; |
763 | 763 | } |
| 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 | + } |
764 | 786 | } |