Index: trunk/extensions/SocialProfile/UserSystemMessages/UserSystemMessagesClass.php |
— | — | @@ -3,25 +3,28 @@ |
4 | 4 | * UserSystemMessage class |
5 | 5 | * Used to send "You have advanced to level [fill in this]" messages |
6 | 6 | * to users when User Levels is activated ($wgUserLevels is defined) |
| 7 | + * |
| 8 | + * @file |
| 9 | + * @ingroup Extensions |
7 | 10 | */ |
8 | 11 | class UserSystemMessage { |
9 | 12 | |
10 | 13 | /** |
11 | 14 | * Adds the message into the database |
12 | 15 | * |
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 |
14 | 17 | * @param $type Integer: 0 by default |
15 | 18 | * @param $message Mixed: message to be sent out |
16 | 19 | */ |
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 ); |
19 | 22 | $dbw = wfGetDB( DB_MASTER ); |
20 | 23 | |
21 | 24 | $dbw->insert( |
22 | 25 | 'user_system_messages', |
23 | 26 | array( |
24 | | - 'um_user_id' => $user_id, |
25 | | - 'um_user_name' => $user_name, |
| 27 | + 'um_user_id' => $userId, |
| 28 | + 'um_user_name' => $userName, |
26 | 29 | 'um_type' => $type, |
27 | 30 | 'um_message' => $message, |
28 | 31 | 'um_date' => date( 'Y-m-d H:i:s' ), |
— | — | @@ -36,7 +39,11 @@ |
37 | 40 | */ |
38 | 41 | static function deleteMessage( $um_id ) { |
39 | 42 | $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 | + ); |
41 | 48 | $dbw->commit(); |
42 | 49 | } |
43 | 50 | |
— | — | @@ -88,27 +95,31 @@ |
89 | 96 | 'gift_given_count' => $row->gift_given_count |
90 | 97 | ); |
91 | 98 | } |
| 99 | + |
92 | 100 | return $requests; |
93 | 101 | } |
94 | 102 | |
95 | 103 | /** |
96 | 104 | * Sends out the "you have advanced to level [fill in this]" messages to the users |
97 | 105 | * |
98 | | - * @param $user_id_to Integer: user ID of the receiver |
| 106 | + * @param $userIdTo Integer: user ID of the receiver |
99 | 107 | * @param $level Mixed: name of the level that the user advanced to |
100 | 108 | */ |
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 ); |
103 | 111 | $user->loadFromDatabase(); |
104 | 112 | 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 | + } |
109 | 120 | $body = wfMsgExt( 'level-advance-body', 'parsemag', |
110 | | - ( ( trim( $user->getRealName() ) ) ? $user->getRealName() : $user->getName() ), |
| 121 | + $name, |
111 | 122 | $level, |
112 | | - $update_profile_link->getFullURL() |
| 123 | + $updateProfileLink->getFullURL() |
113 | 124 | ); |
114 | 125 | $user->sendMail( $subject, $body ); |
115 | 126 | } |