Index: trunk/extensions/SocialProfile/UserProfile/UserProfilePage.php |
— | — | @@ -11,12 +11,12 @@ |
12 | 12 | |
13 | 13 | class UserProfilePage extends Article { |
14 | 14 | |
15 | | - var $title = null; |
| 15 | + public $title = null; |
16 | 16 | |
17 | 17 | /** |
18 | 18 | * Constructor |
19 | 19 | */ |
20 | | - function __construct( &$title ) { |
| 20 | + function __construct( $title ) { |
21 | 21 | global $wgUser; |
22 | 22 | parent::__construct( $title ); |
23 | 23 | $this->user_name = $title->getText(); |
— | — | @@ -219,7 +219,7 @@ |
220 | 220 | array( |
221 | 221 | 'page_title', 'UNIX_TIMESTAMP(poll_date) AS poll_date' |
222 | 222 | ), |
223 | | - /*where*/ array( 'poll_user_id' => $this->user_id ), |
| 223 | + /* WHERE */array( 'poll_user_id' => $this->user_id ), |
224 | 224 | __METHOD__, |
225 | 225 | array( 'ORDER BY' => 'poll_id DESC', 'LIMIT' => 3 ), |
226 | 226 | array( 'page' => array( 'INNER JOIN', 'page_id = poll_page_id' ) ) |
— | — | @@ -516,10 +516,7 @@ |
517 | 517 | $user_level = new UserLevel( $stats_data['points'] ); |
518 | 518 | $level_link = Title::makeTitle( NS_HELP, wfMsgForContent( 'user-profile-userlevels-link' ) ); |
519 | 519 | |
520 | | - if ( !$this->profile_data ) { |
521 | | - $profile = new UserProfile( $user_name ); |
522 | | - $this->profile_data = $profile->getProfile(); |
523 | | - } |
| 520 | + $this->initializeProfileData( $user_name ); |
524 | 521 | $profile_data = $this->profile_data; |
525 | 522 | |
526 | 523 | $defaultCountry = wfMsgForContent( 'user-profile-default-country' ); |
— | — | @@ -636,10 +633,7 @@ |
637 | 634 | return ''; |
638 | 635 | } |
639 | 636 | |
640 | | - if ( !$this->profile_data ) { |
641 | | - $profile = new UserProfile( $user_name ); |
642 | | - $this->profile_data = $profile->getProfile(); |
643 | | - } |
| 637 | + $this->initializeProfileData( $user_name ); |
644 | 638 | |
645 | 639 | $profile_data = $this->profile_data; |
646 | 640 | |
— | — | @@ -707,10 +701,7 @@ |
708 | 702 | return ''; |
709 | 703 | } |
710 | 704 | |
711 | | - if ( !$this->profile_data ) { |
712 | | - $profile = new UserProfile( $user_name ); |
713 | | - $this->profile_data = $profile->getProfile(); |
714 | | - } |
| 705 | + $this->initializeProfileData( $user_name ); |
715 | 706 | |
716 | 707 | $profile_data = $this->profile_data; |
717 | 708 | $joined_data = $profile_data['movies'] . $profile_data['tv'] . |
— | — | @@ -747,7 +738,7 @@ |
748 | 739 | $this->getProfileSection( wfMsg( 'other-info-snacks' ), $profile_data['snacks'], false ) . |
749 | 740 | $this->getProfileSection( wfMsg( 'other-info-drinks' ), $profile_data['drinks'], false ) . |
750 | 741 | '</div>'; |
751 | | - } elseif ( $wgUser->getName() == $user_name ) { |
| 742 | + } elseif ( $this->isOwner() ) { |
752 | 743 | $output .= '<div class="user-section-heading"> |
753 | 744 | <div class="user-section-title">' . |
754 | 745 | wfMsg( 'other-info-title' ) . |
— | — | @@ -786,10 +777,7 @@ |
787 | 778 | $user_level = new UserLevel( $stats_data['points'] ); |
788 | 779 | $level_link = Title::makeTitle( NS_HELP, wfMsgForContent( 'user-profile-userlevels-link' ) ); |
789 | 780 | |
790 | | - if ( !$this->profile_data ) { |
791 | | - $profile = new UserProfile( $user_name ); |
792 | | - $this->profile_data = $profile->getProfile(); |
793 | | - } |
| 781 | + $this->initializeProfileData( $user_name ); |
794 | 782 | $profile_data = $this->profile_data; |
795 | 783 | |
796 | 784 | // Variables and other crap |
— | — | @@ -942,7 +930,7 @@ |
943 | 931 | $avatar = new wAvatar( $this->user_id, 'l' ); |
944 | 932 | $avatarTitle = SpecialPage::getTitleFor( 'UploadAvatar' ); |
945 | 933 | |
946 | | - $output .= '<div class="profile-image">'; |
| 934 | + $output = '<div class="profile-image">'; |
947 | 935 | if ( $wgUser->getName() == $this->user_name ) { |
948 | 936 | if ( strpos( $avatar->getAvatarImage(), 'default_' ) != false ) { |
949 | 937 | $caption = 'upload image'; |
— | — | @@ -1234,63 +1222,6 @@ |
1235 | 1223 | $by_type .= $item; |
1236 | 1224 | } |
1237 | 1225 | $output .= "<div id=\"recent-all\">$by_type</div>"; |
1238 | | - |
1239 | | - $by_type = ''; |
1240 | | - if ( isset( $items_html_type['edit'] ) && is_array( $items_html_type['edit'] ) ) { |
1241 | | - foreach ( $items_html_type['edit'] as $item ) { |
1242 | | - $by_type .= $item; |
1243 | | - } |
1244 | | - } |
1245 | | - |
1246 | | - $by_type = ''; |
1247 | | - if ( isset( $items_html_type['comment'] ) && is_array( $items_html_type['comment'] ) ) { |
1248 | | - foreach ( $items_html_type['comment'] as $item ) { |
1249 | | - $by_type .= $item; |
1250 | | - } |
1251 | | - } |
1252 | | - |
1253 | | - $by_type = ''; |
1254 | | - if ( isset( $items_html_type['gift-sent'] ) && is_array( $items_html_type['gift-sent'] ) ) { |
1255 | | - foreach ( $items_html_type['gift-sent'] as $item ) { |
1256 | | - $by_type .= $item; |
1257 | | - } |
1258 | | - } |
1259 | | - |
1260 | | - $by_type = ''; |
1261 | | - if ( isset( $items_html_type['gift-rec'] ) && is_array( $items_html_type['gift-rec'] ) ) { |
1262 | | - foreach ( $items_html_type['gift-rec'] as $item ) { |
1263 | | - $by_type .= $item; |
1264 | | - } |
1265 | | - } |
1266 | | - |
1267 | | - $by_type = ''; |
1268 | | - if ( isset( $items_html_type['system_gift'] ) && is_array( $items_html_type['system_gift'] ) ) { |
1269 | | - foreach ( $items_html_type['system_gift'] as $item ) { |
1270 | | - $by_type .= $item; |
1271 | | - } |
1272 | | - } |
1273 | | - |
1274 | | - $by_type = ''; |
1275 | | - if ( isset( $items_html_type['friend'] ) && is_array( $items_html_type['friend'] ) ) { |
1276 | | - foreach ( $items_html_type['friend'] as $item ) { |
1277 | | - $by_type .= $item; |
1278 | | - } |
1279 | | - } |
1280 | | - |
1281 | | - $by_type = ''; |
1282 | | - if ( isset( $items_html_type['foe'] ) && is_array( $items_html_type['foe'] ) ) { |
1283 | | - foreach ( $items_html_type['foe'] as $item ) { |
1284 | | - $by_type .= $item; |
1285 | | - } |
1286 | | - } |
1287 | | - |
1288 | | - $by_type = ''; |
1289 | | - if ( isset( $items_html_type['system_message'] ) && is_array( $items_html_type['system_message'] ) ) { |
1290 | | - foreach ( $items_html_type['system_message'] as $item ) { |
1291 | | - $by_type .= $item; |
1292 | | - } |
1293 | | - } |
1294 | | - |
1295 | 1226 | } |
1296 | 1227 | |
1297 | 1228 | return $output; |
— | — | @@ -1548,7 +1479,7 @@ |
1549 | 1480 | if ( $wgUser->isLoggedIn() && !$wgUser->isBlocked() ) { |
1550 | 1481 | $output .= '<div class="user-page-message-form"> |
1551 | 1482 | <input type="hidden" id="user_name_to" name="user_name_to" value="' . addslashes( $user_name ) . '" /> |
1552 | | - <span style="color:#797979;">' . |
| 1483 | + <span class="profile-board-message-type">' . |
1553 | 1484 | wfMsgHtml( 'userboard_messagetype' ) . |
1554 | 1485 | '</span> |
1555 | 1486 | <select id="message_type"> |
— | — | @@ -1782,4 +1713,10 @@ |
1783 | 1714 | return $output; |
1784 | 1715 | } |
1785 | 1716 | |
| 1717 | + private function initializeProfileData( $username ) { |
| 1718 | + if ( !$this->profile_data ) { |
| 1719 | + $profile = new UserProfile( $username ); |
| 1720 | + $this->profile_data = $profile->getProfile(); |
| 1721 | + } |
| 1722 | + } |
1786 | 1723 | } |
Index: trunk/extensions/SocialProfile/UserProfile/UserProfile.css |
— | — | @@ -652,3 +652,8 @@ |
653 | 653 | color: #fff; |
654 | 654 | font-weight: bold; |
655 | 655 | } |
| 656 | + |
| 657 | +/* The text "Message type" on the left side of the message type selector on profile page */ |
| 658 | +.profile-board-message-type { |
| 659 | + color: #797979; |
| 660 | +} |
\ No newline at end of file |
Index: trunk/extensions/SocialProfile/UserProfile/AvatarClass.php |
— | — | @@ -12,9 +12,9 @@ |
13 | 13 | * @ingroup Extensions |
14 | 14 | */ |
15 | 15 | class wAvatar { |
16 | | - var $user_name = null; |
17 | | - var $user_id; |
18 | | - var $avatar_type = 0; |
| 16 | + public $user_name = null; |
| 17 | + public $user_id; |
| 18 | + public $avatar_type = 0; |
19 | 19 | |
20 | 20 | /** |
21 | 21 | * Constructor |
Index: trunk/extensions/SocialProfile/UserProfile/SpecialUpdateProfile.php |
— | — | @@ -39,7 +39,6 @@ |
40 | 40 | __METHOD__ |
41 | 41 | ); |
42 | 42 | if ( $s === false ) { |
43 | | - $dbw = wfGetDB( DB_MASTER ); |
44 | 43 | $dbw->insert( |
45 | 44 | 'user_profile', |
46 | 45 | array( 'up_user_id' => $user->getID() ), |
— | — | @@ -222,7 +221,7 @@ |
223 | 222 | wfRunHooks( 'SpecialUpdateProfile::saveSettings_pref', array( $this, $wgRequest ) ); |
224 | 223 | } |
225 | 224 | |
226 | | - function formatBirthdayDB( $birthday ) { |
| 225 | + public static function formatBirthdayDB( $birthday ) { |
227 | 226 | $dob = explode( '/', $birthday ); |
228 | 227 | if ( count( $dob ) == 2 || count( $dob ) == 3 ) { |
229 | 228 | $year = isset( $dob[2] ) ? $dob[2] : 2007; |
— | — | @@ -235,7 +234,7 @@ |
236 | 235 | return ( $birthday_date ); |
237 | 236 | } |
238 | 237 | |
239 | | - function formatBirthday( $birthday, $showYOB = false ) { |
| 238 | + public static function formatBirthday( $birthday, $showYOB = false ) { |
240 | 239 | $dob = explode( '-', $birthday ); |
241 | 240 | if ( count( $dob ) == 3 ) { |
242 | 241 | $month = $dob[1]; |
— | — | @@ -275,7 +274,7 @@ |
276 | 275 | 'up_hometown_state' => $wgRequest->getVal( 'hometown_state' ), |
277 | 276 | 'up_hometown_country' => $wgRequest->getVal( 'hometown_country' ), |
278 | 277 | |
279 | | - 'up_birthday' => $this->formatBirthdayDB( $wgRequest->getVal( 'birthday' ) ), |
| 278 | + 'up_birthday' => self::formatBirthdayDB( $wgRequest->getVal( 'birthday' ) ), |
280 | 279 | 'up_about' => $wgRequest->getVal( 'about' ), |
281 | 280 | 'up_occupation' => $wgRequest->getVal( 'occupation' ), |
282 | 281 | 'up_schools' => $wgRequest->getVal( 'schools' ), |
— | — | @@ -375,7 +374,7 @@ |
376 | 375 | function displayBasicForm( $user ) { |
377 | 376 | global $wgRequest, $wgUser, $wgOut; |
378 | 377 | |
379 | | - $dbr = wfGetDB( DB_MASTER ); |
| 378 | + $dbr = wfGetDB( DB_SLAVE ); |
380 | 379 | $s = $dbr->selectRow( 'user_profile', |
381 | 380 | array( |
382 | 381 | 'up_location_city', 'up_location_state', 'up_location_country', |
— | — | @@ -398,7 +397,7 @@ |
399 | 398 | $hometown_state = $s->up_hometown_state; |
400 | 399 | $hometown_country = $s->up_hometown_country; |
401 | 400 | $showYOB = $wgUser->getIntOption( 'showyearofbirth', !isset( $s->up_birthday ) ) == 1; |
402 | | - $birthday = $this->formatBirthday( $s->up_birthday, $showYOB ); |
| 401 | + $birthday = self::formatBirthday( $s->up_birthday, $showYOB ); |
403 | 402 | $schools = $s->up_schools; |
404 | 403 | $places = $s->up_places_lived; |
405 | 404 | $websites = $s->up_websites; |
— | — | @@ -473,7 +472,7 @@ |
474 | 473 | } |
475 | 474 | |
476 | 475 | $form .= '</select>'; |
477 | | - $form .= '</p> |
| 476 | + $form .= '</p> |
478 | 477 | <div class="cleared"></div> |
479 | 478 | </div> |
480 | 479 | <div class="cleared"></div>'; |
— | — | @@ -582,8 +581,9 @@ |
583 | 582 | function displayPersonalForm( $user ) { |
584 | 583 | global $wgRequest, $wgUser, $wgOut; |
585 | 584 | |
586 | | - $dbr = wfGetDB( DB_MASTER ); |
587 | | - $s = $dbr->selectRow( 'user_profile', |
| 585 | + $dbr = wfGetDB( DB_SLAVE ); |
| 586 | + $s = $dbr->selectRow( |
| 587 | + 'user_profile', |
588 | 588 | array( |
589 | 589 | 'up_about', 'up_places_lived', 'up_websites', 'up_relationship', |
590 | 590 | 'up_occupation', 'up_companies', 'up_schools', 'up_movies', |
— | — | @@ -676,7 +676,7 @@ |
677 | 677 | function displayPreferencesForm() { |
678 | 678 | global $wgRequest, $wgUser, $wgOut; |
679 | 679 | |
680 | | - $dbr = wfGetDB( DB_MASTER ); |
| 680 | + $dbr = wfGetDB( DB_SLAVE ); |
681 | 681 | $s = $dbr->selectRow( |
682 | 682 | 'user_profile', |
683 | 683 | array( 'up_birthday' ), |
Index: trunk/extensions/SocialProfile/UserProfile/SpecialEditProfile.php |
— | — | @@ -158,7 +158,7 @@ |
159 | 159 | function displayBasicForm( $tar ) { |
160 | 160 | global $wgRequest, $wgUser, $wgOut; |
161 | 161 | |
162 | | - $dbr = wfGetDB( DB_MASTER ); |
| 162 | + $dbr = wfGetDB( DB_SLAVE ); |
163 | 163 | $s = $dbr->selectRow( 'user_profile', |
164 | 164 | array( |
165 | 165 | 'up_location_city', 'up_location_state', 'up_location_country', |
— | — | @@ -179,7 +179,7 @@ |
180 | 180 | $hometown_city = $s->up_hometown_city; |
181 | 181 | $hometown_state = $s->up_hometown_state; |
182 | 182 | $hometown_country = $s->up_hometown_country; |
183 | | - $birthday = $this->formatBirthday( $s->up_birthday, true ); |
| 183 | + $birthday = self::formatBirthday( $s->up_birthday, true ); |
184 | 184 | $schools = $s->up_schools; |
185 | 185 | $places = $s->up_places_lived; |
186 | 186 | $websites = $s->up_websites; |
— | — | @@ -254,7 +254,7 @@ |
255 | 255 | } |
256 | 256 | |
257 | 257 | $form .= '</select>'; |
258 | | - $form .= '</p> |
| 258 | + $form .= '</p> |
259 | 259 | <div class="cleared"></div> |
260 | 260 | </div> |
261 | 261 | <div class="cleared"></div>'; |
— | — | @@ -349,7 +349,7 @@ |
350 | 350 | function displayPersonalForm( $tar ) { |
351 | 351 | global $wgRequest, $wgUser, $wgOut; |
352 | 352 | |
353 | | - $dbr = wfGetDB( DB_MASTER ); |
| 353 | + $dbr = wfGetDB( DB_SLAVE ); |
354 | 354 | $s = $dbr->selectRow( 'user_profile', |
355 | 355 | array( |
356 | 356 | 'up_about', 'up_places_lived', 'up_websites', 'up_relationship', |
— | — | @@ -438,7 +438,7 @@ |
439 | 439 | function displayCustomForm( $tar ) { |
440 | 440 | global $wgRequest, $wgUser, $wgOut; |
441 | 441 | |
442 | | - $dbr = wfGetDB( DB_MASTER ); |
| 442 | + $dbr = wfGetDB( DB_SLAVE ); |
443 | 443 | $s = $dbr->selectRow( |
444 | 444 | 'user_profile', |
445 | 445 | array( |
Index: trunk/extensions/SocialProfile/UserProfile/SpecialToggleUserPageType.php |
— | — | @@ -38,19 +38,18 @@ |
39 | 39 | return; |
40 | 40 | } |
41 | 41 | |
42 | | - $dbr = wfGetDB( DB_MASTER ); |
43 | | - $s = $dbr->selectRow( |
| 42 | + $dbw = wfGetDB( DB_MASTER ); |
| 43 | + $s = $dbw->selectRow( |
44 | 44 | 'user_profile', |
45 | 45 | array( 'up_user_id' ), |
46 | 46 | array( 'up_user_id' => $wgUser->getID() ), |
47 | 47 | __METHOD__ |
48 | 48 | ); |
49 | 49 | if ( $s === false ) { |
50 | | - $dbw = wfGetDB( DB_MASTER ); |
51 | | - $dbw->insert( 'user_profile', |
52 | | - array( |
53 | | - 'up_user_id' => $wgUser->getID() |
54 | | - ), __METHOD__ |
| 50 | + $dbw->insert( |
| 51 | + 'user_profile', |
| 52 | + array( 'up_user_id' => $wgUser->getID() ), |
| 53 | + __METHOD__ |
55 | 54 | ); |
56 | 55 | } |
57 | 56 | |
— | — | @@ -59,8 +58,8 @@ |
60 | 59 | |
61 | 60 | $user_page_type = ( ( $profile_data['user_page_type'] == 1 ) ? 0 : 1 ); |
62 | 61 | |
63 | | - $dbw = wfGetDB( DB_MASTER ); |
64 | | - $dbw->update( 'user_profile', |
| 62 | + $dbw->update( |
| 63 | + 'user_profile', |
65 | 64 | /* SET */array( |
66 | 65 | 'up_type' => $user_page_type |
67 | 66 | ), |
Index: trunk/extensions/SocialProfile/UserProfile/UserProfilePage.js |
— | — | @@ -58,7 +58,7 @@ |
59 | 59 | document.getElementById( 'upload-frame-errors' ).innerHTML = ''; |
60 | 60 | oldHtml = document.getElementById( 'mini-gallery-' + replaceID ).innerHTML; |
61 | 61 | |
62 | | - for( x = 7; x > 0; x-- ) { |
| 62 | + for( var x = 7; x > 0; x-- ) { |
63 | 63 | document.getElementById( 'mini-gallery-' + ( x ) ).innerHTML = |
64 | 64 | document.getElementById( 'mini-gallery-' + ( x - 1 ) ).innerHTML.replace( 'slideShowLink(' + ( x - 1 ) + ')','slideShowLink(' + ( x ) + ')' ); |
65 | 65 | } |
Index: trunk/extensions/SocialProfile/UserProfile/UserProfileClass.php |
— | — | @@ -6,25 +6,25 @@ |
7 | 7 | /** |
8 | 8 | * @var Integer: the current user's user ID. Set in the constructor. |
9 | 9 | */ |
10 | | - var $user_id; |
| 10 | + public $user_id; |
11 | 11 | |
12 | 12 | /** |
13 | 13 | * @var String: the current user's user name. Set in the constructor. |
14 | 14 | */ |
15 | | - var $user_name; |
| 15 | + public $user_name; |
16 | 16 | |
17 | 17 | /** unused, remove me? */ |
18 | | - var $profile; |
| 18 | + public $profile; |
19 | 19 | |
20 | 20 | /** |
21 | 21 | * @var Integer: used in getProfileComplete() |
22 | 22 | */ |
23 | | - var $profile_fields_count; |
| 23 | + public $profile_fields_count; |
24 | 24 | |
25 | 25 | /** |
26 | 26 | * @var Array: array of valid profile fields; used in getProfileComplete() |
27 | 27 | */ |
28 | | - var $profile_fields = array( |
| 28 | + public $profile_fields = array( |
29 | 29 | 'real_name', |
30 | 30 | 'location_city', |
31 | 31 | 'hometown_city', |
— | — | @@ -51,7 +51,7 @@ |
52 | 52 | /** |
53 | 53 | * @var Array: unused, remove me? |
54 | 54 | */ |
55 | | - var $profile_missing = array(); |
| 55 | + public $profile_missing = array(); |
56 | 56 | |
57 | 57 | /** |
58 | 58 | * Constructor |
— | — | @@ -118,7 +118,7 @@ |
119 | 119 | $profile['hometown_city'] = isset( $row->up_hometown_city ) ? $row->up_hometown_city : ''; |
120 | 120 | $profile['hometown_state'] = isset( $row->up_hometown_state ) ? $row->up_hometown_state : ''; |
121 | 121 | $profile['hometown_country'] = isset( $row->up_hometown_country ) ? $row->up_hometown_country : ''; |
122 | | - $profile['birthday'] = $this->formatBirthday( $issetUpBirthday, $showYOB); |
| 122 | + $profile['birthday'] = $this->formatBirthday( $issetUpBirthday, $showYOB ); |
123 | 123 | |
124 | 124 | $profile['about'] = isset( $row->up_about ) ? $row->up_about : ''; |
125 | 125 | $profile['places_lived'] = isset( $row->up_places_lived ) ? $row->up_places_lived : ''; |
Index: trunk/extensions/SocialProfile/UserProfile/UpdateProfile.js |
— | — | @@ -22,13 +22,13 @@ |
23 | 23 | |
24 | 24 | function displaySection( id, country, section ) { |
25 | 25 | country_id = -1; |
26 | | - for( x = 0; x <= countries.length-1; x++ ) { |
| 26 | + for( var x = 0; x <= countries.length-1; x++ ) { |
27 | 27 | if( country == countries[x].country ) { |
28 | 28 | country_id = x; |
29 | 29 | } |
30 | 30 | } |
31 | 31 | |
32 | | - section_select = ''; |
| 32 | + var section_select = ''; |
33 | 33 | if( countries[country_id] ) { |
34 | 34 | document.getElementById( id + '_label' ).innerHTML = countries[country_id].name; |
35 | 35 | section_select += '<select class="profile-form" name="' + id + '" id="' + id + '"><option></option>'; |