45 require_once
'Auth/OpenID/Message.php';
46 require_once
'Auth/OpenID/Extension.php';
51 'fullname' =>
'Full Name',
52 'nickname' =>
'Nickname',
53 'dob' =>
'Date of Birth',
54 'email' =>
'E-mail Address',
56 'postcode' =>
'Postal Code',
57 'country' =>
'Country',
58 'language' =>
'Language',
59 'timezone' =>
'Time Zone');
69 if (!in_array($field_name, array_keys($Auth_OpenID_sreg_data_fields))) {
77 define(
'Auth_OpenID_SREG_NS_URI_1_0',
'http://openid.net/sreg/1.0');
81 define(
'Auth_OpenID_SREG_NS_URI_1_1',
'http://openid.net/extensions/sreg/1.1');
128 $found_ns_uri = null;
134 $alias = $message->namespaces->getAlias($sreg_ns_uri);
135 if ($alias !== null) {
136 $found_ns_uri = $sreg_ns_uri;
141 if ($alias === null) {
154 return $found_ns_uri;
176 static function build($required=null, $optional=null,
179 $cls=
'Auth_OpenID_SRegRequest')
183 $obj->required = array();
184 $obj->optional = array();
185 $obj->policy_url = $policy_url;
186 $obj->ns_uri = $sreg_ns_uri;
189 if (!$obj->requestFields($required,
true,
true)) {
195 if (!$obj->requestFields($optional,
false,
true)) {
219 $obj = call_user_func_array(array($cls,
'build'),
224 $m = $request->message;
226 $obj->ns_uri = $obj->_getSRegNS($m);
227 $args = $m->getArgs($obj->ns_uri);
233 $obj->parseExtensionArgs($args);
264 foreach (array(
'required',
'optional') as $list_name) {
265 $required = ($list_name ==
'required');
268 foreach (explode(
',', $items) as $field_name) {
269 if (!$this->
requestField($field_name, $required, $strict)) {
289 return array_merge($this->required, $this->optional);
305 return (in_array($field_name, $this->required) ||
306 in_array($field_name, $this->optional));
321 $required=
false, $strict=
false)
332 if (in_array($field_name, $this->required)) {
336 if (in_array($field_name, $this->optional)) {
338 unset($this->optional[array_search($field_name,
347 $this->required[] = $field_name;
349 $this->optional[] = $field_name;
368 if (!is_array($field_names)) {
372 foreach ($field_names as $field_name) {
373 if (!$this->
requestField($field_name, $required, $strict=$strict)) {
393 if ($this->required) {
394 $args[
'required'] = implode(
',', $this->required);
397 if ($this->optional) {
398 $args[
'optional'] = implode(
',', $this->optional);
401 if ($this->policy_url) {
402 $args[
'policy_url'] = $this->policy_url;
424 if ($data === null) {
425 $this->data = array();
430 $this->ns_uri = $sreg_ns_uri;
448 $obj->ns_uri = $request->ns_uri;
450 foreach ($request->allRequestedFields() as $field) {
452 if ($value !== null) {
453 $obj->data[$field] = $value;
479 $obj->ns_uri = $obj->_getSRegNS($success_response->message);
482 $args = $success_response->getSignedNS($obj->ns_uri);
484 $args = $success_response->message->getArgs($obj->ns_uri);
491 foreach ($Auth_OpenID_sreg_data_fields as $field_name => $desc) {
492 if (in_array($field_name, array_keys($args))) {
493 $obj->data[$field_name] = $args[$field_name];
506 function get($field_name, $default=null)