Index: trunk/extensions/SocialProfile/UserProfile/UserProfile.php |
— | — | @@ -23,7 +23,9 @@ |
24 | 24 | $wgUploadAvatarInRecentChanges = false; // Same as above, but for avatar uploading |
25 | 25 | |
26 | 26 | $wgAvailableRights[] = 'avatarremove'; |
| 27 | +$wgAvailableRights[] = 'editothersprofiles'; |
27 | 28 | $wgGroupPermissions['sysop']['avatarremove'] = true; |
| 29 | +$wgGroupPermissions['staff']['editothersprofiles'] = true; |
28 | 30 | |
29 | 31 | # Add new log types for profile edits and avatar uploads |
30 | 32 | global $wgLogTypes, $wgLogNames, $wgLogHeaders, $wgLogActions; |
Index: trunk/extensions/SocialProfile/UserProfile/SpecialUpdateProfile.php |
— | — | @@ -18,20 +18,31 @@ |
19 | 19 | parent::__construct( 'UpdateProfile' ); |
20 | 20 | } |
21 | 21 | |
22 | | - function initProfile() { |
| 22 | + /** |
| 23 | + * Initialize the user_profile records for a given user (either $wgUser |
| 24 | + * or someone else; only Special:EditProfile sets the $user parameter). |
| 25 | + * |
| 26 | + * @param $user Object: User object; null by default (=$wgUser) |
| 27 | + */ |
| 28 | + function initProfile( $user = null ) { |
23 | 29 | global $wgUser; |
| 30 | + |
| 31 | + if ( is_null( $user ) ) { |
| 32 | + $user = $wgUser; |
| 33 | + } |
| 34 | + |
24 | 35 | $dbw = wfGetDB( DB_MASTER ); |
25 | 36 | $s = $dbw->selectRow( |
26 | 37 | 'user_profile', |
27 | 38 | array( 'up_user_id' ), |
28 | | - array( 'up_user_id' => $wgUser->getID() ), |
| 39 | + array( 'up_user_id' => $user->getID() ), |
29 | 40 | __METHOD__ |
30 | 41 | ); |
31 | 42 | if ( $s === false ) { |
32 | 43 | $dbw = wfGetDB( DB_MASTER ); |
33 | 44 | $dbw->insert( |
34 | 45 | 'user_profile', |
35 | | - array( 'up_user_id' => $wgUser->getID() ), |
| 46 | + array( 'up_user_id' => $user->getID() ), |
36 | 47 | __METHOD__ |
37 | 48 | ); |
38 | 49 | } |
— | — | @@ -108,9 +119,13 @@ |
109 | 120 | wfMsgForContent( 'user-profile-update-log-section' ) . |
110 | 121 | " '{$section}'" |
111 | 122 | ); |
112 | | - $wgOut->addHTML( '<span class="profile-on">' . wfMsg( 'user-profile-update-saved' ) . '</span><br /><br />' ); |
| 123 | + $wgOut->addHTML( |
| 124 | + '<span class="profile-on">' . |
| 125 | + wfMsg( 'user-profile-update-saved' ) . |
| 126 | + '</span><br /><br />' |
| 127 | + ); |
113 | 128 | |
114 | | - // create user page if not exists |
| 129 | + // create the user page if it doesn't exist yet |
115 | 130 | $title = Title::makeTitle( NS_USER, $wgUser->getName() ); |
116 | 131 | $article = new Article( $title ); |
117 | 132 | if ( !$article->exists() ) { |
— | — | @@ -123,13 +138,13 @@ |
124 | 139 | } |
125 | 140 | switch( $section ) { |
126 | 141 | case 'basic': |
127 | | - $wgOut->addHTML( $this->displayBasicForm() ); |
| 142 | + $wgOut->addHTML( $this->displayBasicForm( $wgUser ) ); |
128 | 143 | break; |
129 | 144 | case 'personal': |
130 | | - $wgOut->addHTML( $this->displayPersonalForm() ); |
| 145 | + $wgOut->addHTML( $this->displayPersonalForm( $wgUser ) ); |
131 | 146 | break; |
132 | 147 | case 'custom': |
133 | | - $wgOut->addHTML( $this->displayCustomForm() ); |
| 148 | + $wgOut->addHTML( $this->displayCustomForm( $wgUser ) ); |
134 | 149 | break; |
135 | 150 | case 'preferences': |
136 | 151 | $wgOut->addHTML( $this->displayPreferencesForm() ); |
— | — | @@ -137,7 +152,16 @@ |
138 | 153 | } |
139 | 154 | } |
140 | 155 | |
141 | | - function saveSettings_basic() { |
| 156 | + /** |
| 157 | + * Save basic settings about the user (real name, e-mail address) into the |
| 158 | + * database. |
| 159 | + * |
| 160 | + * @param $user Object: this parameter is unused but required to stop |
| 161 | + * E_STRICT bitching because Special:EditProfile |
| 162 | + * extends this class to reduce the amount of code |
| 163 | + * duplication |
| 164 | + */ |
| 165 | + function saveSettings_basic( $user ) { |
142 | 166 | global $wgUser, $wgRequest, $wgEmailAuthentication; |
143 | 167 | |
144 | 168 | $wgUser->setRealName( $wgRequest->getVal( 'real_name' ) ); |
— | — | @@ -160,6 +184,9 @@ |
161 | 185 | $wgUser->saveSettings(); |
162 | 186 | } |
163 | 187 | |
| 188 | + /** |
| 189 | + * Save social preferences into the database. |
| 190 | + */ |
164 | 191 | function saveSettings_pref() { |
165 | 192 | global $wgUser, $wgOut, $wgRequest, $wgSitename; |
166 | 193 | |
— | — | @@ -247,9 +274,19 @@ |
248 | 275 | return $birthday_date; |
249 | 276 | } |
250 | 277 | |
251 | | - function saveProfileBasic() { |
| 278 | + /** |
| 279 | + * Save the basic user profile info fields into the database. |
| 280 | + * The $user parameter is only passed by Special:EditProfile. |
| 281 | + * |
| 282 | + * @param $user Object: User object, null by default (=$wgUser) |
| 283 | + */ |
| 284 | + function saveProfileBasic( $user = null ) { |
252 | 285 | global $wgUser, $wgMemc, $wgRequest, $wgSitename; |
253 | 286 | |
| 287 | + if ( is_null( $user ) ) { |
| 288 | + $user = $wgUser; |
| 289 | + } |
| 290 | + |
254 | 291 | $this->initProfile(); |
255 | 292 | $dbw = wfGetDB( DB_MASTER ); |
256 | 293 | $dbw->update( |
— | — | @@ -271,15 +308,26 @@ |
272 | 309 | 'up_websites' => $wgRequest->getVal( 'websites' ), |
273 | 310 | 'up_relationship' => $wgRequest->getVal( 'relationship' ) |
274 | 311 | ), |
275 | | - /* WHERE */array( 'up_user_id' => $wgUser->getID() ), |
| 312 | + /* WHERE */array( 'up_user_id' => $user->getID() ), |
276 | 313 | __METHOD__ |
277 | 314 | ); |
278 | | - $wgMemc->delete( wfMemcKey( 'user', 'profile', 'info', $wgUser->getID() ) ); |
| 315 | + $wgMemc->delete( wfMemcKey( 'user', 'profile', 'info', $user->getID() ) ); |
279 | 316 | } |
280 | 317 | |
281 | | - function saveProfileCustom() { |
| 318 | + /** |
| 319 | + * Save the four custom (site-specific) user profile fields into the |
| 320 | + * database. |
| 321 | + * The $user parameter is only passed by Special:EditProfile. |
| 322 | + * |
| 323 | + * @param $user Object: User object, null by default (=$wgUser) |
| 324 | + */ |
| 325 | + function saveProfileCustom( $user = null ) { |
282 | 326 | global $wgUser, $wgMemc, $wgRequest; |
283 | 327 | |
| 328 | + if ( is_null( $user ) ) { |
| 329 | + $user = $wgUser; |
| 330 | + } |
| 331 | + |
284 | 332 | $this->initProfile(); |
285 | 333 | $dbw = wfGetDB( DB_MASTER ); |
286 | 334 | $dbw->update( |
— | — | @@ -290,15 +338,26 @@ |
291 | 339 | 'up_custom_3' => $wgRequest->getVal( 'custom3' ), |
292 | 340 | 'up_custom_4' => $wgRequest->getVal( 'custom4' ) |
293 | 341 | ), |
294 | | - /* WHERE */array( 'up_user_id' => $wgUser->getID() ), |
| 342 | + /* WHERE */array( 'up_user_id' => $user->getID() ), |
295 | 343 | __METHOD__ |
296 | 344 | ); |
297 | | - $wgMemc->delete( wfMemcKey( 'user', 'profile', 'info', $wgUser->getID() ) ); |
| 345 | + $wgMemc->delete( wfMemcKey( 'user', 'profile', 'info', $user->getID() ) ); |
298 | 346 | } |
299 | 347 | |
300 | | - function saveProfilePersonal() { |
| 348 | + /** |
| 349 | + * Save the user's personal info (interests, such as favorite music or |
| 350 | + * TV programs or video games, etc.) into the database. |
| 351 | + * The $user parameter is only passed by Special:EditProfile. |
| 352 | + * |
| 353 | + * @param $user Object: User object, null by default (=$wgUser) |
| 354 | + */ |
| 355 | + function saveProfilePersonal( $user = null ) { |
301 | 356 | global $wgUser, $wgMemc, $wgRequest; |
302 | 357 | |
| 358 | + if ( is_null( $user ) ) { |
| 359 | + $user = $wgUser; |
| 360 | + } |
| 361 | + |
303 | 362 | $this->initProfile(); |
304 | 363 | $dbw = wfGetDB( DB_MASTER ); |
305 | 364 | $dbw->update( |
— | — | @@ -314,13 +373,19 @@ |
315 | 374 | 'up_snacks' => $wgRequest->getVal( 'snacks' ), |
316 | 375 | 'up_drinks' => $wgRequest->getVal( 'drinks' ) |
317 | 376 | ), |
318 | | - /* WHERE */array( 'up_user_id' => $wgUser->getID() ), |
| 377 | + /* WHERE */array( 'up_user_id' => $user->getID() ), |
319 | 378 | __METHOD__ |
320 | 379 | ); |
321 | | - $wgMemc->delete( wfMemcKey( 'user', 'profile', 'info', $wgUser->getID() ) ); |
| 380 | + $wgMemc->delete( wfMemcKey( 'user', 'profile', 'info', $user->getID() ) ); |
322 | 381 | } |
323 | 382 | |
324 | | - function displayBasicForm() { |
| 383 | + /** |
| 384 | + * @param $user Object: this parameter is unused but required to stop |
| 385 | + * E_STRICT bitching because Special:EditProfile |
| 386 | + * extends this class to reduce the amount of code |
| 387 | + * duplication |
| 388 | + */ |
| 389 | + function displayBasicForm( $user ) { |
325 | 390 | global $wgRequest, $wgUser, $wgOut; |
326 | 391 | |
327 | 392 | $dbr = wfGetDB( DB_MASTER ); |
— | — | @@ -514,7 +579,13 @@ |
515 | 580 | return $form; |
516 | 581 | } |
517 | 582 | |
518 | | - function displayPersonalForm() { |
| 583 | + /** |
| 584 | + * @param $user Object: this parameter is unused but required to stop |
| 585 | + * E_STRICT bitching because Special:EditProfile |
| 586 | + * extends this class to reduce the amount of code |
| 587 | + * duplication |
| 588 | + */ |
| 589 | + function displayPersonalForm( $user ) { |
519 | 590 | global $wgRequest, $wgUser, $wgOut; |
520 | 591 | |
521 | 592 | $dbr = wfGetDB( DB_MASTER ); |
— | — | @@ -646,10 +717,15 @@ |
647 | 718 | } |
648 | 719 | |
649 | 720 | /** |
650 | | - * Displays the form for editing custom (site-specific) information |
| 721 | + * Displays the form for editing custom (site-specific) information. |
| 722 | + * |
| 723 | + * @param $user Object: this parameter is unused but required to stop |
| 724 | + * E_STRICT bitching because Special:EditProfile |
| 725 | + * extends this class to reduce the amount of code |
| 726 | + * duplication |
651 | 727 | * @return $form Mixed: HTML output |
652 | 728 | */ |
653 | | - function displayCustomForm() { |
| 729 | + function displayCustomForm( $user ) { |
654 | 730 | global $wgRequest, $wgUser, $wgOut; |
655 | 731 | |
656 | 732 | $dbr = wfGetDB( DB_MASTER ); |
Index: trunk/extensions/SocialProfile/UserProfile/SpecialEditProfile.php |
— | — | @@ -0,0 +1,500 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * A special page to allow privileged users to update others' social profiles |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + * @author Frozen Wind <tuxlover684@gmail.com> |
| 9 | + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
| 10 | + */ |
| 11 | + |
| 12 | +class SpecialEditProfile extends SpecialUpdateProfile { |
| 13 | + |
| 14 | + /** |
| 15 | + * Constructor |
| 16 | + */ |
| 17 | + public function __construct() { |
| 18 | + SpecialPage::__construct( 'EditProfile', 'editothersprofiles' ); |
| 19 | + } |
| 20 | + |
| 21 | + /** |
| 22 | + * Show the special page |
| 23 | + * |
| 24 | + * @param $section Mixed: parameter passed to the page or null |
| 25 | + */ |
| 26 | + public function execute( $par ) { |
| 27 | + global $wgUser, $wgOut, $wgRequest, $wgUserProfileScripts, $wgScriptPath, $wgUpdateProfileInRecentChanges, $wgSupressPageTitle; |
| 28 | + $wgSupressPageTitle = true; |
| 29 | + |
| 30 | + $wgOut->setHTMLTitle( wfMsg( 'pagetitle', wfMsg( 'edit-profiles-title' ) ) ); |
| 31 | + |
| 32 | + // This feature is only available for logged-in users. |
| 33 | + if ( !$wgUser->isLoggedIn() ) { |
| 34 | + $wgOut->setPageTitle( wfMsgForContent( 'user-profile-update-notloggedin-title' ) ); |
| 35 | + $wgOut->addHTML( |
| 36 | + wfMsgForContent( 'user-profile-update-notloggedin-text', |
| 37 | + SpecialPage::getTitleFor( 'Userlogin' )->escapeFullURL(), |
| 38 | + SpecialPage::getTitleFor( 'Userlogin', 'signup' )->escapeFullURL() |
| 39 | + ) |
| 40 | + ); |
| 41 | + return; |
| 42 | + } |
| 43 | + |
| 44 | + // No need to allow blocked users to access this page, they could abuse it, y'know. |
| 45 | + if ( $wgUser->isBlocked() ) { |
| 46 | + $wgOut->blockedPage( false ); |
| 47 | + return false; |
| 48 | + } |
| 49 | + |
| 50 | + // Database operations require write mode |
| 51 | + if ( wfReadOnly() ) { |
| 52 | + $wgOut->readOnlyPage(); |
| 53 | + return; |
| 54 | + } |
| 55 | + |
| 56 | + // Are we even allowed to do this? |
| 57 | + if ( !$wgUser->isAllowed( 'editothersprofiles' ) ) { |
| 58 | + $wgOut->permissionRequired( 'editothersprofiles' ); |
| 59 | + return; |
| 60 | + } |
| 61 | + |
| 62 | + // Add CSS & JS |
| 63 | + $wgOut->addExtensionStyle( $wgUserProfileScripts . '/UserProfile.css' ); |
| 64 | + $wgOut->addScriptFile( $wgUserProfileScripts . '/UpdateProfile.js' ); |
| 65 | + |
| 66 | + // Get the user's name from the wpUser URL parameter |
| 67 | + $userFromRequest = $wgRequest->getText( 'wpUser' ); |
| 68 | + |
| 69 | + // If the wpUser parameter isn't set but a parameter was passed to the |
| 70 | + // special page, use the given parameter instead |
| 71 | + if ( !$userFromRequest && $par ) { |
| 72 | + $userFromRequest = $par; |
| 73 | + } |
| 74 | + |
| 75 | + // Still not set? Just give up and show the "search for a user" form... |
| 76 | + if ( !$userFromRequest ) { |
| 77 | + $wgOut->addHTML( $this->createUserInputForm() ); |
| 78 | + return; |
| 79 | + } |
| 80 | + |
| 81 | + $target = User::newFromName( $userFromRequest ); |
| 82 | + |
| 83 | + if ( !$target || $target->getID() == 0 ) { |
| 84 | + $wgOut->addHTML( wfMsg( 'nosuchusershort', htmlspecialchars( $userFromRequest ) ) ); |
| 85 | + $wgOut->addHTML( $this->createUserInputForm() ); |
| 86 | + return; |
| 87 | + } |
| 88 | + |
| 89 | + if ( $wgRequest->wasPosted() ) { |
| 90 | + $this->saveProfileBasic( $target ); |
| 91 | + $this->saveSettings_basic( $target ); |
| 92 | + $this->saveProfilePersonal( $target ); |
| 93 | + $this->saveProfileCustom( $target ); |
| 94 | + |
| 95 | + UserProfile::clearCache( $target->getID() ); |
| 96 | + |
| 97 | + $log = new LogPage( wfMsgForContent( 'user-profile-update-profile' ) ); |
| 98 | + if ( !$wgUpdateProfileInRecentChanges ) { |
| 99 | + $log->updateRecentChanges = false; |
| 100 | + } |
| 101 | + $log->addEntry( |
| 102 | + wfMsgForContent( 'user-profile-edit-profile', |
| 103 | + array( '[[User:' . $target->getName() . ']]' ) ), |
| 104 | + $target->getUserPage(), |
| 105 | + '' |
| 106 | + ); |
| 107 | + $wgOut->addHTML( |
| 108 | + '<span class="profile-on">' . |
| 109 | + wfMsg( 'user-profile-edit-profile-update-saved' ) . |
| 110 | + '</span><br /><br />' |
| 111 | + ); |
| 112 | + |
| 113 | + // create the user page if it doesn't exist yet |
| 114 | + $title = Title::makeTitle( NS_USER, $target->getName() ); |
| 115 | + $article = new Article( $title ); |
| 116 | + if ( !$article->exists() ) { |
| 117 | + $article->doEdit( '', 'create user page', EDIT_SUPPRESS_RC ); |
| 118 | + } |
| 119 | + } |
| 120 | + |
| 121 | + $wgOut->addHTML( $this->displayBasicForm( $target ) ); |
| 122 | + $wgOut->addHTML( $this->displayPersonalForm( $target ) ); |
| 123 | + $wgOut->addHTML( $this->displayCustomForm( $target ) ); |
| 124 | + } |
| 125 | + |
| 126 | + function createUserInputForm() { |
| 127 | + $actionUrl = $this->getTitle()->getLocalURL( '' ); |
| 128 | + $form = Xml::openElement( 'fieldset' ) . |
| 129 | + Xml::openElement( 'form', |
| 130 | + array( |
| 131 | + 'id' => 'mw-socialprofile-edit-profile-userform', |
| 132 | + 'method' => 'get', |
| 133 | + 'action' => $actionUrl |
| 134 | + ) |
| 135 | + ) . Xml::label( wfMsg( 'username' ), 'mw-socialprofile-user' ) . |
| 136 | + Xml::input( 'wpUser', 60, '', array( |
| 137 | + 'tabindex' => '1', |
| 138 | + 'id' => 'mw-socialprofile-user', |
| 139 | + 'maxlength' => '200' |
| 140 | + ) ) . |
| 141 | + Xml::submitButton( wfMsg( 'edit' ), array( 'id' => 'mw-namespaces-submit' ) ) . |
| 142 | + Xml::closeElement( 'table' ) . Xml::closeElement( 'form' ) . |
| 143 | + Xml::closeElement( 'fieldset' ); |
| 144 | + return $form; |
| 145 | + } |
| 146 | + |
| 147 | + function saveSettings_basic( $tar ) { |
| 148 | + global $wgUser, $wgRequest, $wgEmailAuthentication; |
| 149 | + |
| 150 | + $tar->setRealName( $wgRequest->getVal( 'real_name' ) ); |
| 151 | + $tar->setEmail( $wgRequest->getVal( 'email' ) ); |
| 152 | + |
| 153 | + if ( $tar->getEmail() != $wgRequest->getVal( 'email' ) ) { |
| 154 | + $wgUser->mEmailAuthenticated = null; # but flag as "dirty" = unauthenticated |
| 155 | + } |
| 156 | + |
| 157 | + $tar->saveSettings(); |
| 158 | + } |
| 159 | + |
| 160 | + function displayBasicForm( $tar ) { |
| 161 | + global $wgRequest, $wgUser, $wgOut; |
| 162 | + |
| 163 | + $dbr = wfGetDB( DB_MASTER ); |
| 164 | + $s = $dbr->selectRow( 'user_profile', |
| 165 | + array( |
| 166 | + 'up_location_city', 'up_location_state', 'up_location_country', |
| 167 | + 'up_hometown_city', 'up_hometown_state', 'up_hometown_country', |
| 168 | + 'up_birthday', 'up_occupation', 'up_about', 'up_schools', |
| 169 | + 'up_places_lived', 'up_websites' |
| 170 | + ), |
| 171 | + array( 'up_user_id' => $tar->getID() ), |
| 172 | + __METHOD__ |
| 173 | + ); |
| 174 | + |
| 175 | + if ( $s !== false ) { |
| 176 | + $location_city = $s->up_location_city; |
| 177 | + $location_state = $s->up_location_state; |
| 178 | + $location_country = $s->up_location_country; |
| 179 | + $about = $s->up_about; |
| 180 | + $occupation = $s->up_occupation; |
| 181 | + $hometown_city = $s->up_hometown_city; |
| 182 | + $hometown_state = $s->up_hometown_state; |
| 183 | + $hometown_country = $s->up_hometown_country; |
| 184 | + $birthday = $this->formatBirthday( $s->up_birthday ); |
| 185 | + $schools = $s->up_schools; |
| 186 | + $places = $s->up_places_lived; |
| 187 | + $websites = $s->up_websites; |
| 188 | + } |
| 189 | + |
| 190 | + if ( !isset( $location_country ) ) { |
| 191 | + $location_country = wfMsgForContent( 'user-profile-default-country' ); |
| 192 | + } |
| 193 | + if ( !isset( $hometown_country ) ) { |
| 194 | + $hometown_country = wfMsgForContent( 'user-profile-default-country' ); |
| 195 | + } |
| 196 | + |
| 197 | + $s = $dbr->selectRow( |
| 198 | + 'user', |
| 199 | + array( 'user_real_name', 'user_email', 'user_email_authenticated' ), |
| 200 | + array( 'user_id' => $tar->getID() ), |
| 201 | + __METHOD__ |
| 202 | + ); |
| 203 | + |
| 204 | + if ( $s !== false ) { |
| 205 | + $real_name = $s->user_real_name; |
| 206 | + $email = $s->user_email; |
| 207 | + $old_email = $s->user_email; |
| 208 | + $email_authenticated = $s->user_email_authenticated; |
| 209 | + } |
| 210 | + |
| 211 | + $countries = explode( "\n*", wfMsgForContent( 'userprofile-country-list' ) ); |
| 212 | + array_shift( $countries ); |
| 213 | + |
| 214 | + $wgOut->setPageTitle( wfMsg( 'edit-profile-title' ) ); |
| 215 | + //$form = UserProfile::getEditProfileNav( wfMsg( 'user-profile-section-personal' ) ); |
| 216 | + $form = '<form action="" method="post" enctype="multipart/form-data" name="profile">'; |
| 217 | + $form .= '<div class="profile-info clearfix">'; |
| 218 | + $form .= '<div class="profile-update"> |
| 219 | + <p class="profile-update-title">' . wfMsg( 'user-profile-personal-info' ) . '</p> |
| 220 | + <p class="profile-update-unit-left">' . wfMsg( 'user-profile-personal-name' ) . '</p> |
| 221 | + <p class="profile-update-unit"><input type="text" size="25" name="real_name" id="real_name" value="' . $real_name . '"/></p> |
| 222 | + <div class="cleared"></div> |
| 223 | + <p class="profile-update-unit-left">' . wfMsg( 'user-profile-personal-email' ) . '</p> |
| 224 | + <p class="profile-update-unit"><input type="text" size="25" name="email" id="email" value="' . $email . '"/>'; |
| 225 | + if ( !$tar->mEmailAuthenticated ) { |
| 226 | + $confirm = SpecialPage::getTitleFor( 'Confirmemail' ); |
| 227 | + $form .= " <a href=\"{$confirm->getFullURL()}\">" . wfMsg( 'user-profile-personal-confirmemail' ) . '</a>'; |
| 228 | + } |
| 229 | + $form .= '</p> |
| 230 | + <div class="cleared"></div>'; |
| 231 | + if ( !$wgUser->mEmailAuthenticated ) { |
| 232 | + $form .= '<p class="profile-update-unit-left"></p> |
| 233 | + <p class="profile-update-unit-small">' . wfMsg( 'user-profile-personal-email-needs-auth' ) . '</p>'; |
| 234 | + } |
| 235 | + $form .= '<div class="cleared"></div> |
| 236 | + </div> |
| 237 | + <div class="cleared"></div>'; |
| 238 | + |
| 239 | + $form .= '<div class="profile-update"> |
| 240 | + <p class="profile-update-title">' . wfMsg( 'user-profile-personal-location' ) . '</p> |
| 241 | + <p class="profile-update-unit-left">' . wfMsg( 'user-profile-personal-city' ) . '</p> |
| 242 | + <p class="profile-update-unit"><input type="text" size="25" name="location_city" id="location_city" value="' . ( isset( $location_city ) ? $location_city : '' ) . '" /></p> |
| 243 | + <div class="cleared"></div> |
| 244 | + <p class="profile-update-unit-left" id="location_state_label">' . wfMsg( 'user-profile-personal-country' ) . '</p>'; |
| 245 | + $form .= '<p class="profile-update-unit">'; |
| 246 | + $form .= '<span id="location_state_form">'; |
| 247 | + $form .= "</span> |
| 248 | + <script type=\"text/javascript\"> |
| 249 | + displaySection(\"location_state\",\"" . $location_country . "\",\"" . ( isset( $location_state ) ? $location_state : '' ) . "\"); |
| 250 | + </script>"; |
| 251 | + $form .= "<select name=\"location_country\" id=\"location_country\" onchange=\"displaySection('location_state',this.value,'')\"><option></option>"; |
| 252 | + |
| 253 | + foreach ( $countries as $country ) { |
| 254 | + $form .= "<option value=\"{$country}\"" . ( ( $country == $location_country ) ? ' selected="selected"' : '' ) . ">"; |
| 255 | + $form .= $country . "</option>\n"; |
| 256 | + } |
| 257 | + |
| 258 | + $form .= '</select>'; |
| 259 | + $form .= '</p> |
| 260 | + <div class="cleared"></div> |
| 261 | + </div> |
| 262 | + <div class="cleared"></div>'; |
| 263 | + |
| 264 | + $form .= '<div class="profile-update"> |
| 265 | + <p class="profile-update-title">' . wfMsg( 'user-profile-personal-hometown' ) . '</p> |
| 266 | + <p class="profile-update-unit-left">' . wfMsg( 'user-profile-personal-city' ) . '</p> |
| 267 | + <p class="profile-update-unit"><input type="text" size="25" name="hometown_city" id="hometown_city" value="' . ( isset( $hometown_city ) ? $hometown_city : '' ) . '" /></p> |
| 268 | + <div class="cleared"></div> |
| 269 | + <p class="profile-update-unit-left" id="hometown_state_label">' . wfMsg( 'user-profile-personal-country' ) . '</p> |
| 270 | + <p class="profile-update-unit">'; |
| 271 | + $form .= '<span id="hometown_state_form">'; |
| 272 | + $form .= "</span> |
| 273 | + <script type=\"text/javascript\"> |
| 274 | + displaySection(\"hometown_state\",\"" . $hometown_country . "\",\"" . ( isset( $hometown_state ) ? $hometown_state : '' ) . "\"); |
| 275 | + </script>"; |
| 276 | + $form .= "<select name=\"hometown_country\" id=\"hometown_country\" onchange=\"displaySection('hometown_state',this.value,'')\"><option></option>"; |
| 277 | + |
| 278 | + foreach ( $countries as $country ) { |
| 279 | + $form .= "<option value=\"{$country}\"" . ( ( $country == $hometown_country ) ? ' selected="selected"' : '' ) . ">"; |
| 280 | + $form .= $country . '</option>'; |
| 281 | + } |
| 282 | + |
| 283 | + $form .= '</select>'; |
| 284 | + $form .= '</p> |
| 285 | + <div class="cleared"></div> |
| 286 | + </div> |
| 287 | + <div class="cleared"></div>'; |
| 288 | + |
| 289 | + $form .= '<div class="profile-update"> |
| 290 | + <p class="profile-update-title">' . wfMsg( 'user-profile-personal-birthday' ) . '</p> |
| 291 | + <p class="profile-update-unit-left">' . wfMsg( 'user-profile-personal-birthdate' ) . '</p> |
| 292 | + <p class="profile-update-unit"><input type="text" size="25" name="birthday" id="birthday" value="' . ( isset( $birthday ) ? $birthday : '' ) . '" /></p> |
| 293 | + <div class="cleared"></div> |
| 294 | + </div><div class="cleared"></div>'; |
| 295 | + |
| 296 | + $form .= '<div class="profile-update" id="profile-update-personal-aboutme"> |
| 297 | + <p class="profile-update-title">' . wfMsg( 'user-profile-personal-aboutme' ) . '</p> |
| 298 | + <p class="profile-update-unit-left">' . wfMsg( 'user-profile-personal-aboutme' ) . '</p> |
| 299 | + <p class="profile-update-unit"> |
| 300 | + <textarea name="about" id="about" rows="3" cols="75">' . ( isset( $about ) ? $about : '' ) . '</textarea> |
| 301 | + </p> |
| 302 | + <div class="cleared"></div> |
| 303 | + </div> |
| 304 | + <div class="cleared"></div> |
| 305 | + |
| 306 | + <div class="profile-update" id="profile-update-personal-work"> |
| 307 | + <p class="profile-update-title">' . wfMsg( 'user-profile-personal-work' ) . '</p> |
| 308 | + <p class="profile-update-unit-left">' . wfMsg( 'user-profile-personal-occupation' ) . '</p> |
| 309 | + <p class="profile-update-unit"> |
| 310 | + <textarea name="occupation" id="occupation" rows="2" cols="75">' . ( isset( $occupation ) ? $occupation : '' ) . '</textarea> |
| 311 | + </p> |
| 312 | + <div class="cleared"></div> |
| 313 | + </div> |
| 314 | + <div class="cleared"></div> |
| 315 | + |
| 316 | + <div class="profile-update" id="profile-update-personal-education"> |
| 317 | + <p class="profile-update-title">' . wfMsg( 'user-profile-personal-education' ) . '</p> |
| 318 | + <p class="profile-update-unit-left">' . wfMsg( 'user-profile-personal-schools' ) . '</p> |
| 319 | + <p class="profile-update-unit"> |
| 320 | + <textarea name="schools" id="schools" rows="2" cols="75">' . ( isset( $schools ) ? $schools : '' ) . '</textarea> |
| 321 | + </p> |
| 322 | + <div class="cleared"></div> |
| 323 | + </div> |
| 324 | + <div class="cleared"></div> |
| 325 | + |
| 326 | + <div class="profile-update" id="profile-update-personal-places"> |
| 327 | + <p class="profile-update-title">' . wfMsg( 'user-profile-personal-places' ) . '</p> |
| 328 | + <p class="profile-update-unit-left">' . wfMsg( 'user-profile-personal-placeslived' ) . '</p> |
| 329 | + <p class="profile-update-unit"> |
| 330 | + <textarea name="places" id="places" rows="3" cols="75">' . ( isset( $places ) ? $places : '' ) . '</textarea> |
| 331 | + </p> |
| 332 | + <div class="cleared"></div> |
| 333 | + </div> |
| 334 | + <div class="cleared"></div> |
| 335 | + |
| 336 | + <div class="profile-update" id="profile-update-personal-web"> |
| 337 | + <p class="profile-update-title">' . wfMsg( 'user-profile-personal-web' ) . '</p> |
| 338 | + <p class="profile-update-unit-left">' . wfMsg( 'user-profile-personal-websites' ) . '</p> |
| 339 | + <p class="profile-update-unit"> |
| 340 | + <textarea name="websites" id="websites" rows="2" cols="75">' . ( isset( $websites ) ? $websites : '' ) . '</textarea> |
| 341 | + </p> |
| 342 | + <div class="cleared"></div> |
| 343 | + </div> |
| 344 | + <div class="cleared"></div>'; |
| 345 | + |
| 346 | + $form .= '</div>'; |
| 347 | + |
| 348 | + return $form; |
| 349 | + } |
| 350 | + |
| 351 | + function displayPersonalForm( $tar ) { |
| 352 | + global $wgRequest, $wgUser, $wgOut; |
| 353 | + |
| 354 | + $dbr = wfGetDB( DB_MASTER ); |
| 355 | + $s = $dbr->selectRow( 'user_profile', |
| 356 | + array( |
| 357 | + 'up_about', 'up_places_lived', 'up_websites', 'up_relationship', |
| 358 | + 'up_occupation', 'up_companies', 'up_schools', 'up_movies', |
| 359 | + 'up_tv', 'up_music', 'up_books', 'up_video_games', |
| 360 | + 'up_magazines', 'up_snacks', 'up_drinks' |
| 361 | + ), |
| 362 | + array( 'up_user_id' => $tar->getID() ), |
| 363 | + __METHOD__ |
| 364 | + ); |
| 365 | + |
| 366 | + if ( $s !== false ) { |
| 367 | + $places = $s->up_places_lived; |
| 368 | + $websites = $s->up_websites; |
| 369 | + $relationship = $s->up_relationship; |
| 370 | + $companies = $s->up_companies; |
| 371 | + $schools = $s->up_schools; |
| 372 | + $movies = $s->up_movies; |
| 373 | + $tv = $s->up_tv; |
| 374 | + $music = $s->up_music; |
| 375 | + $books = $s->up_books; |
| 376 | + $videogames = $s->up_video_games; |
| 377 | + $magazines = $s->up_magazines; |
| 378 | + $snacks = $s->up_snacks; |
| 379 | + $drinks = $s->up_drinks; |
| 380 | + } |
| 381 | + |
| 382 | + $wgOut->setPageTitle( wfMsg( 'user-profile-section-interests' ) ); |
| 383 | + //$form = UserProfile::getEditProfileNav( wfMsg( 'user-profile-section-interests' ) ); |
| 384 | + $form = '<div class="profile-info clearfix"> |
| 385 | + <div class="profile-update"> |
| 386 | + <p class="profile-update-title">' . wfMsg( 'user-profile-interests-entertainment' ) . '</p> |
| 387 | + <p class="profile-update-unit-left">' . wfMsg( 'user-profile-interests-movies' ) . '</p> |
| 388 | + <p class="profile-update-unit"> |
| 389 | + <textarea name="movies" id="movies" rows="3" cols="75">' . ( isset( $movies ) ? $movies : '' ) . '</textarea> |
| 390 | + </p> |
| 391 | + <div class="cleared"></div> |
| 392 | + <p class="profile-update-unit-left">' . wfMsg( 'user-profile-interests-tv' ) . '</p> |
| 393 | + <p class="profile-update-unit"> |
| 394 | + <textarea name="tv" id="tv" rows="3" cols="75">' . ( isset( $tv ) ? $tv : '' ) . '</textarea> |
| 395 | + </p> |
| 396 | + <div class="cleared"></div> |
| 397 | + <p class="profile-update-unit-left">' . wfMsg( 'user-profile-interests-music' ) . '</p> |
| 398 | + <p class="profile-update-unit"> |
| 399 | + <textarea name="music" id="music" rows="3" cols="75">' . ( isset( $music ) ? $music : '' ) . '</textarea> |
| 400 | + </p> |
| 401 | + <div class="cleared"></div> |
| 402 | + <p class="profile-update-unit-left">' . wfMsg( 'user-profile-interests-books' ) . '</p> |
| 403 | + <p class="profile-update-unit"> |
| 404 | + <textarea name="books" id="books" rows="3" cols="75">' . ( isset( $books ) ? $books : '' ) . '</textarea> |
| 405 | + </p> |
| 406 | + <div class="cleared"></div> |
| 407 | + <p class="profile-update-unit-left">' . wfMsg( 'user-profile-interests-magazines' ) . '</p> |
| 408 | + <p class="profile-update-unit"> |
| 409 | + <textarea name="magazines" id="magazines" rows="3" cols="75">' . ( isset( $magazines ) ? $magazines : '' ) . '</textarea> |
| 410 | + </p> |
| 411 | + <div class="cleared"></div> |
| 412 | + <p class="profile-update-unit-left">' . wfMsg( 'user-profile-interests-videogames' ) . '</p> |
| 413 | + <p class="profile-update-unit"> |
| 414 | + <textarea name="videogames" id="videogames" rows="3" cols="75">' . ( isset( $videogames ) ? $videogames : '' ) . '</textarea> |
| 415 | + </p> |
| 416 | + <div class="cleared"></div> |
| 417 | + </div> |
| 418 | + <div class="profile-info clearfix"> |
| 419 | + <p class="profile-update-title">' . wfMsg( 'user-profile-interests-eats' ) . '</p> |
| 420 | + <p class="profile-update-unit-left">' . wfMsg( 'user-profile-interests-foodsnacks' ) . '</p> |
| 421 | + <p class="profile-update-unit"> |
| 422 | + <textarea name="snacks" id="snacks" rows="3" cols="75">' . ( isset( $snacks ) ? $snacks : '' ) . '</textarea> |
| 423 | + </p> |
| 424 | + <div class="cleared"></div> |
| 425 | + <p class="profile-update-unit-left">' . wfMsg( 'user-profile-interests-drinks' ) . '</p> |
| 426 | + <p class="profile-update-unit"> |
| 427 | + <textarea name="drinks" id="drinks" rows="3" cols="75">' . ( isset( $drinks ) ? $drinks : '' ) . '</textarea> |
| 428 | + </p> |
| 429 | + <div class="cleared"></div> |
| 430 | + </div> |
| 431 | + </div>'; |
| 432 | + |
| 433 | + return $form; |
| 434 | + } |
| 435 | + |
| 436 | + /** |
| 437 | + * Displays the form for editing custom (site-specific) information |
| 438 | + * @return $form Mixed: HTML output |
| 439 | + */ |
| 440 | + function displayCustomForm( $tar ) { |
| 441 | + global $wgRequest, $wgUser, $wgOut; |
| 442 | + |
| 443 | + $dbr = wfGetDB( DB_MASTER ); |
| 444 | + $s = $dbr->selectRow( |
| 445 | + 'user_profile', |
| 446 | + array( |
| 447 | + 'up_custom_1', 'up_custom_2', 'up_custom_3', 'up_custom_4', |
| 448 | + 'up_custom_5' |
| 449 | + ), |
| 450 | + array( 'up_user_id' => $tar->getID() ), |
| 451 | + __METHOD__ |
| 452 | + ); |
| 453 | + |
| 454 | + if ( $s !== false ) { |
| 455 | + $custom1 = $s->up_custom_1; |
| 456 | + $custom2 = $s->up_custom_2; |
| 457 | + $custom3 = $s->up_custom_3; |
| 458 | + $custom4 = $s->up_custom_4; |
| 459 | + } |
| 460 | + |
| 461 | + $wgOut->setHTMLTitle( wfMsg( 'pagetitle', wfMsg( 'user-profile-tidbits-title' ) ) ); |
| 462 | + $form = '<h1>' . wfMsg( 'user-profile-tidbits-title' ) . '</h1>'; |
| 463 | + //$form = UserProfile::getEditProfileNav( wfMsg( 'user-profile-section-custom' ) ); |
| 464 | + $form = '<div class="profile-info clearfix"> |
| 465 | + <div class="profile-update"> |
| 466 | + <p class="profile-update-title">' . wfMsgForContent( 'user-profile-tidbits-title' ) . '</p> |
| 467 | + <div id="profile-update-custom1"> |
| 468 | + <p class="profile-update-unit-left">' . wfMsgForContent( 'custom-info-field1' ) . '</p> |
| 469 | + <p class="profile-update-unit"> |
| 470 | + <textarea name="custom1" id="fav_moment" rows="3" cols="75">' . ( isset( $custom1 ) ? $custom1 : '' ) . '</textarea> |
| 471 | + </p> |
| 472 | + </div> |
| 473 | + <div class="cleared"></div> |
| 474 | + <div id="profile-update-custom2"> |
| 475 | + <p class="profile-update-unit-left">' . wfMsgForContent( 'custom-info-field2' ) . '</p> |
| 476 | + <p class="profile-update-unit"> |
| 477 | + <textarea name="custom2" id="least_moment" rows="3" cols="75">' . ( isset( $custom2 ) ? $custom2 : '' ) . '</textarea> |
| 478 | + </p> |
| 479 | + </div> |
| 480 | + <div class="cleared"></div> |
| 481 | + <div id="profile-update-custom3"> |
| 482 | + <p class="profile-update-unit-left">' . wfMsgForContent( 'custom-info-field3' ) . '</p> |
| 483 | + <p class="profile-update-unit"> |
| 484 | + <textarea name="custom3" id="fav_athlete" rows="3" cols="75">' . ( isset( $custom3 ) ? $custom3 : '' ) . '</textarea> |
| 485 | + </p> |
| 486 | + </div> |
| 487 | + <div class="cleared"></div> |
| 488 | + <div id="profile-update-custom4"> |
| 489 | + <p class="profile-update-unit-left">' . wfMsgForContent( 'custom-info-field4' ) . '</p> |
| 490 | + <p class="profile-update-unit"> |
| 491 | + <textarea name="custom4" id="least_fav_athlete" rows="3" cols="75">' . ( isset( $custom4 ) ? $custom4 : '' ) . '</textarea> |
| 492 | + </p> |
| 493 | + </div> |
| 494 | + <div class="cleared"></div> |
| 495 | + </div> |
| 496 | + <input type="submit" value="' . wfMsg( 'user-profile-update-button' ) . '" /> |
| 497 | + </form></div>'; |
| 498 | + |
| 499 | + return $form; |
| 500 | + } |
| 501 | +} |
Index: trunk/extensions/SocialProfile/UserProfile/UserProfile.i18n.php |
— | — | @@ -13,6 +13,7 @@ |
14 | 14 | * @author David Pean |
15 | 15 | */ |
16 | 16 | $messages['en'] = array( |
| 17 | + 'editprofile' => "Edit other users' profiles", |
17 | 18 | 'populateuserprofiles' => 'Populate user profiles', |
18 | 19 | 'user-time-ago' => '$1 ago', |
19 | 20 | 'user-awards-title' => 'Awards', |
— | — | @@ -90,6 +91,7 @@ |
91 | 92 | 'user-profile-update-notloggedin-text' => 'You cannot edit your profile without being logged in. |
92 | 93 | Click <a href="$1">here</a> to login or click <a href="$2">here</a> to register.', |
93 | 94 | 'user-profile-update-saved' => 'Your profile has been saved', |
| 95 | + 'user-profile-edit-profile-update-saved' => 'The user\'s profile was successfully saved', |
94 | 96 | 'user-profile-update-log-section' => 'changed section', |
95 | 97 | 'user-profile-update-profile' => 'profile', |
96 | 98 | 'user-profile-default-country' => 'United States', |
— | — | @@ -164,6 +166,7 @@ |
165 | 167 | 'user-profile-userlevels-link' => 'User levels', |
166 | 168 | 'user-no-images' => 'No images uploaded', |
167 | 169 | 'edit-profile-title' => 'Edit your profile', |
| 170 | + 'edit-profiles-title' => 'Edit profiles', |
168 | 171 | 'user-page-link' => 'User page', |
169 | 172 | 'user-social-profile-link' => 'Social profile', |
170 | 173 | 'user-wiki-link' => 'Wiki userpage', |
— | — | @@ -186,6 +189,7 @@ |
187 | 190 | 'profilelogpage' => 'User profile edit log', |
188 | 191 | 'profilelogpagetext' => 'This is a log of user profile edits', |
189 | 192 | 'profilelogentry' => '', # For compatibility, don't translate this, |
| 193 | + 'user-profile-edit-profile' => "edited $1's profile", |
190 | 194 | 'avatarlogpage' => 'Avatar upload log', |
191 | 195 | 'avatarlogpagetext' => 'This is a log of user avatar uploads', |
192 | 196 | 'avatarlogentry' => '', # For compatibility, don't translate this |
— | — | @@ -429,6 +433,7 @@ |
430 | 434 | *Zimbabwe', |
431 | 435 | // For Special:ListGroupRights |
432 | 436 | 'right-avatarremove' => "Remove user's avatars", |
| 437 | + 'right-editothersprofiles' => "Update other users' social profiles", |
433 | 438 | ); |
434 | 439 | |
435 | 440 | /** Message documentation (Message documentation) |
Index: trunk/extensions/SocialProfile/SocialProfile.php |
— | — | @@ -25,6 +25,7 @@ |
26 | 26 | // Classes to be autoloaded |
27 | 27 | $wgAutoloadClasses['SpecialAddRelationship'] = $dir . 'UserRelationship/SpecialAddRelationship.php'; |
28 | 28 | $wgAutoloadClasses['SpecialBoardBlast'] = $dir . 'UserBoard/SpecialSendBoardBlast.php'; |
| 29 | +$wgAutoloadClasses['SpecialEditProfile'] = $dir . 'UserProfile/SpecialEditProfile.php'; |
29 | 30 | $wgAutoloadClasses['SpecialPopulateUserProfiles'] = $dir . 'UserProfile/SpecialPopulateExistingUsersProfiles.php'; |
30 | 31 | $wgAutoloadClasses['SpecialRemoveRelationship'] = $dir . 'UserRelationship/SpecialRemoveRelationship.php'; |
31 | 32 | $wgAutoloadClasses['SpecialToggleUserPage'] = $dir . 'UserProfile/SpecialToggleUserPageType.php'; |
— | — | @@ -51,6 +52,7 @@ |
52 | 53 | |
53 | 54 | // New special pages |
54 | 55 | $wgSpecialPages['AddRelationship'] = 'SpecialAddRelationship'; |
| 56 | +$wgSpecialPages['EditProfile'] = 'SpecialEditProfile'; |
55 | 57 | $wgSpecialPages['PopulateUserProfiles'] = 'SpecialPopulateUserProfiles'; |
56 | 58 | $wgSpecialPages['RemoveAvatar'] = 'RemoveAvatar'; |
57 | 59 | $wgSpecialPages['RemoveRelationship'] = 'SpecialRemoveRelationship'; |
Index: trunk/extensions/SocialProfile/SocialProfile.alias.php |
— | — | @@ -11,6 +11,7 @@ |
12 | 12 | /** English (English) */ |
13 | 13 | $specialPageAliases['en'] = array( |
14 | 14 | 'AddRelationship' => array( 'AddRelationship' ), |
| 15 | + 'EditProfile' => array( 'EditProfile' ), |
15 | 16 | 'PopulateUserProfiles' => array( 'PopulateUserProfiles' ), |
16 | 17 | 'RemoveAvatar' => array( 'RemoveAvatar' ), |
17 | 18 | 'RemoveRelationship' => array( 'RemoveRelationship' ), |