Index: trunk/extensions/SocialProfile/UserGifts/SpecialViewGift.php |
— | — | @@ -19,26 +19,15 @@ |
20 | 20 | |
21 | 21 | $wgOut->addExtensionStyle( $wgUserGiftsScripts . '/UserGifts.css' ); |
22 | 22 | |
23 | | - $user_name = ''; // Prevent E_NOTICE |
24 | | - |
25 | | - $gift_id = $wgRequest->getVal( 'gift_id' ); |
26 | | - if ( !$gift_id || !is_numeric( $gift_id ) ) { |
| 23 | + $giftId = $wgRequest->getInt( 'gift_id' ); |
| 24 | + if ( !$giftId || !is_numeric( $giftId ) ) { |
27 | 25 | $wgOut->setPageTitle( wfMsg( 'g-error-title' ) ); |
28 | 26 | $wgOut->addHTML( wfMsg( 'g-error-message-invalid-link' ) ); |
29 | 27 | return false; |
30 | 28 | } |
31 | 29 | |
32 | | - if ( !$user_name ) { |
33 | | - $user_name = $wgUser->getName(); |
34 | | - } |
35 | | - $gift = UserGifts::getUserGift( $gift_id ); |
36 | | - $user_safe = urlencode( $gift['user_name_to'] ); |
37 | | - $id = User::idFromName( $user_name ); |
38 | | - $relationship = UserRelationship::getUserRelationshipByID( $id, $wgUser->getID() ); |
| 30 | + $gift = UserGifts::getUserGift( $giftId ); |
39 | 31 | |
40 | | - // DB stuff |
41 | | - $dbr = wfGetDB( DB_SLAVE ); |
42 | | - |
43 | 32 | if ( $gift ) { |
44 | 33 | if ( $gift['status'] == 1 ) { |
45 | 34 | if ( $gift['user_name_to'] == $wgUser->getName() ) { |
— | — | @@ -48,12 +37,14 @@ |
49 | 38 | } |
50 | 39 | } |
51 | 40 | |
| 41 | + // DB stuff |
| 42 | + $dbr = wfGetDB( DB_SLAVE ); |
52 | 43 | $res = $dbr->select( |
53 | 44 | 'user_gift', |
54 | 45 | array( 'DISTINCT ug_user_name_to', 'ug_user_id_to', 'ug_date' ), |
55 | 46 | array( |
56 | 47 | 'ug_gift_id' => $gift['gift_id'], |
57 | | - "ug_user_name_to<>'" . addslashes( $gift['user_name_to'] ) . "'" |
| 48 | + "ug_user_name_to <> '" . addslashes( $gift['user_name_to'] ) . "'" |
58 | 49 | ), |
59 | 50 | __METHOD__, |
60 | 51 | array( |
— | — | @@ -63,58 +54,73 @@ |
64 | 55 | ) |
65 | 56 | ); |
66 | 57 | |
67 | | - $output = $wgOut->setPageTitle( wfMsgExt( 'g-description-title', 'parsemag', $gift['user_name_to'], $gift['name'] ) ); |
| 58 | + $wgOut->setPageTitle( wfMsgExt( |
| 59 | + 'g-description-title', |
| 60 | + 'parsemag', |
| 61 | + $gift['user_name_to'], |
| 62 | + $gift['name'] |
| 63 | + ) ); |
68 | 64 | |
69 | | - $output .= '<div class="back-links"> |
| 65 | + $output = '<div class="back-links"> |
70 | 66 | <a href="' . Title::makeTitle( NS_USER, $gift['user_name_to'] )->escapeFullURL() . '">' |
71 | 67 | . wfMsg( 'g-back-link', $gift['user_name_to'] ) . '</a> |
72 | 68 | </div>'; |
73 | 69 | |
74 | 70 | $user = Title::makeTitle( NS_USER, $gift['user_name_from'] ); |
75 | | - $remove_gift_link = SpecialPage::getTitleFor( 'RemoveGift' ); |
76 | | - $give_gift_link = SpecialPage::getTitleFor( 'GiveGift' ); |
| 71 | + $removeGiftLink = SpecialPage::getTitleFor( 'RemoveGift' ); |
| 72 | + $giveGiftLink = SpecialPage::getTitleFor( 'GiveGift' ); |
77 | 73 | |
78 | 74 | $avatar = new wAvatar( $gift['user_id_from'], 's' ); |
79 | | - $avatar_img = '<img src="' . $wgUploadPath . '/avatars/' . $avatar->getAvatarImage() . '" alt="" border="0" />'; |
80 | | - $gift_image = '<img src="' . $wgUploadPath . '/awards/' . Gifts::getGiftImage( $gift['gift_id'], 'l' ) . '" border="0" alt="" />'; |
| 75 | + $avatar_img = '<img src="' . $wgUploadPath . '/avatars/' . |
| 76 | + $avatar->getAvatarImage() . '" alt="" border="0" />'; |
| 77 | + $giftImage = '<img src="' . $wgUploadPath . '/awards/' . |
| 78 | + Gifts::getGiftImage( $gift['gift_id'], 'l' ) . |
| 79 | + '" border="0" alt="" />'; |
81 | 80 | |
82 | 81 | $message = $wgOut->parse( trim( $gift['message'] ), false ); |
83 | 82 | |
84 | 83 | $output .= '<div class="g-description-container">'; |
85 | | - |
86 | | - $gift_image = '<img src="' . $wgUploadPath . '/awards/' . Gifts::getGiftImage( $gift['gift_id'], 'l' ) . '" border="0" alt="" />'; |
87 | | - |
88 | 84 | $output .= '<div class="g-description">' |
89 | | - . $gift_image . |
| 85 | + . $giftImage . |
90 | 86 | '<div class="g-name">' . $gift['name'] . '</div> |
91 | 87 | <div class="g-timestamp">(' . $gift['timestamp'] . ')</div> |
92 | | - <div class="g-from">' . wfMsg( 'g-from', $user->escapeFullURL(), $gift['user_name_from'] ) . '</div>'; |
| 88 | + <div class="g-from">' . wfMsg( |
| 89 | + 'g-from', |
| 90 | + $user->escapeFullURL(), |
| 91 | + $gift['user_name_from'] |
| 92 | + ) . '</div>'; |
93 | 93 | if ( $message ) { |
94 | 94 | $output .= '<div class="g-user-message">' . $message . '</div>'; |
95 | 95 | } |
96 | 96 | $output .= '<div class="cleared"></div> |
97 | 97 | <div class="g-describe">' . $gift['description'] . '</div> |
98 | 98 | <div class="g-actions"> |
99 | | - <a href="' . $give_gift_link->escapeFullURL( 'gift_id=' . $gift['gift_id'] ) . '">' . wfMsg( 'g-to-another' ) . '</a>'; |
| 99 | + <a href="' . $giveGiftLink->escapeFullURL( 'gift_id=' . $gift['gift_id'] ) . '">' . |
| 100 | + wfMsg( 'g-to-another' ) . '</a>'; |
100 | 101 | if ( $gift['user_name_to'] == $wgUser->getName() ) { |
101 | | - $output .= ' '; |
102 | | - $output .= wfMsgExt( 'pipe-separator' , 'escapenoentities' ); |
103 | | - $output .= ' '; |
104 | | - $output .= '<a href="' . $remove_gift_link->escapeFullURL( 'gift_id=' . $gift['id'] ) . '">' . wfMsg( 'g-remove-gift' ) . '</a>'; |
| 102 | + $output .= ' '; |
| 103 | + $output .= wfMsgExt( 'pipe-separator', 'escapenoentities' ); |
| 104 | + $output .= ' '; |
| 105 | + $output .= '<a href="' . $removeGiftLink->escapeFullURL( 'gift_id=' . $gift['id'] ) . '">' . |
| 106 | + wfMsg( 'g-remove-gift' ) . '</a>'; |
105 | 107 | } |
106 | 108 | $output .= '</div> |
107 | 109 | </div>'; |
108 | 110 | |
109 | 111 | $output .= '<div class="g-recent"> |
110 | | - <div class="g-recent-title">' . wfMsg( 'g-recent-recipients' ) . '</div> |
111 | | - <div class="g-gift-count">' . wfMsgExt( 'g-given', 'parsemag', $gift['gift_count'] ) . '</div>'; |
| 112 | + <div class="g-recent-title">' . |
| 113 | + wfMsg( 'g-recent-recipients' ) . |
| 114 | + '</div> |
| 115 | + <div class="g-gift-count">' . |
| 116 | + wfMsgExt( 'g-given', 'parsemag', $gift['gift_count'] ) . |
| 117 | + '</div>'; |
112 | 118 | |
113 | 119 | foreach ( $res as $row ) { |
114 | | - $user_to_id = $row->ug_user_id_to; |
115 | | - $avatar = new wAvatar( $user_to_id, 'ml' ); |
116 | | - $user_name_link = Title::makeTitle( NS_USER, $row->ug_user_name_to ); |
| 120 | + $userToId = $row->ug_user_id_to; |
| 121 | + $avatar = new wAvatar( $userToId, 'ml' ); |
| 122 | + $userNameLink = Title::makeTitle( NS_USER, $row->ug_user_name_to ); |
117 | 123 | |
118 | | - $output .= '<a href="' . $user_name_link->escapeFullURL() . "\"> |
| 124 | + $output .= '<a href="' . $userNameLink->escapeFullURL() . "\"> |
119 | 125 | {$avatar->getAvatarURL()} |
120 | 126 | </a>"; |
121 | 127 | } |