mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-29 02:02:41 +01:00
0a069cb55a
Summary: Unmuck almost all of the we-sort-of-have-viewers-some-of-the-time mess. There are a few notable cases here: - I used Omnipotent users when indexing objects for search. I think this is correct; we do policy filtering when showing results. - I cheated in a bad way in the Remarkup object rule, but fixing this requires fixing all the PhabricatorRemarkupEngine callsites (there are 85). I'll do that in the next diff. - I cheated in a few random places, like when sending mail about package edits. These aren't a big deal. Test Plan: - Grepped for all PhabricatorObjectHandleData references. - Gave them viewers. Reviewers: vrana Reviewed By: vrana CC: aran, edward Maniphest Tasks: T603 Differential Revision: https://secure.phabricator.com/D5151
102 lines
2.6 KiB
PHP
102 lines
2.6 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @group pholio
|
|
*/
|
|
final class PholioInlineSaveController extends PholioController {
|
|
|
|
private $operation;
|
|
|
|
public function getOperation() {
|
|
return $this->operation;
|
|
}
|
|
|
|
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();
|
|
}
|
|
|
|
$this->operation = $request->getBool('op');
|
|
|
|
if ($this->getOperation() == 'save') {
|
|
$new_content = $request->getStr('comment');
|
|
|
|
if (strlen(trim($new_content)) == 0) {
|
|
return id(new AphrontAjaxResponse())
|
|
->setContent(array('success' => false));
|
|
}
|
|
|
|
$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($new_content);
|
|
|
|
$draft->save();
|
|
|
|
$inline_view = id(new PholioInlineCommentView())
|
|
->setInlineComment($draft)
|
|
->setEditable(true)
|
|
->setHandle(
|
|
PhabricatorObjectHandleData::loadOneHandle(
|
|
$user->getPHID(),
|
|
$user));
|
|
|
|
return id(new AphrontAjaxResponse())
|
|
->setContent(
|
|
$draft->toDictionary() + array(
|
|
'contentHTML' => $inline_view->render(),
|
|
));
|
|
} else {
|
|
$dialog = new PholioInlineCommentSaveView();
|
|
|
|
$dialog->setUser($user);
|
|
$dialog->setSubmitURI($request->getRequestURI());
|
|
|
|
$dialog->setTitle(pht('Make inline comment'));
|
|
|
|
$dialog->addHiddenInput('op', 'save');
|
|
|
|
$dialog->appendChild($this->renderTextArea(''));
|
|
|
|
return id(new AphrontAjaxResponse())->setContent($dialog->render());
|
|
}
|
|
|
|
}
|
|
|
|
private function renderTextArea($text) {
|
|
return javelin_tag(
|
|
'textarea',
|
|
array(
|
|
'class' => 'pholio-inline-comment-dialog-textarea',
|
|
'name' => 'text',
|
|
),
|
|
$text);
|
|
}
|
|
|
|
}
|