r85145 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85144‎ | r85145 | r85146 >
Date:19:25, 1 April 2011
Author:ashley
Status:deferred
Tags:
Comment:
SocialProfile: tweak variable names and change one ternary expression to a proper if() block in UserSystemMessages/UserSystemMessagesClass.php
Modified paths:
  • /trunk/extensions/SocialProfile/UserSystemMessages/UserSystemMessagesClass.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SocialProfile/UserSystemMessages/UserSystemMessagesClass.php
@@ -3,25 +3,28 @@
44 * UserSystemMessage class
55 * Used to send "You have advanced to level [fill in this]" messages
66 * to users when User Levels is activated ($wgUserLevels is defined)
 7+ *
 8+ * @file
 9+ * @ingroup Extensions
710 */
811 class UserSystemMessage {
912
1013 /**
1114 * Adds the message into the database
1215 *
13 - * @param $user_name Mixed: the name of the user who's receiving the message
 16+ * @param $userName Mixed: the name of the user who's receiving the message
1417 * @param $type Integer: 0 by default
1518 * @param $message Mixed: message to be sent out
1619 */
17 - public function addMessage( $user_name, $type, $message ) {
18 - $user_id = User::idFromName( $user_name );
 20+ public function addMessage( $userName, $type, $message ) {
 21+ $userId = User::idFromName( $userName );
1922 $dbw = wfGetDB( DB_MASTER );
2023
2124 $dbw->insert(
2225 'user_system_messages',
2326 array(
24 - 'um_user_id' => $user_id,
25 - 'um_user_name' => $user_name,
 27+ 'um_user_id' => $userId,
 28+ 'um_user_name' => $userName,
2629 'um_type' => $type,
2730 'um_message' => $message,
2831 'um_date' => date( 'Y-m-d H:i:s' ),
@@ -36,7 +39,11 @@
3740 */
3841 static function deleteMessage( $um_id ) {
3942 $dbw = wfGetDB( DB_MASTER );
40 - $dbw->delete( 'user_system_messages', array( 'um_id' => $um_id ), __METHOD__ );
 43+ $dbw->delete(
 44+ 'user_system_messages',
 45+ array( 'um_id' => $um_id ),
 46+ __METHOD__
 47+ );
4148 $dbw->commit();
4249 }
4350
@@ -88,27 +95,31 @@
8996 'gift_given_count' => $row->gift_given_count
9097 );
9198 }
 99+
92100 return $requests;
93101 }
94102
95103 /**
96104 * Sends out the "you have advanced to level [fill in this]" messages to the users
97105 *
98 - * @param $user_id_to Integer: user ID of the receiver
 106+ * @param $userIdTo Integer: user ID of the receiver
99107 * @param $level Mixed: name of the level that the user advanced to
100108 */
101 - public function sendAdvancementNotificationEmail( $user_id_to, $level ) {
102 - $user = User::newFromId( $user_id_to );
 109+ public function sendAdvancementNotificationEmail( $userIdTo, $level ) {
 110+ $user = User::newFromId( $userIdTo );
103111 $user->loadFromDatabase();
104112 if ( $user->isEmailConfirmed() && $user->getIntOption( 'notifyhonorifics', 1 ) ) {
105 - $update_profile_link = SpecialPage::getTitleFor( 'UpdateProfile' );
106 - $subject = wfMsgExt( 'level-advance-subject', 'parsemag',
107 - $level
108 - );
 113+ $updateProfileLink = SpecialPage::getTitleFor( 'UpdateProfile' );
 114+ $subject = wfMsgExt( 'level-advance-subject', 'parsemag', $level );
 115+ if ( trim( $user->getRealName() ) ) {
 116+ $name = $user->getRealName();
 117+ } else {
 118+ $name = $user->getName();
 119+ }
109120 $body = wfMsgExt( 'level-advance-body', 'parsemag',
110 - ( ( trim( $user->getRealName() ) ) ? $user->getRealName() : $user->getName() ),
 121+ $name,
111122 $level,
112 - $update_profile_link->getFullURL()
 123+ $updateProfileLink->getFullURL()
113124 );
114125 $user->sendMail( $subject, $body );
115126 }

Status & tagging log