From: Brion Vibber Date: Thu, 10 Mar 2011 21:55:47 +0000 (-0800) Subject: cleanup... Poll main & response events seem to sorta work over ostatus now X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=eccadb4a7b672685215dc6d9e481577e9fe92d9c;p=quix0rs-gnu-social.git cleanup... Poll main & response events seem to sorta work over ostatus now --- diff --git a/plugins/Poll/PollPlugin.php b/plugins/Poll/PollPlugin.php index f76faedb05..a2e9814555 100644 --- a/plugins/Poll/PollPlugin.php +++ b/plugins/Poll/PollPlugin.php @@ -280,31 +280,34 @@ class PollPlugin extends MicroAppPlugin $object->link = $notice->bestUrl(); $response = Poll_response::getByNotice($notice); - $poll = $response->getPoll(); - - /** - * For the moment, using a kind of icky-looking schema that happens to - * work with out code for generating both Atom and JSON forms, though - * I don't like it: - * - * - * - * "poll:response": { - * "xmlns:poll": http://apinamespace.org/activitystreams/object/poll - * "uri": "http://..../poll/...." - * "selection": 3 - * } - * - */ - // @fixme there's no way to specify an XML node tree here, like - // @fixme there's no way to specify a JSON array or multi-level tree unless you break the XML attribs - // @fixme XML node contents don't get shown in JSON - $data = array('xmlns:poll' => self::POLL_OBJECT, - 'poll' => $poll->uri, - 'selection' => intval($response->selection)); - $object->extra[] = array('poll:response', $data, ''); + if (!$response) { + common_log(LOG_DEBUG, "QQQ notice uri: $notice->uri"); + } else { + $poll = $response->getPoll(); + /** + * For the moment, using a kind of icky-looking schema that happens to + * work with out code for generating both Atom and JSON forms, though + * I don't like it: + * + * + * + * "poll:response": { + * "xmlns:poll": http://apinamespace.org/activitystreams/object/poll + * "uri": "http://..../poll/...." + * "selection": 3 + * } + * + */ + // @fixme there's no way to specify an XML node tree here, like + // @fixme there's no way to specify a JSON array or multi-level tree unless you break the XML attribs + // @fixme XML node contents don't get shown in JSON + $data = array('xmlns:poll' => self::POLL_OBJECT, + 'poll' => $poll->uri, + 'selection' => intval($response->selection)); + $object->extra[] = array('poll:response', $data, ''); + } return $object; } diff --git a/plugins/Poll/Poll_response.php b/plugins/Poll/Poll_response.php index 03dd6f60b5..88e6ea890c 100644 --- a/plugins/Poll/Poll_response.php +++ b/plugins/Poll/Poll_response.php @@ -141,6 +141,14 @@ class Poll_response extends Managed_DataObject return $this->getNotice()->bestUrl(); } + /** + * + * @return Poll + */ + function getPoll() + { + return Poll::staticGet('id', $this->poll_id); + } /** * Save a new poll notice *