r77957 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r77956‎ | r77957 | r77958 >
Date:03:22, 7 December 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Fixed tab display issue when not authorized to use action
Modified paths:
  • /trunk/extensions/Push/Push.i18n.php (modified) (history)
  • /trunk/extensions/Push/Push.php (modified) (history)
  • /trunk/extensions/Push/Push_Settings.php (modified) (history)
  • /trunk/extensions/Push/includes/Push_Tab.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Push/Push.i18n.php
@@ -18,6 +18,7 @@
1919 'push-desc' => 'Lightweight extension to push content to other wiki\'s',
2020 'push-tab-text' => 'Push',
2121 'push-button-text' => 'Push',
 22+ 'push-button-desc' => 'This tab allows you to push the current revision of this page to one or more other wiki\'s.',
2223 'push-button-pushing' => 'Pushing',
2324 'push-button-completed' => 'Push completed',
2425 'push-button-failed' => 'Push failed',
Index: trunk/extensions/Push/Push.php
@@ -49,10 +49,7 @@
5050 $wgHooks['SkinTemplateNavigation'][] = 'PushTab::displayTab2';
5151
5252 $wgAvailableRights[] = 'push';
53 -$wgGroupPermissions['*']['push'] = true;
54 -
5553 $wgAvailableRights[] = 'pushadmin';
56 -$wgGroupPermissions['sysop']['pushadmin'] = true;
5754
5855 $egPushJSMessages = array(
5956 'push-button-pushing',
@@ -77,8 +74,8 @@
7875 );
7976 }
8077
81 -function efPushAddJSLocalisation( $parser = false ) {
82 - global $egPushJSMessages;
 78+function efPushAddJSLocalisation() {
 79+ global $egPushJSMessages, $wgOut;
8380
8481 $data = array();
8582
@@ -86,14 +83,7 @@
8784 $data[$msg] = wfMsgNoTrans( $msg );
8885 }
8986
90 - $js = 'var wgPushMessages = ' . json_encode( $data ) . ';';
91 -
92 - if ( $parser ) {
93 - $parser->getOutput()->addHeadItem( Html::inlineScript( $js ) );
94 - } else {
95 - global $wgOut;
96 - $wgOut->addInlineScript( $js );
97 - }
 87+ $wgOut->addInlineScript( 'var wgPushMessages = ' . json_encode( $data ) . ';' );
9888 }
9989
10090 require_once 'Push_Settings.php';
Index: trunk/extensions/Push/Push_Settings.php
@@ -19,3 +19,6 @@
2020 }
2121
2222 $egPushTargets = array();
 23+
 24+$wgGroupPermissions['*']['push'] = true;
 25+$wgGroupPermissions['sysop']['pushadmin'] = true;
Index: trunk/extensions/Push/includes/Push_Tab.php
@@ -17,8 +17,14 @@
1818 * Adds an "action" (i.e., a tab) to allow pushing the current article.
1919 */
2020 public static function displayTab( $obj, &$content_actions ) {
21 - // Make sure that this is not a special page and that the page exists.
22 - if ( isset( $obj->mTitle ) && $obj->mTitle->getNamespace() != NS_SPECIAL && $obj->mTitle->exists() ) {
 21+ global $wgUser;
 22+
 23+ // Make sure that this is not a special page, the page has contents, and the user can push.
 24+ if (isset( $obj->mTitle )
 25+ && $obj->mTitle->getNamespace() != NS_SPECIAL
 26+ && $obj->mTitle->exists()
 27+ && $wgUser->isAllowed( 'push' ) ) {
 28+
2329 global $wgRequest;
2430
2531 $content_actions['push'] = array(
@@ -97,18 +103,23 @@
98104 public static function displayPushPage( Article $article ) {
99105 global $wgOut, $wgUser, $wgTitle, $wgSitename;
100106
 107+ if ( !$wgUser->isAllowed( 'push' ) ) {
 108+ $wgOut->permissionRequired( 'push' );
 109+ return false;
 110+ }
 111+
 112+ self::loadJs();
 113+
101114 $wgOut->setPageTitle( wfMsgExt( 'push-tab-title', 'parsemag', $article->getTitle()->getText() ) );
102115
103 - self::loadJs();
 116+ $wgOut->addHTML( '<p>' . htmlspecialchars( wfMsg( 'push-button-desc' ) ) . '</p>' );
104117
105118 $wgOut->addHTML(
106119 Html::hidden( 'pageName', $wgTitle->getFullText(), array( 'id' => 'pageName' ) ) .
107120 Html::hidden( 'siteName', $wgSitename, array( 'id' => 'siteName' ) )
108121 );
109122
110 - if ( $wgUser->isAllowed( 'push' ) ) {
111 - self::displayPushList();
112 - }
 123+ self::displayPushList();
113124
114125 if ( $wgUser->isAllowed( 'pushadmin' ) ) {
115126 // TODO
@@ -192,6 +203,15 @@
193204 }
194205
195206 /**
 207+ * Displays several configuration options for the push operations.
 208+ *
 209+ * @since 0.1
 210+ */
 211+ protected static function displayPushOptions() {
 212+ global $wgOut;
 213+ }
 214+
 215+ /**
196216 * Displays a form via which a new psuh item can be added.
197217 *
198218 * @since 0.1

Status & tagging log