cleanup... Poll main & response events seem to sorta work over ostatus now

This commit is contained in:
Brion Vibber 2011-03-10 13:55:47 -08:00
parent 6416f5ea41
commit eccadb4a7b
2 changed files with 36 additions and 25 deletions

View File

@ -280,31 +280,34 @@ class PollPlugin extends MicroAppPlugin
$object->link = $notice->bestUrl(); $object->link = $notice->bestUrl();
$response = Poll_response::getByNotice($notice); $response = Poll_response::getByNotice($notice);
$poll = $response->getPoll(); if (!$response) {
common_log(LOG_DEBUG, "QQQ notice uri: $notice->uri");
/** } else {
* For the moment, using a kind of icky-looking schema that happens to $poll = $response->getPoll();
* work with out code for generating both Atom and JSON forms, though /**
* I don't like it: * 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
* <poll:response xmlns:poll="http://apinamespace.org/activitystreams/object/poll" * I don't like it:
* poll="http://..../poll/...." *
* selection="3" /> * <poll:response xmlns:poll="http://apinamespace.org/activitystreams/object/poll"
* * poll="http://..../poll/...."
* "poll:response": { * selection="3" />
* "xmlns:poll": http://apinamespace.org/activitystreams/object/poll *
* "uri": "http://..../poll/...." * "poll:response": {
* "selection": 3 * "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 <poll><option/><option/></poll> *
// @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 // @fixme there's no way to specify an XML node tree here, like <poll><option/><option/></poll>
$data = array('xmlns:poll' => self::POLL_OBJECT, // @fixme there's no way to specify a JSON array or multi-level tree unless you break the XML attribs
'poll' => $poll->uri, // @fixme XML node contents don't get shown in JSON
'selection' => intval($response->selection)); $data = array('xmlns:poll' => self::POLL_OBJECT,
$object->extra[] = array('poll:response', $data, ''); 'poll' => $poll->uri,
'selection' => intval($response->selection));
$object->extra[] = array('poll:response', $data, '');
}
return $object; return $object;
} }

View File

@ -141,6 +141,14 @@ class Poll_response extends Managed_DataObject
return $this->getNotice()->bestUrl(); return $this->getNotice()->bestUrl();
} }
/**
*
* @return Poll
*/
function getPoll()
{
return Poll::staticGet('id', $this->poll_id);
}
/** /**
* Save a new poll notice * Save a new poll notice
* *