function checkCreateAccount() { global $wgUser; $response = new AjaxResponse(); $fb = new FBConnectAPI(); $fb_user = $fb->user(); $error = json_encode(array("status" => "error")); if (empty($fb_user)) { $response->addText($error); return $response; } if ((int) $wgUser->getId() != 0) { $response->addText($error); return $response; } if (FBConnectDB::getUser($fb_user) != null) { $response->addText($error); return $response; } $titleObj = SpecialPage::getTitleFor('Connect'); if (wfReadOnly()) { $response->addText($error); return $response; } if ($wgUser->isBlockedFromCreateAccount()) { $response->addText($error); return $response; } if (count($permErrors = $titleObj->getUserPermissionsErrors('createaccount', $wgUser, true)) > 0) { $response->addText($error); return $response; } $response->addText(json_encode(array("status" => "ok"))); return $response; }
function mainLoginForm(&$specialConnect, $msg, $msgtype = 'error') { global $wgUser, $wgOut, $wgHiddenPrefs, $wgEnableEmail; global $wgCookiePrefix, $wgLoginLanguageSelector; global $wgAuth, $wgEmailConfirmToEdit, $wgCookieExpiration, $wgRequest; $this->msg = $msg; $this->msgtype = $msgtype; $tmpl = new ChooseNameTemplate(); $tmpl->addInputItem('wpMarketingOptIn', 1, 'checkbox', 'tog-marketingallowed'); $returnto = ""; if (!empty($this->mReturnTo)) { $returnto = '&returnto=' . wfUrlencode($this->mReturnTo); if (!empty($this->mReturnToQuery)) { $returnto .= '&returntoquery=' . wfUrlencode($this->mReturnToQuery); } } $tmpl->set('actioncreate', $specialConnect->getTitle('ChooseName')->getLocalUrl($returnto)); $tmpl->set('link', ''); $tmpl->set('header', ''); //$tmpl->set( 'name', $this->mUsername ); // intelligently defaulted below $tmpl->set('password', $this->mPassword); $tmpl->set('retype', $this->mRetype); $tmpl->set('actiontype', $this->mActionType); $tmpl->set('realname', $this->mRealName); $tmpl->set('domain', $this->mDomain); $tmpl->set('message', $msg); $tmpl->set('messagetype', $msgtype); $tmpl->set('createemail', $wgEnableEmail && $wgUser->isLoggedIn()); $tmpl->set('userealname', !in_array('realname', $wgHiddenPrefs)); $tmpl->set('useemail', $wgEnableEmail); $tmpl->set('emailrequired', $wgEmailConfirmToEdit); $tmpl->set('canreset', $wgAuth->allowPasswordChange()); $tmpl->set('canremember', $wgCookieExpiration > 0); $tmpl->set('remember', $wgUser->getOption('rememberpassword') or $this->mRemember); $tmpl->set('birthyear', $this->wpBirthYear); $tmpl->set('birthmonth', $this->wpBirthMonth); $tmpl->set('birthday', $this->wpBirthDay); # Prepare language selection links as needed if ($wgLoginLanguageSelector) { $tmpl->set('languages', $this->makeLanguageSelector()); if ($this->mLanguage) { $tmpl->set('uselang', $this->mLanguage); } } // Facebook-specific customizations below. global $fbConnectOnly; // Connect to the Facebook API $fb = new FBConnectAPI(); $fb_user = $fb->user(); $userinfo = $fb->getUserInfo($fb_user); // If no email was set yet, then use the value from facebook (which is quite likely also empty, but probably not always). if (!$this->mEmail) { $this->mEmail = FBConnectUser::getOptionFromInfo('email', $userinfo); } $tmpl->set('email', $this->mEmail); // If the langue isn't set already and there is a setting for it from facebook, apply that. if (!$this->mLanguage) { $this->mLanguage = FBConnectUser::getOptionFromInfo('language', $userinfo); } if ($this->mLanguage) { $tmpl->set('uselang', $this->mLanguage); } // Make this an intelligent guess at a good username (based off of their nickname, real name, etc.). if (!$this->mUsername) { if ($wgUser->isLoggedIn()) { $this->mUsername = $wgUser->getName(); } else { $nickname = FBConnectUser::getOptionFromInfo('nickname', $userinfo); if (self::userNameOK($nickname)) { $this->mUsername = $nickname; } else { $fullname = FBConnectUser::getOptionFromInfo('fullname', $userinfo); if (self::userNameOK($fullname)) { $this->mUsername = $fullname; } else { if (empty($nickname)) { $nickname = $fullname; } // Their nickname and full name were taken, so generate a username based on the nickname. $specialConnect->setUserNamePrefix($nickname); $this->mUsername = $specialConnect->generateUserName(); } } } } $tmpl->set('name', $this->mUsername); /* // NOTE: We're not using this at the moment because it seems that there is no need to show these boxes... we'll just default to updating nothing on login (to avoid confusion & to make signup quicker). // Create the checkboxes for the user options. global $wgCookiePrefix; $name = isset($_COOKIE[$wgCookiePrefix . 'UserName']) ? trim($_COOKIE[$wgCookiePrefix . 'UserName']) : ''; // Build an array of attributes to update $updateOptions = array(); foreach ($specialConnect->getAvailableUserUpdateOptions() as $option) { // Translate the MW parameter into a FB parameter $value = FBConnectUser::getOptionFromInfo($option, $userinfo); // If no corresponding value was received from Facebook, then continue if (!$value) { continue; } // Build the list item for the update option $updateOptions[] = "<li><input name=\"wpUpdateUserInfo$option\" type=\"checkbox\" " . "value=\"1\" id=\"wpUpdateUserInfo$option\" /><label for=\"wpUpdateUserInfo$option\">" . wfMsgHtml("fbconnect-$option") . wfMsgExt('colon-separator', array('escapenoentities')) . " <i>$value</i></label></li>"; } // Implode the update options into an unordered list $updateChoices = count($updateOptions) > 0 ? "\n" . wfMsgHtml('fbconnect-updateuserinfo') . "\n<ul>\n" . implode("\n", $updateOptions) . "\n</ul>\n" : ''; $html = "<tr style='display:none'><td>$updateChoices</td></tr>"; $tmpl->set( 'updateOptions', $html); */ $tmpl->set('updateOptions', ''); // Give authentication and captcha plugins a chance to modify the form // NOTE: We don't do this for fbconnect. //$wgAuth->modifyUITemplate( $template ); //wfRunHooks( 'UserCreateForm', array( &$template ) ); $this->ajaxTemplate = $tmpl; }
/** * isFbConnectionNeeded -- checkes is everything OK with Facebook connection * * @access public * @author Jakub * * @return boolean */ public static function isFbConnectionNeeded() { global $wgRequireFBConnectionToComment, $wgEnableFacebookConnectExt, $wgUser; if (!empty($wgRequireFBConnectionToComment) && !empty($wgEnableFacebookConnectExt)) { $fb = new FBConnectAPI(); $tmpArrFaceBookId = FBConnectDB::getFacebookIDs($wgUser); $isFBConnectionProblem = $fb->user() == 0 || !isset($tmpArrFaceBookId[0]) || (int) $fb->user() != (int) $tmpArrFaceBookId[0]; return $isFBConnectionProblem; } else { return false; } }
/** * Handle confirmations from Facebook Connect */ public static function addFacebookConnectConfirmation(&$html) { wfProfileIn(__METHOD__); global $wgRequest, $wgUser; // FBConnect messages if ( F::app()->checkSkin( 'oasis' ) && class_exists('FBConnectHooks')) { $preferencesUrl = SpecialPage::getTitleFor('Preferences')->getFullUrl(); $fbStatus = $wgRequest->getVal('fbconnected'); switch($fbStatus) { // success case 1: $id = FBConnectDB::getFacebookIDs($wgUser, DB_MASTER); if (count($id) > 0) { global $wgEnableFacebookSync; if ($wgEnableFacebookSync == true) { $userURL = AvatarService::getUrl($wgUser->mName); self::addConfirmation(wfMsg('fbconnect-connect-msg-sync-profile', $preferencesUrl, $userURL)); } else { self::addConfirmation(wfMsg('fbconnect-connect-msg', $preferencesUrl)); } } break; // error case 2: $fb = new FBConnectAPI(); if (strlen($fb->user()) < 1) { self::addConfirmation(wfMsgExt('fbconnect-connect-error-msg', array('parseinline'), $preferencesUrl), self::CONFIRMATION_ERROR); } break; } } wfProfileOut(__METHOD__); return true; }
public static function SkinTemplatePageBeforeUserMsg(&$msg) { global $wgRequest, $wgUser, $wgServer; $pref = Title::newFromText("Preferences", NS_SPECIAL); if ($wgRequest->getVal("fbconnected", "") == 1) { $id = FBConnectDB::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('fbconnect-connect-msg', array("\$1" => $pref->getFullUrl())) . "</p>"; /** Wikia change - starts @author Andrzej 'nAndy' Łukaszewski */ wfRunHooks('FounderProgressBarOnFacebookConnect'); /** Wikia change - ends */ } } if ($wgRequest->getVal("fbconnected", "") == 2) { $fb = new FBConnectAPI(); if (strlen($fb->user()) < 1) { $msg = Xml::element("img", array("id" => "fbMsgImage", "src" => $wgServer . '/skins/common/fbconnect/fbiconbig.png')); $msg .= "<p>" . wfMsgExt('fbconnect-connect-error-msg', 'parse', array("\$1" => $pref->getFullUrl())) . "</p>"; } } return true; }