r50765 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50764‎ | r50765 | r50766 >
Date:12:45, 19 May 2009
Author:ashley
Status:deferred
Tags:
Comment:
SocialProfile: tweaks to UpdateProfile special page - only spam unconfirmed users with that confirm email message (it's broken anyway, the links aren't working) and add ids to some elements to that they can be hidden with css
Modified paths:
  • /trunk/extensions/SocialProfile/UserProfile/SpecialUpdateProfile.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SocialProfile/UserProfile/SpecialUpdateProfile.php
@@ -47,7 +47,7 @@
4848
4949 // This feature is only available for logged-in users.
5050 if( !$wgUser->isLoggedIn() ) {
51 - $wgOut->setPagetitle( wfMsgForContent( 'user-profile-update-notloggedin-title' ) );
 51+ $wgOut->setPageTitle( wfMsgForContent( 'user-profile-update-notloggedin-title' ) );
5252 $wgOut->addHTML(
5353 wfMsgForContent( 'user-profile-update-notloggedin-text',
5454 SpecialPage::getTitleFor( 'UserLogin' )->escapeFullURL(),
@@ -64,8 +64,8 @@
6565 }
6666
6767 // Add CSS & JS
68 - $wgOut->addStyle( '../..' . $wgUserProfileScripts . '/UserProfile.css' );
69 - $wgOut->addScriptFile( $wgUserProfileScripts.'/UpdateProfile.js' );
 68+ $wgOut->addExtensionStyle( $wgUserProfileScripts . '/UserProfile.css' );
 69+ $wgOut->addScriptFile( $wgUserProfileScripts . '/UpdateProfile.js' );
7070
7171 if( $wgRequest->wasPosted() ){
7272 //$section = $wgRequest->getVal('section');
@@ -131,7 +131,7 @@
132132 $wgUser->mEmailAuthenticated = null; # but flag as "dirty" = unauthenticated
133133 }
134134
135 - if( $wgEmailAuthentication ) {
 135+ if( $wgEmailAuthentication && !$wgUser->isEmailConfirmed() ) {
136136 # Mail a temporary password to the dirty address.
137137 # User can come back through the confirmation URL to re-enable email.
138138 $result = $wgUser->sendConfirmationMail();
@@ -211,7 +211,7 @@
212212
213213 $this->initProfile();
214214 $dbw = wfGetDB( DB_MASTER );
215 - $dbw->update('user_profile',
 215+ $dbw->update('user_profile',
216216 array( /* SET */
217217 'up_location_city' => $wgRequest->getVal( 'location_city' ),
218218 'up_location_state' => $wgRequest->getVal( 'location_state' ),
@@ -231,9 +231,9 @@
232232 ), array( /* WHERE */
233233 'up_user_id' => $wgUser->getID()
234234 ), __METHOD__
235 - );
 235+ );
236236 // Relevant to Wikia Blackbird.
237 - if( $wgSitename == "Wikia Blackbird" ){
 237+ if( $wgSitename == 'Wikia Blackbird' ){
238238 $enroll = $wgRequest->getVal( 'enroll' );
239239 if( $enroll == '' ) $enroll = 0;
240240 $wgUser->setOption( 'blackbirdenroll', $enroll );
@@ -247,7 +247,7 @@
248248
249249 $this->initProfile();
250250 $dbw = wfGetDB( DB_MASTER );
251 - $dbw->update( 'user_profile',
 251+ $dbw->update( 'user_profile',
252252 array( /* SET */
253253 'up_custom_1' => $wgRequest->getVal( 'custom1' ),
254254 'up_custom_2' => $wgRequest->getVal( 'custom2' ),
@@ -256,7 +256,7 @@
257257 ), array( /* WHERE */
258258 'up_user_id' => $wgUser->getID()
259259 ), __METHOD__
260 - );
 260+ );
261261 $wgMemc->delete( wfMemcKey( 'user', 'profile', 'info', $wgUser->getID() ) );
262262 }
263263
@@ -345,19 +345,19 @@
346346 $form .= '<div class="profile-update">
347347 <p class="profile-update-title">' . wfMsg( 'user-profile-personal-info' ) . '</p>
348348 <p class="profile-update-unit-left">' . wfMsg( 'user-profile-personal-name' ) . '</p>
349 - <p class="profile-update-unit"><input type="text" size="25" name="real_name" id="real_name" value="'. $real_name . '"/></p>
 349+ <p class="profile-update-unit"><input type="text" size="25" name="real_name" id="real_name" value="' . $real_name . '"/></p>
350350 <div class="cleared"></div>
351351 <p class="profile-update-unit-left">' . wfMsg( 'user-profile-personal-email' ) . '</p>
352 - <p class="profile-update-unit"><input type="text" size="25" name="email" id="email" value="'. $email . '"/>';
 352+ <p class="profile-update-unit"><input type="text" size="25" name="email" id="email" value="' . $email . '"/>';
353353 if( !$wgUser->mEmailAuthenticated ){
354354 $confirm = SpecialPage::getTitleFor( 'Confirmemail' );
355 - $form .= " <a href=\"{$confirm->getFullURL()}\">" . wfMsg( 'user-profile-personal-confirmemail' ) . "</a>";
 355+ $form .= " <a href=\"{$confirm->getFullURL()}\">" . wfMsg( 'user-profile-personal-confirmemail' ) . '</a>';
356356 }
357357 $form .= '</p>
358358 <div class="cleared"></div>';
359359 if( !$wgUser->mEmailAuthenticated ){
360360 $form .= '<p class="profile-update-unit-left"></p>
361 - <p class="profile-update-unit-small">'.wfMsg( 'user-profile-personal-email-needs-auth' ).'</p>';
 361+ <p class="profile-update-unit-small">' . wfMsg( 'user-profile-personal-email-needs-auth' ) . '</p>';
362362 }
363363 $form .= '<div class="cleared"></div>
364364 </div>
@@ -391,7 +391,7 @@
392392 $form .= '<div class="profile-update">
393393 <p class="profile-update-title">' . wfMsg( 'user-profile-personal-hometown' ) . '</p>
394394 <p class="profile-update-unit-left">' . wfMsg( 'user-profile-personal-city' ) . '</p>
395 - <p class="profile-update-unit"><input type="text" size="25" name="hometown_city" id="hometown_city" value="'. $hometown_city . '" /></p>
 395+ <p class="profile-update-unit"><input type="text" size="25" name="hometown_city" id="hometown_city" value="' . $hometown_city . '" /></p>
396396 <div class="cleared"></div>
397397 <p class="profile-update-unit-left" id="hometown_state_label">' . wfMsg( 'user-profile-personal-country' ) . '</p>
398398 <p class="profile-update-unit">';
@@ -400,11 +400,11 @@
401401 <script type=\"text/javascript\">
402402 displaySection(\"hometown_state\",\"" . $hometown_country . "\",\"" . $hometown_state . "\")
403403 </script>";
404 - $form .= "<select name=\"hometown_country\" id=\"hometown_country\" onChange=\"displaySection('hometown_state',this.value,'')\"><option></option>";
 404+ $form .= "<select name=\"hometown_country\" id=\"hometown_country\" onchange=\"displaySection('hometown_state',this.value,'')\"><option></option>";
405405
406406 foreach( $countries as $country ) {
407407 $form .= "<option value=\"{$country}\"" . ( ( $country == $hometown_country ) ? ' selected="selected"' : '' ) . ">";
408 - $form .= $country . "</option>";
 408+ $form .= $country . '</option>';
409409 }
410410
411411 $form .= '</select>';
@@ -416,63 +416,64 @@
417417 $form .= '<div class="profile-update">
418418 <p class="profile-update-title">' . wfMsg( 'user-profile-personal-birthday' ) . '</p>
419419 <p class="profile-update-unit-left">' . wfMsg( 'user-profile-personal-birthdate' ) . '</p>
420 - <p class="profile-update-unit"><input type="text" size="25" name="birthday" id="birthday" value="'. $birthday . '" /></p>
 420+ <p class="profile-update-unit"><input type="text" size="25" name="birthday" id="birthday" value="' . $birthday . '" /></p>
421421 <div class="cleared"></div>
422422 </div><div class="cleared"></div>';
423423
424 - $form .= "<div class=\"profile-update\">
425 - <p class=\"profile-update-title\">" . wfMsg( 'user-profile-personal-aboutme' ) . "</p>
426 - <p class=\"profile-update-unit-left\">" . wfMsg( 'user-profile-personal-aboutme' ) . "</p>
427 - <p class=\"profile-update-unit\">
428 - <textarea name=\"about\" id=\"about\" rows=\"3\" cols=\"75\">{$about}</textarea>
 424+ $form .= '<div class="profile-update" id="profile-update-personal-aboutme">
 425+ <p class="profile-update-title">' . wfMsg( 'user-profile-personal-aboutme' ) . '</p>
 426+ <p class="profile-update-unit-left">' . wfMsg( 'user-profile-personal-aboutme' ) . '</p>
 427+ <p class="profile-update-unit">
 428+ <textarea name="about" id="about" rows="3" cols="75">' . $about . '</textarea>
429429 </p>
430 - <div class=\"cleared\"></div>
 430+ <div class="cleared"></div>
431431 </div>
432 - <div class=\"cleared\"></div>
 432+ <div class="cleared"></div>
433433
434 - <div class=\"profile-update\">
435 - <p class=\"profile-update-title\">" . wfMsg( 'user-profile-personal-work' ) . "</p>
436 - <p class=\"profile-update-unit-left\">" . wfMsg( 'user-profile-personal-occupation' ) . "</p>
437 - <p class=\"profile-update-unit\">
438 - <textarea name=\"occupation\" id=\"occupation\" rows=\"2\" cols=\"75\">{$occupation}</textarea>
 434+ <div class="profile-update" id="profile-update-personal-work">
 435+ <p class="profile-update-title">' . wfMsg( 'user-profile-personal-work' ) . '</p>
 436+ <p class="profile-update-unit-left">' . wfMsg( 'user-profile-personal-occupation' ) . '</p>
 437+ <p class="profile-update-unit">
 438+ <textarea name="occupation" id="occupation" rows="2" cols="75">' . $occupation . '</textarea>
439439 </p>
440 - <div class=\"cleared\"></div>
 440+ <div class="cleared"></div>
441441 </div>
442 - <div class=\"cleared\"></div>
 442+ <div class="cleared"></div>
443443
444 - <div class=\"profile-update\">
445 - <p class=\"profile-update-title\">" . wfMsg( 'user-profile-personal-education' ) . "</p>
446 - <p class=\"profile-update-unit-left\">" . wfMsg( 'user-profile-personal-schools' ) . "</p>
447 - <p class=\"profile-update-unit\">
448 - <textarea name=\"schools\" id=\"schools\" rows=\"2\" cols=\"75\">{$schools}</textarea>
 444+ <div class="profile-update" id="profile-update-personal-education">
 445+ <p class="profile-update-title">' . wfMsg( 'user-profile-personal-education' ) . '</p>
 446+ <p class="profile-update-unit-left">' . wfMsg( 'user-profile-personal-schools' ) . '</p>
 447+ <p class="profile-update-unit">
 448+ <textarea name="schools" id="schools" rows="2" cols="75">' . $schools . '</textarea>
449449 </p>
450 - <div class=\"cleared\"></div>
 450+ <div class="cleared"></div>
451451 </div>
452 - <div class=\"cleared\"></div>
 452+ <div class="cleared"></div>
453453
454 - <div class=\"profile-update\">
455 - <p class=\"profile-update-title\">" . wfMsg( 'user-profile-personal-places' ) . "</p>
456 - <p class=\"profile-update-unit-left\">" . wfMsg( 'user-profile-personal-placeslived' ) . "</p>
457 - <p class=\"profile-update-unit\">
458 - <textarea name=\"places\" id=\"places\" rows=\"3\" cols=\"75\">{$places}</textarea>
 454+ <div class="profile-update" id="profile-update-personal-places">
 455+ <p class="profile-update-title">' . wfMsg( 'user-profile-personal-places' ) . '</p>
 456+ <p class="profile-update-unit-left">' . wfMsg( 'user-profile-personal-placeslived' ) . '</p>
 457+ <p class="profile-update-unit">
 458+ <textarea name="places" id="places" rows="3" cols="75">' . $places . '</textarea>
459459 </p>
460 - <div class=\"cleared\"></div>
 460+ <div class="cleared"></div>
461461 </div>
462 - <div class=\"cleared\"></div>
 462+ <div class="cleared"></div>
463463
464 - <div class=\"profile-update\">
465 - <p class=\"profile-update-title\">" . wfMsg( 'user-profile-personal-web' ) . "</p>
466 - <p class=\"profile-update-unit-left\">" . wfMsg( 'user-profile-personal-websites' ) . "</p>
467 - <p class=\"profile-update-unit\">
468 - <textarea name=\"websites\" id=\"websites\" rows=\"2\" cols=\"75\">{$websites}</textarea>
 464+ <div class="profile-update" id="profile-update-personal-web">
 465+ <p class="profile-update-title">' . wfMsg( 'user-profile-personal-web' ) . '</p>
 466+ <p class="profile-update-unit-left">' . wfMsg( 'user-profile-personal-websites' ) . '</p>
 467+ <p class="profile-update-unit">
 468+ <textarea name="websites" id="websites" rows="2" cols="75">' . $websites . '</textarea>
469469 </p>
470 - <div class=\"cleared\"></div>
 470+ <div class="cleared"></div>
471471 </div>
472 - <div class=\"cleared\"></div>";
 472+ <div class="cleared"></div>';
473473
474474 $form .= '
475475 <input type="button" class="site-button" value="' . wfMsg( 'user-profile-update-button' ) . '" size="20" onclick="document.profile.submit()" />
476 - </div></form>';
 476+ </div>
 477+ </form>';
477478
478479 return $form;
479480 }
@@ -605,17 +606,21 @@
606607 return $form;
607608 }
608609
 610+ /**
 611+ * Displays the form for editing custom (site-specific) information
 612+ * @return $form Mixed: HTML output
 613+ */
609614 function displayCustomForm(){
610615 global $wgRequest, $wgUser, $wgOut;
611616
612617 $dbr = wfGetDB( DB_MASTER );
613618 $s = $dbr->selectRow( 'user_profile',
614 - array(
615 - 'up_custom_1', 'up_custom_2','up_custom_3', 'up_custom_4','up_custom_5'
616 - ),
617 - array( 'up_user_id' => $wgUser->getID() ),
618 - __METHOD__
619 - );
 619+ array(
 620+ 'up_custom_1', 'up_custom_2', 'up_custom_3', 'up_custom_4', 'up_custom_5'
 621+ ),
 622+ array( 'up_user_id' => $wgUser->getID() ),
 623+ __METHOD__
 624+ );
620625
621626 if ( $s !== false ) {
622627 $custom1 = $s->up_custom_1;
@@ -629,34 +634,42 @@
630635 $wgOut->setHTMLTitle( wfMsg( 'pagetitle', wfMsg( 'user-profile-tidbits-title' ) ) );
631636 $form = '<h1>' . wfMsg( 'user-profile-tidbits-title' ) . '</h1>';
632637 $form .= UserProfile::getEditProfileNav( wfMsg( 'user-profile-section-custom' ) );
633 - $form .= "<form action=\"\" method=\"post\" enctype=\"multipart/form-data\" name=\"profile\">
634 - <div class=\"profile-info clearfix\">
635 - <div class=\"profile-update\">
636 - <p class=\"profile-update-title\">" . wfMsgForContent( 'user-profile-tidbits-title' ) . "</p>
637 - <p class=\"profile-update-unit-left\">" . wfMsgForContent( 'custom-info-field1' ) . "</p>
638 - <p class=\"profile-update-unit\">
639 - <textarea name=\"custom1\" id=\"fav_moment\" rows=\"3\" cols=\"75\">{$custom1}</textarea>
 638+ $form .= '<form action="" method="post" enctype="multipart/form-data" name="profile">
 639+ <div class="profile-info clearfix">
 640+ <div class="profile-update">
 641+ <p class="profile-update-title">' . wfMsgForContent( 'user-profile-tidbits-title' ) . '</p>
 642+ <div id="profile-update-custom1">
 643+ <p class="profile-update-unit-left">' . wfMsgForContent( 'custom-info-field1' ) . '</p>
 644+ <p class="profile-update-unit">
 645+ <textarea name="custom1" id="fav_moment" rows="3" cols="75">' . $custom1 . '</textarea>
640646 </p>
641 - <div class=\"cleared\"></div>
642 - <p class=\"profile-update-unit-left\">" . wfMsgForContent( 'custom-info-field2' ) . "</p>
643 - <p class=\"profile-update-unit\">
644 - <textarea name=\"custom2\" id=\"least_moment\" rows=\"3\" cols=\"75\">{$custom2}</textarea>
 647+ </div>
 648+ <div class="cleared"></div>
 649+ <div id="profile-update-custom2">
 650+ <p class="profile-update-unit-left">' . wfMsgForContent( 'custom-info-field2' ) . '</p>
 651+ <p class="profile-update-unit">
 652+ <textarea name="custom2" id="least_moment" rows="3" cols="75">' . $custom2 . '</textarea>
645653 </p>
646 - <div class=\"cleared\"></div>
647 - <p class=\"profile-update-unit-left\">" . wfMsgForContent( 'custom-info-field3' ) . "</p>
648 - <p class=\"profile-update-unit\">
649 - <textarea name=\"custom3\" id=\"fav_athlete\" rows=\"3\" cols=\"75\">{$custom3}</textarea>
 654+ </div>
 655+ <div class="cleared"></div>
 656+ <div id="profile-update-custom3">
 657+ <p class="profile-update-unit-left">' . wfMsgForContent( 'custom-info-field3' ) . '</p>
 658+ <p class="profile-update-unit">
 659+ <textarea name="custom3" id="fav_athlete" rows="3" cols="75">' . $custom3 . '</textarea>
650660 </p>
651 - <div class=\"cleared\"></div>
652 - <p class=\"profile-update-unit-left\">" . wfMsgForContent( 'custom-info-field4' ) . "</p>
653 - <p class=\"profile-update-unit\">
654 - <textarea name=\"custom4\" id=\"least_fav_athlete\" rows=\"3\" cols=\"75\">{$custom4}</textarea>
 661+ </div>
 662+ <div class="cleared"></div>
 663+ <div id="profile-update-custom4">
 664+ <p class="profile-update-unit-left">' . wfMsgForContent( 'custom-info-field4' ) . '</p>
 665+ <p class="profile-update-unit">
 666+ <textarea name="custom4" id="least_fav_athlete" rows="3" cols="75">' . $custom4 . '</textarea>
655667 </p>
656 - <div class=\"cleared\"></div>
 668+ </div>
 669+ <div class="cleared"></div>
657670 </div>
658 - <input type=\"button\" class=\"site-button\" value='" . wfMsgForContent('user-profile-update-button') . "' size=\"20\" onclick=\"document.profile.submit()\" />
 671+ <input type="button" class="site-button" value="' . wfMsg( 'user-profile-update-button' ) . '" size="20" onclick="document.profile.submit()" />
659672 </div>
660 - </form>";
 673+ </form>';
661674
662675 return $form;
663676 }

Status & tagging log