public function execute() { global $wgFbStreamlineLogin; if (!empty($wgFbStreamlineLogin)) { $params = $this->extractRequestParams(); $fbUser = new FacebookUser($params['id']); $id = $fbUser->getMWUser()->getId(); if ($id) { //wfLoadExtensionMessages('Facebook'); // Deprecated since 1.16 $specialConnect = new SpecialConnect(); $this->getResult()->addValue(null, null, $specialConnect->getLogoutAndContinueForm($params, $id)); } else { // TODO: Add a LogoutAndCreateNewUser form to SpecialConnect.php. For // now, return an empty response to send user to Special:Connect // (which displays an error message). } } }
/** * Modify the user's persinal toolbar (in the upper right). * * * @param $personal_urls * @param $wgTitle Title * TODO: Better 'returnto' code */ public static function PersonalUrls(&$personal_urls, &$wgTitle) { global $wgUser, $fbPersonalUrls, $fbConnectOnly, $wgEnableUserLoginExt; $skinName = get_class($wgUser->getSkin()); // Get the logged-in user from the Facebook API $fb = new FBConnectAPI(); $fb_user = $fb->user(); $ids = FBConnectDB::getFacebookIDs($wgUser); /* * Personal URLs option: remove_user_talk_link */ if ($fbPersonalUrls['remove_user_talk_link'] && array_key_exists('mytalk', $personal_urls)) { unset($personal_urls['mytalk']); } // If the user is logged in and connected if ($wgUser->isLoggedIn() && $fb_user && count($ids) > 0) { /* * Personal URLs option: use_real_name_from_fb */ $option = $fbPersonalUrls['use_real_name_from_fb']; if ($option === true || $option && strpos($wgUser->getName(), $option) === 0) { // Start with the real name in the database $name = $wgUser->getRealName(); // Ask Facebook for the real name if (!$name || $name == '') { $name = $fb->userName(); } // Make sure we were able to get a name from the database or Facebook if ($name && $name != '') { $personal_urls['userpage']['text'] = $name; } } /* * Personal URLs option: link_back_to_facebook */ if ($fbPersonalUrls['link_back_to_facebook']) { $personal_urls['fblink'] = array('text' => wfMsg('fbconnect-link'), 'href' => "http://www.facebook.com/profile.php?id={$fb_user}", 'active' => false); } } else { if ($wgUser->isLoggedIn()) { /* * Personal URLs option: hide_convert_button */ if (!$fbPersonalUrls['hide_convert_button']) { if ($skinName == "SkinMonaco") { $personal_urls['fbconvert'] = array('text' => wfMsg('fbconnect-convert'), 'href' => SpecialConnect::getTitleFor('Connect', 'Convert')->getLocalURL('returnto=' . $wgTitle->getPrefixedURL()), 'active' => $wgTitle->isSpecial('Connect')); } } } else { /* * Personal URLs option: hide_connect_button */ if (!$fbPersonalUrls['hide_connect_button']) { // Add an option to connect via Facebook Connect // RT#57141 - only show the connect link on monaco and answers. if (in_array($skinName, array('SkinMonaco', 'SkinAnswers', 'SkinOasis'))) { // answers skin might actually get caught under SkinMonaco below. Regardless, all other skins shouldn't get this link. $personal_urls['fbconnect'] = array('text' => wfMsg('fbconnect-connect'), 'class' => 'fb_button fb_button_small', 'href' => '#', 'active' => $wgTitle->isSpecial('Connect')); } if (in_array($skinName, array('SkinMonaco', 'SkinOasis')) && empty($wgEnableUserLoginExt)) { $html = Xml::openElement("span", array("id" => 'fbconnect')); $html .= Xml::openElement("a", array("href" => '#', 'class' => 'fb_button fb_button_small')); $html .= Xml::openElement("span", array("class" => "fb_button_text")); $html .= wfMsg('fbconnect-connect-simple'); $html .= Xml::closeElement("span"); $html .= Xml::closeElement("a"); $html .= Xml::closeElement("span"); $personal_urls['fbconnect']['html'] = $html; } } // Remove other personal toolbar links if ($fbConnectOnly) { foreach (array('login', 'anonlogin') as $k) { if (array_key_exists($k, $personal_urls)) { unset($personal_urls[$k]); } } } } } return true; }