r94903 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94902‎ | r94903 | r94904 >
Date:15:52, 18 August 2011
Author:ashley
Status:deferred (Comments)
Tags:
Comment:
SocialProfile: make Special:UserStatus a listed special page, add standard checks (block+DB read-only mode) and move some hardcoded English texts into the i18n file
Modified paths:
  • /trunk/extensions/SocialProfile/UserStatus/SpecialUserStatus.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserStatus/UserStatus.i18n.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SocialProfile/UserStatus/UserStatus.i18n.php
@@ -12,6 +12,9 @@
1313 * @author Yevhenii Vlasenko
1414 */
1515 $messages['en'] = array(
 16+ 'userstatus' => 'Delete status updates',
 17+ 'userstatus-enter-username' => 'Enter username:',
 18+ 'userstatus-find' => 'Find',
1619 'userstatus-edit' => 'Edit',
1720 'userstatus-save' => 'Save',
1821 'userstatus-cancel' => 'Cancel',
Index: trunk/extensions/SocialProfile/UserStatus/SpecialUserStatus.php
@@ -1,26 +1,53 @@
22 <?php
33
4 -class SpecialUserStatus extends UnlistedSpecialPage {
 4+class SpecialUserStatus extends SpecialPage {
55
66 /**
7 - * Constructor
 7+ * Constructor -- set up the new special page
88 */
99 public function __construct() {
10 - global $wgOut, $wgScriptPath;
11 -
12 - parent::__construct( 'UserStatus' );
13 - $wgOut->addScriptFile( $wgScriptPath . '/extensions/SocialProfile/UserStatus/UserStatus.js' );
 10+ parent::__construct( 'UserStatus', 'delete-status-update' );
1411 }
1512
 13+ /**
 14+ * Show the special page
 15+ *
 16+ * @param $params Mixed: parameter(s) passed to the special page or null
 17+ */
1618 public function execute( $params ) {
17 - global $wgOut,$wgUser;
18 - if ( $wgUser->isAllowed( 'delete-status-update' ) ) {
19 - $output = "Enter username: <input type=\"text\" id=\"us-name-input\"> ";
20 - $output .= "<input type=\"button\" value=\"Find\" onclick=\"javascript:UserStatus.specialGetHistory();\">";
21 - $output .= "<div id=\"us-special\"> </div>";
22 - $wgOut->addHTML($output);
 19+ global $wgOut, $wgScriptPath, $wgUser;
 20+
 21+ // Make sure that the user is allowed to access this special page
 22+ if( !$wgUser->isAllowed( 'delete-status-update' ) ) {
 23+ $wgOut->permissionRequired( 'delete-status-update' );
 24+ return false;
2325 }
24 - return;
 26+
 27+ // Blocked through Special:Block? No access for you either!
 28+ if( $wgUser->isBlocked() ) {
 29+ $wgOut->blockedPage( false );
 30+ return false;
 31+ }
 32+
 33+ // Is the database locked or not?
 34+ if( wfReadOnly() ) {
 35+ $wgOut->readOnlyPage();
 36+ return false;
 37+ }
 38+
 39+ // Set the page title and robot policies
 40+ $this->setHeaders();
 41+
 42+ // Add required JS file
 43+ $wgOut->addScriptFile( $wgScriptPath . '/extensions/SocialProfile/UserStatus/UserStatus.js' );
 44+
 45+ // Build and output the form for deleting users' status updates
 46+ $output = wfMsg( 'userstatus-enter-username' ) .
 47+ ' <input type="text" id="us-name-input" /> ';
 48+ $output .= '<input type="button" value="' .
 49+ wfMsg( 'userstatus-find' ) . '" onclick="javascript:UserStatus.specialGetHistory();" />';
 50+ $output .= '<div id="us-special"> </div>';
 51+ $wgOut->addHTML( $output );
2552 }
26 -
 53+
2754 }

Comments

#Comment by Nikerabbit (talk | contribs)   10:34, 21 September 2011

Should use more escaping.

Status & tagging log