2013-04-16 17:18:52 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @group slowvote
|
|
|
|
*/
|
|
|
|
final class SlowvoteRemarkupRule
|
|
|
|
extends PhabricatorRemarkupRuleObject {
|
|
|
|
|
|
|
|
protected function getObjectNamePrefix() {
|
|
|
|
return 'V';
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function loadObjects(array $ids) {
|
2013-07-13 19:41:30 +02:00
|
|
|
$viewer = $this->getEngine()->getConfig('viewer');
|
2013-04-16 17:18:52 +02:00
|
|
|
|
2013-07-13 19:41:30 +02:00
|
|
|
return id(new PhabricatorSlowvoteQuery())
|
|
|
|
->setViewer($viewer)
|
|
|
|
->withIDs($ids)
|
|
|
|
->execute();
|
2013-04-16 17:18:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function renderObjectEmbed($object, $handle, $options) {
|
|
|
|
$viewer = $this->getEngine()->getConfig('viewer');
|
|
|
|
|
|
|
|
$options = id(new PhabricatorSlowvoteOption())->loadAllWhere(
|
|
|
|
'pollID = %d',
|
|
|
|
$object->getID());
|
|
|
|
$choices = id(new PhabricatorSlowvoteChoice())->loadAllWhere(
|
|
|
|
'pollID = %d',
|
|
|
|
$object->getID());
|
|
|
|
$choices_by_user = mgroup($choices, 'getAuthorPHID');
|
|
|
|
|
|
|
|
$viewer_choices = idx($choices_by_user, $viewer->getPHID(), array());
|
|
|
|
|
|
|
|
$embed = id(new SlowvoteEmbedView())
|
|
|
|
->setPoll($object)
|
|
|
|
->setOptions($options)
|
|
|
|
->setViewerChoices($viewer_choices);
|
|
|
|
|
|
|
|
return $embed->render();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|