From 85cf25a2a8bfbbfe10de485d4affd54626fbbfa4 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 23 Feb 2020 15:28:16 -0800 Subject: add iconfig to zot6 objects --- Zotlabs/Lib/Activity.php | 52 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 5 deletions(-) (limited to 'Zotlabs/Lib/Activity.php') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 1ac3135db..0d8dab95c 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -504,10 +504,47 @@ class Activity { } } } + if ($item['iconfig']) { + foreach ($item['iconfig'] as $att) { + if ($att['sharing']) { + $value = ((preg_match('|^a:[0-9]+:{.*}$|s', $att['v'])) ? unserialize($att['v']) : $att['v']); + $ret[] = [ 'type' => 'PropertyValue', 'name' => 'zot.' . $att['cat'] . '.' . $att['k'], 'value' => $value ]; + } + } + } return $ret; } + static function decode_iconfig($item) { + + $ret = []; + + if (is_array($item['attachment']) && $item['attachment']) { + $ptr = $item['attachment']; + if (! array_key_exists(0,$ptr)) { + $ptr = [ $ptr ]; + } + foreach ($ptr as $att) { + $entry = []; + if ($att['type'] === 'PropertyValue') { + if (array_key_exists('name',$att) && $att['name']) { + $key = explode('.',$att['name']); + if (count($key) === 3 && $key[0] === 'zot') { + $entry['cat'] = $key[1]; + $entry['k'] = $key[2]; + $entry['v'] = $att['value']; + $entry['sharing'] = '1'; + $ret[] = $entry; + } + } + } + } + } + return $ret; + } + + static function decode_attachment($item) { @@ -1888,17 +1925,22 @@ class Activity { } } - $a = self::decode_attachment($act->obj); - if($a) { - $s['attach'] = $a; - } + } + + $a = self::decode_attachment($act->obj); + if ($a) { + $s['attach'] = $a; + } + + $a = self::decode_iconfig($act->obj); + if ($a) { + $s['iconfig'] = $a; } if($act->obj['type'] === 'Note' && $s['attach']) { $s['body'] .= self::bb_attach($s['attach'],$s['body']); } - if ($act->obj['type'] === 'Question' && in_array($act->type,['Create','Update'])) { if ($act->obj['endTime']) { $s['comments_closed'] = datetime_convert('UTC','UTC', $act->obj['endTime']); -- cgit v1.2.3