r73933 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r73932‎ | r73933 | r73934 >
Date:07:35, 29 September 2010
Author:nikerabbit
Status:ok
Tags:
Comment:
Rename and split hooks for clarity
Modified paths:
  • /trunk/extensions/Translate/Translate.php (modified) (history)
  • /trunk/extensions/Translate/tag/PageTranslationHooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/tag/PageTranslationHooks.php
@@ -303,23 +303,23 @@
304304 return true;
305305 }
306306
307 - // Here we disable editing of some existing or unknown pages
308 - public static function translationsCheck( $title, $user, $action, &$result ) {
309 - // Case 1: Unknown section translations
 307+ /// Prevent editing of unknown pages in Translations namespace
 308+ public static function preventUnknownTranslations( $title, $user, $action, &$result ) {
310309 if ( $title->getNamespace() == NS_TRANSLATIONS && $action === 'edit' ) {
311310 $group = self::titleToGroup( $title );
312311 if ( $group === null ) {
313312 // No group means that the page is currently not
314313 // registered to any page translation message groups
315314 $result = array( 'tpt-unknown-page' );
316 -
317315 return false;
318316 }
319 -
320 - return true;
321317 }
322318
323 - // Case 2: Target pages
 319+ return true;
 320+ }
 321+
 322+ /// Prevent editing of translation pages directly
 323+ public static function preventDirectEditing( $title, $user, $action, &$result ) {
324324 $page = TranslatablePage::isTranslationPage( $title );
325325 if ( $page !== false ) {
326326 if ( self::$allowTargetEdit ) {
Index: trunk/extensions/Translate/Translate.php
@@ -523,7 +523,9 @@
524524 $wgHooks['ArticleSaveComplete'][] = 'PageTranslationHooks::addTranstag';
525525
526526 // Prevent editing of unknown pages in Translations namespace
527 - $wgHooks['getUserPermissionsErrorsExpensive'][] = 'PageTranslationHooks::translationsCheck';
 527+ $wgHooks['getUserPermissionsErrorsExpensive'][] = 'PageTranslationHooks::preventUnknownTranslations';
 528+ // Prevent editing of translation pages directly
 529+ $wgHooks['getUserPermissionsErrorsExpensive'][] = 'PageTranslationHooks::preventDirectEditing';
528530
529531 // Locking during page moves
530532 $wgHooks['getUserPermissionsErrorsExpensive'][] = 'PageTranslationHooks::lockedPagesCheck';

Status & tagging log