Index: trunk/extensions/Translate/tag/PageTranslationHooks.php |
— | — | @@ -370,20 +370,41 @@ |
371 | 371 | $result = array( 'tpt-unknown-page' ); |
372 | 372 | return false; |
373 | 373 | } |
374 | | - $priorityLangs = TranslateMetadata::get( $handle->getGroup()->getId() , 'prioritylangs' ); |
375 | | - $priorityForce = TranslateMetadata::get( $handle->getGroup()->getId() , 'priorityforce' ); |
376 | | - if ( strlen( $priorityLangs ) > 0 && $priorityForce ) { |
377 | | - $filter = array_flip( explode ( ',', $priorityLangs ) ); |
378 | | - if ( count( $filter ) > 0 && !isset( $filter[$handle->getCode()] ) ) { |
379 | | - $result = array( 'tpt-translation-restricted' ); |
380 | | - return false; |
381 | | - } |
382 | | - } |
383 | 374 | } |
384 | 375 | return true; |
385 | 376 | } |
386 | 377 | |
387 | 378 | /** |
| 379 | + * Prevent editing of restricted languages |
| 380 | + * Hook: getUserPermissionsErrorsExpensive |
| 381 | + * @since 2012-03-01 |
| 382 | + */ |
| 383 | + public static function preventRestrictedTranslations( Title $title, User $user, $action, &$result ) { |
| 384 | + $handle = new MessageHandle( $title ); |
| 385 | + if ( !$handle->isValid() ) { |
| 386 | + return true; |
| 387 | + } |
| 388 | + |
| 389 | + $groupId = $handle->getGroup()->getId(); |
| 390 | + $priorityForce = TranslateMetadata::get( $groupId, 'priorityforce' ); |
| 391 | + if ( !$priorityForce ) { |
| 392 | + return true; |
| 393 | + } |
| 394 | + |
| 395 | + $priorityLangs = TranslateMetadata::get( $groupId, 'prioritylangs' ); |
| 396 | + $priorityReason = TranslateMetadata::get( $groupId, 'priorityreason' ); |
| 397 | + $filter = array_flip( explode( ',', $priorityLangs ) ); |
| 398 | + if ( !isset( $filter[$handle->getCode()] ) ) { |
| 399 | + $result = array( 'tpt-translation-restricted', $priorityReason ); |
| 400 | + return false; |
| 401 | + } |
| 402 | + |
| 403 | + return true; |
| 404 | + } |
| 405 | + |
| 406 | + |
| 407 | + |
| 408 | + /** |
388 | 409 | * Prevent editing of translation pages directly. |
389 | 410 | * Hook: getUserPermissionsErrorsExpensive |
390 | 411 | */ |
Index: trunk/extensions/Translate/TranslateHooks.php |
— | — | @@ -118,6 +118,8 @@ |
119 | 119 | |
120 | 120 | // Prevent editing of unknown pages in Translations namespace |
121 | 121 | $wgHooks['getUserPermissionsErrorsExpensive'][] = 'PageTranslationHooks::preventUnknownTranslations'; |
| 122 | + // Prevent editing of translation in restricted languages |
| 123 | + $wgHooks['getUserPermissionsErrorsExpensive'][] = 'PageTranslationHooks::preventRestrictedTranslations'; |
122 | 124 | // Prevent editing of translation pages directly |
123 | 125 | $wgHooks['getUserPermissionsErrorsExpensive'][] = 'PageTranslationHooks::preventDirectEditing'; |
124 | 126 | |
Index: trunk/extensions/Translate/PageTranslation.i18n.php |
— | — | @@ -97,7 +97,9 @@ |
98 | 98 | This page is a translation of page [[$1]] and the translation can be updated using [$2 the translation tool].', |
99 | 99 | 'tpt-unknown-page' => 'This namespace is reserved for content page translations. |
100 | 100 | The page you are trying to edit does not seem to correspond any page marked for translation.', |
101 | | - 'tpt-translation-restricted' => 'Translation of this message group to this language has been prevented by translation administrator.', |
| 101 | + 'tpt-translation-restricted' => 'Translation of this message group to this language has been prevented by translation administrator. |
| 102 | + |
| 103 | +Reason for limiting: $1', |
102 | 104 | 'tpt-discouraged-language-force' => 'Translation administrator has limited the languages this message group can be translated to. This language is not among those languages. |
103 | 105 | |
104 | 106 | Reason for limiting: $1', |