本文整理汇总了PHP中Gdn_AuthenticationProviderModel::Save方法的典型用法代码示例。如果您正苦于以下问题:PHP Gdn_AuthenticationProviderModel::Save方法的具体用法?PHP Gdn_AuthenticationProviderModel::Save怎么用?PHP Gdn_AuthenticationProviderModel::Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gdn_AuthenticationProviderModel
的用法示例。
在下文中一共展示了Gdn_AuthenticationProviderModel::Save方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Controller_Index
public function Controller_Index($Sender)
{
$this->AddSliceAsset($this->GetResource('css/wordpress.css', FALSE, FALSE));
$ProviderModel = new Gdn_AuthenticationProviderModel();
$LastState = NULL;
$State = NULL;
do {
$LastState = $State;
$State = $this->State($this->ProxyConnect->Provider);
$Sender->SetData('IntegrationState', $State);
switch ($State) {
case 'Address':
// Gather remote address from user.
// User has submitted the form and provided a URL
if ($Sender->Form->AuthenticatedPostBack()) {
// Address supplied. Query the remote blog.
$Address = $Sender->Form->GetValue('WordpressUrl', NULL);
if (empty($Address)) {
$Sender->Form->AddError("Please enter the URL for your blog.");
return $this->GetView('wordpress.php');
}
$this->ProxyConnect->Provider['URL'] = $Address;
$Response = $this->QueryRemote($this->ProxyConnect->Provider, 'Check', NULL, FALSE);
if (GetValue('X-ProxyConnect-Enabled', $Response) == 'yes') {
// Proxyconnect is enabled at the provided URL.
$ProviderModel->Save($this->ProxyConnect->Provider);
} else {
unset($this->ProxyConnect->Provider['URL']);
$Sender->Form->AddError("Unable to contact remote plugin. Perhaps your blog URL was incorrect?");
return $this->GetView('wordpress.php');
}
} else {
// break out of the loop and let the form render
break 2;
}
break;
case 'Exchange':
if ($LastState == $State) {
// exchanging again.
$Sender->Form->AddError("Unable to poll remote plugin for all required information. Switch to manual integration.");
return $this->GetView('wordpress.php');
}
// 1: push challenge key to remote.
// 2: gather urls
// 3: set cookie domain
// 1 - push challenge key
$Response = $this->QueryRemote($this->ProxyConnect->Provider, 'Secure', array('Challenge' => GetValue('AssociationSecret', $this->ProxyConnect->Provider, 'flam')));
$ChallengeSet = GetValue('X-Autoconfigure-Challenge', $Response);
if ($ChallengeSet != 'set') {
$Sender->Form->AddError("Could not set Challenge key on remote. Reason was: challenge {$ChallengeSet}");
return $this->GetView('wordpress.php');
}
// 2 - gather URLs
$Response = $this->QueryRemote($this->ProxyConnect->Provider, 'Exchange', NULL, TRUE, TRUE);
$Result = json_decode($Response);
$CheckURLs = array('AuthenticateUrl', 'RegisterUrl', 'SignInUrl', 'SignOutUrl', 'PasswordUrl', 'ProfileUrl');
foreach ($CheckURLs as $CheckURL) {
$Value = GetValue($CheckURL, $Result, NULL);
if (!is_null($Value)) {
$this->ProxyConnect->Provider[$CheckURL] = $Value;
}
}
// save the provider data
$ProviderModel->Save($this->ProxyConnect->Provider);
// 3 - set cookie domain
$ExplodedDomain = explode('.', Gdn::Request()->RequestHost());
if (sizeof($ExplodedDomain) == 1) {
$GuessedCookieDomain = '';
} else {
$GuessedCookieDomain = '.' . implode('.', array_slice($ExplodedDomain, -2, 2));
}
$Response = $this->QueryRemote($this->ProxyConnect->Provider, 'Cookie', array('CookieDomain' => $GuessedCookieDomain), TRUE, TRUE);
if (GetValue('X-Autoconfigure-Cookie', $Response, NULL) == 'set') {
// Set local cookie domain too
SaveToConfig('Garden.Cookie.Domain', $GuessedCookieDomain);
}
break;
case NULL:
// provider is fully configured.
$Sender->SetData('BlogURL', GetValue('URL', $this->ProxyConnect->Provider));
break;
case 'Error':
return $this->GetView('providerfailed.php');
break;
}
} while (!is_null($State));
return $this->GetView('wordpress.php');
}