/** * Connects given Wikia account with FB account and sets FB feed preferences * * @param User $user Wikia account */ private function connectWithFacebook(User $user) { FBConnectDB::addFacebookID($user, $this->fbUserId); foreach ($this->fbFeedOptions as $feedName) { $optionName = "fbconnect-push-allow-{$feedName}"; $user->setOption($optionName, 1); } }
/** * Attaches the Facebook ID to an existing wiki account. If the user does * not exist, or the supplied password does not match, then an error page * is sent. Otherwise, the accounts are matched in the database and the new * user object is logged in. * * NOTE: This isn't used by Wikia and hasn't been tested with some of the new * code. Does it handle setting push-preferences correctly? */ protected function attachUser($fb_user, $name, $password) { global $wgOut, $wgUser; wfProfileIn(__METHOD__); // The user must be logged into Facebook before choosing a wiki username if (!$fb_user) { wfDebug("FBConnect: aborting in attachUser(): no Facebook ID was reported.\n"); $wgOut->showErrorPage('fbconnect-error', 'fbconnect-errortext'); return; } // Look up the user by their name $user = new FBConnectUser(User::newFromName($name)); if (!$user || !$user->checkPassword($password)) { $this->sendPage('chooseNameForm', 'wrongpassword'); return; } // Attach the user to their Facebook account in the database FBConnectDB::addFacebookID($user, $fb_user); // Update the user with settings from Facebook $user->updateFromFacebook(); // Store the user in the global user object $wgUser = $user; wfRunHooks('SpecialConnect::userAttached', array(&$this)); $this->sendPage('displaySuccessAttaching'); wfProfileOut(__METHOD__); }