Index: trunk/extensions/SocialProfile/UserProfile/SpecialUploadAvatar.php |
— | — | @@ -78,6 +78,8 @@ |
79 | 79 | wfMsgForContent( 'user-profile-picture-log-entry' ) |
80 | 80 | ); |
81 | 81 | |
| 82 | + $uid = $wgUser->getId(); |
| 83 | + |
82 | 84 | $output = '<h1>' . wfMsg( 'uploadavatar' ) . '</h1>'; |
83 | 85 | $output .= UserProfile::getEditProfileNav( wfMsg( 'user-profile-section-picture' ) ); |
84 | 86 | $output .= '<div class="profile-info">'; |
— | — | @@ -91,7 +93,7 @@ |
92 | 94 | wfMsg( 'user-profile-picture-large' ) . |
93 | 95 | '</td> |
94 | 96 | <td style="padding-bottom:20px;"> |
95 | | - <img src="' . $wgUploadPath . '/avatars/' . $wgDBname . '_' . $wgUser->mId . '_l.' . $ext . '?ts=' . rand() . '" alt="" border="0" /> |
| 97 | + <img src="' . $wgUploadPath . '/avatars/' . $wgDBname . '_' . $uid . '_l.' . $ext . '?ts=' . rand() . '" alt="" border="0" /> |
96 | 98 | </td> |
97 | 99 | </tr>'; |
98 | 100 | $output .= '<tr> |
— | — | @@ -99,7 +101,7 @@ |
100 | 102 | wfMsg( 'user-profile-picture-medlarge' ) . |
101 | 103 | '</td> |
102 | 104 | <td style="padding-bottom:20px;"> |
103 | | - <img src="' . $wgUploadPath . '/avatars/' . $wgDBname . '_' . $wgUser->mId . '_ml.' . $ext . '?ts=' . rand() . '" alt="" border="0" /> |
| 105 | + <img src="' . $wgUploadPath . '/avatars/' . $wgDBname . '_' . $uid . '_ml.' . $ext . '?ts=' . rand() . '" alt="" border="0" /> |
104 | 106 | </td> |
105 | 107 | </tr>'; |
106 | 108 | $output .= '<tr> |
— | — | @@ -107,7 +109,7 @@ |
108 | 110 | wfMsg( 'user-profile-picture-medium' ) . |
109 | 111 | '</td> |
110 | 112 | <td style="padding-bottom:20px;"> |
111 | | - <img src="' . $wgUploadPath . '/avatars/' . $wgDBname . '_' . $wgUser->mId . '_m.' . $ext . '?ts=' . rand() . '" alt="" border="0" /> |
| 113 | + <img src="' . $wgUploadPath . '/avatars/' . $wgDBname . '_' . $uid . '_m.' . $ext . '?ts=' . rand() . '" alt="" border="0" /> |
112 | 114 | </td> |
113 | 115 | </tr>'; |
114 | 116 | $output .= '<tr> |
— | — | @@ -115,7 +117,7 @@ |
116 | 118 | wfMsg( 'user-profile-picture-small' ) . |
117 | 119 | '</td> |
118 | 120 | <td style="padding-bottom:20px;"> |
119 | | - <img src="' . $wgUploadPath . '/avatars/' . $wgDBname . '_' . $wgUser->mId . '_s.' . $ext . '?ts' . rand() . '" alt="" border="0" /> |
| 121 | + <img src="' . $wgUploadPath . '/avatars/' . $wgDBname . '_' . $uid . '_s.' . $ext . '?ts=' . rand() . '" alt="" border="0" /> |
120 | 122 | </td> |
121 | 123 | </tr>'; |
122 | 124 | $output .= '<tr> |
— | — | @@ -235,7 +237,7 @@ |
236 | 238 | function createThumbnail( $imageSrc, $imageInfo, $imgDest, $thumbWidth ) { |
237 | 239 | global $wgImageMagickConvertCommand; |
238 | 240 | |
239 | | - list( $origWidth, $origHeight, $typeCode ) = $imageInfo; |
| 241 | + list( $origWidth, $origHeight, $typeCode ) = $imageInfo; |
240 | 242 | |
241 | 243 | if ( $origWidth < $thumbWidth ) { |
242 | 244 | $thumbWidth = $origWidth; |
— | — | @@ -296,70 +298,74 @@ |
297 | 299 | |
298 | 300 | $dest = $this->avatarUploadDirectory; |
299 | 301 | |
300 | | - $avatar = new wAvatar( $wgUser->getID(), 'l' ); |
| 302 | + $uid = $wgUser->getId(); |
| 303 | + $avatar = new wAvatar( $uid, 'l' ); |
| 304 | + // If this is the user's first custom avatar, update statistics (in |
| 305 | + // case if we want to give out some points to the user for uploading |
| 306 | + // their first avatar) |
301 | 307 | if ( strpos( $avatar->getAvatarImage(), 'default_' ) !== false ) { |
302 | | - $stats = new UserStatsTrack( $wgUser->getID(), $wgUser->getName() ); |
| 308 | + $stats = new UserStatsTrack( $uid, $wgUser->getName() ); |
303 | 309 | $stats->incStatField( 'user_image' ); |
304 | 310 | } |
305 | 311 | |
306 | | - $this->createThumbnail( $this->mTempPath, $imageInfo, $wgDBname . '_' . $wgUser->mId . '_l', 75 ); |
307 | | - $this->createThumbnail( $this->mTempPath, $imageInfo, $wgDBname . '_' . $wgUser->mId . '_ml', 50 ); |
308 | | - $this->createThumbnail( $this->mTempPath, $imageInfo, $wgDBname . '_' . $wgUser->mId . '_m', 30 ); |
309 | | - $this->createThumbnail( $this->mTempPath, $imageInfo, $wgDBname . '_' . $wgUser->mId . '_s', 16 ); |
| 312 | + $this->createThumbnail( $this->mTempPath, $imageInfo, $wgDBname . '_' . $uid . '_l', 75 ); |
| 313 | + $this->createThumbnail( $this->mTempPath, $imageInfo, $wgDBname . '_' . $uid . '_ml', 50 ); |
| 314 | + $this->createThumbnail( $this->mTempPath, $imageInfo, $wgDBname . '_' . $uid . '_m', 30 ); |
| 315 | + $this->createThumbnail( $this->mTempPath, $imageInfo, $wgDBname . '_' . $uid . '_s', 16 ); |
310 | 316 | |
311 | 317 | if ( $ext != 'jpg' ) { |
312 | | - if ( is_file( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $wgUser->mId . '_s.jpg' ) ) { |
313 | | - unlink( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $wgUser->mId . '_s.jpg' ); |
| 318 | + if ( is_file( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_s.jpg' ) ) { |
| 319 | + unlink( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_s.jpg' ); |
314 | 320 | } |
315 | | - if ( is_file( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $wgUser->mId . '_m.jpg' ) ) { |
316 | | - unlink( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $wgUser->mId . '_m.jpg' ); |
| 321 | + if ( is_file( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_m.jpg' ) ) { |
| 322 | + unlink( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_m.jpg' ); |
317 | 323 | } |
318 | | - if ( is_file( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $wgUser->mId . '_l.jpg' ) ) { |
319 | | - unlink( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $wgUser->mId . '_l.jpg' ); |
| 324 | + if ( is_file( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_l.jpg' ) ) { |
| 325 | + unlink( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_l.jpg' ); |
320 | 326 | } |
321 | | - if ( is_file( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $wgUser->mId . '_ml.jpg' ) ) { |
322 | | - unlink( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $wgUser->mId . '_ml.jpg' ); |
| 327 | + if ( is_file( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_ml.jpg' ) ) { |
| 328 | + unlink( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_ml.jpg' ); |
323 | 329 | } |
324 | 330 | } |
325 | 331 | if ( $ext != 'gif' ) { |
326 | | - if ( is_file( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $wgUser->mId . '_s.gif' ) ) { |
327 | | - unlink( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $wgUser->mId . '_s.gif' ); |
| 332 | + if ( is_file( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_s.gif' ) ) { |
| 333 | + unlink( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_s.gif' ); |
328 | 334 | } |
329 | | - if ( is_file( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $wgUser->mId . '_m.gif' ) ) { |
330 | | - unlink( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $wgUser->mId . '_m.gif' ); |
| 335 | + if ( is_file( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_m.gif' ) ) { |
| 336 | + unlink( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_m.gif' ); |
331 | 337 | } |
332 | | - if ( is_file( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $wgUser->mId . '_l.gif' ) ) { |
333 | | - unlink( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $wgUser->mId . '_l.gif' ); |
| 338 | + if ( is_file( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_l.gif' ) ) { |
| 339 | + unlink( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_l.gif' ); |
334 | 340 | } |
335 | | - if ( is_file( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $wgUser->mId . '_ml.gif' ) ) { |
336 | | - unlink( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $wgUser->mId . '_ml.gif' ); |
| 341 | + if ( is_file( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_ml.gif' ) ) { |
| 342 | + unlink( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_ml.gif' ); |
337 | 343 | } |
338 | 344 | } |
339 | 345 | if ( $ext != 'png' ) { |
340 | | - if ( is_file( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $wgUser->mId . '_s.png' ) ) { |
341 | | - unlink( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $wgUser->mId . '_s.png' ); |
| 346 | + if ( is_file( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_s.png' ) ) { |
| 347 | + unlink( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_s.png' ); |
342 | 348 | } |
343 | | - if ( is_file( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $wgUser->mId . '_m.png' ) ) { |
344 | | - unlink( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $wgUser->mId . '_m.png' ); |
| 349 | + if ( is_file( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_m.png' ) ) { |
| 350 | + unlink( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_m.png' ); |
345 | 351 | } |
346 | | - if ( is_file( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $wgUser->mId . '_l.png' ) ) { |
347 | | - unlink( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $wgUser->mId . '_l.png' ); |
| 352 | + if ( is_file( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_l.png' ) ) { |
| 353 | + unlink( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_l.png' ); |
348 | 354 | } |
349 | | - if ( is_file( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $wgUser->mId . '_ml.png' ) ) { |
350 | | - unlink( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $wgUser->mId . '_ml.png' ); |
| 355 | + if ( is_file( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_ml.png' ) ) { |
| 356 | + unlink( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_ml.png' ); |
351 | 357 | } |
352 | 358 | } |
353 | 359 | |
354 | | - $key = wfMemcKey( 'user', 'profile', 'avatar', $wgUser->getID(), 's' ); |
| 360 | + $key = wfMemcKey( 'user', 'profile', 'avatar', $uid, 's' ); |
355 | 361 | $data = $wgMemc->delete( $key ); |
356 | 362 | |
357 | | - $key = wfMemcKey( 'user', 'profile', 'avatar', $wgUser->getID(), 'm' ); |
| 363 | + $key = wfMemcKey( 'user', 'profile', 'avatar', $uid, 'm' ); |
358 | 364 | $data = $wgMemc->delete( $key ); |
359 | 365 | |
360 | | - $key = wfMemcKey( 'user', 'profile', 'avatar', $wgUser->getID() , 'l' ); |
| 366 | + $key = wfMemcKey( 'user', 'profile', 'avatar', $uid , 'l' ); |
361 | 367 | $data = $wgMemc->delete( $key ); |
362 | 368 | |
363 | | - $key = wfMemcKey( 'user', 'profile', 'avatar', $wgUser->getID() , 'ml' ); |
| 369 | + $key = wfMemcKey( 'user', 'profile', 'avatar', $uid, 'ml' ); |
364 | 370 | $data = $wgMemc->delete( $key ); |
365 | 371 | |
366 | 372 | $this->mExtension = $ext; |