http://www.mediawiki.org/wiki/Special:Code/MediaWiki/90787
Revision: 90787
Author: ashley
Date: 2011-06-25 19:27:53 +0000 (Sat, 25 Jun 2011)
Log Message:
-----------
SocialProfile: gift ID must be an int. Also did some coding style tweaks and
fixed some code in GiftManagerLogo::saveUploadedFile(); $type is now defined as
zero and if it's still zero at the end of the function, we will display an
error message to the user. As a result of this, removed the ancient,
commented-out code from that function.
Made URL building in GiftManagerLogo::showSuccess() more robust by using the
proper Title functions instead of hacky DIY stuff.
Modified Paths:
--------------
trunk/extensions/SocialProfile/UserGifts/SpecialGiftManagerLogo.php
trunk/extensions/SocialProfile/UserGifts/SpecialRemoveGift.php
Modified: trunk/extensions/SocialProfile/UserGifts/SpecialGiftManagerLogo.php
===================================================================
--- trunk/extensions/SocialProfile/UserGifts/SpecialGiftManagerLogo.php
2011-06-25 19:23:39 UTC (rev 90786)
+++ trunk/extensions/SocialProfile/UserGifts/SpecialGiftManagerLogo.php
2011-06-25 19:27:53 UTC (rev 90787)
@@ -24,7 +24,7 @@
*/
public function execute( $par ) {
global $wgRequest;
- $this->gift_id = $wgRequest->getVal( 'gift_id' );
+ $this->gift_id = $wgRequest->getInt( 'gift_id' );
$this->initLogo( $wgRequest );
$this->executeLogo();
}
@@ -51,7 +51,7 @@
# GET requests just give the main form; no data except
wpDestfile.
return;
}
- $this->gift_id = $request->getVal( 'gift_id' );
+ $this->gift_id = $request->getInt( 'gift_id' );
$this->mIgnoreWarning = $request->getCheck( 'wpIgnoreWarning' );
$this->mReUpload = $request->getCheck( 'wpReUpload' );
$this->mUpload = $request->getCheck( 'wpUpload' );
@@ -296,6 +296,7 @@
$this->createThumbnail( $tempName, $ext, $this->gift_id . '_m',
30 );
$this->createThumbnail( $tempName, $ext, $this->gift_id . '_s',
16 );
+ $type = 0;
if ( $ext == 'JPG' && is_file( $this->avatarUploadDirectory .
'/' . $this->gift_id . '_l.jpg' ) ) {
$type = 2;
}
@@ -349,13 +350,10 @@
}
}
- if ( $type > 0 ) {
- // $dbw = wfGetDB( DB_MASTER );
- // $sql = "UPDATE user set user_avatar = " . $type . "
WHERE user_id = " . $wgUser->mId;
- // $res = $dbw->query($sql);
- } else {
+ if ( $type === 0 ) {
throw new FatalError( wfMsg( 'filecopyerror',
$tempName, $stash ) ); # FIXME: undefined variable $stash
}
+
return $type;
}
@@ -430,7 +428,7 @@
* @access private
*/
function showSuccess( $status ) {
- global $wgOut, $wgUploadPath, $wgScriptPath, $wgLang;
+ global $wgOut, $wgUploadPath, $wgLang;
$ext = 'jpg';
$output = '<h2>' . wfMsg( 'g-uploadsuccess' ) . '</h2>';
@@ -456,9 +454,12 @@
<td><img src="' . $wgUploadPath . '/awards/' . $this->gift_id .
'_s.' . $ext . '?ts' . rand() . '"></td></tr>';
$output .= '<tr><td><input type="button"
onclick="javascript:history.go(-1)" value="' . wfMsg( 'g-go-back' ) .
'"></td></tr>';
+ $giftManager = SpecialPage::getTitleFor( 'GiftManager' );
$output .= $wgLang->pipeList( array(
- '<tr><td><a href="' . $wgScriptPath .
'/index.php?title=Special:GiftManager">' . wfMsg( 'g-back-gift-list' ) .
'</a> ',
- ' <a href="' . $wgScriptPath .
'/index.php?title=Special:GiftManager&id=' . $this->gift_id . '">' . wfMsg(
'g-back-edit-gift' ) . '</a></td></tr>'
+ '<tr><td><a href="' . $giftManager->escapeFullURL() .
'">' .
+ wfMsg( 'g-back-gift-list' ) . '</a> ',
+ ' <a href="' . $giftManager->escapeFullURL( 'id='
. $this->gift_id ) .
+ '">' . wfMsg( 'g-back-edit-gift' ) .
'</a></td></tr>'
) );
$output .= '</table>';
$wgOut->addHTML( $output );
@@ -598,8 +599,11 @@
global $wgUploadPath;
$gift_image = Gifts::getGiftImage( $this->gift_id, 'l' );
if ( $gift_image != '' ) {
- $output = '<table><tr><td
style="color:#666666;font-weight:800">' . wfMsg( 'g-current-image' ) .
'</td></tr>';
- $output .= '<tr><td><img src="' . $wgUploadPath .
'/images/awards/' . $gift_image . '" border="0" alt="' . wfMsg( 'g-gift' ) . '"
/></td></tr></table><br />';
+ $output = '<table><tr><td
style="color:#666666;font-weight:800">' .
+ wfMsg( 'g-current-image' ) . '</td></tr>';
+ $output .= '<tr><td><img src="' . $wgUploadPath .
+ '/images/awards/' . $gift_image . '" border="0"
alt="' .
+ wfMsg( 'g-gift' ) . '" /></td></tr></table><br
/>';
}
$wgOut->addHTML( $output );
Modified: trunk/extensions/SocialProfile/UserGifts/SpecialRemoveGift.php
===================================================================
--- trunk/extensions/SocialProfile/UserGifts/SpecialRemoveGift.php
2011-06-25 19:23:39 UTC (rev 90786)
+++ trunk/extensions/SocialProfile/UserGifts/SpecialRemoveGift.php
2011-06-25 19:27:53 UTC (rev 90787)
@@ -19,7 +19,7 @@
$wgOut->addExtensionStyle( $wgUserGiftsScripts .
'/UserGifts.css' );
- $this->gift_id = $wgRequest->getVal( 'gift_id' );
+ $this->gift_id = $wgRequest->getInt( 'gift_id' );
$rel = new UserGifts( $wgUser->getName() );
if ( !$this->gift_id || !is_numeric( $this->gift_id ) ) {
@@ -27,6 +27,7 @@
$wgOut->addHTML( wfMsg( 'g-error-message-invalid-link'
) );
return false;
}
+
if ( $rel->doesUserOwnGift( $wgUser->getID(), $this->gift_id )
== false ) {
$wgOut->setPageTitle( wfMsg( 'g-error-title' ) );
$wgOut->addHTML( wfMsg( 'g-error-do-not-own' ) );
@@ -44,15 +45,18 @@
$rel->deleteGift( $this->gift_id );
}
- $gift_image = '<img src="' . $wgUploadPath . '/awards/'
. Gifts::getGiftImage( $gift['gift_id'], 'l' ) . '" border="0" alt="" />';
+ $gift_image = '<img src="' . $wgUploadPath . '/awards/'
.
+ Gifts::getGiftImage( $gift['gift_id'], 'l' ) .
+ '" border="0" alt="" />';
$wgOut->setPageTitle( wfMsg( 'g-remove-success-title',
$gift['name'] ) );
$out = '<div class="back-links">
- <a href="' .
$wgUser->getUserPage()->escapeFullURL() . '">' . wfMsg( 'g-back-link',
$gift['user_name_to'] ) . '</a>
+ <a href="' .
$wgUser->getUserPage()->escapeFullURL() . '">' .
+ wfMsg( 'g-back-link',
$gift['user_name_to'] ) . '</a>
</div>
- <div class="g-container">'
- . $gift_image . wfMsg(
'g-remove-success-message', $gift['name'] ) .
+ <div class="g-container">' .
+ $gift_image . wfMsg(
'g-remove-success-message', $gift['name'] ) .
'<div class="cleared"></div>
</div>
<div class="g-buttons">
@@ -77,22 +81,32 @@
$rel = new UserGifts( $wgUser->getName() );
$gift = $rel->getUserGift( $this->gift_id );
$user = Title::makeTitle( NS_USER, $gift['user_name_from'] );
- $gift_image = '<img src="' . $wgUploadPath . '/awards/' .
Gifts::getGiftImage( $gift['gift_id'], 'l' ) . '" border="0" alt="gift" />';
+ $gift_image = '<img src="' . $wgUploadPath . '/awards/' .
+ Gifts::getGiftImage( $gift['gift_id'], 'l' ) .
+ '" border="0" alt="gift" />';
- $output = $wgOut->setPageTitle( wfMsg( 'g-remove-title',
$gift['name'] ) );
- $output .= '<div class="back-links">
- <a href="' . $wgUser->getUserPage()->escapeFullURL() .
'">' . wfMsg( 'g-back-link', $gift['user_name_to'] ) . '</a>
+ $wgOut->setPageTitle( wfMsg( 'g-remove-title', $gift['name'] )
);
+
+ $output = '<div class="back-links">
+ <a href="' . $wgUser->getUserPage()->escapeFullURL() .
'">' .
+ wfMsg( 'g-back-link', $gift['user_name_to'] ) .
'</a>
</div>
<form action="" method="post" enctype="multipart/form-data"
name="form1">
- <div class="g-remove-message">'
- . wfMsg( 'g-remove-message', $gift['name'] ) .
+ <div class="g-remove-message">' .
+ wfMsg( 'g-remove-message', $gift['name'] ) .
'</div>
- <div class="g-container">'
- . $gift_image .
+ <div class="g-container">' .
+ $gift_image .
'<div class="g-name">' . $gift['name'] . '</div>
- <div class="g-from">' . wfMsg( 'g-from',
$user->escapeFullURL(), $gift['user_name_from'] ) . '</div>';
+ <div class="g-from">' .
+ wfMsg(
+ 'g-from',
+ $user->escapeFullURL(),
+ $gift['user_name_from']
+ ) . '</div>';
if ( $gift['message'] ) {
- $output .= '<div class="g-user-message">' .
$gift['message'] . '</div>';
+ $output .= '<div class="g-user-message">' .
+ $gift['message'] . '</div>';
}
$output .= '</div>
<div class="cleared"></div>
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs