Skip to content

Commit 1bfadd6

Browse files
committed
Checked in FBConnect r91 from 2008 under /tags for archival purposes
0 parents  commit 1bfadd6

20 files changed

+8110
-0
lines changed

FBConnect.alias.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
/**
3+
* FBConnect.alias.php - FBConnect for MediaWiki
4+
*
5+
* Special Page alias file... for when we actually define some special pages ;-)
6+
*/
7+
8+
9+
/*
10+
* Not a valid entry point, skip unless MEDIAWIKI is defined.
11+
*/
12+
if ( !defined( 'MEDIAWIKI' ) ) {
13+
die( 'This file is a MediaWiki extension, it is not a valid entry point' );
14+
}
15+
16+
$aliases = array();
17+
18+
/** English */
19+
$aliases['en'] = array(
20+
'Connect' => array( 'Connect', 'ConnectAccount' ),
21+
);

FBConnect.i18n.php

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
/**
3+
* FBConnect.i18n.php - FBConnect for MediaWiki
4+
*
5+
* Internationalization file... for when Facebook Connect is internationalized ;-)
6+
*/
7+
8+
9+
/*
10+
* Not a valid entry point, skip unless MEDIAWIKI is defined.
11+
*/
12+
if ( !defined( 'MEDIAWIKI' ) ) {
13+
die( 'This file is a MediaWiki extension, it is not a valid entry point' );
14+
}
15+
16+
$messages = array();
17+
18+
if (!defined( 'fb' )) {
19+
define( 'fb', 'fbconnect-' );
20+
}
21+
22+
23+
/** English */
24+
$messages['en'] = array(
25+
// Extension name
26+
'fbconnect' => 'Facebook Connect',
27+
fb.'desc' => 'Enables users to [[Special:Connect|Connect]] with their [http://www.facebook.com Facebook] ' .
28+
'accounts. Offers authentification based on Facebook groups (soon!) and the use of FBML in wiki text.',
29+
// Group containing Facebook Connect users
30+
'group-fb-user' => 'Facebook Connect users',
31+
'group-fb-user-member' => 'Facebook Connect user',
32+
'grouppage-fb-user' => '{{ns:project}}:Facebook Connect users',
33+
// Group for Facebook Connect users beloning to the group specified by $fbUserRightsFromGroup
34+
'group-fb-groupie' => 'Group members',
35+
'group-fb-groupie-member' => 'Group member',
36+
'grouppage-fb-groupie' => '{{ns:project}}:Group members',
37+
// Officers of the Facebook group
38+
'group-fb-officer' => 'Group officers',
39+
'group-fb-officer-member' => 'Group officer',
40+
'grouppage-fb-officer' => '{{ns:project}}:Group officers',
41+
// Admins of the Facebook group
42+
'group-fb-admin' => 'Group admins',
43+
'group-fb-admin-member' => 'Group administrator',
44+
'grouppage-fb-admin' => '{{ns:project}}:Group admins',
45+
// Incredibly good looking people
46+
'right-goodlooking' => 'Really, really, ridiculously good looking',
47+
// Personal toolbar
48+
fb.'connect' => 'Connect this account with Facebook',
49+
fb.'logout' => 'Logout of Facebook',
50+
fb.'link' => 'Back to facebook.com',
51+
// Special:Connect
52+
fb.'title' => 'Connect account with Facebook',
53+
fb.'intro' => 'This wiki is enabled with Facebook Connect, the next evolution of Facebook Platform. This means ' .
54+
'that when you are Connected, in addition to the normal [[Wikipedia:Help:Logging in#Why log in?' .
55+
'|benefits]] you see when logging in, you will be able to take advantage of some extra features...',
56+
fb.'conv' => 'Convenience',
57+
fb.'convdesc' => 'Connected users are automatically logged you in. If permission is given, then this wiki can even ' .
58+
'use Facebook as an email proxy so you can continue to receive important notifications without ' .
59+
'revealing your email address.',
60+
fb.'fbml' => 'Facebook Markup Language',
61+
fb.'fbmldesc' => 'Facebook has provided a bunch of built-in tags that will render dynamic data. Many of these tags ' .
62+
'can be included in wiki text, and will be rendered differently depending on which Connected user ' .
63+
'they are being viewed by.',
64+
fb.'comm' => 'Communication',
65+
fb.'commdesc' => 'Facebook Connect ushers in a whole new level of networking. See which of your friends are using ' .
66+
'the wiki, and optionally share your actions with your friends through the Facebook News Feed.',
67+
fb.'welcome' => 'Welcome, Facebook Connect user!',
68+
fb.'loginbox' => "Or '''login''' with Facebook:\n\n$1",
69+
fb.'merge' => 'Merge your wiki account with your Facebook ID',
70+
fb.'mergebox' => 'This feature has not yet been implemented. Accounts can be merged manually with [[Special:' .
71+
'Renameuser]] if it is installed. For more information, please visit [[MediaWikiWiki:Extension:' .
72+
"Renameuser|Extension:Renameuser]].\n\n\n$1\n\n\nNote: This can be undone by a sysop.",
73+
fb.'logoutbox'=> "$1\n\nThis will also log you out of Facebook and all Connected sites, including this wiki.",
74+
fb.'listusers-header'
75+
=> '$1 and $2 privileges are automatically transfered from the Officer and Admin titles of the ' .
76+
"Facebook group $3.\n\nFor more info, please contact the group creator $4.",
77+
);

FBConnect.php

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
<?php
2+
/**
3+
* Copyright © 2008 Garrett Brown <http://www.mediawiki.org/wiki/User:Gbruin>
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; either version 2 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License along
15+
* with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*
17+
* @author Garrett Bruin
18+
* @copyright Copyright © 2008 Garrett Brown
19+
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
20+
* @addtogroup Extensions
21+
*
22+
*
23+
* FBConnect plugin. Integrates Facebook Connect into MediaWiki.
24+
*
25+
* Facebook Connect single sign on (SSO) experience and XFBML are currently available.
26+
* Please rename config.sample.php to config.php, follow the instructions inside and
27+
* customize variables as you like to set up your Facebook Connect extension.
28+
*
29+
* Info is available at http://www.mediawiki.org/wiki/Extension:FBConnect
30+
* and at http://wiki.developers.facebook.com/index.php/MediaWiki
31+
*
32+
* Limited support is available at http://www.mediawiki.org/wiki/Extension_talk:FBConnect
33+
* and at http://wiki.developers.facebook.com/index.php/Talk:MediaWiki
34+
*
35+
*/
36+
37+
38+
/**
39+
* Not a valid entry point, skip unless MEDIAWIKI is defined.
40+
*/
41+
if ( !defined( 'MEDIAWIKI' )) {
42+
die( 'This file is a MediaWiki extension, it is not a valid entry point' );
43+
}
44+
45+
/**
46+
* FBConnect version. Note: this is not necessarily the most recent SVN revision number.
47+
*/
48+
define( 'MEDIAWIKI_FBCONNECT_VERSION', 'r71, January 25, 2009' );
49+
50+
/**
51+
* Add information about this extension to Special:Version.
52+
*/
53+
$wgExtensionCredits['specialpage'][] = array(
54+
'name' => 'Facebook Connect Plugin',
55+
'author' => 'Garrett Brown',
56+
'url' => 'http://www.mediawiki.org/wiki/Extension:FBConnect',
57+
'descriptionmsg' => 'fbconnect-desc',
58+
'version' => MEDIAWIKI_FBCONNECT_VERSION,
59+
);
60+
61+
/**
62+
* Initialization of the autoloaders and special extension pages.
63+
*/
64+
$dir = dirname(__FILE__) . '/';
65+
require_once $dir . 'config.php';
66+
require_once $dir . 'facebook-client/facebook.php';
67+
68+
$wgExtensionMessagesFiles['FBConnect'] = $dir . 'FBConnect.i18n.php';
69+
$wgExtensionAliasesFiles['FBConnect'] = $dir . 'FBConnect.alias.php';
70+
71+
$wgAutoloadClasses['FBConnectAPI'] = $dir . 'FBConnectAPI.php';
72+
$wgAutoloadClasses['FBConnectAuthPlugin'] = $dir . 'FBConnectAuthPlugin.php';
73+
$wgAutoloadClasses['FBConnectHooks'] = $dir . 'FBConnectHooks.php';
74+
$wgAutoloadClasses['FBConnectXFBML'] = $dir . 'FBConnectXFBML.php';
75+
$wgAutoloadClasses['SpecialConnect'] = $dir . 'SpecialConnect.php';
76+
77+
$wgSpecialPages['Connect'] = 'SpecialConnect';
78+
#$wgSpecialPages['NewsFeed'] = 'SpecialNewsFeed';
79+
80+
$wgExtensionFunctions[] = 'FBConnect::init';
81+
82+
// If we are configured to pull group info from Facebook, then create the group permissions
83+
$wgGroupPermissions['fb-user'] = $wgGroupPermissions['user'];
84+
if( $fbUserRightsFromGroup ) {
85+
$wgGroupPermissions['fb-groupie'] = $wgGroupPermissions['user'];
86+
$wgGroupPermissions['fb-officer'] = $wgGroupPermissions['bureaucrat'];
87+
$wgGroupPermissions['fb-admin'] = $wgGroupPermissions['sysop'];
88+
$wgGroupPermissions['fb-officer']['goodlooking'] = true;
89+
$wgImplictGroups[] = 'fb-groupie';
90+
$wgImplictGroups[] = 'fb-officer';
91+
$wgImplictGroups[] = 'fb-admin';
92+
}
93+
94+
/**/
95+
// Define new autopromote condition (use quoted text, numbers can cause collisions)
96+
define( 'APCOND_FB_INGROUP', 'fb*g' );
97+
define( 'APCOND_FB_ISOFFICER', 'fb*o' );
98+
define( 'APCOND_FB_ISADMIN', 'fb*a' );
99+
100+
$wgAutopromote['fb-groupie'] = APCOND_FB_INGROUP;
101+
$wgAutopromote['fb-officer'] = APCOND_FB_ISOFFICER;
102+
$wgAutopromote['fb-admin'] = APCOND_FB_ISADMIN;
103+
104+
/**
105+
$wgAutopromote['autoconfirmed'] = array( '&', array( APCOND_EDITCOUNT, &$wgAutoConfirmCount ),
106+
array( APCOND_AGE, &$wgAutoConfirmAge ),
107+
array( APCOND_FB_INGROUP ));
108+
/**/
109+
110+
$wgImplicitGroups[] = 'fb-groupie';
111+
$wgImplicitGroups[] = 'fb-officer';
112+
$wgImplicitGroups[] = 'fb-admin';
113+
114+
115+
/**
116+
* Class FBConnect
117+
*
118+
* This class initializes the extension, and contains the core non-hook,
119+
* non-authentification code.
120+
*/
121+
class FBConnect {
122+
// Instance of our Facebook API class
123+
public static $api;
124+
// Whether we are rendering the Special:Connect page
125+
public static $special_connect;
126+
127+
/**
128+
* Initializes and configures the extension.
129+
*/
130+
public static function init() {
131+
global $wgXhtmlNamespaces, $wgAuth, $wgHooks;
132+
133+
self::$special_connect = false;
134+
self::$api = new FBConnectAPI();
135+
136+
// The xmlns:fb attribute is required for proper rendering on IE
137+
$wgXhtmlNamespaces['fb'] = 'http://www.facebook.com/2008/fbml';
138+
139+
// Set the global variable $wgAuth to our custom authentification plugin.
140+
// The AuthPluginSetup hook is called right before init(), so we can't use this hook
141+
$wgAuth = new StubObject( 'wgAuth', 'FBConnectAuthPlugin' );
142+
143+
// Install all public static functions in class FBConnectHooks as MediaWiki hooks
144+
$hooks = self::enumMethods('FBConnectHooks');
145+
foreach( $hooks as $hookName ) {
146+
$wgHooks[$hookName][] = "FBConnectHooks::$hookName";
147+
}
148+
149+
// ParserFirstCallInit was introduced in modern (1.12+) MW versions so as to
150+
// avoid unstubbing $wgParser on setHook() too early, as per r35980
151+
if (!defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' )) {
152+
global $wgParser;
153+
wfRunHooks( 'ParserFirstCallInit', $wgParser );
154+
}
155+
}
156+
157+
/**
158+
* Returns an array with the names of all public static functions
159+
* in the specified class.
160+
*/
161+
public static function enumMethods( $className ) {
162+
$hooks = array();
163+
try {
164+
$class = new ReflectionClass( $className );
165+
foreach( $class->getMethods( ReflectionMethod::IS_PUBLIC ) as $method ) {
166+
if ( $method->isStatic() ) {
167+
$hooks[] = $method->getName();
168+
}
169+
}
170+
} catch( Exception $e ) {
171+
// If PHP's version doesn't support the Reflection API, then exit
172+
die( 'PHP version (' . phpversion() . ') must be great enough to support the Reflection API' );
173+
// or...
174+
$hooks = array('AuthPluginSetup', 'UserLoadFromSession',
175+
'RenderPreferencesForm', 'PersonalUrls',
176+
'ParserAfterTidy', 'BeforePageDisplay');
177+
}
178+
return $hooks;
179+
}
180+
}

0 commit comments

Comments
 (0)