Index: trunk/extensions/SocialProfile/SystemGifts/SystemGiftsClass.php |
— | — | @@ -58,7 +58,11 @@ |
59 | 59 | $res2 = $dbw->select( |
60 | 60 | 'user_stats', |
61 | 61 | array( 'stats_user_id', 'stats_user_name' ), |
62 | | - array( $stats->stats_fields[$this->categories[$row->gift_category]] . " >= {$row->gift_threshold}", 'stats_user_id<>0' ), |
| 62 | + array( |
| 63 | + $stats->stats_fields[$this->categories[$row->gift_category]] . |
| 64 | + " >= {$row->gift_threshold}", |
| 65 | + 'stats_user_id <> 0' |
| 66 | + ), |
63 | 67 | __METHOD__ |
64 | 68 | ); |
65 | 69 | |
— | — | @@ -151,11 +155,16 @@ |
152 | 156 | |
153 | 157 | public function doesGiftExistForThreshold( $category, $threshold ) { |
154 | 158 | $dbr = wfGetDB( DB_SLAVE ); |
| 159 | + wfSuppressWarnings(); |
| 160 | + // Can cause notices like "Notice: Undefined index: user_image" after |
| 161 | + // a user has uploaded their (first) avatar |
| 162 | + $awardCategory = $this->categories[$category]; |
| 163 | + wfRestoreWarnings(); |
155 | 164 | $s = $dbr->selectRow( |
156 | 165 | 'system_gift', |
157 | 166 | array( 'gift_id' ), |
158 | 167 | array( |
159 | | - 'gift_category' => $this->categories[$category], |
| 168 | + 'gift_category' => $awardCategory, |
160 | 169 | 'gift_threshold' => $threshold |
161 | 170 | ), |
162 | 171 | __METHOD__ |
— | — | @@ -198,6 +207,8 @@ |
199 | 208 | * Gets the associated image for a system gift |
200 | 209 | * @param $id Integer: system gift ID number |
201 | 210 | * @param $size String: image size (s, m, ml or l) |
| 211 | + * @return String: gift image filename (following the format |
| 212 | + * sg_ID_SIZE.ext; for example, sg_1_l.jpg) |
202 | 213 | */ |
203 | 214 | static function getGiftImage( $id, $size ) { |
204 | 215 | global $wgUploadDirectory; |
— | — | @@ -208,17 +219,25 @@ |
209 | 220 | } else { |
210 | 221 | $img = 'default_' . $size . '.gif'; |
211 | 222 | } |
| 223 | + |
212 | 224 | return $img . '?r=' . rand(); |
213 | 225 | } |
214 | 226 | |
| 227 | + /** |
| 228 | + * Get the list of all existing system gifts (awards). |
| 229 | + * |
| 230 | + * @param $limit Integer: LIMIT for the SQL query, 0 by default |
| 231 | + * @param $page Integer: used to determine OFFSET for the SQL query; |
| 232 | + * 0 by default |
| 233 | + * @return Array: array containing gift info, including (but not limited |
| 234 | + * to) gift ID, creation timestamp, name, description, etc. |
| 235 | + */ |
215 | 236 | static function getGiftList( $limit = 0, $page = 0 ) { |
216 | 237 | $dbr = wfGetDB( DB_SLAVE ); |
217 | 238 | |
218 | 239 | $limitvalue = 0; |
219 | | - if ( $limit > 0 ) { |
220 | | - if ( $page ) { |
221 | | - $limitvalue = $page * $limit - ( $limit ); |
222 | | - } |
| 240 | + if ( $limit > 0 && $page ) { |
| 241 | + $limitvalue = $page * $limit - ( $limit ); |
223 | 242 | } |
224 | 243 | |
225 | 244 | $res = $dbr->select( |
— | — | @@ -261,6 +280,7 @@ |
262 | 281 | $s = $dbr->selectRow( |
263 | 282 | 'system_gift', |
264 | 283 | array( 'COUNT(*) AS count' ), |
| 284 | + array(), |
265 | 285 | __METHOD__ |
266 | 286 | ); |
267 | 287 | if ( $s !== false ) { |