X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fatomnoticefeed.php;h=b8821729185fa2eb800331b4b26c9d948d5e9c80;hb=24f9a991b6ac8edfc7936b7adfcb7dd5955c66a3;hp=35a45118ce6525ed2f6ce52ba846e307e9d2a9af;hpb=065ecc5573607d21ae005ff2649d04558256fc7e;p=quix0rs-gnu-social.git diff --git a/lib/atomnoticefeed.php b/lib/atomnoticefeed.php index 35a45118ce..b882172918 100644 --- a/lib/atomnoticefeed.php +++ b/lib/atomnoticefeed.php @@ -44,9 +44,22 @@ if (!defined('STATUSNET')) */ class AtomNoticeFeed extends Atom10Feed { - function __construct($indent = true) { + var $cur; + + /** + * Constructor - adds a bunch of XML namespaces we need in our + * notice-specific Atom feeds, and allows setting the current + * authenticated user (useful for API methods). + * + * @param User $cur the current authenticated user (optional) + * @param boolean $indent Whether to indent XML output + * + */ + function __construct($cur = null, $indent = true) { parent::__construct($indent); + $this->cur = $cur; + // Feeds containing notice info use these namespaces $this->addNamespace( @@ -82,7 +95,7 @@ class AtomNoticeFeed extends Atom10Feed $this->addNamespace( 'statusnet', - 'http://status.net/ont/' + 'http://status.net/schema/api/1/' ); } @@ -112,12 +125,17 @@ class AtomNoticeFeed extends Atom10Feed */ function addEntryFromNotice($notice) { - $source = $this->showSource(); - $author = $this->showAuthor(); + try { + $source = $this->showSource(); + $author = $this->showAuthor(); - $cur = common_current_user(); + $cur = empty($this->cur) ? common_current_user() : $this->cur; - $this->addEntryRaw($notice->asAtomEntry(false, $source, $author, $cur)); + $this->addEntryRaw($notice->asAtomEntry(false, $source, $author, $cur)); + } catch (Exception $e) { + common_log(LOG_ERR, $e->getMessage()); + // we continue on exceptions + } } function showSource()