Commit 11f77b2f authored by Zach Copley's avatar Zach Copley

Add PoCo to Activity Streams JSON

parent 97af5e19
......@@ -726,6 +726,10 @@ class ActivityObject
);
}
if (!empty($this->poco)) {
$object['contact'] = $this->poco->asArray();
}
return array_filter($object);
}
}
......@@ -115,7 +115,6 @@ class ActivityStreamJSONDocument
$act = $notice->asActivity($cur);
$act->extra[] = $notice->noticeInfo($cur);
array_push($this->doc['items'], $act->asArray());
}
......
......@@ -241,4 +241,42 @@ class PoCo
$url->outputTo($xo);
}
}
/**
* Output a Portable Contact as an array suitable for serializing
* as JSON
*
* @return $array the PoCo array
*/
function asArray()
{
$poco = array();
$poco['preferredUsername'] = $this->preferredUsername;
$poco['displayName'] = $this->displayName;
if (!empty($this->note)) {
$poco['note'] = $this->note;
}
if (!empty($this->address)) {
$poco['addresses'] = $this->address->asArray();
}
if (!empty($this->urls)) {
$urls = array();
foreach ($this->urls as $url) {
$urls[] = $url->asArray();
}
$poco['urls'] = $urls;
}
return $poco;
}
}
......@@ -56,4 +56,17 @@ class PoCoAddress
$xo->elementEnd('poco:address');
}
}
/**
* Return this PoCo address as an array suitable for serializing in JSON
*
* @return array the address
*/
function asArray()
{
if (!empty($this->formatted)) {
return array('formatted' => $this->formatted);
}
}
}
......@@ -67,4 +67,24 @@ class PoCoURL
}
$xo->elementEnd('poco:urls');
}
/**
* Return this PoCo URL as an array suitable for serializing in JSON
*
* @array $url the url
*/
function asArray()
{
$url = array();
$url['type'] = $this->type;
$url['value'] = $this->value;
if (!empty($this->primary)) {
$url['primary'] = 'true';
}
return $url;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment