mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-01 12:23:50 +01:00
missing @type="NameComponent" and updated examples in docu with @type
This commit is contained in:
parent
8e67e2efad
commit
15a2e546ea
@ -96,15 +96,11 @@ class JsContact
|
|||||||
switch ($name)
|
switch ($name)
|
||||||
{
|
{
|
||||||
case 'uid':
|
case 'uid':
|
||||||
if (!is_string($value) || empty($value))
|
$contact['uid'] = self::parseUid($value);
|
||||||
{
|
|
||||||
throw new \InvalidArgumentException("Missing or invalid uid value!");
|
|
||||||
}
|
|
||||||
$contact['uid'] = $value;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'name':
|
case 'name':
|
||||||
$contact += self::parseNameComponents($value);
|
$contact += self::parseNameComponents($value, $check_at_type);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'fullName':
|
case 'fullName':
|
||||||
@ -981,6 +977,8 @@ class JsContact
|
|||||||
'suffix' => 'n_suffix',
|
'suffix' => 'n_suffix',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const TYPE_NAME_COMPONENT = 'NameComponent';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return name-components objects with "type" and "value" attributes
|
* Return name-components objects with "type" and "value" attributes
|
||||||
*
|
*
|
||||||
@ -996,7 +994,11 @@ class JsContact
|
|||||||
}, self::$nameType2attribute));
|
}, self::$nameType2attribute));
|
||||||
return array_map(function($type, $value)
|
return array_map(function($type, $value)
|
||||||
{
|
{
|
||||||
return ['type' => $type, 'value' => $value];
|
return [
|
||||||
|
self::AT_TYPE => self::TYPE_NAME_COMPONENT,
|
||||||
|
'type' => $type,
|
||||||
|
'value' => $value,
|
||||||
|
];
|
||||||
}, array_keys($components), array_values($components));
|
}, array_keys($components), array_values($components));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1006,7 +1008,7 @@ class JsContact
|
|||||||
* @param array $components
|
* @param array $components
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected static function parseNameComponents(array $components)
|
protected static function parseNameComponents(array $components, bool $check_at_type=true)
|
||||||
{
|
{
|
||||||
$contact = array_combine(array_values(self::$nameType2attribute),
|
$contact = array_combine(array_values(self::$nameType2attribute),
|
||||||
array_fill(0, count(self::$nameType2attribute), null));
|
array_fill(0, count(self::$nameType2attribute), null));
|
||||||
@ -1017,6 +1019,10 @@ class JsContact
|
|||||||
{
|
{
|
||||||
throw new \InvalidArgumentException("Invalid name-component (must have type and value attributes): ".json_encode($component, self::JSON_OPTIONS_ERROR));
|
throw new \InvalidArgumentException("Invalid name-component (must have type and value attributes): ".json_encode($component, self::JSON_OPTIONS_ERROR));
|
||||||
}
|
}
|
||||||
|
if ($check_at_type && $component[self::AT_TYPE] !== self::TYPE_NAME_COMPONENT)
|
||||||
|
{
|
||||||
|
throw new \InvalidArgumentException("Missing or invalid @type: ".json_encode($component, self::JSON_OPTIONS_ERROR));
|
||||||
|
}
|
||||||
$contact[self::$nameType2attribute[$component['type']]] = $component['value'];
|
$contact[self::$nameType2attribute[$component['type']]] = $component['value'];
|
||||||
}
|
}
|
||||||
return $contact;
|
return $contact;
|
||||||
|
@ -62,12 +62,13 @@ curl https://example.org/egroupware/groupdav.php/<username>/addressbook/ -H "Acc
|
|||||||
"created": "2010-10-21T09:55:42Z",
|
"created": "2010-10-21T09:55:42Z",
|
||||||
"updated": "2014-06-02T14:45:24Z",
|
"updated": "2014-06-02T14:45:24Z",
|
||||||
"name": [
|
"name": [
|
||||||
{ "type": "personal", "value": "Default" },
|
{ "@type": "NameComponent", "type": "personal", "value": "Default" },
|
||||||
{ "type": "surname", "value": "Tester" }
|
{ "@type": "NameComponent", "type": "surname", "value": "Tester" }
|
||||||
],
|
],
|
||||||
"fullName": { "value": "Default Tester" },
|
"fullName": { "value": "Default Tester" },
|
||||||
"organizations": {
|
"organizations": {
|
||||||
"org": {
|
"org": {
|
||||||
|
"@type": "Organization",
|
||||||
"name": "default.org",
|
"name": "default.org",
|
||||||
"units": {
|
"units": {
|
||||||
"org_unit": "department.default.org"
|
"org_unit": "department.default.org"
|
||||||
@ -75,30 +76,30 @@ curl https://example.org/egroupware/groupdav.php/<username>/addressbook/ -H "Acc
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"emails": {
|
"emails": {
|
||||||
"work": { "email": "test@test.com", "contexts": { "work": true }, "pref": 1 }
|
"work": { "@type": "EmailAddress", "email": "test@test.com", "contexts": { "work": true }, "pref": 1 }
|
||||||
},
|
},
|
||||||
"phones": {
|
"phones": {
|
||||||
"tel_work": { "phone": "+49 123 4567890", "pref": 1, "features": { "voice": true }, "contexts": { "work": true } },
|
"tel_work": { "@type": "Phone", "phone": "+49 123 4567890", "pref": 1, "features": { "voice": true }, "contexts": { "work": true } },
|
||||||
"tel_cell": { "phone": "012 3723567", "features": { "cell": true }, "contexts": { "work": true } }
|
"tel_cell": { "@type": "Phone", "phone": "012 3723567", "features": { "cell": true }, "contexts": { "work": true } }
|
||||||
},
|
},
|
||||||
"online": {
|
"online": {
|
||||||
"url": { "resource": "https://www.test.com/", "type": "uri", "contexts": { "work": true } }
|
"url": { "@type": "Resource", "resource": "https://www.test.com/", "type": "uri", "contexts": { "work": true } }
|
||||||
},
|
},
|
||||||
"notes": [
|
"notes": [
|
||||||
"Test test TEST\n\\server\\share\n\\\nother\nblah"
|
"Test test TEST\n\\server\\share\n\\\nother\nblah"
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"/<username>/addressbook/list-36": {
|
"/<username>/addressbook/list-36": {
|
||||||
"uid": "dfa5cac5-987b-448b-85d7-6c8b529a835c",
|
"uid": "urn:uuid:dfa5cac5-987b-448b-85d7-6c8b529a835c",
|
||||||
"name": "Example distribution list",
|
"name": "Example distribution list",
|
||||||
"card": {
|
"card": {
|
||||||
"uid": "dfa5cac5-987b-448b-85d7-6c8b529a835c",
|
"uid": "urn:uuid:dfa5cac5-987b-448b-85d7-6c8b529a835c",
|
||||||
"prodId": "EGroupware Addressbook 21.1.001",
|
"prodId": "EGroupware Addressbook 21.1.001",
|
||||||
"updated": "2018-04-11T14:46:43Z",
|
"updated": "2018-04-11T14:46:43Z",
|
||||||
"fullName": { "value": "Example distribution list" }
|
"fullName": { "value": "Example distribution list" }
|
||||||
},
|
},
|
||||||
"members": {
|
"members": {
|
||||||
"urn:uuid:5638-8623c4830472a8ede9f9f8b30d435ea4": true
|
"5638-8623c4830472a8ede9f9f8b30d435ea4": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -193,8 +194,8 @@ curl 'https://example.org/egroupware/groupdav.php/addressbook/?sync-token=https:
|
|||||||
"created": "2010-10-21T09:55:42Z",
|
"created": "2010-10-21T09:55:42Z",
|
||||||
"updated": "2014-06-02T14:45:24Z",
|
"updated": "2014-06-02T14:45:24Z",
|
||||||
"name": [
|
"name": [
|
||||||
{ "type": "personal", "value": "Default" },
|
{ "@type": "NameComponent", "type": "personal", "value": "Default" },
|
||||||
{ "type": "surname", "value": "Tester" }
|
{ "@type": "NameComponent", "type": "surname", "value": "Tester" }
|
||||||
],
|
],
|
||||||
"fullName": "Default Tester",
|
"fullName": "Default Tester",
|
||||||
....
|
....
|
||||||
@ -217,8 +218,8 @@ curl 'https://example.org/egroupware/groupdav.php/addressbook/5593' -H "Accept:
|
|||||||
"created": "2010-10-21T09:55:42Z",
|
"created": "2010-10-21T09:55:42Z",
|
||||||
"updated": "2014-06-02T14:45:24Z",
|
"updated": "2014-06-02T14:45:24Z",
|
||||||
"name": [
|
"name": [
|
||||||
{ "type": "personal", "value": "Default" },
|
{ "@type": "NameComponent", "type": "personal", "value": "Default" },
|
||||||
{ "type": "surname", "value": "Tester" }
|
{ "@type": "NameComponent", "type": "surname", "value": "Tester" }
|
||||||
],
|
],
|
||||||
"fullName": "Default Tester",
|
"fullName": "Default Tester",
|
||||||
....
|
....
|
||||||
@ -239,8 +240,8 @@ cat <<EOF | curl -i 'https://example.org/egroupware/groupdav.php/<username>/addr
|
|||||||
"created": "2010-10-21T09:55:42Z",
|
"created": "2010-10-21T09:55:42Z",
|
||||||
"updated": "2014-06-02T14:45:24Z",
|
"updated": "2014-06-02T14:45:24Z",
|
||||||
"name": [
|
"name": [
|
||||||
{ "type": "personal", "value": "Default" },
|
{ "type": "@type": "NameComponent", "personal", "value": "Default" },
|
||||||
{ "type": "surname", "value": "Tester" }
|
{ "type": "@type": "NameComponent", "surname", "value": "Tester" }
|
||||||
],
|
],
|
||||||
"fullName": { "value": "Default Tester" },
|
"fullName": { "value": "Default Tester" },
|
||||||
....
|
....
|
||||||
|
Loading…
Reference in New Issue
Block a user