r94639 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94638‎ | r94639 | r94640 >
Date:14:18, 16 August 2011
Author:ashley
Status:ok
Tags:
Comment:
SocialProfile: move some code specific to UserMailingList out of here and add two new hooks for UserMailingList; using a hook is a lot better than checking for $wgSitename here
Modified paths:
  • /trunk/extensions/SocialProfile/UserProfile/SpecialUpdateProfile.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SocialProfile/UserProfile/SpecialUpdateProfile.php
@@ -183,7 +183,7 @@
184184 * Save social preferences into the database.
185185 */
186186 function saveSettings_pref() {
187 - global $wgUser, $wgOut, $wgRequest, $wgSitename;
 187+ global $wgUser, $wgRequest;
188188
189189 $notify_friend = $wgRequest->getVal( 'notify_friend' );
190190 $notify_gift = $wgRequest->getVal( 'notify_gift' );
@@ -211,36 +211,9 @@
212212 $wgUser->setOption( 'notifyhonorifics', $notify_honorifics );
213213 $wgUser->setOption( 'notifymessage', $notify_message );
214214 $wgUser->saveSettings();
215 - // This code is mostly related to ArmchairGM, however can be fixed to be used for others.
216 - if ( $wgSitename == 'ArmchairGM' ) {
217 - $dbw = wfGetDB( DB_MASTER );
218 - // If the user wants a weekly email, we'll put some info about that to the user_mailing_list table
219 - if ( $wgRequest->getVal( 'weeklyemail' ) == 1 ) {
220 - $s = $dbw->selectRow(
221 - 'user_mailing_list',
222 - array( 'um_user_id' ),
223 - array( 'um_user_id' => $wgUser->getID() ),
224 - __METHOD__
225 - );
226 - if ( $s === false ) {
227 - $dbw->insert(
228 - 'user_mailing_list',
229 - array(
230 - 'um_user_id' => $wgUser->getID(),
231 - 'um_user_name' => $wgUser->getName(),
232 - ),
233 - __METHOD__
234 - );
235 - }
236 - } else {
237 - // Otherwise, just delete the entry.
238 - $dbw->delete(
239 - 'user_mailing_list',
240 - array( 'um_user_id' => $wgUser->getID() ),
241 - __METHOD__
242 - );
243 - }
244 - }
 215+
 216+ // Allow extensions like UserMailingList do their magic here
 217+ wfRunHooks( 'SpecialUpdateProfile::saveSettings_pref', array( $this, $wgRequest ) );
245218 }
246219
247220 function formatBirthdayDB( $birthday ) {
@@ -712,6 +685,9 @@
713686 ' <input type="checkbox" size="25" name="notify_honorifics" id="notify_honorifics" value="1"' . ( ( $wgUser->getIntOption( 'notifyhonorifics', 1 ) == 1 ) ? 'checked' : '' ) . '/>
714687 </p>';
715688
 689+ // Allow extensions (like UserMailingList) to add new checkboxes
 690+ wfRunHooks( 'SpecialUpdateProfile::displayPreferencesForm', array( $this, &$form ) );
 691+
716692 $form .= '</div>
717693 <div class="cleared"></div>';
718694 $form .= '<input type="button" class="site-button" value="' . wfMsg( 'user-profile-update-button' ) . '" size="20" onclick="document.profile.submit()" />

Status & tagging log