Something went wrong. Try again.
@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
Something went wrong. Try again.
2.2 kB · 87 lines
PHP
at commit a5f55d50
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788<?php
final class DiffusionInlineCommentController extends PhabricatorInlineCommentController {
private $commitPHID;
public function willProcessRequest(array $data) { $this->commitPHID = $data['phid']; }
protected function createComment() {
// Verify commit and path correspond to actual objects. $commit_phid = $this->commitPHID; $path_id = $this->getChangesetID();
$commit = id(new PhabricatorRepositoryCommit())->loadOneWhere( 'phid = %s', $commit_phid); if (!$commit) { throw new Exception("Invalid commit ID!"); }
// TODO: Write a real PathQuery object?
$path = queryfx_one( id(new PhabricatorRepository())->establishConnection('r'), 'SELECT path FROM %T WHERE id = %d', PhabricatorRepository::TABLE_PATH, $path_id);
if (!$path) { throw new Exception("Invalid path ID!"); }
return id(new PhabricatorAuditInlineComment()) ->setCommitPHID($commit_phid) ->setPathID($path_id); }
protected function loadComment($id) { return id(new PhabricatorAuditInlineComment())->load($id); }
protected function loadCommentForEdit($id) { $request = $this->getRequest(); $user = $request->getUser();
$inline = $this->loadComment($id); if (!$this->canEditInlineComment($user, $inline)) { throw new Exception("That comment is not editable!"); } return $inline; }
private function canEditInlineComment( PhabricatorUser $user, PhabricatorAuditInlineComment $inline) {
// Only the author may edit a comment. if ($inline->getAuthorPHID() != $user->getPHID()) { return false; }
// Saved comments may not be edited. if ($inline->getAuditCommentID()) { return false; }
// Inline must be attached to the active revision. if ($inline->getCommitPHID() != $this->commitPHID) { return false; }
return true; }
protected function deleteComment(PhabricatorInlineCommentInterface $inline) { return $inline->delete(); }
protected function saveComment(PhabricatorInlineCommentInterface $inline) { return $inline->save(); }
}