r113797 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113796‎ | r113797 | r113798 >
Date:05:13, 14 March 2012
Author:santhosh
Status:ok
Tags:i18nreview 
Comment:
Add logging for adding and removing a group t/from an aggregategroup.
Validate the group before adding or removing to aggregategroup
Modified paths:
  • /trunk/extensions/Translate/PageTranslation.i18n.php (modified) (history)
  • /trunk/extensions/Translate/TranslateHooks.php (modified) (history)
  • /trunk/extensions/Translate/api/ApiAggregateGroups.php (modified) (history)
  • /trunk/extensions/Translate/tag/PageTranslationHooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/tag/PageTranslationHooks.php
@@ -616,6 +616,10 @@
617617 } else {
618618 return wfMsgExt( 'pt-log-priority-langs', $opts, $title->getPrefixedText(), $user , $_['languages'], $_['reason'] );
619619 }
 620+ } elseif ( $action === 'associate' ) {
 621+ return wfMsgExt( 'pt-log-aggregategroup-associate', $opts, $title->getPrefixedText(), $user, $_['aggregategroup'] );
 622+ } elseif ( $action === 'dissociate' ) {
 623+ return wfMsgExt( 'pt-log-aggregategroup-dissociate', $opts, $title->getPrefixedText(), $user, $_['aggregategroup'] );
620624 }
621625 return '';
622626 }
Index: trunk/extensions/Translate/TranslateHooks.php
@@ -70,6 +70,8 @@
7171 $wgLogActionsHandlers['pagetranslation/encourage'] = 'PageTranslationHooks::formatLogEntry';
7272 $wgLogActionsHandlers['pagetranslation/discourage'] = 'PageTranslationHooks::formatLogEntry';
7373 $wgLogActionsHandlers['pagetranslation/prioritylanguages'] = 'PageTranslationHooks::formatLogEntry';
 74+ $wgLogActionsHandlers['pagetranslation/associate'] = 'PageTranslationHooks::formatLogEntry';
 75+ $wgLogActionsHandlers['pagetranslation/dissociate'] = 'PageTranslationHooks::formatLogEntry';
7476
7577 global $wgJobClasses;
7678 $wgJobClasses['RenderJob'] = 'RenderJob';
Index: trunk/extensions/Translate/PageTranslation.i18n.php
@@ -145,6 +145,8 @@
146146 'pt-log-priority-langs-unset' => '{{GENDER:$2|removed}} priority languages from translatable page [[:$1]]',
147147 'pt-log-priority-langs' => '{{GENDER:$2|set}} the priority languages for translatable page [[:$1]] to $3. Reason: $4',
148148 'pt-log-priority-langs-force' => '{{GENDER:$2|limited}} languages for translatable page [[:$1]] to $3. Reason: $4',
 149+ 'pt-log-aggregategroup-associate' => '{{GENDER:$2|added}} page [[:$1]] to $3.',
 150+ 'pt-log-aggregategroup-dissociate' => '{{GENDER:$2|removed}} page [[:$1]] from $3.',
149151
150152 # move page replacement
151153 'pt-movepage-title' => 'Move translatable page $1',
@@ -299,6 +301,8 @@
300302 'pt-log-priority-langs-unset' => '{{logentry|[[Special:Log/pagetranslation]]}}',
301303 'pt-log-priority-langs' => 'Used on [[Special:Log/pagetranslation]]. $3 is comma-separated list of languages.',
302304 'pt-log-priority-langs-force' => 'Used on [[Special:Log/pagetranslation]]. $3 is a comma-separated list of languages.',
 305+ 'pt-log-aggregategroup-associate' => '{{logentry|[[Special:Log/pagetranslation]]}}',
 306+ 'pt-log-aggregategroup-dissociate' => '{{logentry|[[Special:Log/pagetranslation]]}}',
303307 'pt-movepage-block-base-exists' => "'''base page''' refers to the untranslated version of the translatable page.",
304308 'pt-movepage-block-tp-exists' => 'translation page is a translated version of a translatable page',
305309 'pt-movepage-block-section-exists' => 'Section page is a translation of one section. Translation page consists of many translation sections.',
Index: trunk/extensions/Translate/api/ApiAggregateGroups.php
@@ -26,6 +26,7 @@
2727 $this->dieUsage( 'Permission denied', 'permissiondenied' );
2828 }
2929
 30+ $logger = new LogPage( 'pagetranslation' );
3031 $params = $this->extractRequestParams();
3132 $aggregateGroup = $params['aggregategroup'];
3233 $action = $params['do'];
@@ -37,7 +38,7 @@
3839 }
3940
4041 // Get the list of group ids
41 - $group = $params['group'];
 42+ $groupId = $params['group'];
4243 $subgroups = TranslateMetadata::get( $aggregateGroup, 'subgroups' );
4344 if ( $subgroups ) {
4445 $subgroups = array_map( 'trim', explode( ',', $subgroups ) );
@@ -45,22 +46,29 @@
4647 // For newly created groups the subgroups value might be empty
4748 $subgroups = array();
4849 }
 50+ $group = MessageGroups::getGroup( $groupId );
 51+ if ( $group === null || !$group instanceof WikiPageMessageGroup ) {
 52+ $this->dieUsage( 'Group does not exist or invalid', 'invalidgroup' );
 53+ }
4954
50 - // @FIXME: check that the group id is a translatable page
5155 // @FIXME: handle pages with a comma in their name
5256
5357 // Add or remove from the list
54 - // @TODO logging
5558 if ( $action === 'associate' ) {
56 - $subgroups[] = $group;
 59+ $subgroups[] = $groupId;
5760 $subgroups = array_unique( $subgroups );
5861 } elseif ( $action === 'dissociate' ) {
5962 $subgroups = array_flip( $subgroups ) ;
60 - unset( $subgroups[$group] );
 63+ unset( $subgroups[$groupId] );
6164 $subgroups = array_flip( $subgroups );
6265 }
6366
6467 TranslateMetadata::set( $aggregateGroup, 'subgroups', implode( ',', $subgroups ) ) ;
 68+ $logparams = array(
 69+ 'user' => $wgUser->getName() ,
 70+ 'aggregategroup' => TranslateMetadata::get( $aggregateGroup, 'name' ),
 71+ );
 72+ $logger->addEntry( $action, $group->getTitle(), null, array( serialize( $logparams ) ) );
6573 } elseif ( $action === 'remove' ) {
6674 TranslateMetadata::set( $aggregateGroup, 'subgroups', false ) ;
6775 TranslateMetadata::set( $aggregateGroup, 'name', false ) ;

Status & tagging log