r95399 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95398‎ | r95399 | r95400 >
Date:14:16, 24 August 2011
Author:ashley
Status:ok
Tags:
Comment:
SocialProfile: check for permission, not for group membership in Special:GiftManager and fix an old to-do about undefined variables. This caused a nice, subtle bug where all gifts created by users who were not in the 'giftadmin' group were created as private instead of public. As a result, your gift table could have many entries (=many gifts), but Special:GiveGift still wouldn't work for everyone, because that special page allows sending out either only public gifts or gifts that you have created yourself and by default Special:GiftManager is restricted to users with the 'giftmanager' user right.
Modified paths:
  • /trunk/extensions/SocialProfile/UserGifts/SpecialGiftManager.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SocialProfile/UserGifts/SpecialGiftManager.php
@@ -237,18 +237,24 @@
238238
239239 // If the user isn't in the gift admin group, they can only create
240240 // private gifts
241 - if ( !in_array( 'giftadmin', $wgUser->getGroups() ) ) {
 241+ if ( !$wgUser->isAllowed( 'giftadmin' ) ) {
242242 $form .= '<input type="hidden" name="access" value="1" />';
243243 } else {
244 - // FIXME: undefined variable gift (twice)
 244+ $publicSelected = $privateSelected = '';
 245+ if ( isset( $gift['access'] ) && $gift['access'] == 0 ) {
 246+ $publicSelected = ' selected="selected"';
 247+ }
 248+ if ( isset( $gift['access'] ) && $gift['access'] == 1 ) {
 249+ $privateSelected = ' selected="selected"';
 250+ }
245251 $form .= '<tr>
246252 <td class="view-form">' . wfMsg( 'giftmanager-access' ) . '</td>
247253 <td>
248254 <select name="access">
249 - <option value="0"' . ( ( $gift['access'] == 0 ) ? ' selected="selected"' : '' ) . '>' .
 255+ <option value="0"' . $publicSelected . '>' .
250256 wfMsg( 'giftmanager-public' ) .
251257 '</option>
252 - <option value="1"' . ( ( $gift['access'] == 1 ) ? ' selected="selected"' : '' ) . '>' .
 258+ <option value="1"' . $privateSelected . '>' .
253259 wfMsg( 'giftmanager-private' ) .
254260 '</option>
255261 </select>

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r46690* re-revert r46688 to r46264. The fixes are proper, as tested. See screenshot...siebrand22:26, 1 February 2009

Status & tagging log