作者:Stony-Brook-Universit
项目:doitsb
function test_two()
{
$uri1 = 'http://janrain.com/';
$alias1 = 'openid_hackers';
$this->aliases->addAlias($uri1, $alias1);
$uri2 = 'http://jyte.com/';
$alias2 = 'openid_hack';
$this->aliases->addAlias($uri2, $alias2);
$uris = Auth_OpenID_AX_toTypeURIs($this->aliases, implode(',', array($alias1, $alias2)));
$this->assertEquals(array($uri1, $uri2), $uris);
}
作者:kaantun
项目:MYK-BO
/**
* Given attribute exchange arguments, populate this FetchRequest.
*
* @return $result Auth_OpenID_AX_Error if the data to be parsed
* does not follow the attribute exchange specification. At least
* when 'if_available' or 'required' is not specified for a
* particular attribute type. Returns true otherwise.
*/
function parseExtensionArgs($ax_args)
{
$result = $this->_checkMode($ax_args);
if (Auth_OpenID_AX::isError($result)) {
return $result;
}
$aliases = new Auth_OpenID_NamespaceMap();
foreach ($ax_args as $key => $value) {
if (strpos($key, 'type.') === 0) {
$alias = substr($key, 5);
$type_uri = $value;
$alias = $aliases->addAlias($type_uri, $alias);
if ($alias === null) {
return new Auth_OpenID_AX_Error(sprintf("Could not add alias %s for URI %s", $alias, $type_uri));
}
$count_s = Auth_OpenID::arrayGet($ax_args, 'count.' . $alias);
if ($count_s) {
$count = Auth_OpenID::intval($count_s);
if ($count === false && $count_s === Auth_OpenID_AX_UNLIMITED_VALUES) {
$count = $count_s;
}
} else {
$count = 1;
}
if ($count === false) {
return new Auth_OpenID_AX_Error(sprintf("Integer value expected for %s, got %s", 'count.' . $alias, $count_s));
}
$attrinfo = Auth_OpenID_AX_AttrInfo::make($type_uri, $count, false, $alias);
if (Auth_OpenID_AX::isError($attrinfo)) {
return $attrinfo;
}
$this->add($attrinfo);
}
}
$required = Auth_OpenID_AX_toTypeURIs($aliases, Auth_OpenID::arrayGet($ax_args, 'required'));
foreach ($required as $type_uri) {
$attrib =& $this->requested_attributes[$type_uri];
$attrib->required = true;
}
$if_available = Auth_OpenID_AX_toTypeURIs($aliases, Auth_OpenID::arrayGet($ax_args, 'if_available'));
$all_type_uris = array_merge($required, $if_available);
foreach ($aliases->iterNamespaceURIs() as $type_uri) {
if (!in_array($type_uri, $all_type_uris)) {
return new Auth_OpenID_AX_Error(sprintf('Type URI %s was in the request but not ' . 'present in "required" or "if_available"', $type_uri));
}
}
$this->update_url = Auth_OpenID::arrayGet($ax_args, 'update_url');
return true;
}