Page MenuHomePhabricator

Feature request: Allow editing of other user's profiles
Closed, ResolvedPublic

Description

Author: g33kdyoo

Description:
Ideally, Special:UpdateProfile should let privileged users to let them edit profiles.

Initial patch coming soon.


Version: unspecified
Severity: enhancement

Details

Reference
bz27032

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 11:18 PM
bzimport added a project: SocialProfile.
bzimport set Reference to bz27032.

g33kdyoo wrote:

Patch to add Special:EditProfile

It looks like I forgot this bug in the dust. Oh well then. I have an initial version ready.

It's VERY hacky, and while it works I need more opinions on it.

attachment sp-27032.patch ignored as obsolete

(In reply to comment #1)

Created attachment 8328 [details]
Patch to add Special:EditProfile
It looks like I forgot this bug in the dust. Oh well then. I have an initial
version ready.
It's VERY hacky, and while it works I need more opinions on it.

Firstly, thanks for writing this feature! It looks very cool and definitely something I'd like to see in core SocialProfile after a bit of cleanup. :-)

The most obvious thing I see here is the amount of code duplication. Could we reduce the amount of code duplication by moving some methods into the UserProfile class (/extensions/SocialProfile/UserProfile/UserProfileClass.php) or maybe by creating a new class? I think that'd be a lot better solution that the current one.

+ * @author David Pean <david.pean@gmail.com>
+ * @copyright Copyright © 2007, Wikia Inc.

You're not Dave, are you? :)

+ // Are we even allowed to do this?
+ if ( !$wgUser->isAllowed( 'editothersprofiles' ) ) {
+ $wgOut->showPermissionsErrorPage( array ("You do not have access to this function.") );

This is icky and contains hardcoded English (while you and I might be okay with that, some other folks will not be). I'd suggest using $wgOut->permissionRequired( 'editothersprofiles' ); or something like that instead.

+ if ( !$_GET['user'] ) {
+ $wgOut->addHTML( '<form action="" method="get"><input type="hidden" name="title" value="Special:EditProfile" />Username: <input name="wpUser"><input type=submit value="Edit user profile"/></form>' );
+ return;
+ }
+
+ $target = User::newFromName( $_GET['wpUser'] );

Use WebRequest ($wgRequest), don't use the $_GET superglobal directly. Also the form construction should probably be in its own function (makeForm() or something) and it needs to use MediaWiki's i18n functions (wfMsg() and friends) properly.

+ $wgOut->addHTML( 'No such user' );

Use i18n functions properly.

+ $log->addEntry(
+ wfMsgForContent( 'user-profile-update-profile' ),
+ $wgUser->getUserPage(),
+ "edited " . $target->getName() . "'s profile section '{$section}'"
+ );

Same here.

  • 'user-profile-update-saved' => 'Your profile has been saved',

+ 'user-profile-update-saved' => 'Profile has been saved',

I think we should use the 'user-profile-update-saved' message when /you/ have saved /your/ profile and use a new message EditProfile; maybe 'user-profile-edit-profile-changes-saved' with "Changes to $1's profile were saved" or something as the text.

+ 'right-editothersprofiles' => "Update anyone's profile",

I don't exactly like the user right name; I'd prefer 'edituserprofiles' or something with "Update other users' social profiles" or something as the text.

Again, thanks for writing this feature! Please let me know if you need any help with the code cleanup process.

attachment sp-27032.patch ignored as obsolete

g33kdyoo wrote:

That's why I warned you. Anyway, will implement.

g33kdyoo wrote:

new version

This patch is more i18n friendly now, along with your other suggestions.

Attached:

I've committed your patch with some modifications in r84989. It took me a while to figure out how to reduce the amount of code duplication, but I eventually figured it out.