-
Notifications
You must be signed in to change notification settings - Fork 0
/
SocialProfile.php
203 lines (172 loc) · 8.63 KB
/
SocialProfile.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<?php
/**
* Protect against register_globals vulnerabilities.
* This line must be present before any global variable is referenced.
*/
if ( !defined( 'MEDIAWIKI' ) ) {
die(
'This is the setup file for the SocialProfile extension to MediaWiki.' .
'Please see https://www.mediawiki.org/wiki/Extension:SocialProfile for' .
' more information about this extension.'
);
}
/**
* This is the loader file for the SocialProfile extension. You should include
* this file in your wiki's LocalSettings.php to activate SocialProfile.
*
* If you want to use the UserWelcome extension (bundled with SocialProfile),
* the <topusers /> tag or the user levels feature, there are some other files
* you will need to include in LocalSettings.php. The online manual has more
* details about this.
*
* For more info about SocialProfile, please see https://www.mediawiki.org/wiki/Extension:SocialProfile.
*/
// Internationalization files
$wgMessagesDirs['SocialProfile'] = __DIR__ . '/i18n';
$wgExtensionMessagesFiles['SocialProfileAlias'] = __DIR__ . '/SocialProfile.alias.php';
$wgMessagesDirs['SocialProfileUserProfile'] = __DIR__ . '/UserProfile/i18n';
$wgExtensionMessagesFiles['SocialProfileNamespaces'] = __DIR__ . '/SocialProfile.namespaces.php';
$wgExtensionMessagesFiles['AvatarMagic'] = __DIR__ . '/UserProfile/includes/avatar/Avatar.i18n.magic.php';
// Hack to make installer load extension properly. (T243861)
// Based on Installer::includeExtensions()
if ( defined( 'MEDIAWIKI_INSTALL' ) ) {
$subext = [
__DIR__ . '/SystemGifts/extension.json' => 1,
__DIR__ . '/UserActivity/extension.json' => 1,
__DIR__ . '/UserBoard/extension.json' => 1,
__DIR__ . '/UserRelationship/extension.json' => 1,
__DIR__ . '/UserStats/extension.json' => 1,
__DIR__ . '/UserGifts/extension.json' => 1,
];
$registry = new ExtensionRegistry();
$data = $registry->readFromQueue( $subext );
if ( method_exists( AutoLoader::class, 'registerClasses' ) ) {
// MediaWiki 1.39+
AutoLoader::registerClasses( $data['autoloaderClasses'] );
if ( !isset( $wgAutoloadClasses ) ) {
$wgAutoloadClasses = [];
}
} else {
// @phan-suppress-next-line PhanUndeclaredVariableAssignOp
$wgAutoloadClasses += $data['globals']['wgAutoloadClasses'];
}
}
// Classes to be autoloaded
$wgAutoloadClasses['SocialProfileFileBackend'] = __DIR__ . '/SocialProfileFileBackend.php';
$wgAutoloadClasses['SpecialEditProfile'] = __DIR__ . '/UserProfile/includes/specials/SpecialEditProfile.php';
$wgAutoloadClasses['SpecialPopulateUserProfiles'] = __DIR__ . '/UserProfile/includes/specials/SpecialPopulateExistingUsersProfiles.php';
$wgAutoloadClasses['SpecialToggleUserPage'] = __DIR__ . '/UserProfile/includes/specials/SpecialToggleUserPageType.php';
$wgAutoloadClasses['SpecialUpdateProfile'] = __DIR__ . '/UserProfile/includes/specials/SpecialUpdateProfile.php';
$wgAutoloadClasses['SpecialUploadAvatar'] = __DIR__ . '/UserProfile/includes/specials/SpecialUploadAvatar.php';
$wgAutoloadClasses['UploadAvatar'] = __DIR__ . '/UserProfile/includes/avatar/UploadAvatar.php';
$wgAutoloadClasses['UploadAvatarFromUrl'] = __DIR__ . '/UserProfile/includes/avatar/UploadAvatarFromUrl.php';
$wgAutoloadClasses['UploadAvatarTrait'] = __DIR__ . '/UserProfile/includes/avatar/UploadAvatarTrait.php';
$wgAutoloadClasses['RemoveAvatar'] = __DIR__ . '/UserProfile/includes/specials/SpecialRemoveAvatar.php';
$wgAutoloadClasses['UserProfile'] = __DIR__ . '/UserProfile/includes/UserProfile.php';
$wgAutoloadClasses['UserProfileHooks'] = __DIR__ . '/UserProfile/includes/UserProfileHooks.php';
$wgAutoloadClasses['UserProfilePage'] = __DIR__ . '/UserProfile/includes/UserProfilePage.php';
$wgAutoloadClasses['wAvatar'] = __DIR__ . '/UserProfile/includes/avatar/Avatar.php';
$wgAutoloadClasses['AvatarParserFunction'] = __DIR__ . '/UserProfile/includes/parser/AvatarParserFunction.php';
$wgAutoloadClasses['SPUserSecurity'] = __DIR__ . '/UserProfile/includes/SPUserSecurity.php';
$wgAutoloadClasses['RandomUsersWithAvatars'] = __DIR__ . '/UserProfile/includes/parser/RandomUsersWithAvatars.php';
$wgAutoloadClasses['NewUsersList'] = __DIR__ . '/UserProfile/includes/parser/NewUsersList.php';
$wgAutoloadClasses['MigrateOldUserProfileUserColumnToActor'] = __DIR__ . '/UserProfile/maintenance/migrateOldUserProfileUserColumnToActor.php';
$wgAutoloadClasses['MigrateOldUserFieldPrivacyUserColumnToActor'] = __DIR__ . '/UserProfile/maintenance/migrateOldUserFieldPrivacyUserColumnToActor.php';
// API modules
$wgAutoloadClasses['ApiUserProfilePrivacy'] = __DIR__ . '/UserProfile/includes/api/ApiUserProfilePrivacy.php';
$wgAPIModules['smpuserprivacy'] = 'ApiUserProfilePrivacy';
$wgAutoloadClasses['ApiUserProfileType'] = __DIR__ . '/UserProfile/includes/api/ApiUserProfileType.php';
$wgAPIModules['smpuserprofiletype'] = 'ApiUserProfileType';
$wgDefaultUserOptions['echo-subscriptions-web-social-rel'] = true;
$wgDefaultUserOptions['echo-subscriptions-email-social-rel'] = false;
// New special pages
$wgSpecialPages['EditProfile'] = 'SpecialEditProfile';
$wgSpecialPages['PopulateUserProfiles'] = 'SpecialPopulateUserProfiles';
$wgSpecialPages['RemoveAvatar'] = 'RemoveAvatar';
$wgSpecialPages['ToggleUserPage'] = 'SpecialToggleUserPage';
$wgSpecialPages['UpdateProfile'] = 'SpecialUpdateProfile';
$wgSpecialPages['UploadAvatar'] = 'SpecialUploadAvatar';
// file backend to use defaults to FileSystem
// this allows you to use e.g. swift.
// to setup your own file backend see
// https://www.mediawiki.org/wiki/Manual:$wgFileBackends
$wgSocialProfileFileBackend = '';
// What to display on social profile pages by default?
$wgUserProfileDisplay['board'] = true;
$wgUserProfileDisplay['foes'] = true;
$wgUserProfileDisplay['friends'] = true;
$wgUserProfileDisplay['avatar'] = true; // If set to false, disables both avatar display and upload
// Should we display UserBoard-related things on social profile pages?
$wgUserBoard = true;
// Whether to enable friending or not -- this doesn't do very much actually, so don't rely on it
$wgFriendingEnabled = true;
// Prefix SocialProfile will use to store avatars
// for global avatars on a wikifarm or groups of wikis,
// set this to something static.
// Use GLOBALS to access wgDBname as for some reason
// accessing the config directly doesn't work under MW 1.40.
$wgAvatarKey = $GLOBALS['wgDBname'];
// Extension credits that show up on Special:Version
$wgExtensionCredits['other'][] = [
'path' => __FILE__,
'name' => 'SocialProfile',
'author' => [ 'Aaron Wright', 'David Pean', 'Jack Phoenix' ],
'version' => '1.14',
'url' => 'https://www.mediawiki.org/wiki/Extension:SocialProfile',
'descriptionmsg' => 'socialprofile-desc',
];
// Hooked functions
$wgAutoloadClasses['SocialProfileHooks'] = __DIR__ . '/SocialProfileHooks.php';
// Loader files
require_once __DIR__ . '/UserProfile/UserProfile.php'; // Profile page configuration loader file
wfLoadExtensions( [
'SocialProfile/SystemGifts', // SystemGifts (awards functionality)
'SocialProfile/UserActivity', // UserActivity - recent social changes
'SocialProfile/UserBoard',
'SocialProfile/UserRelationship',
'SocialProfile/UserStats',
'SocialProfile/UserGifts',
] );
$wgHooks['BeforePageDisplay'][] = 'SocialProfileHooks::onBeforePageDisplay';
$wgHooks['CanonicalNamespaces'][] = 'SocialProfileHooks::onCanonicalNamespaces';
$wgHooks['LoadExtensionSchemaUpdates'][] = 'SocialProfileHooks::onLoadExtensionSchemaUpdates';
$wgHooks['ParserFirstCallInit'][] = 'AvatarParserFunction::setupAvatarParserFunction';
// ResourceLoader module definitions for certain components which do not have
// their own loader file
// General
$wgResourceModules['ext.socialprofile.clearfix'] = [
'styles' => 'clearfix.css',
'localBasePath' => __DIR__ . '/shared',
'remoteExtPath' => 'SocialProfile/shared',
];
$wgResourceModules['ext.socialprofile.responsive'] = [
'styles' => 'responsive.less',
'localBasePath' => __DIR__ . '/shared',
'remoteExtPath' => 'SocialProfile/shared',
];
// General/shared JS modules -- not (necessarily) directly used by SocialProfile,
// but rather by other social tools which depend on SP
// @see https://phabricator.wikimedia.org/T100025
$wgResourceModules['ext.socialprofile.flash'] = [
'scripts' => 'flash.js',
'localBasePath' => __DIR__ . '/shared',
'remoteExtPath' => 'SocialProfile/shared',
];
$wgResourceModules['ext.socialprofile.LightBox'] = [
'scripts' => 'LightBox.js',
'localBasePath' => __DIR__ . '/shared',
'remoteExtPath' => 'SocialProfile/shared',
];
// End ResourceLoader stuff
if ( !defined( 'NS_USER_WIKI' ) ) {
define( 'NS_USER_WIKI', 200 );
}
if ( !defined( 'NS_USER_WIKI_TALK' ) ) {
define( 'NS_USER_WIKI_TALK', 201 );
}
if ( !defined( 'NS_USER_PROFILE' ) ) {
define( 'NS_USER_PROFILE', 202 );
}
if ( !defined( 'NS_USER_PROFILE_TALK' ) ) {
define( 'NS_USER_PROFILE_TALK', 203 );
}