2012-08-10 19:44:04 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PonderVoteSaveController extends PonderController {
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
$request = $this->getRequest();
|
2013-07-29 04:28:00 +02:00
|
|
|
$viewer = $request->getUser();
|
|
|
|
$phid = $request->getStr('phid');
|
|
|
|
$newvote = $request->getInt('vote');
|
2012-08-10 19:44:04 +02:00
|
|
|
|
|
|
|
if (1 < $newvote || $newvote < -1) {
|
|
|
|
return new Aphront400Response();
|
|
|
|
}
|
|
|
|
|
|
|
|
$target = null;
|
|
|
|
|
2013-07-29 04:28:00 +02:00
|
|
|
$object = id(new PhabricatorObjectQuery())
|
|
|
|
->setViewer($viewer)
|
|
|
|
->withPHIDs(array($phid))
|
|
|
|
->executeOne();
|
|
|
|
if (!$object) {
|
2012-08-10 19:44:04 +02:00
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
|
|
|
|
$editor = id(new PonderVoteEditor())
|
2013-07-29 04:28:00 +02:00
|
|
|
->setVotable($object)
|
|
|
|
->setActor($viewer)
|
2012-08-10 19:44:04 +02:00
|
|
|
->setVote($newvote)
|
|
|
|
->saveVote();
|
|
|
|
|
2013-07-29 04:28:00 +02:00
|
|
|
return id(new AphrontAjaxResponse())->setContent(array());
|
2012-08-10 19:44:04 +02:00
|
|
|
}
|
|
|
|
}
|