2013-02-06 20:28:03 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @group pholio
|
|
|
|
*/
|
|
|
|
final class PholioInlineSaveController extends PholioController {
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$user = $request->getUser();
|
|
|
|
|
|
|
|
$mock = id(new PholioMockQuery())
|
|
|
|
->setViewer($user)
|
|
|
|
->withIDs(array($request->getInt('mockID')))
|
|
|
|
->executeOne();
|
|
|
|
|
|
|
|
if (!$mock) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
|
|
|
|
$draft = id(new PholioTransactionComment());
|
|
|
|
$draft->setImageID($request->getInt('imageID'));
|
|
|
|
$draft->setX($request->getInt('startX'));
|
|
|
|
$draft->setY($request->getInt('startY'));
|
|
|
|
|
|
|
|
$draft->setCommentVersion(1);
|
|
|
|
$draft->setAuthorPHID($user->getPHID());
|
|
|
|
$draft->setEditPolicy($user->getPHID());
|
|
|
|
$draft->setViewPolicy(PhabricatorPolicies::POLICY_PUBLIC);
|
|
|
|
|
|
|
|
$content_source = PhabricatorContentSource::newForSource(
|
|
|
|
PhabricatorContentSource::SOURCE_WEB,
|
|
|
|
array(
|
|
|
|
'ip' => $request->getRemoteAddr(),
|
|
|
|
));
|
|
|
|
|
|
|
|
$draft->setContentSource($content_source);
|
|
|
|
|
|
|
|
$draft->setWidth($request->getInt('endX') - $request->getInt('startX'));
|
|
|
|
$draft->setHeight($request->getInt('endY') - $request->getInt('startY'));
|
|
|
|
|
|
|
|
$draft->setContent($request->getStr('comment'));
|
|
|
|
|
|
|
|
$draft->save();
|
2013-02-19 23:12:33 +01:00
|
|
|
$inlineID = $draft->getID();
|
|
|
|
|
|
|
|
if ($request->isAjax()) {
|
|
|
|
$inline_view = id(new PholioInlineCommentView())
|
|
|
|
->setInlineComment($draft)
|
|
|
|
->setEditable(true)
|
|
|
|
->setHandle(
|
|
|
|
PhabricatorObjectHandleData::loadOneHandle($user->getPHID()));
|
|
|
|
|
|
|
|
return id(new AphrontAjaxResponse())
|
|
|
|
->setContent(array('contentHTML' => $inline_view->render()));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
return id(new AphrontRedirectResponse())->setUri('/M'.$mock->getID());
|
|
|
|
}
|
2013-02-06 20:28:03 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|