Exemplo n.º 1
0
 /**
 * This hook is unused.
 *
 	public static function SkinTemplatePageBeforeUserMsg(&$msg) {
 		global $wgRequest, $wgUser, $wgServer, $facebook;
 		//wfLoadExtensionMessages('Facebook'); // Deprecated since 1.16
 		$pref = Title::newFromText('Preferences', NS_SPECIAL);
 		if ($wgRequest->getVal('fbconnected', '') == 1) {
 			$id = FacebookDB::getFacebookIDs($wgUser, DB_MASTER);
 			if( count($id) > 0 ) {
 				$msg =  Xml::element("img", array("id" => "fbMsgImage", "src" => $wgServer.'/skins/common/fbconnect/fbiconbig.png' ));
 				$msg .= "<p>".wfMsg('facebook-connect-msg', array("$1" => $pref->getFullUrl() ))."</p>";
 			}
 		}
 		if ($wgRequest->getVal('fbconnected', '') == 2) {
 			if( strlen($facebook->getUser()) < 1 ) {
 				$msg =  Xml::element("img", array("id" => "fbMsgImage", "src" => $wgServer.'/skins/common/fbconnect/fbiconbig.png' ));
 				$msg .= "<p>".wfMsgExt('facebook-connect-error-msg', 'parse', array("$1" => $pref->getFullUrl() ))."</p>";
 			}
 		}
 		return true;
 	}
 	
 	/**
 * Show the real name of users on Special:ListUsers if $wgFbUseRealName is
 * true. The local database is queried first for two reasons: performance
 * (each Facebook lookup is done separately) and an OAuth access_token may
 * be required to query the Facebook user's name (our access token is
 * usually only valid for the currently-logged-in user).
 */
 static function SpecialListusersFormatRow(&$item, $row)
 {
     global $wgFbUseRealName, $wgFbLogo;
     if (!empty($wgFbUseRealName)) {
         $user = User::newFromId($row->user_id);
         $fb_ids = FacebookDB::getFacebookIDs($user);
         if (count($fb_ids)) {
             // Start with the real name in the database
             $name = $user->getRealName();
             if (empty($name)) {
                 // Ask Facebook for the real name
                 $fbUser = new FacebookUser($fb_ids[0]);
                 $name = $fbUser->getUserInfo('name');
             }
             // Make sure we were able to get a name from the database or Facebook
             if (!empty($name)) {
                 // Instead of regexes, we know the text so just search for it
                 $item = str_replace(">{$row->user_name}</a>", ">{$name}</a>", $item);
             }
             // Add a pretty Facebook logo next to Facebook users
             if (!empty($wgFbLogo)) {
                 // Look to see if class="..." appears in the link
                 $regs = array();
                 preg_match('/^([^>]*?)class=(["\'])([^"]*)\\2(.*)/', $item, $regs);
                 if (count($regs)) {
                     // If so, append "mw-facebook-logo" to the end of the class list
                     $item = $regs[1] . "class={$regs['2']}{$regs['3']} mw-facebook-logo{$regs['2']}" . $regs[4];
                 } else {
                     // Otherwise, stick class="mw-facebook-logo" into the link just before the '>'
                     preg_match('/^([^>]*)(.*)/', $item, $regs);
                     $item = $regs[1] . ' class="mw-facebook-logo"' . $regs[2];
                 }
             }
         }
     }
     return true;
 }
 /**
  * This error page is shown when the user logs in to Facebook, but the
  * Facebook account is associated with a different user.
  * 
  * A precondition is that a different MediaWiki user is logged in. So, ask
  * them to log out and continue.
  * 
  * TODO: But what about the case where a Facebook user is logged in, but
  * not as a wiki user, and then logs into the wiki with the wrong account?
  */
 private function logoutAndContinueView($userId)
 {
     global $wgOut;
     $wgOut->setPageTitle(wfMsg('facebook-logout-and-continue'));
     $fbUser = new FacebookUser();
     $userinfo = $fbUser->getUserInfo();
     $form = $this->getLogoutAndContinueForm($userinfo, $userId);
     // TODO
     //$form .= '<p>Not $userId? Log in as a different facebook user...</p>';
     $wgOut->addHTML($form . "<br/>\n");
     // Render the "Return to" text retrieved from the URL
     $wgOut->returnToMain(false, $this->mReturnTo, $this->mReturnToQuery);
 }