function encodeToURL($server_url)
{
if (!$this->return_to) {
return new Auth_OpenID_NoReturnToError();
}
// Imported from the alternate reality where these classes are
// used in both the client and server code, so Requests are
// Encodable too. That's right, code imported from alternate
// realities all for the love of you, id_res/user_setup_url.
$q = array('mode' => $this->mode,
'identity' => $this->identity,
'claimed_id' => $this->claimed_id,
'return_to' => $this->return_to);
if ($this->trust_root) {
if ($this->message->isOpenID1()) {
$q['trust_root'] = $this->trust_root;
} else {
$q['realm'] = $this->trust_root;
}
}
if ($this->assoc_handle) {
$q['assoc_handle'] = $this->assoc_handle;
}
$response = new Auth_OpenID_Message(
$this->message->getOpenIDNamespace());
$response->updateArgs(Auth_OpenID_OPENID_NS, $q);
return $response->toURL($server_url);
}