Index: trunk/extensions/FBConnect/FBConnectXFBML.php |
— | — | @@ -1,16 +1,16 @@ |
2 | 2 | <?php |
3 | | -/* |
| 3 | +/** |
4 | 4 | * Copyright © 2008-2010 Garrett Brown <http://www.mediawiki.org/wiki/User:Gbruin> |
5 | 5 | * This program is free software; you can redistribute it and/or modify |
6 | 6 | * it under the terms of the GNU General Public License as published by |
7 | 7 | * the Free Software Foundation; either version 2 of the License, or |
8 | 8 | * (at your option) any later version. |
9 | | - * |
| 9 | + * |
10 | 10 | * This program is distributed in the hope that it will be useful, |
11 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | 13 | * GNU General Public License for more details. |
14 | | - * |
| 14 | + * |
15 | 15 | * You should have received a copy of the GNU General Public License along |
16 | 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | */ |
— | — | @@ -26,10 +26,10 @@ |
27 | 27 | |
28 | 28 | /** |
29 | 29 | * Class FBConnectXFBML |
30 | | - * |
| 30 | + * |
31 | 31 | * This class allows FBML (Facebook Markup Language, an extension to HTML) to |
32 | 32 | * be incorporated into the wiki through XFBML. |
33 | | - * |
| 33 | + * |
34 | 34 | * See: <http://wiki.developers.facebook.com/index.php/XFBML> |
35 | 35 | */ |
36 | 36 | class FBConnectXFBML { |
— | — | @@ -40,24 +40,24 @@ |
41 | 41 | * function that simply redirects to parserHook(), filling in the missing |
42 | 42 | * $tag argument with the $tag provided to createParserHook. |
43 | 43 | */ |
44 | | - static function parserHook($innertext, $args, &$parser, $tag = '' ) { |
| 44 | + static function parserHook( $innertext, $args, &$parser, $tag = '' ) { |
45 | 45 | global $wgFbAllowFacebookImages; |
46 | | - |
| 46 | + |
47 | 47 | // Run hook to allow modifying the default behavior. If $override is |
48 | | - // set, it is used instead. Return false to disable the tag. |
| 48 | + // set, it is used instead. Return false to disable the tag. |
49 | 49 | $override = ''; |
50 | 50 | if ( !wfRunHooks('XFBMLParseTag', |
51 | | - array( $tag, &$args, &$innertext, &$override )) ) { |
| 51 | + array( $tag, &$args, &$innertext, &$override ) ) ) { |
52 | 52 | return ''; |
53 | 53 | } |
54 | 54 | if ( $override != '' ) { |
55 | 55 | return $override; |
56 | 56 | } |
57 | | - |
58 | | - switch ($tag) { |
| 57 | + |
| 58 | + switch ( $tag ) { |
59 | 59 | case '': |
60 | 60 | break; // Error: We shouldn't be here! |
61 | | - |
| 61 | + |
62 | 62 | // To implement a custom XFBML tag handler, simply case it here like so |
63 | 63 | case 'fb:add-profile-tab': |
64 | 64 | // Disable these tags by returning an empty string |
— | — | @@ -70,7 +70,7 @@ |
71 | 71 | case 'fb:profile-pic': |
72 | 72 | #case 'fb:photo': // Dropped in new JavaScript SDK |
73 | 73 | #case 'fb:video': // Dropped in new JavaScript SDK |
74 | | - if (!$wgFbAllowFacebookImages) { |
| 74 | + if ( !$wgFbAllowFacebookImages ) { |
75 | 75 | break; |
76 | 76 | } |
77 | 77 | // Careful - no "break;" if $wgFbAllowFacebookImages is true |
— | — | @@ -82,108 +82,110 @@ |
83 | 83 | // Strip the tag entirely |
84 | 84 | return ''; |
85 | 85 | } |
86 | | - |
| 86 | + |
87 | 87 | /** |
88 | 88 | * Helper function to create name-value pairs from the list of attributes passed to the |
89 | 89 | * parser hook. |
90 | 90 | */ |
91 | 91 | static function implodeAttrs( $args ) { |
92 | | - $attrs = ""; |
| 92 | + $attrs = ''; |
93 | 93 | // The default action is to strip all event handlers and allow the tag |
94 | 94 | foreach( $args as $name => $value ) { |
95 | 95 | // Disable all event handlers (e.g. onClick, onligin) |
96 | | - if ( substr( $name, 0, 2 ) == "on" ) |
| 96 | + if ( substr( $name, 0, 2 ) == 'on' ) { |
97 | 97 | continue; |
| 98 | + } |
98 | 99 | // Otherwise, pass the attribute through htmlspecialchars unmodified |
99 | 100 | $attrs .= " $name=\"" . htmlspecialchars( $value ) . '"'; |
100 | 101 | } |
101 | 102 | return $attrs; |
102 | 103 | } |
103 | | - |
| 104 | + |
104 | 105 | /** |
105 | 106 | * Helper function for parserHook. Originally, all tags were directed to |
106 | 107 | * that function, but I had no way of knowing which tag provoked the function. |
107 | 108 | */ |
108 | | - static function createParserHook($tag) { |
| 109 | + static function createParserHook( $tag ) { |
109 | 110 | $args = '$text,$args,&$parser'; |
110 | | - $code = 'return FBConnectXFBML::parserHook($text,$args,$parser,\''.$tag.'\');'; |
111 | | - return create_function($args, $code); |
| 111 | + $code = 'return FBConnectXFBML::parserHook($text,$args,$parser,\'' . $tag . '\');'; |
| 112 | + return create_function( $args, $code ); |
112 | 113 | } |
113 | | - |
| 114 | + |
114 | 115 | /** |
115 | 116 | * Returns true if XFBML is enabled (i.e. $wgFbUseMarkup is not false). |
116 | 117 | * Defaults to true if $wgFbUseMarkup is not set. |
117 | 118 | */ |
118 | 119 | static function isEnabled() { |
119 | 120 | global $wgFbUseMarkup; |
120 | | - return !isset($wgFbUseMarkup) || $wgFbUseMarkup; |
| 121 | + return !isset( $wgFbUseMarkup ) || $wgFbUseMarkup; |
121 | 122 | } |
122 | | - |
| 123 | + |
123 | 124 | /** |
124 | 125 | * Returns the availabe XFBML tags. For help on including these in your |
125 | 126 | * site, please see: <http://developers.facebook.com/plugins>. |
126 | | - * |
| 127 | + * |
127 | 128 | * If Facebook adds a new tag (or you create your own!) then this list can |
128 | 129 | * be updated with the XFBMLAvailableTags hook. |
129 | 130 | */ |
130 | 131 | static function availableTags() { |
131 | | - if (!self::isEnabled()) { |
| 132 | + if ( !self::isEnabled() ) { |
132 | 133 | // If XFBML isn't enabled, then don't report any tags |
133 | | - return array( ); |
| 134 | + return array(); |
134 | 135 | } |
135 | 136 | // http://github.com/facebook/connect-js/blob/master/src/xfbml/xfbml.js#L237 |
136 | | - $tags = array('fb:activity', |
137 | | - 'fb:add-profile-tab', |
138 | | - 'fb:bookmark', |
139 | | - 'fb:comments', |
140 | | - 'fb:connect-bar', |
141 | | - 'fb:fan', |
142 | | - 'fb:like', |
143 | | - 'fb:like-box', |
144 | | - 'fb:live-stream', |
145 | | - 'fb:login', |
146 | | - 'fb:login-button', |
147 | | - 'fb:facepile', |
148 | | - 'fb:name', |
149 | | - 'fb:profile-pic', |
150 | | - 'fb:recommendations', |
151 | | - 'fb:serverfbml', |
152 | | - 'fb:share-button', |
153 | | - 'fb:social-bar', |
154 | | - /* |
155 | | - * From the Facebook Developer's Wiki under the old JS library. |
156 | | - * These may still be possible with a <fb:serverFbml> tag. |
157 | | - * <http://wiki.developers.facebook.com/index.php/XFBML> |
158 | | - */ |
159 | | - #'fb:connect-form', |
160 | | - #'fb:container', |
161 | | - #'fb:eventlink', |
162 | | - #'fb:grouplink', |
163 | | - #'fb:photo', |
164 | | - #'fb:prompt-permission', |
165 | | - #'fb:pronoun', |
166 | | - #'fb:unconnected-friends-count', |
167 | | - #'fb:user-status' |
168 | | - /* |
169 | | - * In 2008 I found these in the deprecated Facebook Connect |
170 | | - * JavaScript library, connect.js.pkg.php, though no documentation |
171 | | - * was available for them on the Facebook dev wiki. |
172 | | - */ |
173 | | - #'fb:add-section-button', |
174 | | - #'fb:share-button', |
175 | | - #'fb:userlink', |
176 | | - #'fb:video', |
| 137 | + $tags = array( |
| 138 | + 'fb:activity', |
| 139 | + 'fb:add-profile-tab', |
| 140 | + 'fb:bookmark', |
| 141 | + 'fb:comments', |
| 142 | + 'fb:connect-bar', |
| 143 | + 'fb:fan', |
| 144 | + 'fb:like', |
| 145 | + 'fb:like-box', |
| 146 | + 'fb:live-stream', |
| 147 | + 'fb:login', |
| 148 | + 'fb:login-button', |
| 149 | + 'fb:facepile', |
| 150 | + 'fb:name', |
| 151 | + 'fb:profile-pic', |
| 152 | + 'fb:recommendations', |
| 153 | + 'fb:serverfbml', |
| 154 | + 'fb:share-button', |
| 155 | + 'fb:social-bar', |
| 156 | + /* |
| 157 | + * From the Facebook Developer's Wiki under the old JS library. |
| 158 | + * These may still be possible with a <fb:serverFbml> tag. |
| 159 | + * <http://wiki.developers.facebook.com/index.php/XFBML> |
| 160 | + */ |
| 161 | + #'fb:connect-form', |
| 162 | + #'fb:container', |
| 163 | + #'fb:eventlink', |
| 164 | + #'fb:grouplink', |
| 165 | + #'fb:photo', |
| 166 | + #'fb:prompt-permission', |
| 167 | + #'fb:pronoun', |
| 168 | + #'fb:unconnected-friends-count', |
| 169 | + #'fb:user-status' |
| 170 | + /* |
| 171 | + * In 2008 I found these in the deprecated Facebook Connect |
| 172 | + * JavaScript library, connect.js.pkg.php, though no documentation |
| 173 | + * was available for them on the Facebook dev wiki. |
| 174 | + */ |
| 175 | + #'fb:add-section-button', |
| 176 | + #'fb:share-button', |
| 177 | + #'fb:userlink', |
| 178 | + #'fb:video', |
177 | 179 | ); |
178 | | - |
| 180 | + |
179 | 181 | // Reject discarded tags (that return an empty string) from Special:Version |
180 | 182 | $tempParser = new DummyParser(); |
181 | 183 | foreach( $tags as $i => $tag ) { |
182 | | - if ( self::parserHook('', array(), $tempParser, $tag) == '' ) { |
| 184 | + if ( self::parserHook( '', array(), $tempParser, $tag ) == '' ) { |
183 | 185 | unset( $tags[$i] ); |
184 | 186 | } |
185 | 187 | } |
186 | 188 | // Allow other functions to modify the available XFBML tags |
187 | | - wfRunHooks( 'XFBMLAvailableTags', array( &$tags )); |
| 189 | + wfRunHooks( 'XFBMLAvailableTags', array( &$tags ) ); |
188 | 190 | return $tags; |
189 | 191 | } |
190 | 192 | } |
— | — | @@ -191,7 +193,7 @@ |
192 | 194 | |
193 | 195 | /** |
194 | 196 | * Class DummyParser |
195 | | - * |
| 197 | + * |
196 | 198 | * Allows FBConnectXML::availableTags() to pre-sanatize the list of tags reported to |
197 | 199 | * MediaWiki, excluding any tags that result in the tag being replaced by an empty |
198 | 200 | * string. Sorry for the confusing summary here, its really late. =) |
Index: trunk/extensions/FBConnect/SpecialConnect.php |
— | — | @@ -1,32 +1,34 @@ |
2 | 2 | <?php |
3 | | -/* |
| 3 | +/** |
4 | 4 | * Copyright © 2008-2010 Garrett Brown <http://www.mediawiki.org/wiki/User:Gbruin> |
5 | 5 | * This program is free software; you can redistribute it and/or modify |
6 | 6 | * it under the terms of the GNU General Public License as published by |
7 | 7 | * the Free Software Foundation; either version 2 of the License, or |
8 | 8 | * (at your option) any later version. |
9 | | - * |
| 9 | + * |
10 | 10 | * This program is distributed in the hope that it will be useful, |
11 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | 13 | * GNU General Public License for more details. |
14 | | - * |
| 14 | + * |
15 | 15 | * You should have received a copy of the GNU General Public License along |
16 | 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | */ |
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Class SpecialConnect |
21 | | - * |
| 21 | + * |
22 | 22 | * This class represents the body class for the page Special:Connect. |
23 | | - * |
| 23 | + * |
24 | 24 | * Currently, this page has one valid subpage at Special:Connect/ChooseName. |
25 | 25 | * Visiting the subpage will generate an error; it is only useful when POSTed to. |
26 | 26 | */ |
27 | 27 | class SpecialConnect extends SpecialPage { |
28 | 28 | private $userNamePrefix; |
29 | | - static private $availableUserUpdateOptions = array('fullname', 'nickname', 'email', 'language', 'timecorrection'); |
30 | | - |
| 29 | + static private $availableUserUpdateOptions = array( |
| 30 | + 'fullname', 'nickname', 'email', 'language', 'timecorrection' |
| 31 | + ); |
| 32 | + |
31 | 33 | /** |
32 | 34 | * Constructor. |
33 | 35 | */ |
— | — | @@ -36,26 +38,26 @@ |
37 | 39 | parent::__construct( 'Connect' ); |
38 | 40 | // Add this special page to the "login" group of special pages |
39 | 41 | $wgSpecialPageGroups['Connect'] = 'login'; |
40 | | - |
| 42 | + |
41 | 43 | wfLoadExtensionMessages( 'FBConnect' ); |
42 | | - $this->userNamePrefix = wfMsg('fbconnect-usernameprefix'); |
| 44 | + $this->userNamePrefix = wfMsg( 'fbconnect-usernameprefix' ); |
43 | 45 | } |
44 | | - |
| 46 | + |
45 | 47 | /** |
46 | | - * Allows the prefix to be changed at runtime. This is useful, for example, |
47 | | - * to generate a username based off of a facebook name. |
| 48 | + * Allows the prefix to be changed at runtime. This is useful, for example, |
| 49 | + * to generate a username based off of a Facebook name. |
48 | 50 | */ |
49 | | - public function setUserNamePrefix( $prefix ){ |
| 51 | + public function setUserNamePrefix( $prefix ) { |
50 | 52 | $this->userNamePrefix = $prefix; |
51 | 53 | } |
52 | | - |
| 54 | + |
53 | 55 | /** |
54 | | - * Returns the list of user options that can be updated by facebook on each login. |
| 56 | + * Returns the list of user options that can be updated by Facebook on each login. |
55 | 57 | */ |
56 | | - public function getAvailableUserUpdateOptions(){ |
| 58 | + public function getAvailableUserUpdateOptions() { |
57 | 59 | return self::$availableUserUpdateOptions; |
58 | 60 | } |
59 | | - |
| 61 | + |
60 | 62 | /** |
61 | 63 | * Overrides getDescription() in SpecialPage. Looks in a different wiki message |
62 | 64 | * for this extension's description. |
— | — | @@ -63,72 +65,77 @@ |
64 | 66 | function getDescription() { |
65 | 67 | return wfMsg( 'fbconnect-title' ); |
66 | 68 | } |
67 | | - |
| 69 | + |
68 | 70 | /** |
69 | 71 | * Performs any necessary execution and outputs the resulting Special page. |
70 | 72 | */ |
71 | | - function execute( $par ) { |
| 73 | + public function execute( $par ) { |
72 | 74 | global $wgUser, $facebook, $wgRequest; |
73 | | - |
74 | | - if ( $wgRequest->getVal("action", "") == "disconnect" ) { |
75 | | - self::disconnectAction(); |
| 75 | + |
| 76 | + if ( $wgRequest->getVal( 'action', '' ) == 'disconnect' ) { |
| 77 | + self::disconnectAction(); |
76 | 78 | } |
77 | | - |
| 79 | + |
78 | 80 | // Check to see if the user is already logged in |
79 | 81 | if ( $wgUser->getID() ) { |
80 | | - $this->sendPage('alreadyLoggedIn'); |
| 82 | + $this->sendPage( 'alreadyLoggedIn' ); |
81 | 83 | return; |
82 | 84 | } |
83 | | - |
| 85 | + |
84 | 86 | $fbid = $facebook->getUser(); |
85 | 87 | /* |
86 | 88 | // Connect to the Facebook API |
87 | 89 | try { |
88 | | - $me = $facebook->api('/me'); |
89 | | - |
90 | | - } catch (FacebookApiException $e) { |
91 | | - error_log($e); |
| 90 | + $me = $facebook->api( '/me' ); |
| 91 | + |
| 92 | + } catch ( FacebookApiException $e ) { |
| 93 | + error_log( $e ); |
92 | 94 | } |
93 | 95 | */ |
94 | | - |
| 96 | + |
95 | 97 | // Look at the subpage name to discover where we are in the login process |
96 | 98 | switch ( $par ) { |
97 | 99 | case 'ChooseName': |
98 | | - $choice = $wgRequest->getText('wpNameChoice'); |
99 | | - if ($wgRequest->getCheck('wpCancel')) { |
100 | | - $this->sendError('fbconnect-cancel', 'fbconnect-canceltext'); |
101 | | - } |
102 | | - else switch ($choice) { |
| 100 | + $choice = $wgRequest->getText( 'wpNameChoice' ); |
| 101 | + if ( $wgRequest->getCheck( 'wpCancel' ) ) { |
| 102 | + $this->sendError( 'fbconnect-cancel', 'fbconnect-canceltext' ); |
| 103 | + } else |
| 104 | + switch ( $choice ) { |
103 | 105 | // Check to see if the user opted to connect an existing account |
104 | 106 | case 'existing': |
105 | | - $this->attachUser($fbid, $wgRequest->getText('wpExistingName'), |
106 | | - $wgRequest->getText('wpExistingPassword')); |
| 107 | + $this->attachUser( |
| 108 | + $fbid, |
| 109 | + $wgRequest->getText( 'wpExistingName' ), |
| 110 | + $wgRequest->getText( 'wpExistingPassword' ) |
| 111 | + ); |
107 | 112 | break; |
108 | 113 | // Check to see if the user selected another valid option |
109 | 114 | case 'nick': |
110 | 115 | case 'first': |
111 | 116 | case 'full': |
112 | 117 | // Get the username from Facebook (Note: not from the form) |
113 | | - $username = FBConnectUser::getOptionFromInfo($choice . 'name', |
114 | | - $facebook->getUserInfo()); |
| 118 | + $username = FBConnectUser::getOptionFromInfo( |
| 119 | + $choice . 'name', |
| 120 | + $facebook->getUserInfo() |
| 121 | + ); |
115 | 122 | case 'manual': |
116 | | - if (!isset($username) || !$this->userNameOK($username)) { |
| 123 | + if ( !isset( $username ) || !$this->userNameOK( $username ) ) { |
117 | 124 | // Use manual name if no username is set, even if manual wasn't chosen |
118 | | - $username = $wgRequest->getText('wpName2'); |
| 125 | + $username = $wgRequest->getText( 'wpName2' ); |
119 | 126 | } |
120 | 127 | // If no valid username was found, something's not right; ask again |
121 | | - if (!$this->userNameOK($username)) { |
122 | | - $this->sendPage('chooseNameForm', 'fbconnect-invalidname'); |
| 128 | + if ( !$this->userNameOK( $username ) ) { |
| 129 | + $this->sendPage( 'chooseNameForm', 'fbconnect-invalidname' ); |
123 | 130 | } else { |
124 | | - $this->createUser($fbid, $username); |
| 131 | + $this->createUser( $fbid, $username ); |
125 | 132 | } |
126 | 133 | break; |
127 | 134 | case 'auto': |
128 | 135 | // Create a user with a unique generated username |
129 | | - $this->createUser($fbid, $this->generateUserName()); |
| 136 | + $this->createUser( $fbid, $this->generateUserName() ); |
130 | 137 | break; |
131 | 138 | default: |
132 | | - $this->sendError('fbconnect-invalid', 'fbconnect-invalidtext'); |
| 139 | + $this->sendError( 'fbconnect-invalid', 'fbconnect-invalidtext' ); |
133 | 140 | } |
134 | 141 | break; |
135 | 142 | default: |
— | — | @@ -137,12 +144,12 @@ |
138 | 145 | # $this->setReturnTo( $wgRequest->getText( 'returnto' ), |
139 | 146 | # $wgRequest->getVal( 'returntoquery' ) ); |
140 | 147 | #} |
141 | | - if ($fbid) { |
| 148 | + if ( $fbid ) { |
142 | 149 | // If the user is connected, log them in |
143 | | - $this->login($fbid); |
| 150 | + $this->login( $fbid ); |
144 | 151 | } else { |
145 | 152 | // If the user isn't Connected, then show a form with the Connect button |
146 | | - $this->sendPage('connectForm'); |
| 153 | + $this->sendPage( 'connectForm' ); |
147 | 154 | } |
148 | 155 | } |
149 | 156 | } |
— | — | @@ -152,89 +159,89 @@ |
153 | 160 | * an account on the wiki, then they are presented with a form prompting |
154 | 161 | * them to choose a wiki username. |
155 | 162 | */ |
156 | | - protected function login($fb_id) { |
| 163 | + protected function login( $fb_id ) { |
157 | 164 | global $wgUser; |
158 | | - |
| 165 | + |
159 | 166 | // Check to see if the Connected user exists in the database |
160 | | - if ($fb_id) { |
161 | | - $user = FBConnectDB::getUser($fb_id); |
| 167 | + if ( $fb_id ) { |
| 168 | + $user = FBConnectDB::getUser( $fb_id ); |
162 | 169 | } |
163 | | - |
| 170 | + |
164 | 171 | // If the user doesn't exist yet locally, allow hooks to check to see if this is a clustered set up |
165 | | - if ( !(isset($user) && $user instanceof User ) && |
166 | | - !wfRunHooks('SpecialConnect::login::notFoundLocally', array(&$this, &$user, $fb_id))) { |
| 172 | + if ( !( isset( $user ) && $user instanceof User ) && |
| 173 | + !wfRunHooks( 'SpecialConnect::login::notFoundLocally', array( &$this, &$user, $fb_id ) ) ) { |
167 | 174 | return; |
168 | 175 | } |
169 | | - |
170 | | - if ( isset($user) && $user instanceof User ) { |
171 | | - $fbUser = new FBConnectUser($user); |
| 176 | + |
| 177 | + if ( isset( $user ) && $user instanceof User ) { |
| 178 | + $fbUser = new FBConnectUser( $user ); |
172 | 179 | // Update user from facebook (see class FBConnectUser) |
173 | 180 | $fbUser->updateFromFacebook(); |
174 | | - |
| 181 | + |
175 | 182 | // Setup the session |
176 | 183 | global $wgSessionStarted; |
177 | | - if (!$wgSessionStarted) { |
| 184 | + if ( !$wgSessionStarted ) { |
178 | 185 | wfSetupSession(); |
179 | 186 | } |
180 | | - |
| 187 | + |
181 | 188 | $user->setCookies(); |
182 | 189 | $wgUser = $user; |
183 | | - |
| 190 | + |
184 | 191 | // Similar to what's done in LoginForm::authenticateUserData(). |
185 | 192 | // Load $wgUser now. This is necessary because loading $wgUser (say |
186 | 193 | // by calling getName()) calls the UserLoadFromSession hook, which |
187 | 194 | // potentially creates the user in the local database. |
188 | 195 | $sessionUser = User::newFromSession(); |
189 | 196 | $sessionUser->load(); |
190 | | - |
191 | | - $this->sendPage('displaySuccessLogin'); |
192 | | - } else if ($fb_id) { |
193 | | - $this->sendPage('chooseNameForm'); |
| 197 | + |
| 198 | + $this->sendPage( 'displaySuccessLogin' ); |
| 199 | + } elseif ( $fb_id ) { |
| 200 | + $this->sendPage( 'chooseNameForm' ); |
194 | 201 | } else { |
195 | 202 | // TODO: send an error message saying only Connected users can log in |
196 | 203 | // or ask them to Connect. |
197 | | - $this->sendError('fbconnect-cancel', 'fbconnect-canceltext'); |
| 204 | + $this->sendError( 'fbconnect-cancel', 'fbconnect-canceltext' ); |
198 | 205 | } |
199 | 206 | } |
200 | 207 | |
201 | | - protected function createUser($fb_id, $name) { |
| 208 | + protected function createUser( $fb_id, $name ) { |
202 | 209 | global $wgUser, $wgOut, $wgFbConnectOnly, $wgAuth, $wgRequest, $wgMemc; |
203 | | - wfProfileIn(__METHOD__); |
204 | | - |
| 210 | + wfProfileIn( __METHOD__ ); |
| 211 | + |
205 | 212 | // Handle accidental reposts. |
206 | 213 | if ( $wgUser->isLoggedIn() ) { |
207 | | - $this->sendPage('displaySuccessLogin'); |
208 | | - wfProfileOut(__METHOD__); |
| 214 | + $this->sendPage( 'displaySuccessLogin' ); |
| 215 | + wfProfileOut( __METHOD__ ); |
209 | 216 | return; |
210 | 217 | } |
211 | | - |
| 218 | + |
212 | 219 | // Make sure we're not stealing an existing user account. |
213 | | - if (!$name || !$this->userNameOK($name)) { |
| 220 | + if ( !$name || !$this->userNameOK( $name ) ) { |
214 | 221 | // TODO: Provide an error message that explains that they need to pick a name or the name is taken. |
215 | | - wfDebug("FBConnect: Name not OK: '$name'\n"); |
216 | | - $this->sendPage('chooseNameForm'); |
| 222 | + wfDebug( "FBConnect: Name not OK: '$name'\n" ); |
| 223 | + $this->sendPage( 'chooseNameForm' ); |
217 | 224 | return; |
218 | 225 | } |
219 | | - |
| 226 | + |
220 | 227 | /// START OF TYPICAL VALIDATIONS AND RESTRICITONS ON ACCOUNT-CREATION. /// |
221 | | - |
| 228 | + |
222 | 229 | // Check the restrictions again to make sure that the user can create this account. |
223 | 230 | $titleObj = SpecialPage::getTitleFor( 'Connect' ); |
224 | 231 | if ( wfReadOnly() ) { |
225 | 232 | $wgOut->readOnlyPage(); |
226 | 233 | return; |
227 | | - } elseif ( !isset($wgFbConnectOnly) || !$wgFbConnectOnly ) { |
| 234 | + } elseif ( !isset( $wgFbConnectOnly ) || !$wgFbConnectOnly ) { |
228 | 235 | // These two permissions don't apply in $wgFbConnectOnly mode |
229 | 236 | if ( $wgUser->isBlockedFromCreateAccount() ) { |
230 | | - wfDebug("FBConnect: Blocked user was attempting to create account via Facebook Connect.\n"); |
231 | | - $wgOut->showErrorPage('fbconnect-error', 'fbconnect-errortext'); |
| 237 | + wfDebug( "FBConnect: Blocked user was attempting to create account via Facebook Connect.\n" ); |
| 238 | + $wgOut->showErrorPage( 'fbconnect-error', 'fbconnect-errortext' ); |
232 | 239 | return; |
233 | | - } elseif ( count( $permErrors = $titleObj->getUserPermissionsErrors( 'createaccount', $wgUser, true ) )>0 ) { |
| 240 | + } elseif ( count( $permErrors = $titleObj->getUserPermissionsErrors( 'createaccount', $wgUser, true ) ) > 0 ) { |
234 | 241 | $wgOut->showPermissionsErrorPage( $permErrors, 'createaccount' ); |
235 | 242 | return; |
236 | 243 | } |
237 | 244 | } |
238 | | - |
| 245 | + |
239 | 246 | // If we are not allowing users to login locally, we should be checking |
240 | 247 | // to see if the user is actually able to authenticate to the authenti- |
241 | 248 | // cation server before they create an account (otherwise, they can |
— | — | @@ -243,44 +250,44 @@ |
244 | 251 | $mDomain = $wgRequest->getText( 'wpDomain' ); |
245 | 252 | if( 'local' != $mDomain && '' != $mDomain ) { |
246 | 253 | if( !$wgAuth->canCreateAccounts() && ( !$wgAuth->userExists( $name ) ) ) { |
247 | | - $wgOut->showErrorPage('fbconnect-error', 'wrongpassword'); |
| 254 | + $wgOut->showErrorPage( 'fbconnect-error', 'wrongpassword' ); |
248 | 255 | return false; |
249 | 256 | } |
250 | 257 | } |
251 | | - |
| 258 | + |
252 | 259 | // IP-blocking (and open proxy blocking) protection from SpecialUserLogin |
253 | 260 | global $wgEnableSorbs, $wgProxyWhitelist; |
254 | 261 | $ip = wfGetIP(); |
255 | 262 | if ( $wgEnableSorbs && !in_array( $ip, $wgProxyWhitelist ) && |
256 | 263 | $wgUser->inSorbsBlacklist( $ip ) ) |
257 | 264 | { |
258 | | - $wgOut->showErrorPage('fbconnect-error', 'sorbs_create_account_reason'); |
| 265 | + $wgOut->showErrorPage( 'fbconnect-error', 'sorbs_create_account_reason' ); |
259 | 266 | return; |
260 | 267 | } |
261 | | - |
| 268 | + |
262 | 269 | /** |
263 | 270 | // Test to see if we are denied by $wgAuth or the user can't create an account |
264 | 271 | if ( !$wgAuth->autoCreate() || !$wgAuth->userExists( $userName ) || |
265 | | - !$wgAuth->authenticate( $userName )) { |
| 272 | + !$wgAuth->authenticate( $userName ) ) { |
266 | 273 | $result = false; |
267 | 274 | return true; |
268 | 275 | } |
269 | 276 | /**/ |
270 | | - |
| 277 | + |
271 | 278 | // Run a hook to let custom forms make sure that it is okay to proceed with processing the form. |
272 | 279 | // This hook should only check preconditions and should not store values. Values should be stored using the hook at the bottom of this function. |
273 | | - // Can use 'this' to call sendPage('chooseNameForm', 'SOME-ERROR-MSG-CODE-HERE') if some of the preconditions are invalid. |
274 | | - if(! wfRunHooks( 'SpecialConnect::createUser::validateForm', array( &$this ) )){ |
| 280 | + // Can use 'this' to call sendPage( 'chooseNameForm', 'SOME-ERROR-MSG-CODE-HERE' ) if some of the preconditions are invalid. |
| 281 | + if( !wfRunHooks( 'SpecialConnect::createUser::validateForm', array( &$this ) ) ) { |
275 | 282 | return; |
276 | 283 | } |
277 | 284 | |
278 | | - $user = User::newFromName($name); |
279 | | - if (!$user) { |
280 | | - wfDebug("FBConnect: Error creating new user.\n"); |
281 | | - $wgOut->showErrorPage('fbconnect-error', 'fbconnect-error-creating-user'); |
| 285 | + $user = User::newFromName( $name ); |
| 286 | + if ( !$user ) { |
| 287 | + wfDebug( "FBConnect: Error creating new user.\n" ); |
| 288 | + $wgOut->showErrorPage( 'fbconnect-error', 'fbconnect-error-creating-user' ); |
282 | 289 | return; |
283 | 290 | } |
284 | | - |
| 291 | + |
285 | 292 | // Let extensions abort the account creation. If you have extensions which are expecting a Real Name or Email, you may need to disable |
286 | 293 | // them since these are not requirements of Facebook Connect (so users will not have them). |
287 | 294 | // NOTE: Currently this is commented out because it seems that most wikis might have a handful of restrictions that won't be needed on |
— | — | @@ -290,11 +297,11 @@ |
291 | 298 | if( !wfRunHooks( 'AbortNewAccount', array( $user, &$abortError ) ) ) { |
292 | 299 | // Hook point to add extra creation throttles and blocks |
293 | 300 | wfDebug( "SpecialConnect::createUser: a hook blocked creation\n" ); |
294 | | - $wgOut->showErrorPage('fbconnect-error', 'fbconnect-error-user-creation-hook-aborted', array($abortError)); |
| 301 | + $wgOut->showErrorPage( 'fbconnect-error', 'fbconnect-error-user-creation-hook-aborted', array( $abortError ) ); |
295 | 302 | return false; |
296 | 303 | } |
297 | | - /**/ |
298 | | - |
| 304 | + */ |
| 305 | + |
299 | 306 | // Apply account-creation throttles |
300 | 307 | global $wgAccountCreationThrottle; |
301 | 308 | if ( $wgAccountCreationThrottle && $wgUser->isPingLimitable() ) { |
— | — | @@ -309,71 +316,71 @@ |
310 | 317 | } |
311 | 318 | $wgMemc->incr( $key ); |
312 | 319 | } |
313 | | - |
| 320 | + |
314 | 321 | /// END OF TYPICAL VALIDATIONS AND RESTRICITONS ON ACCOUNT-CREATION. /// |
315 | | - |
| 322 | + |
316 | 323 | // Create the account (locally on main cluster or via wgAuth on other clusters) |
317 | | - $email = $realName = ""; // The real values will get filled in outside of the scope of this function. |
| 324 | + $email = $realName = ''; // The real values will get filled in outside of the scope of this function. |
318 | 325 | $pass = null; |
319 | 326 | if( !$wgAuth->addUser( $user, $pass, $email, $realName ) ) { |
320 | | - wfDebug("FBConnect: Error adding new user to database.\n"); |
321 | | - $wgOut->showErrorPage('fbconnect-error', 'fbconnect-errortext'); |
| 327 | + wfDebug( "FBConnect: Error adding new user to database.\n" ); |
| 328 | + $wgOut->showErrorPage( 'fbconnect-error', 'fbconnect-errortext' ); |
322 | 329 | return; |
323 | 330 | } |
324 | | - |
| 331 | + |
325 | 332 | // Adds the user to the local database (regardless of whether wgAuth was used) |
326 | 333 | $user = $this->initUser( $user, true ); |
327 | | - |
| 334 | + |
328 | 335 | // Attach the user to their Facebook account in the database |
329 | 336 | // This must be done up here so that the data is in the database before copy-to-local is done for sharded setups |
330 | | - FBConnectDB::addFacebookID($user, $fb_id); |
331 | | - |
| 337 | + FBConnectDB::addFacebookID( $user, $fb_id ); |
| 338 | + |
332 | 339 | wfRunHooks( 'AddNewAccount', array( $user ) ); |
333 | | - |
| 340 | + |
334 | 341 | // Mark that the user is a Facebook user |
335 | | - $user->addGroup('fb-user'); |
336 | | - |
337 | | - // Store which fields should be auto-updated from Facebook when the user logs in. |
338 | | - $updateFormPrefix = "wpUpdateUserInfo"; |
339 | | - foreach (self::$availableUserUpdateOptions as $option) { |
340 | | - if($wgRequest->getVal($updateFormPrefix.$option, '') != ""){ |
341 | | - $user->setOption("fbconnect-update-on-login-$option", 1); |
| 342 | + $user->addGroup( 'fb-user' ); |
| 343 | + |
| 344 | + // Store which fields should be auto-updated from Facebook when the user logs in. |
| 345 | + $updateFormPrefix = 'wpUpdateUserInfo'; |
| 346 | + foreach ( self::$availableUserUpdateOptions as $option ) { |
| 347 | + if( $wgRequest->getVal( $updateFormPrefix . $option, '' ) != '' ) { |
| 348 | + $user->setOption( "fbconnect-update-on-login-$option", 1 ); |
342 | 349 | } else { |
343 | | - $user->setOption("fbconnect-update-on-login-$option", 0); |
| 350 | + $user->setOption( "fbconnect-update-on-login-$option", 0 ); |
344 | 351 | } |
345 | 352 | } |
346 | | - |
| 353 | + |
347 | 354 | // Process the FBConnectPushEvent preference checkboxes if fbConnectPushEvents are enabled. |
348 | 355 | global $wgFbEnablePushToFacebook; |
349 | | - if($wgFbEnablePushToFacebook){ |
| 356 | + if( $wgFbEnablePushToFacebook ) { |
350 | 357 | global $fbPushEventClasses; |
351 | | - if(!empty($fbPushEventClasses)){ |
352 | | - foreach($fbPushEventClasses as $pushEventClassName){ |
| 358 | + if( !empty( $fbPushEventClasses ) ) { |
| 359 | + foreach( $fbPushEventClasses as $pushEventClassName ) { |
353 | 360 | $pushObj = new $pushEventClassName; |
354 | 361 | $className = get_class(); |
355 | 362 | $prefName = $pushObj->getUserPreferenceName(); |
356 | | - |
357 | | - $user->setOption($prefName, ($wgRequest->getCheck($prefName)?"1":"0")); |
| 363 | + |
| 364 | + $user->setOption( $prefName, ( $wgRequest->getCheck( $prefName ) ? '1' : '0' ) ); |
358 | 365 | } |
359 | 366 | } |
360 | 367 | } |
361 | | - |
| 368 | + |
362 | 369 | // Unfortunately, performs a second database lookup |
363 | | - $fbUser = new FBConnectUser($user); |
| 370 | + $fbUser = new FBConnectUser( $user ); |
364 | 371 | // Update the user with settings from Facebook |
365 | 372 | $fbUser->updateFromFacebook(); |
366 | | - |
| 373 | + |
367 | 374 | // Start the session if it's not already been started |
368 | 375 | global $wgSessionStarted; |
369 | | - if (!$wgSessionStarted) { |
| 376 | + if ( !$wgSessionStarted ) { |
370 | 377 | wfSetupSession(); |
371 | 378 | } |
372 | | - |
| 379 | + |
373 | 380 | // Log the user in |
374 | 381 | $user->setCookies(); |
375 | 382 | // Store the new user as the global user object |
376 | 383 | $wgUser = $user; |
377 | | - |
| 384 | + |
378 | 385 | /* |
379 | 386 | * Similar to what's done in LoginForm::authenticateUserData(). Load |
380 | 387 | * $wgUser now. This is necessary because loading $wgUser (say by |
— | — | @@ -382,93 +389,93 @@ |
383 | 390 | */ |
384 | 391 | $sessionUser = User::newFromSession(); |
385 | 392 | $sessionUser->load(); |
386 | | - |
| 393 | + |
387 | 394 | // Allow custom form processing to store values since this form submission was successful. |
388 | 395 | // This hook should not fail on invalid input, instead check the input using the SpecialConnect::createUser::validateForm hook above. |
389 | 396 | wfRunHooks( 'SpecialConnect::createUser::postProcessForm', array( &$this ) ); |
390 | | - |
| 397 | + |
391 | 398 | // TODO: Which MediaWiki versions can we call this function in? |
392 | 399 | $user->addNewUserLogEntryAutoCreate(); |
393 | 400 | #$user->addNewUserLogEntry(); |
394 | | - |
395 | | - $this->sendPage('displaySuccessLogin'); |
396 | | - |
397 | | - wfProfileOut(__METHOD__); |
| 401 | + |
| 402 | + $this->sendPage( 'displaySuccessLogin' ); |
| 403 | + |
| 404 | + wfProfileOut( __METHOD__ ); |
398 | 405 | } |
399 | | - |
400 | | - /** |
401 | | - * Actually add a user to the database. |
402 | | - * Give it a User object that has been initialised with a name. |
403 | | - * |
404 | | - * This is a custom version of similar code in SpecialUserLogin's LoginForm with differences |
405 | | - * due to the fact that this code doesn't require a password, etc. |
406 | | - * |
407 | | - * @param $u User object. |
408 | | - * @param $autocreate boolean -- true if this is an autocreation via auth plugin |
409 | | - * @return User object. |
410 | | - * @private |
411 | | - */ |
| 406 | + |
| 407 | + /** |
| 408 | + * Actually add a user to the database. |
| 409 | + * Give it a User object that has been initialised with a name. |
| 410 | + * |
| 411 | + * This is a custom version of similar code in SpecialUserLogin's LoginForm with differences |
| 412 | + * due to the fact that this code doesn't require a password, etc. |
| 413 | + * |
| 414 | + * @param $u User object. |
| 415 | + * @param $autocreate boolean -- true if this is an autocreation via auth plugin |
| 416 | + * @return User object. |
| 417 | + * @private |
| 418 | + */ |
412 | 419 | protected function initUser( $u, $autocreate ) { |
413 | 420 | global $wgAuth; |
414 | | - |
| 421 | + |
415 | 422 | $u->addToDatabase(); |
416 | | - |
| 423 | + |
417 | 424 | // No passwords for FBConnect accounts. |
418 | 425 | /** |
419 | 426 | if ( $wgAuth->allowPasswordChange() ) { |
420 | | - $u->setPassword( $this->mPassword ); |
| 427 | + $u->setPassword( $this->mPassword ); |
421 | 428 | } |
422 | | - /** |
| 429 | + |
423 | 430 | $u->setEmail( $this->mEmail ); // emails aren't required by FBConnect extension (some customizations such as Wikia require it on their own). |
424 | 431 | $u->setRealName( $this->mRealName ); // real name isn't required for FBConnect |
425 | | - /**/ |
| 432 | + */ |
426 | 433 | $u->setToken(); |
427 | | - |
| 434 | + |
428 | 435 | $wgAuth->initUser( $u, $autocreate ); |
429 | | - $wgAuth->updateUser($u); |
430 | | - |
| 436 | + $wgAuth->updateUser( $u ); |
| 437 | + |
431 | 438 | //$u->setOption( 'rememberpassword', $this->mRemember ? 1 : 0 ); |
432 | | - $u->setOption('skinoverwrite', 1); |
| 439 | + $u->setOption( 'skinoverwrite', 1 ); |
433 | 440 | $u->saveSettings(); |
434 | | - |
| 441 | + |
435 | 442 | # Update user count |
436 | 443 | $ssUpdate = new SiteStatsUpdate( 0, 0, 0, 0, 1 ); |
437 | 444 | $ssUpdate->doUpdate(); |
438 | | - |
| 445 | + |
439 | 446 | return $u; |
440 | 447 | } |
441 | | - |
| 448 | + |
442 | 449 | /** |
443 | 450 | * Attaches the Facebook ID to an existing wiki account. If the user does |
444 | 451 | * not exist, or the supplied password does not match, then an error page |
445 | 452 | * is sent. Otherwise, the accounts are matched in the database and the new |
446 | 453 | * user object is logged in. |
447 | 454 | */ |
448 | | - protected function attachUser($fbid, $name, $password) { |
| 455 | + protected function attachUser( $fbid, $name, $password ) { |
449 | 456 | global $wgOut, $wgUser; |
450 | | - wfProfileIn(__METHOD__); |
| 457 | + wfProfileIn( __METHOD__ ); |
451 | 458 | |
452 | 459 | // The user must be logged into Facebook before choosing a wiki username |
453 | 460 | if ( !$fbid ) { |
454 | | - wfDebug("FBConnect: aborting in attachUser(): no Facebook ID was reported.\n"); |
| 461 | + wfDebug( "FBConnect: aborting in attachUser(): no Facebook ID was reported.\n" ); |
455 | 462 | $wgOut->showErrorPage( 'fbconnect-error', 'fbconnect-errortext' ); |
456 | 463 | return; |
457 | 464 | } |
458 | 465 | // Look up the user by their name |
459 | | - $user = new FBConnectUser(User::newFromName($name)); |
460 | | - if (!$user || !$user->checkPassword($password)) { |
461 | | - $this->sendPage('chooseNameForm', 'wrongpassword'); |
| 466 | + $user = new FBConnectUser( User::newFromName( $name ) ); |
| 467 | + if ( !$user || !$user->checkPassword( $password ) ) { |
| 468 | + $this->sendPage( 'chooseNameForm', 'wrongpassword' ); |
462 | 469 | return; |
463 | 470 | } |
464 | 471 | // Attach the user to their Facebook account in the database |
465 | | - FBConnectDB::addFacebookID($user, $fbid); |
| 472 | + FBConnectDB::addFacebookID( $user, $fbid ); |
466 | 473 | // Update the user with settings from Facebook |
467 | 474 | $user->updateFromFacebook(); |
468 | 475 | // Store the user in the global user object |
469 | 476 | $wgUser = $user; |
470 | | - $this->sendPage('displaySuccessLogin'); |
471 | | - |
472 | | - wfProfileOut(__METHOD__); |
| 477 | + $this->sendPage( 'displaySuccessLogin' ); |
| 478 | + |
| 479 | + wfProfileOut( __METHOD__ ); |
473 | 480 | } |
474 | 481 | |
475 | 482 | /** |
— | — | @@ -483,9 +490,9 @@ |
484 | 491 | // Because $i is incremented the first time through the while loop |
485 | 492 | $i = FBConnectDB::countUsers(); |
486 | 493 | #$i = 1; // This is the DUMB WAY to do this for large databases |
487 | | - while ($i < PHP_INT_MAX) { |
| 494 | + while ( $i < PHP_INT_MAX ) { |
488 | 495 | $name = $this->userNamePrefix . $i; |
489 | | - if ($this->userNameOK($name)) { |
| 496 | + if ( $this->userNameOK( $name ) ) { |
490 | 497 | return $name; |
491 | 498 | } |
492 | 499 | ++$i; |
— | — | @@ -496,20 +503,20 @@ |
497 | 504 | /** |
498 | 505 | * Tests whether the name is OK to use as a user name. |
499 | 506 | */ |
500 | | - public function userNameOK ($name) { |
| 507 | + public function userNameOK( $name ) { |
501 | 508 | global $wgReservedUsernames; |
502 | | - return ($name && (null == User::idFromName($name)) && !in_array($name, $wgReservedUsernames)); |
| 509 | + return ( $name && ( null == User::idFromName( $name ) ) && !in_array( $name, $wgReservedUsernames ) ); |
503 | 510 | } |
504 | 511 | |
505 | 512 | /** |
506 | 513 | * Displays a simple error page. |
507 | 514 | */ |
508 | | - protected function sendError($titleMsg, $textMsg) { |
| 515 | + protected function sendError( $titleMsg, $textMsg ) { |
509 | 516 | global $wgOut; |
510 | | - $wgOut->showErrorPage($titleMsg, $textMsg); |
| 517 | + $wgOut->showErrorPage( $titleMsg, $textMsg ); |
511 | 518 | } |
512 | | - |
513 | | - public function sendPage($function, $arg = NULL) { |
| 519 | + |
| 520 | + public function sendPage( $function, $arg = null ) { |
514 | 521 | global $wgOut; |
515 | 522 | // Setup the page for rendering |
516 | 523 | wfLoadExtensionMessages( 'FBConnect' ); |
— | — | @@ -518,21 +525,24 @@ |
519 | 526 | $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
520 | 527 | $wgOut->setArticleRelated( false ); |
521 | 528 | // Call the specified function to continue generating the page |
522 | | - if (is_null($arg)) { |
| 529 | + if ( is_null( $arg ) ) { |
523 | 530 | $this->$function(); |
524 | 531 | } else { |
525 | | - $this->$function($arg); |
| 532 | + $this->$function( $arg ); |
526 | 533 | } |
527 | 534 | } |
528 | | - |
| 535 | + |
529 | 536 | private function alreadyLoggedIn() { |
530 | 537 | global $wgOut, $wgUser, $wgRequest, $wgSitename; |
531 | | - $wgOut->setPageTitle(wfMsg('fbconnect-error')); |
532 | | - $wgOut->addWikiMsg('fbconnect-alreadyloggedin', $wgUser->getName()); |
533 | | - $wgOut->addWikiMsg('fbconnect-click-to-connect-existing', $wgSitename); |
534 | | - $wgOut->addHTML('<fb:login-button'.FBConnect::getPermissionsAttribute().FBConnect::getOnLoginAttribute().'></fb:login-button>'); |
| 538 | + $wgOut->setPageTitle( wfMsg( 'fbconnect-error' ) ); |
| 539 | + $wgOut->addWikiMsg( 'fbconnect-alreadyloggedin', $wgUser->getName() ); |
| 540 | + $wgOut->addWikiMsg( 'fbconnect-click-to-connect-existing', $wgSitename ); |
| 541 | + $wgOut->addHTML( |
| 542 | + '<fb:login-button' . FBConnect::getPermissionsAttribute() . |
| 543 | + FBConnect::getOnLoginAttribute() . '></fb:login-button>' |
| 544 | + ); |
535 | 545 | // Render the "Return to" text retrieved from the URL |
536 | | - $wgOut->returnToMain(false, $wgRequest->getText('returnto'), $wgRequest->getVal('returntoquery')); |
| 546 | + $wgOut->returnToMain( false, $wgRequest->getText( 'returnto' ), $wgRequest->getVal( 'returntoquery' ) ); |
537 | 547 | } |
538 | 548 | |
539 | 549 | private function displaySuccessLogin() { |
— | — | @@ -544,7 +554,7 @@ |
545 | 555 | wfRunHooks( 'UserLoginComplete', array( &$wgUser, &$inject_html ) ); |
546 | 556 | $wgOut->addHtml( $inject_html ); |
547 | 557 | // Render the "return to" text retrieved from the URL |
548 | | - $wgOut->returnToMain(false, $wgRequest->getText('returnto'), $wgRequest->getVal('returntoquery')); |
| 558 | + $wgOut->returnToMain( false, $wgRequest->getText( 'returnto' ), $wgRequest->getVal( 'returntoquery' ) ); |
549 | 559 | } |
550 | 560 | |
551 | 561 | /** |
— | — | @@ -556,7 +566,7 @@ |
557 | 567 | * NOTE: The above might be done now that we have checkboxes for which options |
558 | 568 | * to update from fb. Haven't tested it though. |
559 | 569 | */ |
560 | | - private function chooseNameForm($messagekey = 'fbconnect-chooseinstructions') { |
| 570 | + private function chooseNameForm( $messagekey = 'fbconnect-chooseinstructions' ) { |
561 | 571 | // Permissions restrictions. |
562 | 572 | global $wgUser, $facebook, $wgOut, $wgFbConnectOnly; |
563 | 573 | $titleObj = SpecialPage::getTitleFor( 'Connect' ); |
— | — | @@ -564,24 +574,23 @@ |
565 | 575 | // The wiki is in read-only mode |
566 | 576 | $wgOut->readOnlyPage(); |
567 | 577 | return; |
568 | | - } elseif ( !isset($wgFbConnectOnly) || !$wgFbConnectOnly ) { |
| 578 | + } elseif ( !isset( $wgFbConnectOnly ) || !$wgFbConnectOnly ) { |
569 | 579 | // These two permissions don't apply in $wgFbConnectOnly mode |
570 | 580 | if ( $wgUser->isBlockedFromCreateAccount() ) { |
571 | | - wfDebug("FBConnect: Blocked user was attempting to create account via Facebook Connect.\n"); |
572 | | - $wgOut->showErrorPage('fbconnect-error', 'fbconnect-errortext'); |
| 581 | + wfDebug( "FBConnect: Blocked user was attempting to create account via Facebook Connect.\n" ); |
| 582 | + $wgOut->showErrorPage( 'fbconnect-error', 'fbconnect-errortext' ); |
573 | 583 | return; |
574 | | - } elseif ( count( $permErrors = $titleObj->getUserPermissionsErrors( 'createaccount', $wgUser, true ) )>0 ) { |
| 584 | + } elseif ( count( $permErrors = $titleObj->getUserPermissionsErrors( 'createaccount', $wgUser, true ) ) > 0 ) { |
575 | 585 | $wgOut->showPermissionsErrorPage( $permErrors, 'createaccount' ); |
576 | 586 | return; |
577 | 587 | } |
578 | 588 | } |
579 | | - |
580 | 589 | |
581 | 590 | // Allow other code to have a custom form here (so that this extension can be integrated with existing custom login screens). |
582 | | - if( !wfRunHooks( 'SpecialConnect::chooseNameForm', array( &$this, &$messagekey ) ) ){ |
| 591 | + if( !wfRunHooks( 'SpecialConnect::chooseNameForm', array( &$this, &$messagekey ) ) ) { |
583 | 592 | return; |
584 | 593 | } |
585 | | - |
| 594 | + |
586 | 595 | // Connect to the Facebook API |
587 | 596 | $userinfo = $facebook->getUserInfo(); |
588 | 597 | |
— | — | @@ -592,68 +601,72 @@ |
593 | 602 | $this->outputHeader(); |
594 | 603 | // If a different $messagekey was passed (like 'wrongpassword'), use it instead |
595 | 604 | $wgOut->addWikiMsg( $messagekey ); |
596 | | - // TODO: Format the html a little nicer |
| 605 | + // TODO: Format the HTML a little nicer |
597 | 606 | $wgOut->addHTML(' |
598 | | - <form action="' . $this->getTitle('ChooseName')->getLocalUrl() . '" method="POST"> |
| 607 | + <form action="' . $this->getTitle( 'ChooseName' )->getLocalURL() . '" method="POST"> |
599 | 608 | <fieldset id="mw-fbconnect-choosename"> |
600 | | - <legend>' . wfMsg('fbconnect-chooselegend') . '</legend> |
601 | | - <table>'); |
| 609 | + <legend>' . wfMsg( 'fbconnect-chooselegend' ) . '</legend> |
| 610 | + <table>' |
| 611 | + ); |
602 | 612 | // Let them attach to an existing user if $wgFbConnectOnly allows it |
603 | | - if (!$wgFbConnectOnly) { |
| 613 | + if ( !$wgFbConnectOnly ) { |
604 | 614 | // Grab the UserName from the cookie if it exists |
605 | 615 | global $wgCookiePrefix; |
606 | | - $name = isset($_COOKIE[$wgCookiePrefix . 'UserName']) ? |
607 | | - trim($_COOKIE[$wgCookiePrefix . 'UserName']) : ''; |
| 616 | + $name = isset( $_COOKIE[$wgCookiePrefix . 'UserName'] ) ? |
| 617 | + trim( $_COOKIE[$wgCookiePrefix . 'UserName'] ) : ''; |
608 | 618 | // Build an array of attributes to update |
609 | 619 | $updateOptions = array(); |
610 | | - foreach (self::$availableUserUpdateOptions as $option) { |
| 620 | + foreach ( self::$availableUserUpdateOptions as $option ) { |
611 | 621 | // Translate the MW parameter into a FB parameter |
612 | | - $value = FBConnectUser::getOptionFromInfo($option, $userinfo); |
| 622 | + $value = FBConnectUser::getOptionFromInfo( $option, $userinfo ); |
613 | 623 | // If no corresponding value was received from Facebook, then continue |
614 | | - if (!$value) { |
| 624 | + if ( !$value ) { |
615 | 625 | continue; |
616 | 626 | } |
617 | 627 | // Build the list item for the update option |
618 | 628 | $updateOptions[] = "<li><input name=\"wpUpdateUserInfo$option\" type=\"checkbox\" " . |
619 | 629 | "value=\"1\" id=\"wpUpdateUserInfo$option\" /><label for=\"wpUpdateUserInfo$option\">" . |
620 | | - wfMsgHtml("fbconnect-$option") . wfMsgExt('colon-separator', array('escapenoentities')) . |
| 630 | + wfMsgHtml( "fbconnect-$option" ) . wfMsgExt( 'colon-separator', array( 'escapenoentities' ) ) . |
621 | 631 | " <i>$value</i></label></li>"; |
622 | 632 | } |
623 | 633 | // Implode the update options into an unordered list |
624 | | - $updateChoices = count($updateOptions) > 0 ? "<br />\n" . wfMsgHtml('fbconnect-updateuserinfo') . |
625 | | - "\n<ul>\n" . implode("\n", $updateOptions) . "\n</ul>\n" : ''; |
| 634 | + $updateChoices = count( $updateOptions ) > 0 ? "<br />\n" . wfMsgHtml( 'fbconnect-updateuserinfo' ) . |
| 635 | + "\n<ul>\n" . implode( "\n", $updateOptions ) . "\n</ul>\n" : ''; |
626 | 636 | // Create the HTML for the "existing account" option |
627 | 637 | $html = '<tr><td class="wm-label"><input name="wpNameChoice" type="radio" ' . |
628 | 638 | 'value="existing" id="wpNameChoiceExisting"/></td><td class="mw-input">' . |
629 | | - '<label for="wnNameChoiceExisting">' . wfMsg('fbconnect-chooseexisting') . '<br/>' . |
630 | | - wfMsgHtml('fbconnect-chooseusername') . '<input name="wpExistingName" size="16" value="' . |
631 | | - $name . '" id="wpExistingName"/>' . wfMsgHtml('fbconnect-choosepassword') . |
| 639 | + '<label for="wnNameChoiceExisting">' . wfMsg( 'fbconnect-chooseexisting' ) . '<br />' . |
| 640 | + wfMsgHtml( 'fbconnect-chooseusername' ) . '<input name="wpExistingName" size="16" value="' . |
| 641 | + $name . '" id="wpExistingName"/>' . wfMsgHtml( 'fbconnect-choosepassword' ) . |
632 | 642 | '<input name="wpExistingPassword" ' . 'size="" value="" type="password"/>' . $updateChoices . |
633 | 643 | '</td></tr>'; |
634 | | - $wgOut->addHTML($html); |
| 644 | + $wgOut->addHTML( $html ); |
635 | 645 | } |
636 | | - |
| 646 | + |
637 | 647 | // Add the options for nick name, first name and full name if we can get them |
638 | 648 | // TODO: Wikify the usernames (i.e. Full name should have an _ ) |
639 | | - foreach (array('nick', 'first', 'full') as $option) { |
640 | | - $nickname = FBConnectUser::getOptionFromInfo($option . 'name', $userinfo); |
641 | | - if ($nickname && $this->userNameOK($nickname)) { |
642 | | - $wgOut->addHTML('<tr><td class="mw-label"><input name="wpNameChoice" type="radio" value="' . |
643 | | - $option . ($checked ? '' : '" checked="checked') . '" id="wpNameChoice' . $option . |
| 649 | + foreach ( array( 'nick', 'first', 'full' ) as $option ) { |
| 650 | + $nickname = FBConnectUser::getOptionFromInfo( $option . 'name', $userinfo ); |
| 651 | + if ( $nickname && $this->userNameOK( $nickname ) ) { |
| 652 | + $wgOut->addHTML( |
| 653 | + '<tr><td class="mw-label"><input name="wpNameChoice" type="radio" value="' . |
| 654 | + $option . ( $checked ? '' : '" checked="checked' ) . '" id="wpNameChoice' . $option . |
644 | 655 | '"/></td><td class="mw-input"><label for="wpNameChoice' . $option . '">' . |
645 | | - wfMsg('fbconnect-choose' . $option, $nickname) . '</label></td></tr>'); |
| 656 | + wfMsg( 'fbconnect-choose' . $option, $nickname ) . '</label></td></tr>' |
| 657 | + ); |
646 | 658 | // When the first radio is checked, this flag is set and subsequent options aren't checked |
647 | 659 | $checked = true; |
648 | 660 | } |
649 | 661 | } |
650 | 662 | |
651 | 663 | // The options for auto and manual usernames are always available |
652 | | - $wgOut->addHTML('<tr><td class="mw-label"><input name="wpNameChoice" type="radio" value="auto" ' . |
653 | | - ($checked ? '' : 'checked="checked" ') . 'id="wpNameChoiceAuto"/></td><td class="mw-input">' . |
654 | | - '<label for="wpNameChoiceAuto">' . wfMsg('fbconnect-chooseauto', $this->generateUserName()) . |
| 664 | + $wgOut->addHTML( |
| 665 | + '<tr><td class="mw-label"><input name="wpNameChoice" type="radio" value="auto" ' . |
| 666 | + ( $checked ? '' : 'checked="checked" ' ) . 'id="wpNameChoiceAuto"/></td><td class="mw-input">' . |
| 667 | + '<label for="wpNameChoiceAuto">' . wfMsg( 'fbconnect-chooseauto', $this->generateUserName() ) . |
655 | 668 | '</label></td></tr><tr><td class="mw-label"><input name="wpNameChoice" type="radio" ' . |
656 | 669 | 'value="manual" id="wpNameChoiceManual"/></td><td class="mw-input"><label ' . |
657 | | - 'for="wpNameChoiceManual">' . wfMsg('fbconnect-choosemanual') . '</label> ' . |
| 670 | + 'for="wpNameChoiceManual">' . wfMsg( 'fbconnect-choosemanual' ) . '</label> ' . |
658 | 671 | '<input name="wpName2" size="16" value="" id="wpName2"/></td></tr>' . |
659 | 672 | // Finish with two options, "Log in" or "Cancel" |
660 | 673 | '<tr><td></td><td class="mw-submit"><input type="submit" value="Log in" name="wpOK"/>' . |
— | — | @@ -672,63 +685,68 @@ |
673 | 686 | $this->outputHeader(); |
674 | 687 | |
675 | 688 | // Render a humble Facebook Connect button |
676 | | - $wgOut->addHTML('<h2>' . wfMsg( 'fbconnect' ) . '</h2> |
677 | | - <div>'.wfMsgExt( 'fbconnect-intro', array('parse', 'content')) . '<br/>' . wfMsg( 'fbconnect-click-to-login', $wgSitename ) .' |
678 | | - <fb:login-button size="large" background="black" length="long"'.FBConnect::getPermissionsAttribute().FBConnect::getOnLoginAttribute().'></fb:login-button> |
| 689 | + $wgOut->addHTML( |
| 690 | + '<h2>' . wfMsg( 'fbconnect' ) . '</h2> |
| 691 | + <div>' . wfMsgExt( 'fbconnect-intro', array( 'parse', 'content' ) ) . |
| 692 | + '<br />' . wfMsg( 'fbconnect-click-to-login', $wgSitename ) . ' |
| 693 | + <fb:login-button size="large" background="black" length="long"' . |
| 694 | + FBConnect::getPermissionsAttribute() . FBConnect::getOnLoginAttribute() . |
| 695 | + '></fb:login-button> |
679 | 696 | </div>' |
680 | 697 | ); |
681 | 698 | } |
682 | | - |
683 | | - /** |
| 699 | + |
| 700 | + /** |
684 | 701 | * Disconnect from Facebook |
685 | | - */ |
| 702 | + */ |
686 | 703 | private function disconnectAction() { |
687 | 704 | global $wgRequest, $wgOut, $wgUser; |
688 | | - |
| 705 | + |
689 | 706 | if( $wgRequest->wasPosted() ) { |
690 | | - $id = FBConnectDB::getFacebookIDs($wgUser); |
691 | | - if( count($id) > 0 ) { |
| 707 | + $id = FBConnectDB::getFacebookIDs( $wgUser ); |
| 708 | + if( count( $id ) > 0 ) { |
692 | 709 | FBConnectDB::removeFacebookID( $wgUser, $id['user_fbid'] ); |
693 | 710 | } |
694 | 711 | } |
695 | | - |
| 712 | + |
696 | 713 | $title = SpecialPage::getTitleFor( 'Preferences' ); |
697 | | - $url = $title->getFullUrl("#prefsection-10"); |
698 | | - $wgOut->redirect($url); |
| 714 | + $url = $title->getFullURL( '#prefsection-10' ); |
| 715 | + $wgOut->redirect( $url ); |
699 | 716 | |
700 | 717 | return true; |
701 | 718 | } |
702 | | - |
| 719 | + |
703 | 720 | /** |
704 | 721 | * Creates a Login Form template object and propogates it with parameters. |
705 | 722 | * |
706 | 723 | private function createLoginForm() { |
707 | 724 | global $wgUser, $wgEnableEmail, $wgEmailConfirmToEdit, |
708 | 725 | $wgCookiePrefix, $wgCookieExpiration, $wgAuth; |
709 | | - |
| 726 | + |
710 | 727 | $template = new UserloginTemplate(); |
711 | | - |
| 728 | + |
712 | 729 | // Pull the name from $wgUser or cookies |
713 | | - if( $wgUser->isLoggedIn() ) |
| 730 | + if( $wgUser->isLoggedIn() ) { |
714 | 731 | $name = $wgUser->getName(); |
715 | | - else if( isset( $_COOKIE[$wgCookiePrefix . 'UserName'] )) |
| 732 | + } elseif( isset( $_COOKIE[$wgCookiePrefix . 'UserName'] ) ) { |
716 | 733 | $name = $_COOKIE[$wgCookiePrefix . 'UserName']; |
717 | | - else |
| 734 | + } else { |
718 | 735 | $name = null; |
| 736 | + } |
719 | 737 | // Alias some common URLs for $action and $link |
720 | 738 | $loginTitle = self::getTitleFor( 'Userlogin' ); |
721 | 739 | $this_href = wfUrlencode( $this->getTitle() ); |
722 | 740 | // Action URL that gets posted to |
723 | 741 | $action = $loginTitle->getLocalUrl('action=submitlogin&type=login&returnto=' . $this_href); |
724 | 742 | // Don't show a "create account" link if the user is not allowed to create an account |
725 | | - if ($wgUser->isAllowed( 'createaccount' )) { |
726 | | - $link_href = htmlspecialchars($loginTitle->getLocalUrl('type=signup&returnto=' . $this_href)); |
| 743 | + if ( $wgUser->isAllowed( 'createaccount' ) ) { |
| 744 | + $link_href = htmlspecialchars( $loginTitle->getLocalURL( 'type=signup&returnto=' . $this_href ) ); |
727 | 745 | $link_text = wfMsgHtml( 'nologinlink' ); |
728 | 746 | $link = wfMsgWikiHtml( 'nologin', "<a href=\"$link_href\">$link_text</a>" ); |
729 | 747 | } else { |
730 | 748 | $link = ''; |
731 | 749 | } |
732 | | - |
| 750 | + |
733 | 751 | // Set the appropriate options for this template |
734 | 752 | $template->set( 'header', '' ); |
735 | 753 | $template->set( 'name', $name ); |
— | — | @@ -746,11 +764,11 @@ |
747 | 765 | // Give authentication and captcha plugins a chance to modify the form |
748 | 766 | $type = 'login'; |
749 | 767 | $wgAuth->modifyUITemplate( $template, $type ); |
750 | | - wfRunHooks( 'UserLoginForm', array( &$template )); |
751 | | - |
752 | | - |
| 768 | + wfRunHooks( 'UserLoginForm', array( &$template ) ); |
| 769 | + |
| 770 | + |
753 | 771 | // Spit out the form we just made |
754 | 772 | return $template; |
755 | 773 | } |
756 | | - /**/ |
| 774 | + */ |
757 | 775 | } |
Index: trunk/extensions/FBConnect/FBConnectAPI.php |
— | — | @@ -5,12 +5,12 @@ |
6 | 6 | * it under the terms of the GNU General Public License as published by |
7 | 7 | * the Free Software Foundation; either version 2 of the License, or |
8 | 8 | * (at your option) any later version. |
9 | | - * |
| 9 | + * |
10 | 10 | * This program is distributed in the hope that it will be useful, |
11 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | 13 | * GNU General Public License for more details. |
14 | | - * |
| 14 | + * |
15 | 15 | * You should have received a copy of the GNU General Public License along |
16 | 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | */ |
— | — | @@ -26,9 +26,9 @@ |
27 | 27 | |
28 | 28 | /** |
29 | 29 | * Class FBConnectAPI |
30 | | - * |
| 30 | + * |
31 | 31 | * This class contains the code used to interface with Facebook via the |
32 | | - * Facebook Platform API. |
| 32 | + * Facebook Platform API. |
33 | 33 | */ |
34 | 34 | class FBConnectAPI extends Facebook { |
35 | 35 | // Constructor |
— | — | @@ -44,12 +44,12 @@ |
45 | 45 | 'cookie' => true, |
46 | 46 | ); |
47 | 47 | // Include the optional domain parameter if it has been set |
48 | | - if ( !empty($wgFbDomain) && $wgFbDomain != 'BASE_DOMAIN' ) { |
| 48 | + if ( !empty( $wgFbDomain ) && $wgFbDomain != 'BASE_DOMAIN' ) { |
49 | 49 | $config['domain'] = $wgFbDomain; |
50 | 50 | } |
51 | 51 | parent::__construct( $config ); |
52 | 52 | } |
53 | | - |
| 53 | + |
54 | 54 | /** |
55 | 55 | * Check to make sure config.sample.php was properly renamed to config.php |
56 | 56 | * and the instructions to fill out the first two important variables were |
— | — | @@ -57,23 +57,23 @@ |
58 | 58 | */ |
59 | 59 | public function isConfigSetup() { |
60 | 60 | global $wgFbAppId, $wgFbSecret; |
61 | | - $isSetup = isset($wgFbAppId) && $wgFbAppId != 'YOUR_APP_KEY' && |
62 | | - isset($wgFbSecret) && $wgFbSecret != 'YOUR_SECRET'; |
63 | | - if(!$isSetup) { |
| 61 | + $isSetup = isset( $wgFbAppId ) && $wgFbAppId != 'YOUR_APP_KEY' && |
| 62 | + isset( $wgFbSecret ) && $wgFbSecret != 'YOUR_SECRET'; |
| 63 | + if( !$isSetup ) { |
64 | 64 | // Check to see if they are still using the old variables |
65 | 65 | global $fbApiKey, $fbApiSecret; |
66 | | - if ( isset($fbApiKey) ) { |
| 66 | + if ( isset( $fbApiKey ) ) { |
67 | 67 | $wgFbAppId = $fbApiKey; |
68 | 68 | } |
69 | | - if ( isset($fbApiSecret) ) { |
| 69 | + if ( isset( $fbApiSecret ) ) { |
70 | 70 | $wgFbSecret= $fbApiSecret; |
71 | 71 | } |
72 | | - $isSetup = isset($wgFbAppId) && $wgFbAppId != 'YOUR_APP_KEY' && |
73 | | - isset($wgFbSecret) && $wgFbSecret != 'YOUR_SECRET'; |
| 72 | + $isSetup = isset( $wgFbAppId ) && $wgFbAppId != 'YOUR_APP_KEY' && |
| 73 | + isset( $wgFbSecret ) && $wgFbSecret != 'YOUR_SECRET'; |
74 | 74 | } |
75 | 75 | return $isSetup; |
76 | 76 | } |
77 | | - |
| 77 | + |
78 | 78 | /** |
79 | 79 | * Calls users.getInfo. Requests information about the user from Facebook. |
80 | 80 | */ |
— | — | @@ -86,117 +86,119 @@ |
87 | 87 | try { |
88 | 88 | // Cache information about users to reduce the number of Facebook hits |
89 | 89 | static $userinfo = array(); |
90 | | - |
91 | | - if ( !isset($userinfo[$user]) ) { |
| 90 | + |
| 91 | + if ( !isset( $userinfo[$user] ) ) { |
92 | 92 | // Query the Facebook API with the users.getInfo method |
93 | 93 | $query = array( |
94 | | - 'method' => 'users.getInfo', |
95 | | - 'uids' => $user, |
96 | | - 'fields' => join(',', array( |
97 | | - 'first_name', 'name', 'sex', 'timezone', 'locale', |
98 | | - /*'profile_url',*/ |
99 | | - 'username', 'proxied_email', 'contact_email', |
100 | | - )), |
| 94 | + 'method' => 'users.getInfo', |
| 95 | + 'uids' => $user, |
| 96 | + 'fields' => join( ',', array( |
| 97 | + 'first_name', 'name', 'sex', 'timezone', 'locale', |
| 98 | + /*'profile_url',*/ |
| 99 | + 'username', 'proxied_email', 'contact_email', |
| 100 | + )), |
101 | 101 | ); |
102 | 102 | $user_details = $this->api( $query ); |
103 | 103 | // Cache the data in the $userinfo array |
104 | 104 | $userinfo[$user] = $user_details[0]; |
105 | 105 | } |
106 | | - return isset($userinfo[$user]) ? $userinfo[$user] : null; |
107 | | - } catch (FacebookApiException $e) { |
| 106 | + return isset( $userinfo[$user] ) ? $userinfo[$user] : null; |
| 107 | + } catch ( FacebookApiException $e ) { |
108 | 108 | error_log( 'Failure in the api when requesting users.getInfo ' . |
109 | | - "on uid $user: " . $e->getMessage()); |
| 109 | + "on uid $user: " . $e->getMessage() ); |
110 | 110 | } |
111 | 111 | return null; |
112 | 112 | } |
113 | | - |
| 113 | + |
114 | 114 | /** |
115 | 115 | * Retrieves group membership data from Facebook. |
116 | 116 | */ |
117 | 117 | public function getGroupRights( $user = null ) { |
118 | 118 | global $wgFbUserRightsFromGroup; |
119 | | - |
| 119 | + |
120 | 120 | // Groupies can be members, officers or admins (the latter two infer the former) |
121 | | - $rights = array('member' => false, |
122 | | - 'officer' => false, |
123 | | - 'admin' => false); |
124 | | - |
125 | | - $gid = !empty($wgFbUserRightsFromGroup) ? $wgFbUserRightsFromGroup : false; |
126 | | - if (// If no group ID is specified, then there's no group to belong to |
| 121 | + $rights = array( |
| 122 | + 'member' => false, |
| 123 | + 'officer' => false, |
| 124 | + 'admin' => false |
| 125 | + ); |
| 126 | + |
| 127 | + $gid = !empty( $wgFbUserRightsFromGroup ) ? $wgFbUserRightsFromGroup : false; |
| 128 | + if ( // If no group ID is specified, then there's no group to belong to |
127 | 129 | !$gid || |
128 | 130 | // If $user wasn't specified, set it to the logged in user |
129 | 131 | !$user || |
130 | 132 | // If there is no logged in user |
131 | | - !($user = $this->getUser()) |
| 133 | + !( $user = $this->getUser() ) |
132 | 134 | ) { |
133 | 135 | return $rights; |
134 | 136 | } |
135 | | - |
| 137 | + |
136 | 138 | // If a User object was provided, translate it into a Facebook ID |
137 | | - if ($user instanceof User) { |
| 139 | + if ( $user instanceof User ) { |
138 | 140 | // TODO: Does this call for a special api call without access_token? |
139 | | - $users = FBConnectDB::getFacebookIDs($user); |
140 | | - if (count($users)) { |
| 141 | + $users = FBConnectDB::getFacebookIDs( $user ); |
| 142 | + if ( count( $users ) ) { |
141 | 143 | $user = $users[0]; |
142 | 144 | } else { |
143 | 145 | // Not a Connected user, can't be in a group |
144 | 146 | return $rights; |
145 | 147 | } |
146 | 148 | } |
147 | | - |
| 149 | + |
148 | 150 | // Cache the rights for an individual user to prevent hitting Facebook for duplicate info |
149 | 151 | static $rights_cache = array(); |
150 | | - if ( array_key_exists( $user, $rights_cache )) { |
| 152 | + if ( array_key_exists( $user, $rights_cache ) ) { |
151 | 153 | // Retrieve the rights from the cache |
152 | 154 | return $rights_cache[$user]; |
153 | 155 | } |
154 | | - |
| 156 | + |
155 | 157 | // This can contain up to 500 IDs, avoid requesting this info twice |
156 | 158 | static $members = false; |
157 | 159 | // Get a random 500 group members, along with officers, admins and not_replied's |
158 | | - if ($members === false) { |
| 160 | + if ( $members === false ) { |
159 | 161 | try { |
160 | 162 | // Check to make sure our session is still valid |
161 | | - $members = $this->api(array( |
162 | | - 'method' => 'groups.getMembers', |
163 | | - 'gid' => $gid |
| 163 | + $members = $this->api( array( |
| 164 | + 'method' => 'groups.getMembers', |
| 165 | + 'gid' => $gid |
164 | 166 | )); |
165 | | - } catch (FacebookApiException $e) { |
| 167 | + } catch ( FacebookApiException $e ) { |
166 | 168 | // Invalid session; we're not going to be able to get the rights |
167 | | - error_log($e); |
| 169 | + error_log( $e ); |
168 | 170 | $rights_cache[$user] = $rights; |
169 | 171 | return $rights; |
170 | 172 | } |
171 | 173 | } |
172 | | - |
| 174 | + |
173 | 175 | if ( $members ) { |
174 | 176 | // Check to see if the user is an officer |
175 | | - if (array_key_exists('officers', $members) && in_array($user, $members['officers'])) { |
| 177 | + if ( array_key_exists( 'officers', $members ) && in_array( $user, $members['officers'] ) ) { |
176 | 178 | $rights['member'] = $rights['officer'] = true; |
177 | 179 | } |
178 | 180 | // Check to see if the user is an admin of the group |
179 | | - if (array_key_exists('admins', $members) && in_array($user, $members['admins'])) { |
| 181 | + if ( array_key_exists( 'admins', $members ) && in_array( $user, $members['admins'] ) ) { |
180 | 182 | $rights['member'] = $rights['admin'] = true; |
181 | 183 | } |
182 | 184 | // Because the latter two rights infer the former, this step isn't always necessary |
183 | 185 | if( !$rights['member'] ) { |
184 | 186 | // Check to see if we are one of the (up to 500) random users |
185 | | - if ((array_key_exists('not_replied', $members) && is_array($members['not_replied']) && |
186 | | - in_array($user, $members['not_replied'])) || in_array($user, $members['members'])) { |
| 187 | + if ( ( array_key_exists( 'not_replied', $members ) && is_array( $members['not_replied'] ) && |
| 188 | + in_array( $user, $members['not_replied'] ) ) || in_array( $user, $members['members'] ) ) { |
187 | 189 | $rights['member'] = true; |
188 | 190 | } else { |
189 | 191 | // For groups of over 500ish, we must use this extra API call |
190 | 192 | // Notice that it occurs last, because we can hopefully avoid having to call it |
191 | 193 | try { |
192 | | - $group = $this->api(array( |
193 | | - 'method' => 'groups.get', |
194 | | - 'uid' => $user, |
195 | | - 'gids' => $gid |
| 194 | + $group = $this->api( array( |
| 195 | + 'method' => 'groups.get', |
| 196 | + 'uid' => $user, |
| 197 | + 'gids' => $gid |
196 | 198 | )); |
197 | | - } catch (FacebookApiException $e) { |
198 | | - error_log($e); |
| 199 | + } catch ( FacebookApiException $e ) { |
| 200 | + error_log( $e ); |
199 | 201 | } |
200 | | - if (is_array($group) && is_array($group[0]) && $group[0]['gid'] == "$gid") { |
| 202 | + if ( is_array( $group ) && is_array( $group[0] ) && $group[0]['gid'] == "$gid" ) { |
201 | 203 | $rights['member'] = true; |
202 | 204 | } |
203 | 205 | } |
— | — | @@ -206,11 +208,11 @@ |
207 | 209 | $rights_cache[$user] = $rights; |
208 | 210 | return $rights; |
209 | 211 | } |
210 | | - |
211 | | - /* |
| 212 | + |
| 213 | + /** |
212 | 214 | * Publish message on Facebook wall. |
213 | 215 | */ |
214 | | - public function publishStream($message, $link = "", $link_title ) { |
| 216 | + public function publishStream( $message, $link = '', $link_title ) { |
215 | 217 | /* |
216 | 218 | $attachment = array( |
217 | 219 | 'name' => $message, |
— | — | @@ -218,38 +220,38 @@ |
219 | 221 | 'caption' => $caption, |
220 | 222 | 'description' => $description |
221 | 223 | ); |
222 | | - |
223 | | - if( count($media) > 0 ) { |
| 224 | + |
| 225 | + if( count( $media ) > 0 ) { |
224 | 226 | foreach ( $media as $value ) { |
225 | | - $attachment[ 'media' ][] = $value; |
| 227 | + $attachment['media'][] = $value; |
226 | 228 | } |
227 | 229 | } |
228 | | - /**/ |
| 230 | + */ |
229 | 231 | // $api_error_descriptions |
230 | 232 | $attachment = array(); |
231 | | - |
| 233 | + |
232 | 234 | $query = array( |
233 | 235 | 'method' => 'stream.publish', |
234 | | - 'attachment' => json_encode($attachment), |
235 | | - 'action_links' => json_encode(array( |
| 236 | + 'attachment' => json_encode( $attachment ), |
| 237 | + 'action_links' => json_encode( array( |
236 | 238 | 'text' => $link_title, |
237 | 239 | 'href' => $link |
238 | 240 | )), |
239 | 241 | ); |
240 | | - |
| 242 | + |
241 | 243 | $result = json_decode( $this->api( $query ) ); |
242 | | - |
| 244 | + |
243 | 245 | if ( is_array( $result ) ) { |
244 | 246 | // Error |
245 | 247 | #error_log(FacebookAPIErrorCodes::$api_error_descriptions[$result]); |
246 | | - error_log("stream.publish returned error code $result->error_code"); |
| 248 | + error_log( "stream.publish returned error code $result->error_code" ); |
247 | 249 | return false; |
248 | | - } else if ( is_string( $result ) ) { |
| 250 | + } elseif ( is_string( $result ) ) { |
249 | 251 | // Success! Return value is "$UserId_$PostId" |
250 | 252 | return true; |
251 | 253 | } else { |
252 | | - error_log("stream.publish: Unknown return type: " . gettype($result)); |
| 254 | + error_log( 'stream.publish: Unknown return type: ' . gettype( $result ) ); |
253 | 255 | return false; |
254 | 256 | } |
255 | | - } |
| 257 | + } |
256 | 258 | } |
Index: trunk/extensions/FBConnect/FBConnectUser.php |
— | — | @@ -1,16 +1,16 @@ |
2 | 2 | <?php |
3 | | -/* |
| 3 | +/** |
4 | 4 | * Copyright © 2010 Garrett Brown <http://www.mediawiki.org/wiki/User:Gbruin> |
5 | 5 | * This program is free software; you can redistribute it and/or modify |
6 | 6 | * it under the terms of the GNU General Public License as published by |
7 | 7 | * the Free Software Foundation; either version 2 of the License, or |
8 | 8 | * (at your option) any later version. |
9 | | - * |
| 9 | + * |
10 | 10 | * This program is distributed in the hope that it will be useful, |
11 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | 13 | * GNU General Public License for more details. |
14 | | - * |
| 14 | + * |
15 | 15 | * You should have received a copy of the GNU General Public License along |
16 | 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | */ |
— | — | @@ -26,19 +26,19 @@ |
27 | 27 | |
28 | 28 | /** |
29 | 29 | * Class FBConnectUser |
30 | | - * |
| 30 | + * |
31 | 31 | * Extends the User class. |
32 | 32 | */ |
33 | 33 | class FBConnectUser extends User { |
34 | 34 | /** |
35 | 35 | * Constructor: Create this object from an existing User. Bonus points if |
36 | | - * the existing User was created form an ID and has not yet been loaded! |
| 36 | + * the existing User was created form an ID and has not yet been loaded! |
37 | 37 | */ |
38 | | - function __construct($user) { |
| 38 | + function __construct( $user ) { |
39 | 39 | $this->mId = $user->getId(); |
40 | 40 | $this->mFrom = 'id'; |
41 | 41 | } |
42 | | - |
| 42 | + |
43 | 43 | /** |
44 | 44 | * Update a user's settings with the values retrieved from the current |
45 | 45 | * logged-in Facebook user. Settings are only updated if a different value |
— | — | @@ -46,68 +46,72 @@ |
47 | 47 | * login. |
48 | 48 | */ |
49 | 49 | function updateFromFacebook() { |
50 | | - wfProfileIn(__METHOD__); |
| 50 | + wfProfileIn( __METHOD__ ); |
51 | 51 | global $facebook; |
52 | | - |
| 52 | + |
53 | 53 | // Keep track of whether any settings were modified |
54 | 54 | $mod = false; |
55 | | - // Connect to the Facebook API and retrieve the user's info |
| 55 | + // Connect to the Facebook API and retrieve the user's info |
56 | 56 | $userinfo = $facebook->getUserInfo(); |
57 | 57 | // Update the following options if the user's settings allow it |
58 | | - $updateOptions = array('nickname', 'fullname', 'language', |
59 | | - 'timecorrection', 'email'); |
60 | | - foreach ($updateOptions as $option) { |
| 58 | + $updateOptions = array( |
| 59 | + 'nickname', 'fullname', 'language', |
| 60 | + 'timecorrection', 'email' |
| 61 | + ); |
| 62 | + foreach ( $updateOptions as $option ) { |
61 | 63 | // Translate Facebook parameters into MediaWiki parameters |
62 | | - $value = self::getOptionFromInfo($option, $userinfo); |
63 | | - if ($value && ($this->getOption("fbconnect-update-on-login-$option", "0") == "1")) { |
64 | | - switch ($option) { |
| 64 | + $value = self::getOptionFromInfo( $option, $userinfo ); |
| 65 | + if ( $value && ( $this->getOption( "fbconnect-update-on-login-$option", '0' ) == '1' ) ) { |
| 66 | + switch ( $option ) { |
65 | 67 | case 'fullname': |
66 | | - $this->setRealName($value); |
| 68 | + $this->setRealName( $value ); |
67 | 69 | break; |
68 | 70 | default: |
69 | | - $this->setOption($option, $value); |
| 71 | + $this->setOption( $option, $value ); |
70 | 72 | } |
71 | 73 | $mod = true; |
72 | 74 | } |
73 | 75 | } |
74 | 76 | // Only save the updated settings if something was changed |
75 | | - if ($mod) { |
| 77 | + if ( $mod ) { |
76 | 78 | $this->saveSettings(); |
77 | 79 | } |
78 | | - |
79 | | - wfProfileOut(__METHOD__); |
| 80 | + |
| 81 | + wfProfileOut( __METHOD__ ); |
80 | 82 | } |
81 | | - |
| 83 | + |
82 | 84 | /** |
83 | 85 | * Helper function for updateFromFacebook(). Takes an array of info from |
84 | 86 | * Facebook, and looks up the corresponding MediaWiki parameter. |
85 | 87 | */ |
86 | | - static function getOptionFromInfo($option, $userinfo) { |
| 88 | + static function getOptionFromInfo( $option, $userinfo ) { |
87 | 89 | // Lookup table for the names of the settings |
88 | | - $params = array('nickname' => 'username', |
89 | | - 'fullname' => 'name', |
90 | | - 'firstname' => 'first_name', |
91 | | - 'gender' => 'sex', |
92 | | - 'language' => 'locale', |
93 | | - 'timecorrection' => 'timezone', |
94 | | - 'email' => 'contact_email'); |
95 | | - if (empty($userinfo)) { |
| 90 | + $params = array( |
| 91 | + 'nickname' => 'username', |
| 92 | + 'fullname' => 'name', |
| 93 | + 'firstname' => 'first_name', |
| 94 | + 'gender' => 'sex', |
| 95 | + 'language' => 'locale', |
| 96 | + 'timecorrection' => 'timezone', |
| 97 | + 'email' => 'contact_email' |
| 98 | + ); |
| 99 | + if ( empty( $userinfo ) ) { |
96 | 100 | return null; |
97 | 101 | } |
98 | | - $value = array_key_exists($params[$option], $userinfo) ? $userinfo[$params[$option]] : ''; |
| 102 | + $value = array_key_exists( $params[$option], $userinfo ) ? $userinfo[$params[$option]] : ''; |
99 | 103 | // Special handling of several settings |
100 | | - switch ($option) { |
| 104 | + switch ( $option ) { |
101 | 105 | case 'fullname': |
102 | 106 | case 'firstname': |
103 | 107 | // If real names aren't allowed, then simply ignore the parameter from Facebook |
104 | 108 | global $wgAllowRealName; |
105 | | - if (!$wgAllowRealName) { |
| 109 | + if ( !$wgAllowRealName ) { |
106 | 110 | $value = ''; |
107 | 111 | } |
108 | 112 | break; |
109 | 113 | case 'gender': |
110 | 114 | // Unfortunately, Facebook genders are localized (but this might change) |
111 | | - if ($value != 'male' || $value != 'female') { |
| 115 | + if ( $value != 'male' || $value != 'female' ) { |
112 | 116 | $value = ''; |
113 | 117 | } |
114 | 118 | break; |
— | — | @@ -119,25 +123,27 @@ |
120 | 124 | * For an up-to-date list of MediaWiki languages, see: |
121 | 125 | * <http://svn.wikimedia.org/svnroot/mediawiki/trunk/phase3/languages/Names.php>. |
122 | 126 | */ |
123 | | - if ($value == '') { |
| 127 | + if ( $value == '' ) { |
124 | 128 | break; |
125 | 129 | } |
126 | 130 | // These regional languages get special treatment |
127 | | - $locales = array('en_PI' => 'en', # Pirate English |
128 | | - 'en_GB' => 'en-gb', # British English |
129 | | - 'en_UD' => 'en', # Upside Down English |
130 | | - 'fr_CA' => 'fr', # Canadian French |
131 | | - 'fb_LT' => 'en', # Leet Speak |
132 | | - 'pt_BR' => 'pt-br', # Brazilian Portuguese |
133 | | - 'zh_CN' => 'zh-cn', # Simplified Chinese |
134 | | - 'es_ES' => 'es', # European Spanish |
135 | | - 'zh_HK' => 'zh-hk', # Traditional Chinese (Hong Kong) |
136 | | - 'zh_TW' => 'zh-tw'); # Traditional Chinese (Taiwan) |
137 | | - if (array_key_exists($value, $locales)) { |
| 131 | + $locales = array( |
| 132 | + 'en_PI' => 'en', # Pirate English |
| 133 | + 'en_GB' => 'en-gb', # British English |
| 134 | + 'en_UD' => 'en', # Upside Down English |
| 135 | + 'fr_CA' => 'fr', # Canadian French |
| 136 | + 'fb_LT' => 'en', # Leet Speak |
| 137 | + 'pt_BR' => 'pt-br', # Brazilian Portuguese |
| 138 | + 'zh_CN' => 'zh-cn', # Simplified Chinese |
| 139 | + 'es_ES' => 'es', # European Spanish |
| 140 | + 'zh_HK' => 'zh-hk', # Traditional Chinese (Hong Kong) |
| 141 | + 'zh_TW' => 'zh-tw' # Traditional Chinese (Taiwan) |
| 142 | + ); |
| 143 | + if ( array_key_exists( $value, $locales ) ) { |
138 | 144 | $value = $locales[$value]; |
139 | 145 | } else { |
140 | 146 | // No special regional treatment exists in MW; chop it off |
141 | | - $value = substr($value, 0, 2); |
| 147 | + $value = substr( $value, 0, 2 ); |
142 | 148 | } |
143 | 149 | break; |
144 | 150 | case 'timecorrection': |
— | — | @@ -147,7 +153,7 @@ |
148 | 154 | break; |
149 | 155 | case 'email': |
150 | 156 | // If a contact email isn't available, then use a proxied email |
151 | | - if ($value == '') { |
| 157 | + if ( $value == '' ) { |
152 | 158 | // TODO: update the user's email from $userinfo['proxied_email'] |
153 | 159 | // instead (the address must stay hidden from the user) |
154 | 160 | $value = ''; |
Index: trunk/extensions/FBConnect/FBConnect.php |
— | — | @@ -5,12 +5,12 @@ |
6 | 6 | * it under the terms of the GNU General Public License as published by |
7 | 7 | * the Free Software Foundation; either version 2 of the License, or |
8 | 8 | * (at your option) any later version. |
9 | | - * |
| 9 | + * |
10 | 10 | * This program is distributed in the hope that it will be useful, |
11 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | 13 | * GNU General Public License for more details. |
14 | | - * |
| 14 | + * |
15 | 15 | * You should have received a copy of the GNU General Public License along |
16 | 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | */ |
— | — | @@ -23,21 +23,21 @@ |
24 | 24 | * Info is available at http://www.mediawiki.org/wiki/Extension:FBConnect |
25 | 25 | * and at http://wiki.developers.facebook.com/index.php/MediaWiki |
26 | 26 | * |
27 | | - * Limited support is available at http://www.mediawiki.org/wiki/Extension_talk:FBConnect |
| 27 | + * Limited support is available at http://www.mediawiki.org/wiki/Extension_talk:FBConnect |
28 | 28 | * and at http://wiki.developers.facebook.com/index.php/Talk:MediaWiki |
29 | 29 | * |
30 | 30 | * @file |
| 31 | + * @ingroup Extensions |
31 | 32 | * @author Garrett Bruin |
32 | 33 | * @copyright Copyright © 2008 Garrett Brown |
33 | 34 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
34 | | - * @ingroup Extensions |
35 | 35 | */ |
36 | 36 | |
37 | 37 | |
38 | 38 | /* |
39 | 39 | * Not a valid entry point, skip unless MEDIAWIKI is defined. |
40 | 40 | */ |
41 | | -if ( !defined( 'MEDIAWIKI' )) { |
| 41 | +if ( !defined( 'MEDIAWIKI' ) ) { |
42 | 42 | die( 'This file is a MediaWiki extension, it is not a valid entry point' ); |
43 | 43 | } |
44 | 44 | |
— | — | @@ -61,16 +61,16 @@ |
62 | 62 | /* |
63 | 63 | * Initialization of the autoloaders and special extension pages. |
64 | 64 | */ |
65 | | -$dir = dirname(__FILE__) . '/'; |
| 65 | +$dir = dirname( __FILE__ ) . '/'; |
66 | 66 | require_once $dir . 'config.default.php'; |
67 | 67 | require_once $dir . 'php-sdk/facebook.php'; |
68 | | -if (!empty( $wgFbIncludePreferencesExtension ) && version_compare($wgVersion, '1.16', '<')) { |
| 68 | +if ( !empty( $wgFbIncludePreferencesExtension ) && version_compare( $wgVersion, '1.16', '<' ) ) { |
69 | 69 | require_once $dir . 'PreferencesExtension.php'; |
70 | 70 | } |
71 | 71 | |
72 | 72 | $wgExtensionFunctions[] = 'FBConnect::init'; |
73 | 73 | |
74 | | -if( !empty( $wgFbEnablePushToFacebook ) ){ |
| 74 | +if( !empty( $wgFbEnablePushToFacebook ) ) { |
75 | 75 | // Need to include it explicitly instead of autoload since it has initialization code of its own. |
76 | 76 | // This should be done after FBConnect::init is added to wgExtensionFunctions so that FBConnect |
77 | 77 | // gets fully initialized first. |
— | — | @@ -98,7 +98,7 @@ |
99 | 99 | $wgGroupPermissions['fb-user'] = $wgGroupPermissions['user']; |
100 | 100 | |
101 | 101 | // If we are configured to pull group info from Facebook, then create the group permissions |
102 | | -if ($wgFbUserRightsFromGroup) { |
| 102 | +if ( $wgFbUserRightsFromGroup ) { |
103 | 103 | $wgGroupPermissions['fb-groupie'] = $wgGroupPermissions['user']; |
104 | 104 | $wgGroupPermissions['fb-officer'] = $wgGroupPermissions['bureaucrat']; |
105 | 105 | $wgGroupPermissions['fb-admin'] = $wgGroupPermissions['sysop']; |
— | — | @@ -119,7 +119,7 @@ |
120 | 120 | |
121 | 121 | /** |
122 | 122 | * Class FBConnect |
123 | | - * |
| 123 | + * |
124 | 124 | * This class initializes the extension, and contains the core non-hook, |
125 | 125 | * non-authentification code. |
126 | 126 | */ |
— | — | @@ -132,27 +132,27 @@ |
133 | 133 | public static function init() { |
134 | 134 | global $wgXhtmlNamespaces, $wgSharedTables, $facebook, $wgHooks; |
135 | 135 | global $wgFbOnLoginJsOverride; |
136 | | - |
| 136 | + |
137 | 137 | // The xmlns:fb attribute is required for proper rendering on IE |
138 | 138 | $wgXhtmlNamespaces['fb'] = 'http://www.facebook.com/2008/fbml'; |
139 | | - |
| 139 | + |
140 | 140 | // Facebook/username associations should be shared when $wgSharedDB is enabled |
141 | 141 | $wgSharedTables[] = 'user_fbconnect'; |
142 | | - |
| 142 | + |
143 | 143 | // Create our Facebook instance and make it available through $facebook |
144 | 144 | $facebook = new FBConnectAPI(); |
145 | | - |
| 145 | + |
146 | 146 | // Install all public static functions in class FBConnectHooks as MediaWiki hooks |
147 | | - $hooks = self::enumMethods('FBConnectHooks'); |
| 147 | + $hooks = self::enumMethods( 'FBConnectHooks' ); |
148 | 148 | foreach( $hooks as $hookName ) { |
149 | 149 | $wgHooks[$hookName][] = "FBConnectHooks::$hookName"; |
150 | 150 | } |
151 | 151 | |
152 | 152 | // Allow configurable over-riding of the onLogin handler. |
153 | | - if(!empty($wgFbOnLoginJsOverride)){ |
| 153 | + if( !empty( $wgFbOnLoginJsOverride ) ) { |
154 | 154 | self::$fbOnLoginJs = $wgFbOnLoginJsOverride; |
155 | 155 | } else { |
156 | | - self::$fbOnLoginJs = "window.location.reload(true);"; |
| 156 | + self::$fbOnLoginJs = 'window.location.reload(true);'; |
157 | 157 | } |
158 | 158 | } |
159 | 159 | |
— | — | @@ -173,35 +173,37 @@ |
174 | 174 | // If PHP's version doesn't support the Reflection API, then exit |
175 | 175 | die( 'PHP version (' . phpversion() . ') must be great enough to support the Reflection API' ); |
176 | 176 | // Or list the extensions here manually... |
177 | | - $hooks = array('AuthPluginSetup', 'UserLoadFromSession', |
178 | | - 'RenderPreferencesForm', 'PersonalUrls', |
179 | | - 'ParserAfterTidy', 'BeforePageDisplay', /*...*/ ); |
| 177 | + $hooks = array( |
| 178 | + 'AuthPluginSetup', 'UserLoadFromSession', |
| 179 | + 'RenderPreferencesForm', 'PersonalUrls', |
| 180 | + 'ParserAfterTidy', 'BeforePageDisplay', /*...*/ |
| 181 | + ); |
180 | 182 | } |
181 | 183 | return $hooks; |
182 | 184 | } |
183 | | - |
| 185 | + |
184 | 186 | /** |
185 | 187 | * Return the code for the permissions attribute (with leading space) to use on all fb:login-buttons. |
186 | 188 | */ |
187 | | - public static function getPermissionsAttribute(){ |
| 189 | + public static function getPermissionsAttribute() { |
188 | 190 | global $wgFbExtendedPermissions; |
189 | | - $attr = ""; |
190 | | - if(!empty($wgFbExtendedPermissions)){ |
191 | | - $attr = " perms=\"".implode(",", $wgFbExtendedPermissions)."\""; |
| 191 | + $attr = ''; |
| 192 | + if( !empty( $wgFbExtendedPermissions ) ) { |
| 193 | + $attr = ' perms="' . implode( ',', $wgFbExtendedPermissions ) . '"'; |
192 | 194 | } |
193 | 195 | return $attr; |
194 | 196 | } // end getPermissionsAttribute() |
195 | | - |
| 197 | + |
196 | 198 | /** |
197 | 199 | * Return the code for the onlogin attribute which should be appended to all fb:login-button's in this |
198 | 200 | * extension. |
199 | 201 | * |
200 | 202 | * TODO: Generate the entire fb:login-button in a function in this class. We have numerous buttons now. |
201 | 203 | */ |
202 | | - public static function getOnLoginAttribute(){ |
203 | | - $attr = ""; |
204 | | - if(!empty(self::$fbOnLoginJs)){ |
205 | | - $attr = " onlogin=\"".self::$fbOnLoginJs."\""; |
| 204 | + public static function getOnLoginAttribute() { |
| 205 | + $attr = ''; |
| 206 | + if( !empty( self::$fbOnLoginJs ) ) { |
| 207 | + $attr = ' onlogin="' . self::$fbOnLoginJs . '"'; |
206 | 208 | } |
207 | 209 | return $attr; |
208 | 210 | } // end getOnLoginAttribute() |
Index: trunk/extensions/FBConnect/fbconnect.css |
— | — | @@ -65,7 +65,7 @@ |
66 | 66 | padding: 1px 5px; |
67 | 67 | } |
68 | 68 | |
69 | | -.box_left #specialconnect_box h1, .box_left #specialconnect_box .box_content { |
| 69 | +.box_left #specialconnect_box h1, .box_left #specialconnect_box .box_content { |
70 | 70 | padding-right: 120px; |
71 | 71 | } |
72 | 72 | |
Index: trunk/extensions/FBConnect/FBConnectPushEvent.php |
— | — | @@ -18,13 +18,13 @@ |
19 | 19 | protected $isAllowedUserPreferenceName = ''; // implementing classes MUST override this with their own value. |
20 | 20 | |
21 | 21 | // This must correspond to the name of the message for the text on the tab itself. |
22 | | - static protected $PREFERENCES_TAB_NAME = "fbconnect-prefstext"; |
| 22 | + static protected $PREFERENCES_TAB_NAME = 'fbconnect-prefstext'; |
23 | 23 | |
24 | 24 | /** |
25 | 25 | * Accessor for the user preference to which (if set to 1) allows this type of event |
26 | 26 | * to be used. |
27 | 27 | */ |
28 | | - public function getUserPreferenceName(){ |
| 28 | + public function getUserPreferenceName() { |
29 | 29 | return $this->isAllowedUserPreferenceName; |
30 | 30 | } |
31 | 31 | |
— | — | @@ -32,44 +32,48 @@ |
33 | 33 | * Initialize the extension itself. This includes creating the user-preferences for |
34 | 34 | * the push events. |
35 | 35 | */ |
36 | | - static public function initExtension(){ |
37 | | - wfProfileIn(__METHOD__); |
| 36 | + static public function initExtension() { |
| 37 | + wfProfileIn( __METHOD__ ); |
38 | 38 | |
39 | 39 | // The push feature of the extension requires the publish_stream extended permission. |
40 | 40 | global $wgFbExtendedPermissions; |
41 | 41 | $PERMISSION_TO_PUBLISH = 'publish_stream'; |
42 | | - if(empty($wgFbExtendedPermissions) || !is_array($wgFbExtendedPermissions)){ |
43 | | - $wgFbExtendedPermissions = array($PERMISSION_TO_PUBLISH); |
44 | | - } else if(!in_array($PERMISSION_TO_PUBLISH, $wgFbExtendedPermissions)){ |
| 42 | + if( empty( $wgFbExtendedPermissions ) || !is_array( $wgFbExtendedPermissions ) ) { |
| 43 | + $wgFbExtendedPermissions = array( $PERMISSION_TO_PUBLISH); |
| 44 | + } elseif( !in_array( $PERMISSION_TO_PUBLISH, $wgFbExtendedPermissions ) ) { |
45 | 45 | $wgFbExtendedPermissions[] = $PERMISSION_TO_PUBLISH; |
46 | 46 | } |
47 | 47 | |
48 | 48 | // Make sure that all of the push events were configured correctly. |
49 | 49 | self::initAll(); |
50 | 50 | |
51 | | - // TODO: This initialization should only be run if the user is fb-connected. Otherwise, the same Connect form as Special:Connect should be shown. |
52 | | - |
53 | | - // TODO: Can we detect if this is Special:Preferences and only add the checkboxes if that is the case? Can't think of anything else that would break. |
54 | | - |
55 | | - wfProfileOut(__METHOD__); |
| 51 | + // TODO: This initialization should only be run if the user is fb-connected. |
| 52 | + // Otherwise, the same Connect form as Special:Connect should be shown. |
| 53 | + |
| 54 | + // TODO: Can we detect if this is Special:Preferences and only add the checkboxes if that is the case? |
| 55 | + // Can't think of anything else that would break. |
| 56 | + |
| 57 | + wfProfileOut( __METHOD__ ); |
56 | 58 | } // end initExtension() |
57 | 59 | |
58 | 60 | /** |
59 | 61 | * Adds enable/disable toggles to the Preferences form for controlling all push events. |
60 | 62 | * |
| 63 | + * @param $user Object: User object |
| 64 | + * @param $preferences Object: Preferences object |
61 | 65 | */ |
62 | | - static public function addPreferencesToggles( $user, &$preferences ){ |
| 66 | + static public function addPreferencesToggles( $user, &$preferences ) { |
63 | 67 | global $fbPushEventClasses; |
64 | | - |
| 68 | + |
65 | 69 | // TODO: PREF_TOGGLE_T is not defined in v1.16 |
66 | | - /** |
67 | | - if( !defined('PREF_TOGGLE_T') ) { |
| 70 | + /* |
| 71 | + if( !defined( 'PREF_TOGGLE_T' ) ) { |
68 | 72 | return true; |
69 | 73 | } |
70 | | - /**/ |
71 | | - |
72 | | - if( !empty($fbPushEventClasses) ){ |
73 | | - foreach($fbPushEventClasses as $pushEventClassName){ |
| 74 | + */ |
| 75 | + |
| 76 | + if( !empty( $fbPushEventClasses ) ) { |
| 77 | + foreach( $fbPushEventClasses as $pushEventClassName ) { |
74 | 78 | $pushObj = new $pushEventClassName; |
75 | 79 | $className = get_class(); |
76 | 80 | $prefName = $pushObj->getUserPreferenceName(); |
— | — | @@ -80,9 +84,9 @@ |
81 | 85 | 'section' => self::$PREFERENCES_TAB_NAME, |
82 | 86 | 'default' => '1', |
83 | 87 | ); |
84 | | - |
| 88 | + |
85 | 89 | // Prior to v1.16 |
86 | | - if( defined('PREF_TOGGLE_T') ) { |
| 90 | + if( defined( 'PREF_TOGGLE_T' ) ) { |
87 | 91 | $preferences[$prefName]['int-type'] = PREF_TOGGLE_T; |
88 | 92 | $preferences[$prefName]['name'] = $prefName; |
89 | 93 | } |
— | — | @@ -91,41 +95,41 @@ |
92 | 96 | |
93 | 97 | return true; |
94 | 98 | } // end addPreferencesToggles() |
95 | | - |
| 99 | + |
96 | 100 | /** |
97 | 101 | * This function returns HTML which contains toggles (in a list) for setting the push |
98 | | - * Preferences. It is designed to be used inside of a form (such as on Special:Connect). |
| 102 | + * Preferences. It is designed to be used inside of a form (such as on Special:Connect). |
99 | 103 | * |
100 | 104 | * This is not used by the code which adds the form to Special:Preferences. |
101 | 105 | * |
102 | 106 | * If firstTime is set to true, the checkboxes will default to being checked, otherwise |
103 | 107 | * they will default to the current user-option setting for the user. |
104 | 108 | */ |
105 | | - static public function createPreferencesToggles($firstTime = false){ |
| 109 | + static public function createPreferencesToggles( $firstTime = false ) { |
106 | 110 | global $wgUser, $wgLang, $fbPushEventClasses; |
107 | | - wfProfileIn(__METHOD__); |
| 111 | + wfProfileIn( __METHOD__ ); |
108 | 112 | |
109 | | - $html = ""; |
110 | | - if(!empty($fbPushEventClasses)){ |
111 | | - foreach($fbPushEventClasses as $pushEventClassName){ |
| 113 | + $html = ''; |
| 114 | + if( !empty( $fbPushEventClasses ) ) { |
| 115 | + foreach( $fbPushEventClasses as $pushEventClassName ) { |
112 | 116 | $pushObj = new $pushEventClassName; |
113 | 117 | $className = get_class(); |
114 | 118 | $prefName = $pushObj->getUserPreferenceName(); |
115 | 119 | |
116 | 120 | $prefText = $wgLang->getUserToggle( $prefName ); |
117 | | - if($firstTime){ |
| 121 | + if( $firstTime ) { |
118 | 122 | $checked = ' checked="checked"'; |
119 | 123 | } else { |
120 | 124 | $checked = $wgUser->getOption( $prefName ) == 1 ? ' checked="checked"' : ''; |
121 | 125 | } |
122 | | - $html .= "<div class='toggle'>"; |
| 126 | + $html .= '<div class="toggle">'; |
123 | 127 | $html .= "<input type='checkbox' value='1' id=\"$prefName\" name=\"$prefName\"$checked />"; |
124 | 128 | $html .= "<label for=\"$prefName\">$prefText</label>"; |
125 | 129 | $html .= "</div>\n"; |
126 | 130 | } |
127 | 131 | } |
128 | 132 | |
129 | | - wfProfileOut(__METHOD__); |
| 133 | + wfProfileOut( __METHOD__ ); |
130 | 134 | return $html; |
131 | 135 | } // end createPreferencesToggles() |
132 | 136 | |
— | — | @@ -133,35 +137,35 @@ |
134 | 138 | * This static function is called by the FBConnect extension if push events are enabled. It checks |
135 | 139 | * to make sure that the configured push-events are valid and then gives them each a chance to initialize. |
136 | 140 | */ |
137 | | - static public function initAll(){ |
| 141 | + static public function initAll() { |
138 | 142 | global $fbPushEventClasses, $wgUser; |
139 | | - wfProfileIn(__METHOD__); |
140 | | - |
| 143 | + wfProfileIn( __METHOD__ ); |
| 144 | + |
141 | 145 | if( !empty( $fbPushEventClasses ) ) { |
142 | 146 | // Fail fast (and hard) if a push event was coded incorrectly. |
143 | | - foreach($fbPushEventClasses as $pushEventClassName){ |
| 147 | + foreach( $fbPushEventClasses as $pushEventClassName ) { |
144 | 148 | $pushObj = new $pushEventClassName; |
145 | 149 | $className = get_class(); |
146 | 150 | $prefName = $pushObj->getUserPreferenceName(); |
147 | | - if(empty($prefName)){ |
| 151 | + if( empty( $prefName ) ) { |
148 | 152 | $dirName = dir( __FILE__ ); |
149 | 153 | $msg = "FATAL ERROR: The push event class <strong>\"$pushEventClassName\"</strong> does not return a valid user preference name! "; |
150 | | - $msg.= " It was probably written incorrectly. Either fix the class or remove it from being used in <strong>$dirName/config.php</strong>"; |
151 | | - die($msg); |
152 | | - } else if(!is_subclass_of($pushObj, $className)){ |
| 154 | + $msg .= " It was probably written incorrectly. Either fix the class or remove it from being used in <strong>$dirName/config.php</strong>"; |
| 155 | + die( $msg ); |
| 156 | + } elseif( !is_subclass_of( $pushObj, $className ) ) { |
153 | 157 | $msg = "FATAL ERROR: The push event class <strong>\"$pushEventClassName\"</strong> is not a subclass of <strong>$className</strong>! "; |
154 | | - $msg.= " It was probably written incorrectly. Either fix the class or remove it from being used in <strong>$dirName/config.php</strong>"; |
155 | | - die($msg); |
| 158 | + $msg .= " It was probably written incorrectly. Either fix the class or remove it from being used in <strong>$dirName/config.php</strong>"; |
| 159 | + die( $msg ); |
156 | 160 | } |
157 | | - |
| 161 | + |
158 | 162 | // The push event is valid, let it initialize itself if needed. |
159 | | - if( $wgUser->getOption($prefName) ) { |
| 163 | + if( $wgUser->getOption( $prefName ) ) { |
160 | 164 | $pushObj->init(); |
161 | 165 | } |
162 | 166 | } |
163 | 167 | } |
164 | 168 | |
165 | | - wfProfileOut(__METHOD__); |
| 169 | + wfProfileOut( __METHOD__ ); |
166 | 170 | } |
167 | 171 | |
168 | 172 | /** |
— | — | @@ -171,14 +175,14 @@ |
172 | 176 | * and the getUserPreferenceName() call checks out (the result must be non-empty). |
173 | 177 | */ |
174 | 178 | public function init(){} |
175 | | - |
176 | | - /** |
177 | | - * Put Facebook message. |
178 | | - */ |
179 | | - public function pushEvent($message, $link = null, $link_title = null) { |
| 179 | + |
| 180 | + /** |
| 181 | + * Put Facebook message. |
| 182 | + */ |
| 183 | + public function pushEvent( $message, $link = null, $link_title = null ) { |
180 | 184 | global $facebook; |
181 | | - |
182 | | - return $facebook->publishStream($message, $link, $link_title); |
183 | | - } |
184 | | - |
| 185 | + |
| 186 | + return $facebook->publishStream( $message, $link, $link_title ); |
| 187 | + } |
| 188 | + |
185 | 189 | } // end FBConnectPushEvent class |
Index: trunk/extensions/FBConnect/FBConnectHooks.php |
— | — | @@ -1,23 +1,23 @@ |
2 | 2 | <?php |
3 | | -/* |
| 3 | +/** |
4 | 4 | * Copyright © 2008-2010 Garrett Brown <http://www.mediawiki.org/wiki/User:Gbruin> |
5 | 5 | * This program is free software; you can redistribute it and/or modify |
6 | 6 | * it under the terms of the GNU General Public License as published by |
7 | 7 | * the Free Software Foundation; either version 2 of the License, or |
8 | 8 | * (at your option) any later version. |
9 | | - * |
| 9 | + * |
10 | 10 | * This program is distributed in the hope that it will be useful, |
11 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | 13 | * GNU General Public License for more details. |
14 | | - * |
| 14 | + * |
15 | 15 | * You should have received a copy of the GNU General Public License along |
16 | 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | */ |
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Class FBConnectHooks |
21 | | - * |
| 21 | + * |
22 | 22 | * This class contains all the hooks used in this extension. HOOKS DO NOT NEED |
23 | 23 | * TO BE EXPLICITLY ADDED TO $wgHooks. Simply write a public static function |
24 | 24 | * with the same name as the hook that provokes it, place it inside this class |
— | — | @@ -34,13 +34,13 @@ |
35 | 35 | // Get the article title |
36 | 36 | $nt = $article->getTitle(); |
37 | 37 | // If the page being viewed is a user page |
38 | | - if ($nt && $nt->getNamespace() == NS_USER && strpos($nt->getText(), '/') === false) { |
39 | | - $user = User::newFromName($nt->getText()); |
40 | | - if (!$user || $user->getID() == 0) { |
| 38 | + if ( $nt && $nt->getNamespace() == NS_USER && strpos( $nt->getText(), '/' ) === false ) { |
| 39 | + $user = User::newFromName( $nt->getText() ); |
| 40 | + if ( !$user || $user->getID() == 0 ) { |
41 | 41 | return true; |
42 | 42 | } |
43 | | - $fb_id = FBConnectDB::getFacebookIDs($user->getId()); |
44 | | - if (!count($fb_id) || !($fb_id = $fb_id[0])) { |
| 43 | + $fb_id = FBConnectDB::getFacebookIDs( $user->getId() ); |
| 44 | + if ( !count( $fb_id ) || !( $fb_id = $fb_id[0] ) ) { |
45 | 45 | return true; |
46 | 46 | } |
47 | 47 | // TODO: Something with the Facebook ID stored in $fb_id |
— | — | @@ -48,22 +48,24 @@ |
49 | 49 | } |
50 | 50 | return true; |
51 | 51 | } |
52 | | - |
| 52 | + |
53 | 53 | /** |
54 | 54 | * Checks the autopromote condition for a user. |
55 | 55 | */ |
56 | 56 | static function AutopromoteCondition( $cond_type, $args, $user, &$result ) { |
57 | 57 | global $wgFbUserRightsFromGroup; |
58 | | - |
| 58 | + |
59 | 59 | // Probably a redundant check, but with PHP you can never be too sure... |
60 | | - if (!$wgFbUserRightsFromGroup) { |
| 60 | + if ( !$wgFbUserRightsFromGroup ) { |
61 | 61 | // No group to pull rights from, so the user can't be a member |
62 | 62 | $result = false; |
63 | 63 | return true; |
64 | 64 | } |
65 | | - $types = array(APCOND_FB_INGROUP => 'member', |
66 | | - APCOND_FB_ISOFFICER => 'officer', |
67 | | - APCOND_FB_ISADMIN => 'admin'); |
| 65 | + $types = array( |
| 66 | + APCOND_FB_INGROUP => 'member', |
| 67 | + APCOND_FB_ISOFFICER => 'officer', |
| 68 | + APCOND_FB_ISADMIN => 'admin' |
| 69 | + ); |
68 | 70 | $type = $types[$cond_type]; |
69 | 71 | switch( $type ) { |
70 | 72 | case 'member': |
— | — | @@ -71,22 +73,22 @@ |
72 | 74 | case 'admin': |
73 | 75 | global $facebook; |
74 | 76 | // Connect to the Facebook API and ask if the user is in the group |
75 | | - $rights = $facebook->getGroupRights($user); |
| 77 | + $rights = $facebook->getGroupRights( $user ); |
76 | 78 | $result = $rights[$type]; |
77 | 79 | } |
78 | | - |
| 80 | + |
79 | 81 | return true; |
80 | 82 | } |
81 | | - |
| 83 | + |
82 | 84 | /** |
83 | | - * Injects some important CSS and Javascript into the <head> of the page. |
| 85 | + * Injects some important CSS and JavaScript into the <head> of the page. |
84 | 86 | */ |
85 | 87 | public static function BeforePageDisplay( &$out, &$sk ) { |
86 | 88 | global $wgVersion, $wgFbLogo, $wgFbScript, $wgFbExtensionScript, $wgFbIncludeJquery, |
87 | 89 | $wgScriptPath, $wgJsMimeType, $wgStyleVersion; |
88 | | - |
| 90 | + |
89 | 91 | // Asynchronously load the Facebook Connect JavaScript SDK before the page's content |
90 | | - if(!empty($wgFbScript)){ |
| 92 | + if( !empty( $wgFbScript ) ) { |
91 | 93 | $out->prependHTML(' |
92 | 94 | <div id="fb-root"></div> |
93 | 95 | <script> |
— | — | @@ -96,56 +98,56 @@ |
97 | 99 | </script>' . "\n" |
98 | 100 | ); |
99 | 101 | } |
100 | | - |
| 102 | + |
101 | 103 | // Inserts list of global JavaScript variables if necessary |
102 | | - if (self::MGVS_hack( $mgvs_script )) { |
| 104 | + if ( self::MGVS_hack( $mgvs_script ) ) { |
103 | 105 | $out->addInlineScript( $mgvs_script ); |
104 | 106 | } |
105 | | - |
| 107 | + |
106 | 108 | // Add a Facebook logo to the class .mw-fblink |
107 | | - $style = empty($wgFbLogo) ? '' : <<<STYLE |
| 109 | + $style = empty( $wgFbLogo ) ? '' : <<<STYLE |
108 | 110 | /* Add a pretty logo to Facebook links */ |
109 | 111 | .mw-fblink { |
110 | 112 | background: url($wgFbLogo) top left no-repeat !important; |
111 | 113 | padding-left: 17px !important; |
112 | 114 | } |
113 | 115 | STYLE; |
114 | | - |
| 116 | + |
115 | 117 | // Things get a little simpler in 1.16... |
116 | | - if (version_compare($wgVersion, '1.16', '>=')) { |
| 118 | + if ( version_compare( $wgVersion, '1.16', '>=' ) ) { |
117 | 119 | // Add a pretty Facebook logo if $wgFbLogo is set |
118 | | - if ( !empty( $wgFbLogo) ) { |
119 | | - $out->addInlineStyle($style); |
| 120 | + if ( !empty( $wgFbLogo ) ) { |
| 121 | + $out->addInlineStyle( $style ); |
120 | 122 | } |
121 | | - |
| 123 | + |
122 | 124 | // Don't include jQuery if it's already in use on the site |
123 | 125 | #$out->includeJQuery(); |
124 | 126 | // Temporary workaround until until MW is bundled with jQuery 1.4.2: |
125 | | - $out->addScriptFile('http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js'); |
126 | | - |
| 127 | + $out->addScriptFile( 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js' ); |
| 128 | + |
127 | 129 | // Add the script file specified by $url |
128 | | - if(!empty($wgFbExtensionScript)){ |
129 | | - $out->addScriptFile($wgFbExtensionScript); |
| 130 | + if( !empty( $wgFbExtensionScript ) ) { |
| 131 | + $out->addScriptFile( $wgFbExtensionScript ); |
130 | 132 | } |
131 | 133 | } else { |
132 | 134 | // Add a pretty Facebook logo if $wgFbLogo is set |
133 | | - if ( !empty( $wgFbLogo) ) { |
134 | | - $out->addScript('<style type="text/css">' . $style . '</style>'); |
| 135 | + if ( !empty( $wgFbLogo ) ) { |
| 136 | + $out->addScript( '<style type="text/css">' . $style . '</style>' ); |
135 | 137 | } |
136 | | - |
| 138 | + |
137 | 139 | // Don't include jQuery if it's already in use on the site |
138 | | - if (!empty($wgFbIncludeJquery)){ |
139 | | - $out->addScriptFile("http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"); |
| 140 | + if ( !empty( $wgFbIncludeJquery ) ) { |
| 141 | + $out->addScriptFile( 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js' ); |
140 | 142 | } |
141 | | - |
| 143 | + |
142 | 144 | // Add the script file specified by $url |
143 | | - if(!empty($wgFbExtensionScript)){ |
144 | | - $out->addScript("<script type=\"$wgJsMimeType\" src=\"$wgFbExtensionScript?$wgStyleVersion\"></script>\n"); |
| 145 | + if( !empty( $wgFbExtensionScript ) ) { |
| 146 | + $out->addScript( "<script type=\"$wgJsMimeType\" src=\"$wgFbExtensionScript?$wgStyleVersion\"></script>\n" ); |
145 | 147 | } |
146 | 148 | } |
147 | 149 | return true; |
148 | 150 | } |
149 | | - |
| 151 | + |
150 | 152 | /** |
151 | 153 | * Fired when MediaWiki is updated to allow FBConnect to update the database. |
152 | 154 | * If the database type is supported, then a new tabled named 'user_fbconnect' |
— | — | @@ -157,22 +159,22 @@ |
158 | 160 | global $wgDBtype, $wgDBprefix, $wgExtNewTables; |
159 | 161 | $base = dirname( __FILE__ ); |
160 | 162 | if ( $wgDBtype == 'mysql' ) { |
161 | | - $wgExtNewTables[] = array("{$wgDBprefix}user_fbconnect", "$base/fbconnect_table.sql"); |
162 | | - } else if ( $wgDBtype == 'postgres' ) { |
163 | | - $wgExtNewTables[] = array("{$wgDBprefix}user_fbconnect", "$base/fbconnect_table.pg.sql"); |
| 163 | + $wgExtNewTables[] = array( "{$wgDBprefix}user_fbconnect", "$base/fbconnect_table.sql" ); |
| 164 | + } elseif ( $wgDBtype == 'postgres' ) { |
| 165 | + $wgExtNewTables[] = array( "{$wgDBprefix}user_fbconnect", "$base/fbconnect_table.pg.sql" ); |
164 | 166 | } |
165 | 167 | return true; |
166 | 168 | } |
167 | | - |
| 169 | + |
168 | 170 | /** |
169 | 171 | * Adds several Facebook Connect variables to the page: |
170 | | - * |
| 172 | + * |
171 | 173 | * fbAppId The application ID (see $wgFbAppId in config.php) |
172 | 174 | * fbSession Assist the JavaScript SDK with loading the session |
173 | 175 | * fbUseMarkup Should XFBML tags be rendered (see $wgFbUseMarkup in config.php) |
174 | 176 | * fbLogo Facebook logo (see $wgFbLogo in config.php) |
175 | 177 | * fbLogoutURL The URL to be redirected to on a disconnect |
176 | | - * |
| 178 | + * |
177 | 179 | * This hook was added in MediaWiki version 1.14. See: |
178 | 180 | * http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/includes/Skin.php?view=log&pathrev=38397 |
179 | 181 | * If we are not at revision 38397 or later, this function is called from BeforePageDisplay |
— | — | @@ -191,7 +193,7 @@ |
192 | 194 | $vars['wgPagequery'] = wfUrlencode( wfArrayToCGI( $query ) ); |
193 | 195 | return true; |
194 | 196 | } |
195 | | - |
| 197 | + |
196 | 198 | /** |
197 | 199 | * Hack: Run MakeGlobalVariablesScript for backwards compatability. |
198 | 200 | * The MakeGlobalVariablesScript hook was added to MediaWiki 1.14 in revision 38397: |
— | — | @@ -199,23 +201,22 @@ |
200 | 202 | */ |
201 | 203 | private static function MGVS_hack( &$script ) { |
202 | 204 | global $wgVersion, $IP; |
203 | | - if (version_compare($wgVersion, '1.14', '<')) { |
204 | | - $svn = SpecialVersion::getSvnRevision($IP); |
| 205 | + if ( version_compare( $wgVersion, '1.14', '<' ) ) { |
| 206 | + $svn = SpecialVersion::getSvnRevision( $IP ); |
205 | 207 | // if !$svn, then we must be using 1.13.x (as opposed to 1.14alpha+) |
206 | | - if (!$svn || $svn < 38397) |
207 | | - { |
208 | | - $script = ""; |
| 208 | + if ( !$svn || $svn < 38397 ) { |
| 209 | + $script = ''; |
209 | 210 | $vars = array(); |
210 | | - wfRunHooks('MakeGlobalVariablesScript', array(&$vars)); |
| 211 | + wfRunHooks( 'MakeGlobalVariablesScript', array( &$vars ) ); |
211 | 212 | foreach( $vars as $name => $value ) { |
212 | | - $script .= "\t\tvar $name = " . json_encode($value) . ";\n"; |
| 213 | + $script .= "\t\tvar $name = " . json_encode( $value ) . ";\n"; |
213 | 214 | } |
214 | 215 | return true; |
215 | 216 | } |
216 | 217 | } |
217 | 218 | return false; |
218 | 219 | } |
219 | | - |
| 220 | + |
220 | 221 | /** |
221 | 222 | * Installs a parser hook for every tag reported by FBConnectXFBML::availableTags(). |
222 | 223 | * Accomplishes this by asking FBConnectXFBML to create a hook function that then |
— | — | @@ -224,29 +225,29 @@ |
225 | 226 | public static function ParserFirstCallInit( &$parser ) { |
226 | 227 | $pHooks = FBConnectXFBML::availableTags(); |
227 | 228 | foreach( $pHooks as $tag ) { |
228 | | - $parser->setHook( $tag, FBConnectXFBML::createParserHook( $tag )); |
| 229 | + $parser->setHook( $tag, FBConnectXFBML::createParserHook( $tag ) ); |
229 | 230 | } |
230 | 231 | return true; |
231 | 232 | } |
232 | | - |
| 233 | + |
233 | 234 | /** |
234 | 235 | * Modify the user's persinal toolbar (in the upper right). |
235 | | - * |
| 236 | + * |
236 | 237 | * TODO: Better 'returnto' code |
237 | 238 | */ |
238 | 239 | public static function PersonalUrls( &$personal_urls, &$wgTitle ) { |
239 | 240 | global $facebook, $wgUser, $wgLang, $wgShowIPinHeader; |
240 | 241 | global $wgFbPersonalUrls, $wgFbConnectOnly; |
241 | | - wfLoadExtensionMessages('FBConnect'); |
242 | | - |
| 242 | + wfLoadExtensionMessages( 'FBConnect' ); |
| 243 | + |
243 | 244 | /* |
244 | 245 | * Personal URLs option: remove_user_talk_link |
245 | 246 | */ |
246 | | - if ($wgFbPersonalUrls['remove_user_talk_link'] && |
247 | | - array_key_exists('mytalk', $personal_urls)) { |
248 | | - unset($personal_urls['mytalk']); |
| 247 | + if ( $wgFbPersonalUrls['remove_user_talk_link'] && |
| 248 | + array_key_exists( 'mytalk', $personal_urls ) ) { |
| 249 | + unset( $personal_urls['mytalk'] ); |
249 | 250 | } |
250 | | - |
| 251 | + |
251 | 252 | // If the user is logged in and connected |
252 | 253 | if ( $wgUser->isLoggedIn() && $facebook->getSession() ) { |
253 | 254 | /* |
— | — | @@ -256,37 +257,38 @@ |
257 | 258 | // Start with the real name in the database |
258 | 259 | $name = $wgUser->getRealName(); |
259 | 260 | // Ask Facebook for the real name |
260 | | - if (!$name || $name == '') { |
| 261 | + if ( !$name || $name == '' ) { |
261 | 262 | try { |
262 | 263 | // This might fail if we load a stale session from cookies |
263 | | - $fbUser = $facebook->api('/me'); |
| 264 | + $fbUser = $facebook->api( '/me' ); |
264 | 265 | $name = $fbUser['name']; |
265 | | - } catch (FacebookApiException $e) { |
266 | | - error_log($e); |
| 266 | + } catch ( FacebookApiException $e ) { |
| 267 | + error_log( $e ); |
267 | 268 | } |
268 | 269 | } |
269 | 270 | // Make sure we were able to get a name from the database or Facebook |
270 | | - if ($name && $name != '') { |
| 271 | + if ( $name && $name != '' ) { |
271 | 272 | $personal_urls['userpage']['text'] = $name; |
272 | 273 | } |
273 | 274 | } |
274 | 275 | // Replace logout link with a button to disconnect from Facebook Connect |
275 | | - if( empty( $wgFbPersonalUrls['hide_logout_of_fb'] ) ){ |
| 276 | + if( empty( $wgFbPersonalUrls['hide_logout_of_fb'] ) ) { |
276 | 277 | unset( $personal_urls['logout'] ); |
277 | 278 | $personal_urls['fblogout'] = array( |
278 | 279 | 'text' => wfMsg( 'fbconnect-logout' ), |
279 | 280 | 'href' => '#', |
280 | | - 'active' => false ); |
| 281 | + 'active' => false |
| 282 | + ); |
281 | 283 | } |
282 | | - |
| 284 | + |
283 | 285 | /* |
284 | 286 | * Personal URLs option: link_back_to_facebook |
285 | 287 | */ |
286 | | - if ($wgFbPersonalUrls['link_back_to_facebook']) { |
| 288 | + if ( $wgFbPersonalUrls['link_back_to_facebook'] ) { |
287 | 289 | try { |
288 | | - $fbUser = $facebook->api('/me'); |
| 290 | + $fbUser = $facebook->api( '/me' ); |
289 | 291 | $link = $fbUser['link']; |
290 | | - } catch (FacebookApiException $e) { |
| 292 | + } catch ( FacebookApiException $e ) { |
291 | 293 | $link = 'http://www.facebook.com/profile.php?id=' . |
292 | 294 | $facebook->getUser(); |
293 | 295 | } |
— | — | @@ -298,76 +300,74 @@ |
299 | 301 | } |
300 | 302 | } |
301 | 303 | // User is logged in but not Connected |
302 | | - else if ($wgUser->isLoggedIn()) { |
| 304 | + elseif ( $wgUser->isLoggedIn() ) { |
303 | 305 | /* |
304 | 306 | * Personal URLs option: hide_convert_button |
305 | 307 | */ |
306 | | - if (!$wgFbPersonalUrls['hide_convert_button']) { |
| 308 | + if ( !$wgFbPersonalUrls['hide_convert_button'] ) { |
307 | 309 | $personal_urls['fbconvert'] = array( |
308 | 310 | 'text' => wfMsg( 'fbconnect-convert' ), |
309 | | - 'href' => SpecialConnect::getTitleFor('Connect', 'Convert')->getLocalURL( |
310 | | - 'returnto=' . $wgTitle->getPrefixedURL()), |
| 311 | + 'href' => SpecialConnect::getTitleFor( 'Connect', 'Convert' )->getLocalURL( |
| 312 | + 'returnto=' . $wgTitle->getPrefixedURL() ), |
311 | 313 | 'active' => $wgTitle->isSpecial( 'Connect' ) |
312 | 314 | ); |
313 | 315 | } |
314 | | - } |
315 | | - // User is not logged in |
316 | | - else { |
| 316 | + } else { // User is not logged in |
317 | 317 | /* |
318 | 318 | * Personal URLs option: hide_connect_button |
319 | 319 | */ |
320 | | - if (!$wgFbPersonalUrls['hide_connect_button']) { |
| 320 | + if ( !$wgFbPersonalUrls['hide_connect_button'] ) { |
321 | 321 | // Add an option to connect via Facebook Connect |
322 | 322 | $personal_urls['fbconnect'] = array( |
323 | 323 | 'text' => wfMsg( 'fbconnect-connect' ), |
324 | 324 | 'href' => SpecialPage::getTitleFor( 'Connect' )-> |
325 | | - getLocalUrl( 'returnto=' . $wgTitle->getPrefixedURL() ), |
326 | | - 'active' => $wgTitle->isSpecial('Connect') |
| 325 | + getLocalUrl( 'returnto=' . $wgTitle->getPrefixedURL() ), |
| 326 | + 'active' => $wgTitle->isSpecial( 'Connect' ) |
327 | 327 | ); |
328 | 328 | } |
329 | | - |
| 329 | + |
330 | 330 | // Remove other personal toolbar links |
331 | 331 | if ( !empty( $wgFbConnectOnly ) ) { |
332 | | - foreach (array('login', 'anonlogin') as $k) { |
333 | | - if (array_key_exists($k, $personal_urls)) { |
334 | | - unset($personal_urls[$k]); |
| 332 | + foreach ( array( 'login', 'anonlogin') as $k ) { |
| 333 | + if ( array_key_exists( $k, $personal_urls ) ) { |
| 334 | + unset( $personal_urls[$k] ); |
335 | 335 | } |
336 | 336 | } |
337 | 337 | } |
338 | 338 | } |
339 | 339 | return true; |
340 | 340 | } |
341 | | - |
| 341 | + |
342 | 342 | /** |
343 | 343 | * Modify the preferences form. At the moment, we simply turn the user name |
344 | | - * into a link to the user's facebook profile. |
345 | | - * |
| 344 | + * into a link to the user's Facebook profile. |
| 345 | + * |
346 | 346 | * TODO! |
347 | 347 | */ |
348 | 348 | public static function RenderPreferencesForm( $form, $output ) { |
349 | 349 | global $facebook, $wgUser; |
350 | | - |
| 350 | + |
351 | 351 | // This hook no longer seems to work... |
352 | 352 | return true; |
353 | | - |
| 353 | + |
354 | 354 | if( $facebook->getSession() ) { |
355 | 355 | $html = $output->getHTML(); |
356 | 356 | $name = $wgUser->getName(); |
357 | 357 | $i = strpos( $html, $name ); |
358 | | - if ($i !== FALSE) { |
| 358 | + if ( $i !== false ) { |
359 | 359 | // If the user has a valid Facebook ID, link to the Facebook profile |
360 | 360 | try { |
361 | | - $fbUser = $facebook->api('/me'); |
| 361 | + $fbUser = $facebook->api( '/me' ); |
362 | 362 | // Replace the old output with the new output |
363 | 363 | $html = substr( $html, 0, $i ) . |
364 | 364 | preg_replace("/$name/", "$name (<a href=\"$fbUser[link]\" " . |
365 | | - "class='mw-userlink mw-fbconnectuser'>" . |
366 | | - wfMsg('fbconnect-link-to-profile') . "</a>", |
367 | | - substr( $html, $i ), 1); |
| 365 | + "class='mw-userlink mw-fbconnectuser'>" . |
| 366 | + wfMsg('fbconnect-link-to-profile') . '</a>', |
| 367 | + substr( $html, $i ), 1 ); |
368 | 368 | $output->clearHTML(); |
369 | 369 | $output->addHTML( $html ); |
370 | | - } catch (FacebookApiException $e) { |
371 | | - error_log($e); |
| 370 | + } catch ( FacebookApiException $e ) { |
| 371 | + error_log( $e ); |
372 | 372 | } |
373 | 373 | } |
374 | 374 | } |
— | — | @@ -380,17 +380,17 @@ |
381 | 381 | */ |
382 | 382 | static function SpecialListusersFormatRow( &$item, $row ) { |
383 | 383 | global $fbSpecialUsers; |
384 | | - |
| 384 | + |
385 | 385 | // Only modify Facebook Connect users |
386 | | - if (!$fbSpecialUsers || |
387 | | - !count(FBConnectDB::getFacebookIDs(User::newFromName($row->user_name)))) { |
| 386 | + if ( !$fbSpecialUsers || |
| 387 | + !count( FBConnectDB::getFacebookIDs( User::newFromName( $row->user_name ) ) ) ) { |
388 | 388 | return true; |
389 | 389 | } |
390 | | - |
| 390 | + |
391 | 391 | // Look to see if class="..." appears in the link |
392 | 392 | $regs = array(); |
393 | 393 | preg_match( '/^([^>]*?)class=(["\'])([^"]*)\2(.*)/', $item, $regs ); |
394 | | - if (count( $regs )) { |
| 394 | + if ( count( $regs ) ) { |
395 | 395 | // If so, append " mw-userlink" to the end of the class list |
396 | 396 | $item = $regs[1] . "class=$regs[2]$regs[3] mw-userlink$regs[2]" . $regs[4]; |
397 | 397 | } else { |
— | — | @@ -400,25 +400,25 @@ |
401 | 401 | } |
402 | 402 | return true; |
403 | 403 | } |
404 | | - |
| 404 | + |
405 | 405 | /** |
406 | 406 | * Adds some info about the governing Facebook group to the header form of |
407 | 407 | * Special:ListUsers. |
408 | 408 | */ |
409 | 409 | static function SpecialListusersHeaderForm( &$pager, &$out ) { |
410 | 410 | global $wgFbUserRightsFromGroup, $facebook, $wgFbLogo; |
411 | | - if ( empty($wgFbUserRightsFromGroup) ) { |
| 411 | + if ( empty( $wgFbUserRightsFromGroup ) ) { |
412 | 412 | return true; |
413 | 413 | } |
414 | | - |
| 414 | + |
415 | 415 | // TODO: Do we need to verify the Facebook session here? |
416 | | - |
| 416 | + |
417 | 417 | $gid = $wgFbUserRightsFromGroup; |
418 | 418 | // Connect to the API and get some info about the group |
419 | 419 | try { |
420 | | - $group = $facebook->api('/' . $gid); |
421 | | - } catch (FacebookApiException $e) { |
422 | | - error_log($e); |
| 420 | + $group = $facebook->api( '/' . $gid ); |
| 421 | + } catch ( FacebookApiException $e ) { |
| 422 | + error_log( $e ); |
423 | 423 | } |
424 | 424 | $out .= ' |
425 | 425 | <table style="border-collapse: collapse;"> |
— | — | @@ -437,7 +437,7 @@ |
438 | 438 | </table>"; |
439 | 439 | return true; |
440 | 440 | } |
441 | | - |
| 441 | + |
442 | 442 | /** |
443 | 443 | * Removes Special:UserLogin and Special:CreateAccount from the list of |
444 | 444 | * special pages if $wgFbConnectOnly is set to true. |
— | — | @@ -445,21 +445,21 @@ |
446 | 446 | static function SpecialPage_initList( &$aSpecialPages ) { |
447 | 447 | global $wgFbConnectOnly; |
448 | 448 | if ( !empty( $wgFbConnectOnly) ) { |
449 | | - $aSpecialPages['Userlogin'] = array('SpecialRedirectToSpecial', 'UserLogin', |
450 | | - 'Connect', false, array('returnto', 'returntoquery')); |
| 449 | + $aSpecialPages['Userlogin'] = array( 'SpecialRedirectToSpecial', 'UserLogin', |
| 450 | + 'Connect', false, array( 'returnto', 'returntoquery' ) ); |
451 | 451 | // Used in 1.12.x and above |
452 | | - $aSpecialPages['CreateAccount'] = array('SpecialRedirectToSpecial', |
453 | | - 'CreateAccount', 'Connect'); |
| 452 | + $aSpecialPages['CreateAccount'] = array( 'SpecialRedirectToSpecial', |
| 453 | + 'CreateAccount', 'Connect' ); |
454 | 454 | } |
455 | 455 | return true; |
456 | 456 | } |
457 | | - |
| 457 | + |
458 | 458 | /** |
459 | 459 | * HACK: Please someone fix me or explain why this is necessary! |
460 | | - * |
| 460 | + * |
461 | 461 | * Unstub $wgUser to avoid race conditions and stop returning stupid false |
462 | 462 | * negatives! |
463 | | - * |
| 463 | + * |
464 | 464 | * This might be due to a bug in User::getRights() [called from |
465 | 465 | * User::isAllowed('read'), called from Title::userCanRead()], where mRights |
466 | 466 | * is retrieved from an uninitialized user. From my probing, it seems that |
— | — | @@ -470,12 +470,12 @@ |
471 | 471 | * that instead of being null, mRights is equal to the array |
472 | 472 | * (createaccount, createpage, createtalk, writeapi). |
473 | 473 | */ |
474 | | - static function userCan (&$title, &$user, $action, &$result) { |
| 474 | + static function userCan( &$title, &$user, $action, &$result ) { |
475 | 475 | // Unstub $wgUser (is there a more succinct way to do this?) |
476 | 476 | $user->getId(); |
477 | 477 | return true; |
478 | 478 | } |
479 | | - |
| 479 | + |
480 | 480 | /** |
481 | 481 | * Removes the 'createaccount' right from users if $wgFbConnectOnly is true. |
482 | 482 | */ |
— | — | @@ -491,28 +491,28 @@ |
492 | 492 | } |
493 | 493 | return true; |
494 | 494 | } |
495 | | - |
| 495 | + |
496 | 496 | /** |
497 | 497 | * If the user isn't logged in, try to auto-authenticate via Facebook |
498 | 498 | * Connect. The Single Sign On magic of FBConnect happens in this function. |
499 | 499 | */ |
500 | 500 | static function UserLoadFromSession( $user, &$result ) { |
501 | 501 | global $facebook, $wgCookiePrefix, $wgTitle, $wgOut, $wgUser; |
502 | | - |
| 502 | + |
503 | 503 | // Check to see if the user can be logged in from Facebook |
504 | 504 | $fbId = $facebook->getSession() ? $facebook->getUser() : 0; |
505 | 505 | // Check to see if the user can be loaded from the session |
506 | | - $localId = isset($_COOKIE["{$wgCookiePrefix}UserID"]) ? |
507 | | - intval($_COOKIE["{$wgCookiePrefix}UserID"]) : |
508 | | - (isset($_SESSION['wsUserID']) ? $_SESSION['wsUserID'] : 0); |
509 | | - |
| 506 | + $localId = isset( $_COOKIE["{$wgCookiePrefix}UserID"] ) ? |
| 507 | + intval( $_COOKIE["{$wgCookiePrefix}UserID"] ) : |
| 508 | + ( isset( $_SESSION['wsUserID'] ) ? $_SESSION['wsUserID'] : 0 ); |
| 509 | + |
510 | 510 | // Case: Not logged into Facebook, but logged into the wiki |
511 | | - if (!$fbId && $localId) { |
512 | | - $mwUser = User::newFromId($localId); |
| 511 | + if ( !$fbId && $localId ) { |
| 512 | + $mwUser = User::newFromId( $localId ); |
513 | 513 | // If the user was Connected, the JS should have logged them out... |
514 | 514 | // TODO: test to see if they logged in normally (with a password) |
515 | 515 | #if (FBConnectDB::userLoggedInWithPassword($mwUser)) return true; |
516 | | - if (count(FBConnectDB::getFacebookIDs($mwUser))) { |
| 516 | + if ( count( FBConnectDB::getFacebookIDs( $mwUser ) ) ) { |
517 | 517 | // Oh well, they shouldn't be here anyways; silently log them out |
518 | 518 | $mwUser->logout(); |
519 | 519 | // Defaults have just been loaded, so save some time |
— | — | @@ -520,23 +520,23 @@ |
521 | 521 | } |
522 | 522 | } |
523 | 523 | // Case: Logged into Facebook, not logged into the wiki |
524 | | - else if ($fbId && !$localId) { |
| 524 | + elseif ( $fbId && !$localId ) { |
525 | 525 | // Look up the MW ID of the Facebook user |
526 | | - $mwUser = FBConnectDB::getUser($fbId); |
| 526 | + $mwUser = FBConnectDB::getUser( $fbId ); |
527 | 527 | $id = $mwUser ? $mwUser->getId() : 0; |
528 | 528 | // If the user doesn't exist, ask them to name their new account |
529 | | - if (!$id) { |
| 529 | + if ( !$id ) { |
530 | 530 | // TODO: $wgTitle was empty for some strange reason... |
531 | | - if (!empty( $wgTitle )) { |
532 | | - $returnto = $wgTitle->isSpecial('Userlogout') || $wgTitle->isSpecial('Connect') ? |
| 531 | + if ( !empty( $wgTitle ) ) { |
| 532 | + $returnto = $wgTitle->isSpecial( 'Userlogout' ) || $wgTitle->isSpecial( 'Connect' ) ? |
533 | 533 | '' : 'returnto=' . $wgTitle->getPrefixedURL(); |
534 | 534 | } else { |
535 | 535 | $returnto = ''; |
536 | 536 | } |
537 | 537 | // Don't redirect if we're on certain special pages |
538 | | - if ($returnto != '') { |
| 538 | + if ( $returnto != '' ) { |
539 | 539 | // Redirect to Special:Connect so the Facebook user can choose a nickname |
540 | | - $wgOut->redirect($wgUser->getSkin()->makeSpecialUrl('Connect', $returnto)); |
| 540 | + $wgOut->redirect( $wgUser->getSkin()->makeSpecialUrl( 'Connect', $returnto ) ); |
541 | 541 | } |
542 | 542 | } else { |
543 | 543 | // TODO: To complete the SSO experience, this should log the user on |
— | — | @@ -546,7 +546,7 @@ |
547 | 547 | $user->mFrom = 'id'; |
548 | 548 | $user->load(); |
549 | 549 | // Update user's info from Facebook |
550 | | - $fbUser = new FBConnectUser($mwUser); |
| 550 | + $fbUser = new FBConnectUser( $mwUser ); |
551 | 551 | $fbUser->updateFromFacebook(); |
552 | 552 | // Authentification okay, no need to continue with User::loadFromSession() |
553 | 553 | $result = true; |
— | — | @@ -557,31 +557,35 @@ |
558 | 558 | // Case: Logged into Facebook, logged into the wiki |
559 | 559 | return true; |
560 | 560 | } |
561 | | - |
| 561 | + |
562 | 562 | /** |
563 | | - * |
564 | | - * |
| 563 | + * |
| 564 | + * |
565 | 565 | */ |
566 | | - static function initPreferencesExtensionForm($user, &$wgExtensionPreferences) { |
567 | | - $id = FBConnectDB::getFacebookIDs($user); |
568 | | - if( count($id) > 0 ) { |
| 566 | + static function initPreferencesExtensionForm( $user, &$wgExtensionPreferences ) { |
| 567 | + $id = FBConnectDB::getFacebookIDs( $user ); |
| 568 | + if( count( $id ) > 0 ) { |
569 | 569 | //action="/index.php?title=TechTeam_QA_8_Wiki&action=submit" method="post" |
570 | 570 | $action = SpecialPage::getTitleFor( 'Connect' ); |
571 | | - $action = $action->getFullURL("action=disconnect"); |
572 | | - $html = Xml::openElement("div"); |
573 | | - $html .= Xml::openElement( "form", array("submit" => "post", "action" => $action) ); |
574 | | - $html .= Xml::element( "input", array("type" => "submit", "value" => "Disconent"), '', true ); |
575 | | - $html .= Xml::closeElement( "form" ); |
576 | | - $html .= Xml::closeElement( "div" ); |
| 571 | + $action = $action->getFullURL( 'action=disconnect' ); |
| 572 | + $html = Xml::openElement( 'div' ); |
| 573 | + $html .= Xml::openElement( 'form', array( 'submit' => 'post', 'action' => $action ) ); |
| 574 | + $html .= Xml::element( 'input', array( 'type' => 'submit', 'value' => 'Disconent' ), '', true ); |
| 575 | + $html .= Xml::closeElement( 'form' ); |
| 576 | + $html .= Xml::closeElement( 'div' ); |
577 | 577 | $wgExtensionPreferences = array_merge( |
578 | 578 | array( |
579 | 579 | array( |
580 | 580 | 'name' => 'ssasasas', |
581 | 581 | 'section' => 'fbconnect-prefstext', |
582 | 582 | 'html' => $html, |
583 | | - 'type' => PREF_CUSTOM_HTML_T) ), $wgExtensionPreferences); |
| 583 | + 'type' => PREF_CUSTOM_HTML_T |
| 584 | + ) |
| 585 | + ), |
| 586 | + $wgExtensionPreferences |
| 587 | + ); |
584 | 588 | } |
585 | | - |
| 589 | + |
586 | 590 | return true; |
587 | 591 | } |
588 | 592 | } |
Index: trunk/extensions/FBConnect/FBConnectDB.php |
— | — | @@ -1,16 +1,16 @@ |
2 | 2 | <?php |
3 | | -/* |
| 3 | +/** |
4 | 4 | * Copyright © 2010 Garrett Brown <http://www.mediawiki.org/wiki/User:Gbruin> |
5 | 5 | * This program is free software; you can redistribute it and/or modify |
6 | 6 | * it under the terms of the GNU General Public License as published by |
7 | 7 | * the Free Software Foundation; either version 2 of the License, or |
8 | 8 | * (at your option) any later version. |
9 | | - * |
| 9 | + * |
10 | 10 | * This program is distributed in the hope that it will be useful, |
11 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | 13 | * GNU General Public License for more details. |
14 | | - * |
| 14 | + * |
15 | 15 | * You should have received a copy of the GNU General Public License along |
16 | 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | */ |
— | — | @@ -26,15 +26,15 @@ |
27 | 27 | |
28 | 28 | /** |
29 | 29 | * Class FBConnectDB |
30 | | - * |
| 30 | + * |
31 | 31 | * This class abstracts the manipulation of the custom table used by this |
32 | 32 | * extension. If $wgDBprefix is set, this class will pull from the translated |
33 | 33 | * tables. If the table 'users_fbconnect' does not exist in your database |
34 | 34 | * you will receive errors like this: |
35 | | - * |
| 35 | + * |
36 | 36 | * Database error from within function "FBConnectDB::getUser". Database |
37 | 37 | * returned error "Table 'user_fbconnect' doesn't exist". |
38 | | - * |
| 38 | + * |
39 | 39 | * In this case, you will need to fix this by running the MW updater: |
40 | 40 | * >php maintenance/update.php |
41 | 41 | */ |
— | — | @@ -70,7 +70,7 @@ |
71 | 71 | $prefix = self::getPrefix(); |
72 | 72 | // NOTE: Do not just pass this dbr into getUserByDB since that function prevents |
73 | 73 | // rewriting of the database name for shared tables. |
74 | | - $dbr = & wfGetDB( DB_SLAVE, array(), self::sharedDB() ); |
| 74 | + $dbr = & wfGetDB( DB_SLAVE, array(), self::sharedDB() ); |
75 | 75 | $id = $dbr->selectField( |
76 | 76 | array( "{$prefix}user_fbconnect" ), |
77 | 77 | array( 'user_id' ), |
— | — | @@ -84,12 +84,12 @@ |
85 | 85 | return null; |
86 | 86 | } |
87 | 87 | } |
88 | | - |
| 88 | + |
89 | 89 | /** |
90 | 90 | * Add a User <-> Facebook ID association to the database. |
91 | 91 | */ |
92 | 92 | public static function addFacebookID( $user, $fbid ) { |
93 | | - wfProfileIn(__METHOD__); |
| 93 | + wfProfileIn( __METHOD__ ); |
94 | 94 | |
95 | 95 | $prefix = self::getPrefix(); |
96 | 96 | $dbw = wfGetDB( DB_MASTER, array(), self::sharedDB() ); |
— | — | @@ -101,9 +101,9 @@ |
102 | 102 | ), |
103 | 103 | __METHOD__ |
104 | 104 | ); |
105 | | - wfProfileOut(__METHOD__); |
| 105 | + wfProfileOut( __METHOD__ ); |
106 | 106 | } |
107 | | - |
| 107 | + |
108 | 108 | /** |
109 | 109 | * Remove a User <-> Facebook ID association from the database. |
110 | 110 | */ |
— | — | @@ -120,7 +120,7 @@ |
121 | 121 | ); |
122 | 122 | return (bool) $dbw->affectedRows(); |
123 | 123 | } |
124 | | - |
| 124 | + |
125 | 125 | /** |
126 | 126 | * Estimates the total number of User <-> Facebook ID associations in the |
127 | 127 | * database. If there are no users, then the estimate will probably be 1. |
— | — | @@ -129,28 +129,28 @@ |
130 | 130 | $prefix = self::getPrefix(); |
131 | 131 | $dbr = wfGetDB( DB_SLAVE, array(), self::sharedDB() ); |
132 | 132 | // An estimate is good enough for choosing a unique nickname |
133 | | - $count = $dbr->estimateRowCount("{$prefix}user_fbconnect"); |
| 133 | + $count = $dbr->estimateRowCount( "{$prefix}user_fbconnect" ); |
134 | 134 | // Avoid returning 0 or -1 |
135 | 135 | return $count >= 1 ? $count : 1; |
136 | 136 | } |
137 | | - |
| 137 | + |
138 | 138 | /** |
139 | 139 | * Returns the name of the shared database, if one is in use for the Facebook |
140 | 140 | * Connect users table. Note that 'user_fbconnect' (without respecting |
141 | 141 | * $wgSharedPrefix) is added to $wgSharedTables in FBConnect::init by default. |
142 | 142 | * This function can also be used as a test for whether a shared database for |
143 | 143 | * Facebook Connect users is in use. |
144 | | - * |
| 144 | + * |
145 | 145 | * See also: <http://www.mediawiki.org/wiki/Manual:Shared_database> |
146 | 146 | */ |
147 | 147 | private static function sharedDB() { |
148 | 148 | global $wgExternalSharedDB; |
149 | | - if (!empty($wgExternalSharedDB)) { |
150 | | - return $wgExternalSharedDB; |
| 149 | + if ( !empty( $wgExternalSharedDB ) ) { |
| 150 | + return $wgExternalSharedDB; |
151 | 151 | } |
152 | | - return false; |
| 152 | + return false; |
153 | 153 | } |
154 | | - |
| 154 | + |
155 | 155 | /** |
156 | 156 | * Returns the table prefix name, either $wgDBprefix, $wgSharedPrefix |
157 | 157 | * depending on whether a shared database is in use. |
Index: trunk/extensions/FBConnect/pushEvents/FBPush_OnWatchArticle.i18n.php |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | $messages['en'] = array( |
5 | | - 'tog-fbconnect-push-allow-OnWatchArticle' => "Post to my Facebook News Feed when I follow (watchlist) an article.", |
| 5 | + 'tog-fbconnect-push-allow-OnWatchArticle' => 'Post to my Facebook News Feed when I follow (watchlist) an article.', |
6 | 6 | ); |
Index: trunk/extensions/FBConnect/pushEvents/FBPush_OnAddImage.i18n.php |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | $messages['en'] = array( |
5 | | - 'tog-fbconnect-push-allow-OnAddImage' => "Post to my Facebook News Feed when I add an image.", |
| 5 | + 'tog-fbconnect-push-allow-OnAddImage' => 'Post to my Facebook News Feed when I add an image.', |
6 | 6 | ); |
Index: trunk/extensions/FBConnect/pushEvents/FBPush_OnWatchArticle.php |
— | — | @@ -6,30 +6,29 @@ |
7 | 7 | */ |
8 | 8 | |
9 | 9 | global $wgExtensionMessagesFiles; |
10 | | -$pushDir = dirname(__FILE__) . '/'; |
11 | | -$wgExtensionMessagesFiles['FBPush_OnWatchArticle'] = $pushDir . "FBPush_OnWatchArticle.i18n.php"; |
| 10 | +$pushDir = dirname( __FILE__ ) . '/'; |
| 11 | +$wgExtensionMessagesFiles['FBPush_OnWatchArticle'] = $pushDir . 'FBPush_OnWatchArticle.i18n.php'; |
12 | 12 | |
13 | 13 | class FBPush_OnWatchArticle extends FBConnectPushEvent { |
14 | 14 | protected $isAllowedUserPreferenceName = 'fbconnect-push-allow-OnWatchArticle'; // must correspond to an i18n message that is 'tog-[the value of the string on this line]'. |
15 | | - |
16 | | - public function init(){ |
| 15 | + |
| 16 | + public function init() { |
17 | 17 | global $wgHooks; |
18 | | - wfProfileIn(__METHOD__); |
| 18 | + wfProfileIn( __METHOD__ ); |
19 | 19 | |
20 | 20 | $wgHooks['ArticleSaveComplete'][] = 'FBPush_OnWatchArticle::articleCountPagesAddedInLastHour'; |
21 | | - wfLoadExtensionMessages('FBPush_OnWatchArticle'); |
22 | | - |
23 | | - wfProfileOut(__METHOD__); |
| 21 | + wfLoadExtensionMessages( 'FBPush_OnWatchArticle' ); |
| 22 | + |
| 23 | + wfProfileOut( __METHOD__ ); |
24 | 24 | } |
25 | | - |
26 | | - |
27 | | - public static function articleCountPagesAddedInLastHour(&$article, &$user, $text, $summary,$flag, $fake1, $fake2, &$flags, $revision, &$status, $baseRevId){ |
| 25 | + |
| 26 | + public static function articleCountPagesAddedInLastHour( &$article, &$user, $text, $summary,$flag, $fake1, $fake2, &$flags, $revision, &$status, $baseRevId ) { |
28 | 27 | global $wgContentNamespaces; |
29 | | - wfProfileIn(__METHOD__); |
30 | | - if( in_array($article->getTitle()->getNamespace(), $wgContentNamespaces) ) { |
31 | | - self::pushEvent($article->getTitle()->getText(), $article->getTitle()->getFullURL(), "Read more"); |
| 28 | + wfProfileIn( __METHOD__ ); |
| 29 | + if( in_array( $article->getTitle()->getNamespace(), $wgContentNamespaces ) ) { |
| 30 | + self::pushEvent( $article->getTitle()->getText(), $article->getTitle()->getFullURL(), 'Read more' ); |
32 | 31 | } |
33 | | - wfProfileOut(__METHOD__); |
| 32 | + wfProfileOut( __METHOD__ ); |
34 | 33 | return true; |
35 | 34 | } |
36 | 35 | } |
Index: trunk/extensions/FBConnect/pushEvents/FBPush_OnAddImage.php |
— | — | @@ -6,17 +6,17 @@ |
7 | 7 | */ |
8 | 8 | |
9 | 9 | global $wgExtensionMessagesFiles; |
10 | | -$pushDir = dirname(__FILE__) . '/'; |
11 | | -$wgExtensionMessagesFiles['FBPush_OnAddImage'] = $pushDir . "FBPush_OnAddImage.i18n.php"; |
| 10 | +$pushDir = dirname( __FILE__ ) . '/'; |
| 11 | +$wgExtensionMessagesFiles['FBPush_OnAddImage'] = $pushDir . 'FBPush_OnAddImage.i18n.php'; |
12 | 12 | |
13 | 13 | class FBPush_OnAddImage extends FBConnectPushEvent { |
14 | 14 | protected $isAllowedUserPreferenceName = 'fbconnect-push-allow-OnAddImage'; // must correspond to an i18n message that is 'tog-[the value of the string on this line]'. |
15 | | - |
16 | | - public function init(){ |
17 | | - wfProfileIn(__METHOD__); |
18 | 15 | |
19 | | - wfLoadExtensionMessages('FBPush_OnAddImage'); |
20 | | - |
21 | | - wfProfileOut(__METHOD__); |
| 16 | + public function init() { |
| 17 | + wfProfileIn( __METHOD__ ); |
| 18 | + |
| 19 | + wfLoadExtensionMessages( 'FBPush_OnAddImage' ); |
| 20 | + |
| 21 | + wfProfileOut( __METHOD__ ); |
22 | 22 | } |
23 | 23 | } |
Index: trunk/extensions/FBConnect/pushEvents/FBPush_OnLargeEdit.i18n.php |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | $messages['en'] = array( |
5 | | - 'tog-fbconnect-push-allow-OnLargeEdit' => "Post to my Facebook News Feed when I make an edit over ".FBPush_OnLargeEdit::getMinCharsToPush()." characters.", |
| 5 | + 'tog-fbconnect-push-allow-OnLargeEdit' => 'Post to my Facebook News Feed when I make an edit over ' . FBPush_OnLargeEdit::getMinCharsToPush() . ' characters.', |
6 | 6 | ); |
Index: trunk/extensions/FBConnect/pushEvents/FBPush_OnLargeEdit.php |
— | — | @@ -6,22 +6,22 @@ |
7 | 7 | */ |
8 | 8 | |
9 | 9 | global $wgExtensionMessagesFiles; |
10 | | -$pushDir = dirname(__FILE__) . '/'; |
11 | | -$wgExtensionMessagesFiles['FBPush_OnLargeEdit'] = $pushDir . "FBPush_OnLargeEdit.i18n.php"; |
| 10 | +$pushDir = dirname( __FILE__ ) . '/'; |
| 11 | +$wgExtensionMessagesFiles['FBPush_OnLargeEdit'] = $pushDir . 'FBPush_OnLargeEdit.i18n.php'; |
12 | 12 | |
13 | 13 | class FBPush_OnLargeEdit extends FBConnectPushEvent { |
14 | 14 | protected $isAllowedUserPreferenceName = 'fbconnect-push-allow-OnLargeEdit'; // must correspond to an i18n message that is 'tog-[the value of the string on this line]'. |
15 | 15 | static private $MIN_CHARS_TO_PUSH = 300; // number of chars that need to be changed |
16 | | - |
17 | | - static public function getMinCharsToPush(){ |
| 16 | + |
| 17 | + static public function getMinCharsToPush() { |
18 | 18 | return self::$MIN_CHARS_TO_PUSH; |
19 | 19 | } |
20 | | - |
21 | | - public function init(){ |
22 | | - wfProfileIn(__METHOD__); |
23 | 20 | |
24 | | - wfLoadExtensionMessages('FBPush_OnLargeEdit'); |
25 | | - |
26 | | - wfProfileOut(__METHOD__); |
| 21 | + public function init() { |
| 22 | + wfProfileIn( __METHOD__ ); |
| 23 | + |
| 24 | + wfLoadExtensionMessages( 'FBPush_OnLargeEdit' ); |
| 25 | + |
| 26 | + wfProfileOut( __METHOD__ ); |
27 | 27 | } |
28 | 28 | } |
Index: trunk/extensions/FBConnect/fbconnect.js |
— | — | @@ -4,36 +4,36 @@ |
5 | 5 | * it under the terms of the GNU General Public License as published by |
6 | 6 | * the Free Software Foundation; either version 2 of the License, or |
7 | 7 | * (at your option) any later version. |
8 | | - * |
| 8 | + * |
9 | 9 | * This program is distributed in the hope that it will be useful, |
10 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | * GNU General Public License for more details. |
13 | | - * |
| 13 | + * |
14 | 14 | * You should have received a copy of the GNU General Public License along |
15 | 15 | * with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | 16 | */ |
17 | 17 | |
18 | 18 | /** |
19 | 19 | * fbconnect.js and fbconnect-min.js |
20 | | - * |
| 20 | + * |
21 | 21 | * FBConnect relies on several different libraries and frameworks for its |
22 | 22 | * JavaScript code. Each framework has its own method to verify that the proper |
23 | 23 | * code won't be called before it's ready. (Below, lambda represents a named or |
24 | 24 | * anonymous function.) |
25 | | - * |
| 25 | + * |
26 | 26 | * MediaWiki: addOnloadHook(lambda); |
27 | 27 | * This function manages an array of window.onLoad event handlers to be |
28 | 28 | * called be called by a MediaWiki script when the window is fully loaded. |
29 | 29 | * Because the DOM may be ready before the window (due to large images to |
30 | 30 | * be downloaded), a faster alternative is JQuery's document-ready function. |
31 | | - * |
| 31 | + * |
32 | 32 | * Facebook JavaScript SDK: window.fbAsyncInit = lambda; |
33 | 33 | * This global variable is called when the JavaScript SDK is fully |
34 | 34 | * initialized asynchronously to the document's state. This might be long |
35 | 35 | * after the document is finished rendering the first time the script is |
36 | 36 | * downloaded. Subsequently, it may even be called before the DOM is ready. |
37 | | - * |
| 37 | + * |
38 | 38 | * jQuery: $(document).ready(lambda); |
39 | 39 | * Self-explanatory; to be called when the DOM is ready to be manipulated. |
40 | 40 | * Typically this should occur sooner than MediaWiki's addOnloadHook |
— | — | @@ -56,15 +56,17 @@ |
57 | 57 | |
58 | 58 | // NOTE: Auth.login doesn't appear to work anymore. |
59 | 59 | // The onlogin attribute of the fb:login-buttons is being used instead. |
60 | | - |
| 60 | + |
61 | 61 | // Register a function for when the user logs out of Facebook |
62 | | - FB.Event.subscribe('auth.logout', function(response) { |
| 62 | + FB.Event.subscribe( 'auth.logout', function( response ) { |
63 | 63 | // TODO: Internationalize |
64 | | - var login = confirm("Not logged in.\n\nYou have been loggout out of " + |
65 | | - "Facebook. Press OK to log in via Facebook Connect " + |
66 | | - "again, or press Cancel to stay on the current page."); |
67 | | - if (login) { |
68 | | - window.location = window.wgArticlePath.replace(/\$1/, "Special:Connect"); |
| 64 | + var login = confirm( |
| 65 | + "Not logged in.\n\nYou have been loggout out of " + |
| 66 | + "Facebook. Press OK to log in via Facebook Connect " + |
| 67 | + "again, or press Cancel to stay on the current page." |
| 68 | + ); |
| 69 | + if ( login ) { |
| 70 | + window.location = window.wgArticlePath.replace( /\$1/, 'Special:Connect' ); |
69 | 71 | } |
70 | 72 | }); |
71 | 73 | }; |
— | — | @@ -74,15 +76,15 @@ |
75 | 77 | */ |
76 | 78 | $(document).ready(function() { |
77 | 79 | // Add a pretty logo to Facebook links |
78 | | - $('#pt-fbconnect,#pt-fblink,#pt-fbconvert').addClass('mw-fblink'); |
79 | | - |
| 80 | + $( '#pt-fbconnect,#pt-fblink,#pt-fbconvert' ).addClass( 'mw-fblink' ); |
| 81 | + |
80 | 82 | // Add the logout behavior to the "Logout of Facebook" button |
81 | | - $('#pt-fblogout').click(function() { |
| 83 | + $( '#pt-fblogout' ).click( function() { |
82 | 84 | // TODO: Where did the fancy DHTML window go? Maybe consider jQuery Alert Dialogs: |
83 | 85 | // http://abeautifulsite.net/2008/12/jquery-alert-dialogs/ |
84 | | - var logout = confirm("You are logging out of both this site and Facebook."); |
85 | | - if (logout) { |
86 | | - FB.logout(function(response) { |
| 86 | + var logout = confirm( 'You are logging out of both this site and Facebook.' ); |
| 87 | + if ( logout ) { |
| 88 | + FB.logout( function( response ) { |
87 | 89 | window.location = window.fbLogoutURL; |
88 | 90 | }); |
89 | 91 | } |
— | — | @@ -96,7 +98,7 @@ |
97 | 99 | * |
98 | 100 | * TODO: Also set the value for 'returntoquery'!! |
99 | 101 | */ |
100 | | -function sendToConnectOnLogin(){ |
101 | | - var destUrl = wgServer + wgScript + "?title=Special:Connect&returnto=" + wgPageName + "&returntoquery=" + wgPagequery; |
| 102 | +function sendToConnectOnLogin() { |
| 103 | + var destUrl = wgServer + wgScript + '?title=Special:Connect&returnto=' + wgPageName + '&returntoquery=' + wgPagequery; |
102 | 104 | window.location.href = destUrl; |
103 | 105 | } |
Index: trunk/extensions/FBConnect/config.default.php |
— | — | @@ -9,7 +9,7 @@ |
10 | 10 | * This will be seen by users when they sign up for your site. |
11 | 11 | * 3. Enter the Site URL and Locale, then click "Create application". |
12 | 12 | * 4. Copy the displayed App ID and Secret into this config file. |
13 | | - * |
| 13 | + * |
14 | 14 | * Optionally, you may customize your application: |
15 | 15 | * A. Click "developer dashboard" link on the previous screen or visit: |
16 | 16 | * http://www.facebook.com/developers/apps.php |
— | — | @@ -43,7 +43,7 @@ |
44 | 44 | * $wgAllowExternalImages with the added benefit that all photos are screened |
45 | 45 | * against Facebook's Code of Conduct <http://www.facebook.com/codeofconduct.php> |
46 | 46 | * and subject to dynamic privacy. To disable just <fb:photo> tags, set this to false. |
47 | | - * |
| 47 | + * |
48 | 48 | * Disabled until the JavaScript SDK supports <fb:photo> tags. |
49 | 49 | */ |
50 | 50 | #$wgFbAllowFacebookImages = true; |
— | — | @@ -51,11 +51,11 @@ |
52 | 52 | /** |
53 | 53 | * For easier wiki rights management, create a group on Facebook and place the |
54 | 54 | * group ID here. Three new implicit groups will be created: |
55 | | - * |
| 55 | + * |
56 | 56 | * fb-groupie A member of the specified group |
57 | 57 | * fb-officer A group member with an officer title |
58 | 58 | * fb-admin An administrator of the Facebook group |
59 | | - * |
| 59 | + * |
60 | 60 | * By default, they map to User, Bureaucrat and Sysop privileges, respectively. |
61 | 61 | * Users will automatically be promoted or demoted when their membership, title |
62 | 62 | * or admin status is modified from the group page within Facebook. |
— | — | @@ -68,7 +68,7 @@ |
69 | 69 | |
70 | 70 | /** |
71 | 71 | * Options regarding the personal toolbar (in the upper right). |
72 | | - * |
| 72 | + * |
73 | 73 | * == Key == == Effect == |
74 | 74 | * hide_connect_button Hides the "Log in with Facebook Connect" button. |
75 | 75 | * hide_convert_button Hides "Connect this account with Facebook" for non- |
— | — | @@ -80,7 +80,7 @@ |
81 | 81 | * "in front" of Facebook. |
82 | 82 | * remove_user_talk_link Remove link to user's talk page |
83 | 83 | * use_real_name_from_fb Show the real name for all Connected users |
84 | | - * |
| 84 | + * |
85 | 85 | * Additionally, use $wgShowIPinHeader to hide the IP and its talk link. |
86 | 86 | * For more information, see <http://www.mediawiki.org/wiki/Manual:$wgShowIPinHeader>. |
87 | 87 | */ |
— | — | @@ -105,7 +105,7 @@ |
106 | 106 | * a beta release, changes to the APIs may be made on a regular basis. If you |
107 | 107 | * use FBConnect on your production website, you may wish to insulate yourself |
108 | 108 | * from these changes by downloading and hosting your own copy of the library. |
109 | | - * |
| 109 | + * |
110 | 110 | * For more info, see <http://developers.facebook.com/docs/reference/javascript/> |
111 | 111 | */ |
112 | 112 | $wgFbScript = 'http://connect.facebook.net/en_US/all.js'; |
— | — | @@ -173,9 +173,9 @@ |
174 | 174 | * of the push events to use. |
175 | 175 | */ |
176 | 176 | $wgFbEnablePushToFacebook = false; |
177 | | -if(!empty($wgFbEnablePushToFacebook)){ |
178 | | - $fbPushDir = dirname(__FILE__) . '/pushEvents/'; |
179 | | - |
| 177 | +if( !empty( $wgFbEnablePushToFacebook ) ) { |
| 178 | + $fbPushDir = dirname( __FILE__ ) . '/pushEvents/'; |
| 179 | + |
180 | 180 | // Convenience loop for push event classes in the fbPushDir directory |
181 | 181 | // whose file-name corresponds to the class-name. To add a push event |
182 | 182 | // which does not meet these criteria, just explicitly add it below. |
— | — | @@ -184,7 +184,7 @@ |
185 | 185 | 'FBPush_OnLargeEdit', |
186 | 186 | 'FBPush_OnWatchArticle', |
187 | 187 | ); |
188 | | - foreach($pushEventClassNames as $pClassName){ |
| 188 | + foreach( $pushEventClassNames as $pClassName ) { |
189 | 189 | $fbPushEventClasses[] = $pClassName; |
190 | 190 | $wgAutoloadClasses[$pClassName] = $fbPushDir . "$pClassName.php"; |
191 | 191 | } |