r101134 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101133‎ | r101134 | r101135 >
Date:14:26, 28 October 2011
Author:nikerabbit
Status:ok
Tags:
Comment:
Do not show accept queue tasks for users who cannot accept translations
Modified paths:
  • /trunk/extensions/Translate/TranslateTasks.php (modified) (history)
  • /trunk/extensions/Translate/specials/SpecialTranslate.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/TranslateTasks.php
@@ -167,6 +167,14 @@
168168 $callback = $this->options->getPagingCB();
169169 call_user_func( $callback, $this->options->getOffset(), $left, $total );
170170 }
 171+
 172+ /**
 173+ * Override this method if the task depends on user rights.
 174+ * @return \string
 175+ */
 176+ public function isAllowedFor( User $user ) {
 177+ return true;
 178+ }
171179 }
172180
173181 /**
@@ -343,6 +351,10 @@
344352 $this->collection->filter( 'reviewer', true, $wgUser->getId() );
345353 $this->collection->filter( 'last-translator', true, $wgUser->getId() );
346354 }
 355+
 356+ public function isAllowedFor( User $user ) {
 357+ return $user->isAllowed( 'translate-messagereview' );
 358+ }
347359 }
348360
349361 /**
Index: trunk/extensions/Translate/specials/SpecialTranslate.php
@@ -262,13 +262,16 @@
263263 /* Selectors ahead */
264264
265265 protected function taskSelector( $pageTranslation = false ) {
 266+ global $wgUser;
266267 $selector = new XmlSelect( 'task', 'task' );
267268 $selector->setDefault( $this->options['task'] );
268269
269270 $isPageTranslation = $this->group instanceof WikiPageMessageGroup;
270271 foreach ( TranslateTasks::getTasks( $isPageTranslation ) as $id ) {
271 - $label = TranslateTask::labelForTask( $id );
272 - $selector->addOption( $label, $id );
 272+ if ( TranslateTasks::getTask( $id )->isAllowedFor( $wgUser ) ) {
 273+ $label = TranslateTask::labelForTask( $id );
 274+ $selector->addOption( $label, $id );
 275+ }
273276 }
274277
275278 return $selector->getHTML();

Status & tagging log