@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
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Write pathway for Differential Comments

+602 -122
+7 -2
src/__phutil_library_map__.php
··· 8 8 phutil_register_library_map(array( 9 9 'class' => 10 10 array( 11 + 'Aphront400Response' => 'aphront/response/400', 11 12 'Aphront404Response' => 'aphront/response/404', 12 13 'AphrontAjaxResponse' => 'aphront/response/ajax', 13 14 'AphrontApplicationConfiguration' => 'aphront/applicationconfiguration', ··· 74 75 'DifferentialChangesetParser' => 'applications/differential/parser/changeset', 75 76 'DifferentialChangesetViewController' => 'applications/differential/controller/changesetview', 76 77 'DifferentialComment' => 'applications/differential/storage/comment', 78 + 'DifferentialCommentEditor' => 'applications/differential/editor/comment', 79 + 'DifferentialCommentMail' => 'applications/differential/mail/comment', 80 + 'DifferentialCommentSaveController' => 'applications/differential/controller/commentsave', 77 81 'DifferentialController' => 'applications/differential/controller/base', 78 82 'DifferentialDAO' => 'applications/differential/storage/base', 79 83 'DifferentialDiff' => 'applications/differential/storage/diff', ··· 81 85 'DifferentialDiffProperty' => 'applications/differential/storage/diffproperty', 82 86 'DifferentialDiffTableOfContentsView' => 'applications/differential/view/difftableofcontents', 83 87 'DifferentialDiffViewController' => 'applications/differential/controller/diffview', 84 - 'DifferentialFeedbackMail' => 'applications/differential/mail/feedback', 85 88 'DifferentialHunk' => 'applications/differential/storage/hunk', 86 89 'DifferentialLintStatus' => 'applications/differential/constants/lintstatus', 87 90 'DifferentialMail' => 'applications/differential/mail/base', ··· 184 187 ), 185 188 'requires_class' => 186 189 array( 190 + 'Aphront400Response' => 'AphrontResponse', 187 191 'Aphront404Response' => 'AphrontResponse', 188 192 'AphrontAjaxResponse' => 'AphrontResponse', 189 193 'AphrontDefaultApplicationConfiguration' => 'AphrontApplicationConfiguration', ··· 232 236 'DifferentialChangesetListView' => 'AphrontView', 233 237 'DifferentialChangesetViewController' => 'DifferentialController', 234 238 'DifferentialComment' => 'DifferentialDAO', 239 + 'DifferentialCommentMail' => 'DifferentialMail', 240 + 'DifferentialCommentSaveController' => 'DifferentialController', 235 241 'DifferentialController' => 'PhabricatorController', 236 242 'DifferentialDAO' => 'PhabricatorLiskDAO', 237 243 'DifferentialDiff' => 'DifferentialDAO', ··· 239 245 'DifferentialDiffProperty' => 'DifferentialDAO', 240 246 'DifferentialDiffTableOfContentsView' => 'AphrontView', 241 247 'DifferentialDiffViewController' => 'DifferentialController', 242 - 'DifferentialFeedbackMail' => 'DifferentialMail', 243 248 'DifferentialHunk' => 'DifferentialDAO', 244 249 'DifferentialNewDiffMail' => 'DifferentialReviewRequestMail', 245 250 'DifferentialReviewRequestMail' => 'DifferentialMail',
+8
src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php
··· 86 86 'changeset/(?<id>\d+)/$' => 'DifferentialChangesetViewController', 87 87 'revision/edit/(?:(?<id>\d+)/)?$' 88 88 => 'DifferentialRevisionEditController', 89 + 'comment/' => array( 90 + 'preview/$' => 'DifferentialCommentPreviewController', 91 + 'save/$' => 'DifferentialCommentSaveController', 92 + 'inline/' => array( 93 + 'preview/$' => 'DifferentialInlineCommentPreviewController', 94 + 'edit/$' => 'DifferentialInlineCommentEditController', 95 + ), 96 + ), 89 97 ), 90 98 91 99 '/res/' => array(
+28
src/aphront/response/400/Aphront400Response.php
··· 1 + <?php 2 + 3 + /* 4 + * Copyright 2011 Facebook, Inc. 5 + * 6 + * Licensed under the Apache License, Version 2.0 (the "License"); 7 + * you may not use this file except in compliance with the License. 8 + * You may obtain a copy of the License at 9 + * 10 + * http://www.apache.org/licenses/LICENSE-2.0 11 + * 12 + * Unless required by applicable law or agreed to in writing, software 13 + * distributed under the License is distributed on an "AS IS" BASIS, 14 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 + * See the License for the specific language governing permissions and 16 + * limitations under the License. 17 + */ 18 + 19 + /** 20 + * @group aphront 21 + */ 22 + class Aphront400Response extends AphrontResponse { 23 + 24 + public function buildResponseString() { 25 + return '400 Bad Request'; 26 + } 27 + 28 + }
+12
src/aphront/response/400/__init__.php
··· 1 + <?php 2 + /** 3 + * This file is automatically generated. Lint this module to rebuild it. 4 + * @generated 5 + */ 6 + 7 + 8 + 9 + phutil_require_module('phabricator', 'aphront/response/base'); 10 + 11 + 12 + phutil_require_source('Aphront400Response.php');
+56
src/applications/differential/controller/commentsave/DifferentialCommentSaveController.php
··· 1 + <?php 2 + 3 + /* 4 + * Copyright 2011 Facebook, Inc. 5 + * 6 + * Licensed under the Apache License, Version 2.0 (the "License"); 7 + * you may not use this file except in compliance with the License. 8 + * You may obtain a copy of the License at 9 + * 10 + * http://www.apache.org/licenses/LICENSE-2.0 11 + * 12 + * Unless required by applicable law or agreed to in writing, software 13 + * distributed under the License is distributed on an "AS IS" BASIS, 14 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 + * See the License for the specific language governing permissions and 16 + * limitations under the License. 17 + */ 18 + 19 + class DifferentialCommentSaveController extends DifferentialController { 20 + 21 + public function processRequest() { 22 + $request = $this->getRequest(); 23 + if (!$request->isFormPost()) { 24 + return new Aphront400Response(); 25 + } 26 + 27 + $revision_id = $request->getInt('revision_id'); 28 + $revision = id(new DifferentialRevision())->load($revision_id); 29 + if (!$revision) { 30 + return new Aphront400Response(); 31 + } 32 + 33 + $comment = $request->getStr('comment'); 34 + $action = $request->getStr('action'); 35 + $reviewers = $request->getStr('reviewers'); 36 + 37 + $editor = new DifferentialCommentEditor( 38 + $revision, 39 + $request->getUser()->getPHID(), 40 + $action); 41 + 42 + $editor 43 + ->setMessage($comment) 44 + ->setAttachInlineComments(true) 45 + ->setAddCC($action != DifferentialAction::ACTION_RESIGN) 46 + ->setAddedReviewers($reviewers) 47 + ->save(); 48 + 49 + // TODO: Diff change detection? 50 + // TODO: Clear draft 51 + 52 + return id(new AphrontRedirectResponse()) 53 + ->setURI('/D'.$revision->getID()); 54 + } 55 + 56 + }
+18
src/applications/differential/controller/commentsave/__init__.php
··· 1 + <?php 2 + /** 3 + * This file is automatically generated. Lint this module to rebuild it. 4 + * @generated 5 + */ 6 + 7 + 8 + 9 + phutil_require_module('phabricator', 'aphront/response/400'); 10 + phutil_require_module('phabricator', 'aphront/response/redirect'); 11 + phutil_require_module('phabricator', 'applications/differential/controller/base'); 12 + phutil_require_module('phabricator', 'applications/differential/editor/comment'); 13 + phutil_require_module('phabricator', 'applications/differential/storage/revision'); 14 + 15 + phutil_require_module('phutil', 'utils'); 16 + 17 + 18 + phutil_require_source('DifferentialCommentSaveController.php');
+1
src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php
··· 83 83 $comment_form = new DifferentialAddCommentView(); 84 84 $comment_form->setRevision($revision); 85 85 $comment_form->setActions($this->getRevisionCommentActions($revision)); 86 + $comment_form->setActionURI('/differential/comment/save/'); 86 87 87 88 return $this->buildStandardPageResponse( 88 89 '<div class="differential-primary-pane">'.
+329
src/applications/differential/editor/comment/DifferentialCommentEditor.php
··· 1 + <?php 2 + 3 + /* 4 + * Copyright 2011 Facebook, Inc. 5 + * 6 + * Licensed under the Apache License, Version 2.0 (the "License"); 7 + * you may not use this file except in compliance with the License. 8 + * You may obtain a copy of the License at 9 + * 10 + * http://www.apache.org/licenses/LICENSE-2.0 11 + * 12 + * Unless required by applicable law or agreed to in writing, software 13 + * distributed under the License is distributed on an "AS IS" BASIS, 14 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 + * See the License for the specific language governing permissions and 16 + * limitations under the License. 17 + */ 18 + 19 + class DifferentialCommentEditor { 20 + 21 + protected $revision; 22 + protected $actorPHID; 23 + protected $action; 24 + 25 + protected $attachInlineComments; 26 + protected $message; 27 + protected $addCC; 28 + protected $changedByCommit; 29 + protected $addedReviewers = array(); 30 + 31 + public function __construct( 32 + DifferentialRevision $revision, 33 + $actor_phid, 34 + $action) { 35 + 36 + $this->revision = $revision; 37 + $this->actorPHID = $actor_phid; 38 + $this->action = $action; 39 + } 40 + 41 + public function setMessage($message) { 42 + $this->message = $message; 43 + return $this; 44 + } 45 + 46 + public function setAttachInlineComments($attach) { 47 + $this->attachInlineComments = $attach; 48 + return $this; 49 + } 50 + 51 + public function setAddCC($add) { 52 + $this->addCC = $add; 53 + return $this; 54 + } 55 + 56 + public function setChangedByCommit($changed_by_commit) { 57 + $this->changedByCommit = $changed_by_commit; 58 + return $this; 59 + } 60 + 61 + public function getChangedByCommit() { 62 + return $this->changedByCommit; 63 + } 64 + 65 + public function setAddedReviewers($added_reviewers) { 66 + $this->addedReviewers = $added_reviewers; 67 + return $this; 68 + } 69 + 70 + public function getAddedReviewers() { 71 + return $this->addedReviewers; 72 + } 73 + 74 + public function save() { 75 + $revision = $this->revision; 76 + $action = $this->action; 77 + $actor_phid = $this->actorPHID; 78 + $actor_is_author = ($actor_phid == $revision->getAuthorPHID()); 79 + $revision_status = $revision->getStatus(); 80 + 81 + $revision->loadRelationships(); 82 + $reviewer_phids = $revision->getReviewers(); 83 + if ($reviewer_phids) { 84 + $reviewer_phids = array_combine($reviewer_phids, $reviewer_phids); 85 + } 86 + 87 + switch ($action) { 88 + case DifferentialAction::ACTION_COMMENT: 89 + break; 90 + 91 + case DifferentialAction::ACTION_RESIGN: 92 + if ($actor_is_author) { 93 + throw new Exception('You can not resign from your own revision!'); 94 + } 95 + if (isset($reviewer_phids[$actor_phid])) { 96 + DifferentialRevisionEditor::alterReviewers( 97 + $revision, 98 + $reviewer_phids, 99 + $rem = array($actor_phid), 100 + $add = array(), 101 + $actor_phid); 102 + } 103 + break; 104 + 105 + case DifferentialAction::ACTION_ABANDON: 106 + if (!$actor_is_author) { 107 + throw new Exception('You can only abandon your revisions.'); 108 + } 109 + if ($revision_status == DifferentialRevisionStatus::COMMITTED) { 110 + throw new Exception('You can not abandon a committed revision.'); 111 + } 112 + if ($revision_status == DifferentialRevisionStatus::ABANDONED) { 113 + $action = DifferentialAction::ACTION_COMMENT; 114 + break; 115 + } 116 + 117 + $revision 118 + ->setStatus(DifferentialRevisionStatus::ABANDONED) 119 + ->save(); 120 + break; 121 + 122 + case DifferentialAction::ACTION_ACCEPT: 123 + if ($actor_is_author) { 124 + throw new Exception('You can not accept your own revision.'); 125 + } 126 + if (($revision_status != DifferentialRevisionStatus::NEEDS_REVIEW) && 127 + ($revision_status != DifferentialRevisionStatus::NEEDS_REVISION)) { 128 + $action = DifferentialAction::ACTION_COMMENT; 129 + break; 130 + } 131 + 132 + $revision 133 + ->setStatus(DifferentialRevisionStatus::ACCEPTED) 134 + ->save(); 135 + 136 + if (!isset($reviewer_phids[$actor_phid])) { 137 + DifferentialRevisionEditor::addReviewers( 138 + $revision, 139 + $reviewer_phids, 140 + $rem = array(), 141 + $add = array($actor_phid), 142 + $actor_phid); 143 + } 144 + break; 145 + 146 + case DifferentialAction::ACTION_REQUEST: 147 + if (!$actor_is_author) { 148 + throw new Exception('You must own a revision to request review.'); 149 + } 150 + if (($revision_status != DifferentialRevisionStatus::NEEDS_REVISION) && 151 + ($revision_status != DifferentialRevisionStatus::ACCEPTED)) { 152 + $action = DifferentialAction::ACTION_COMMENT; 153 + break; 154 + } 155 + 156 + $revision 157 + ->setStatus(DifferentialRevisionStatus::NEEDS_REVIEW) 158 + ->save(); 159 + break; 160 + 161 + case DifferentialAction::ACTION_REJECT: 162 + if ($actor_is_author) { 163 + throw new Exception( 164 + 'You can not request changes to your own revision.'); 165 + } 166 + if (($revision_status != DifferentialRevisionStatus::NEEDS_REVIEW) && 167 + ($revision_status != DifferentialRevisionStatus::ACCEPTED)) { 168 + $action = DifferentialAction::ACTION_COMMENT; 169 + break; 170 + } 171 + 172 + if (!isset($reviewer_phids[$actor_phid])) { 173 + DifferentialRevisionEditor::addReviewers( 174 + $revision, 175 + $reviewer_phids, 176 + $rem = array(), 177 + $add = array($actor_phid), 178 + $actor_phid); 179 + } 180 + 181 + $revision 182 + ->setStatus(DifferentialRevisionStatus::NEEDS_REVISION) 183 + ->save(); 184 + break; 185 + 186 + case DifferentialAction::ACTION_RECLAIM: 187 + if (!$actor_is_author) { 188 + throw new Exception('You can not reclaim a revision you do not own.'); 189 + } 190 + if ($revision_status != DifferentialRevisionStatus::ABANDONED) { 191 + $action = DifferentialAction::ACTION_COMMENT; 192 + break; 193 + } 194 + $revision 195 + ->setStatus(DifferentialRevisionStatus::NEEDS_REVIEW) 196 + ->save(); 197 + break; 198 + 199 + case DifferentialAction::ACTION_COMMIT: 200 + // This is handled externally. (TODO) 201 + break; 202 + 203 + case DifferentialAction::ACTION_ADDREVIEWERS: 204 + $added_reviewers = $this->getAddedReviewers(); 205 + foreach ($added_reviewers as $k => $user_phid) { 206 + if ($user_phid == $revision->getAuthorPHID()) { 207 + unset($added_reviewers[$k]); 208 + } 209 + if (!empty($reviewer_phids[$user_phid])) { 210 + unset($added_reviewers[$k]); 211 + } 212 + } 213 + 214 + $added_reviewers = array_unique($added_reviewers); 215 + 216 + if ($added_reviewers) { 217 + DifferentialRevisionEditor::addReviewers( 218 + $revision, 219 + $reviewer_phids, 220 + $rem = array(), 221 + $add = $added_reviewers, 222 + $actor_phid); 223 + 224 + // TODO 225 + // $unixnames = unixname_multi($added_reviewers); 226 + $usernames = $added_reviewers; 227 + 228 + $this->message = 229 + 'Added reviewers: '.implode(', ', $usernames)."\n\n". 230 + $this->message; 231 + 232 + } else { 233 + $action = DifferentialAction::ACTION_COMMENT; 234 + } 235 + break; 236 + 237 + default: 238 + throw new Exception('Unsupported action.'); 239 + } 240 + 241 + // Reload relationships to pick up any reviewer changes. 242 + $revision->loadRelationships(); 243 + 244 + /* 245 + TODO 246 + 247 + $inline_comments = array(); 248 + if ($this->attachInlineComments) { 249 + $inline_comments = id(new DifferentialInlineComment()) 250 + ->loadAllUnsaved($revision, $this->actorPHID); 251 + } 252 + */ 253 + 254 + $comment = id(new DifferentialComment()) 255 + ->setAuthorPHID($this->actorPHID) 256 + ->setRevisionID($revision->getID()) 257 + ->setAction($action) 258 + ->setContent((string)$this->message) 259 + ->save(); 260 + 261 + /* 262 + $diff = id(new Diff())->loadActiveWithRevision($revision); 263 + $changesets = id(new DifferentialChangeset())->loadAllWithDiff($diff); 264 + 265 + if ($inline_comments) { 266 + // We may have feedback on non-current changesets. Rather than orphaning 267 + // it, just submit it. This is non-ideal but not horrible. 268 + $inline_changeset_ids = array_pull($inline_comments, 'getChangesetID'); 269 + $load = array(); 270 + foreach ($inline_changeset_ids as $id) { 271 + if (empty($changesets[$id])) { 272 + $load[] = $id; 273 + } 274 + } 275 + if ($load) { 276 + $changesets += id(new DifferentialChangeset())->loadAllWithIDs($load); 277 + } 278 + foreach ($inline_comments as $inline) { 279 + $inline->setFeedbackID($feedback->getID()); 280 + $inline->save(); 281 + } 282 + } 283 + */ 284 + 285 + id(new DifferentialCommentMail( 286 + $revision, 287 + $this->actorPHID, 288 + $comment, 289 + /* $changesets TODO */ array(), 290 + /* $inline_comments TODO */ array())) 291 + ->setToPHIDs( 292 + array_merge( 293 + $revision->getReviewers(), 294 + array($revision->getAuthorPHID()))) 295 + ->setCCPHIDs($revision->getCCPHIDs()) 296 + ->setChangedByCommit($this->getChangedByCommit()) 297 + ->send(); 298 + 299 + /* 300 + 301 + tODO 302 + 303 + if ($this->addCC) { 304 + require_module_lazy('site/tools/differential/lib/editor/revision'); 305 + DifferentialRevisionEditor::addCCFBID( 306 + $revision, 307 + $this->actorPHID, 308 + $this->actorPHID); 309 + } 310 + */ 311 + 312 + /* 313 + 314 + TODO 315 + 316 + $event = array( 317 + 'revision_id' => $revision->getID(), 318 + 'fbid' => $revision->getFBID(), 319 + 'feedback_id' => $feedback->getID(), 320 + 'action' => $feedback->getAction(), 321 + 'actor' => $this->actorPHID, 322 + ); 323 + id(new ToolsTimelineEvent('difx', fb_json_encode($event)))->record(); 324 + */ 325 + 326 + return $comment; 327 + } 328 + 329 + }
+18
src/applications/differential/editor/comment/__init__.php
··· 1 + <?php 2 + /** 3 + * This file is automatically generated. Lint this module to rebuild it. 4 + * @generated 5 + */ 6 + 7 + 8 + 9 + phutil_require_module('phabricator', 'applications/differential/constants/action'); 10 + phutil_require_module('phabricator', 'applications/differential/constants/revisionstatus'); 11 + phutil_require_module('phabricator', 'applications/differential/editor/revision'); 12 + phutil_require_module('phabricator', 'applications/differential/mail/comment'); 13 + phutil_require_module('phabricator', 'applications/differential/storage/comment'); 14 + 15 + phutil_require_module('phutil', 'utils'); 16 + 17 + 18 + phutil_require_source('DifferentialCommentEditor.php');
+5 -5
src/applications/differential/mail/base/DifferentialMail.php
··· 27 27 protected $actorID; 28 28 29 29 protected $revision; 30 - protected $feedback; 30 + protected $comment; 31 31 protected $changesets; 32 32 protected $inlineComments; 33 33 protected $isFirstMailAboutRevision; ··· 214 214 return "<differential-rev-{$phid}-req@TODO.com>"; 215 215 } 216 216 217 - public function setFeedback($feedback) { 218 - $this->feedback = $feedback; 217 + public function setComment($comment) { 218 + $this->comment = $comment; 219 219 return $this; 220 220 } 221 221 222 - public function getFeedback() { 223 - return $this->feedback; 222 + public function getComment() { 223 + return $this->comment; 224 224 } 225 225 226 226 public function setChangesets($changesets) {
+114
src/applications/differential/mail/comment/DifferentialCommentMail.php
··· 1 + <?php 2 + 3 + /* 4 + * Copyright 2011 Facebook, Inc. 5 + * 6 + * Licensed under the Apache License, Version 2.0 (the "License"); 7 + * you may not use this file except in compliance with the License. 8 + * You may obtain a copy of the License at 9 + * 10 + * http://www.apache.org/licenses/LICENSE-2.0 11 + * 12 + * Unless required by applicable law or agreed to in writing, software 13 + * distributed under the License is distributed on an "AS IS" BASIS, 14 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 + * See the License for the specific language governing permissions and 16 + * limitations under the License. 17 + */ 18 + 19 + class DifferentialCommentMail extends DifferentialMail { 20 + 21 + protected $changedByCommit; 22 + 23 + public function setChangedByCommit($changed_by_commit) { 24 + $this->changedByCommit = $changed_by_commit; 25 + return $this; 26 + } 27 + 28 + public function getChangedByCommit() { 29 + return $this->changedByCommit; 30 + } 31 + 32 + public function __construct( 33 + DifferentialRevision $revision, 34 + $actor_id, 35 + DifferentialComment $comment, 36 + array $changesets, 37 + array $inline_comments) { 38 + 39 + $this->setRevision($revision); 40 + $this->setActorID($actor_id); 41 + $this->setComment($comment); 42 + $this->setChangesets($changesets); 43 + $this->setInlineComments($inline_comments); 44 + 45 + } 46 + 47 + protected function renderSubject() { 48 + $revision = $this->getRevision(); 49 + $verb = $this->getVerb(); 50 + return ucwords($verb).': '.$revision->getTitle(); 51 + } 52 + 53 + protected function getVerb() { 54 + $comment = $this->getComment(); 55 + $action = $comment->getAction(); 56 + $verb = DifferentialAction::getActionPastTenseVerb($action); 57 + return $verb; 58 + } 59 + 60 + protected function renderBody() { 61 + 62 + $comment = $this->getComment(); 63 + 64 + $actor = $this->getActorName(); 65 + $name = $this->getRevision()->getTitle(); 66 + $verb = $this->getVerb(); 67 + 68 + $body = array(); 69 + 70 + $body[] = "{$actor} has {$verb} the revision \"{$name}\"."; 71 + $body[] = null; 72 + 73 + $content = $comment->getContent(); 74 + if (strlen($content)) { 75 + $body[] = $this->formatText($content); 76 + $body[] = null; 77 + } 78 + 79 + if ($this->getChangedByCommit()) { 80 + $body[] = 'CHANGED PRIOR TO COMMIT'; 81 + $body[] = ' This revision was updated prior to commit.'; 82 + $body[] = null; 83 + } 84 + 85 + $inlines = $this->getInlineComments(); 86 + if ($inlines) { 87 + $body[] = 'INLINE COMMENTS'; 88 + $changesets = $this->getChangesets(); 89 + foreach ($inlines as $inline) { 90 + $changeset = $changesets[$inline->getChangesetID()]; 91 + if (!$changeset) { 92 + throw new Exception('Changeset missing!'); 93 + } 94 + $file = $changeset->getFilename(); 95 + $line = $inline->renderLineRange(); 96 + $content = $inline->getContent(); 97 + $body[] = $this->formatText("{$file}:{$line} {$content}"); 98 + } 99 + $body[] = null; 100 + } 101 + 102 + $body[] = $this->renderRevisionDetailLink(); 103 + $revision = $this->getRevision(); 104 + if ($revision->getStatus() == DifferentialRevisionStatus::COMMITTED) { 105 + $rev_ref = $revision->getRevisionRef(); 106 + if ($rev_ref) { 107 + $body[] = " Detail URL: ".$rev_ref->getDetailURL(); 108 + } 109 + } 110 + $body[] = null; 111 + 112 + return implode("\n", $body); 113 + } 114 + }
-114
src/applications/differential/mail/feedback/DifferentialFeedbackMail.php
··· 1 - <?php 2 - 3 - /* 4 - * Copyright 2011 Facebook, Inc. 5 - * 6 - * Licensed under the Apache License, Version 2.0 (the "License"); 7 - * you may not use this file except in compliance with the License. 8 - * You may obtain a copy of the License at 9 - * 10 - * http://www.apache.org/licenses/LICENSE-2.0 11 - * 12 - * Unless required by applicable law or agreed to in writing, software 13 - * distributed under the License is distributed on an "AS IS" BASIS, 14 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 - * See the License for the specific language governing permissions and 16 - * limitations under the License. 17 - */ 18 - 19 - class DifferentialFeedbackMail extends DifferentialMail { 20 - 21 - protected $changedByCommit; 22 - 23 - public function setChangedByCommit($changed_by_commit) { 24 - $this->changedByCommit = $changed_by_commit; 25 - return $this; 26 - } 27 - 28 - public function getChangedByCommit() { 29 - return $this->changedByCommit; 30 - } 31 - 32 - public function __construct( 33 - DifferentialRevision $revision, 34 - $actor_id, 35 - DifferentialFeedback $feedback, 36 - array $changesets, 37 - array $inline_comments) { 38 - 39 - $this->setRevision($revision); 40 - $this->setActorID($actor_id); 41 - $this->setFeedback($feedback); 42 - $this->setChangesets($changesets); 43 - $this->setInlineComments($inline_comments); 44 - 45 - } 46 - 47 - protected function renderSubject() { 48 - $revision = $this->getRevision(); 49 - $verb = $this->getVerb(); 50 - return ucwords($verb).': '.$revision->getName(); 51 - } 52 - 53 - protected function getVerb() { 54 - $feedback = $this->getFeedback(); 55 - $action = $feedback->getAction(); 56 - $verb = DifferentialAction::getActionVerb($action); 57 - return $verb; 58 - } 59 - 60 - protected function renderBody() { 61 - 62 - $feedback = $this->getFeedback(); 63 - 64 - $actor = $this->getActorName(); 65 - $name = $this->getRevision()->getName(); 66 - $verb = $this->getVerb(); 67 - 68 - $body = array(); 69 - 70 - $body[] = "{$actor} has {$verb} the revision \"{$name}\"."; 71 - $body[] = null; 72 - 73 - $content = $feedback->getContent(); 74 - if (strlen($content)) { 75 - $body[] = $this->formatText($content); 76 - $body[] = null; 77 - } 78 - 79 - if ($this->getChangedByCommit()) { 80 - $body[] = 'CHANGED PRIOR TO COMMIT'; 81 - $body[] = ' This revision was updated prior to commit.'; 82 - $body[] = null; 83 - } 84 - 85 - $inlines = $this->getInlineComments(); 86 - if ($inlines) { 87 - $body[] = 'INLINE COMMENTS'; 88 - $changesets = $this->getChangesets(); 89 - foreach ($inlines as $inline) { 90 - $changeset = $changesets[$inline->getChangesetID()]; 91 - if (!$changeset) { 92 - throw new Exception('Changeset missing!'); 93 - } 94 - $file = $changeset->getFilename(); 95 - $line = $inline->renderLineRange(); 96 - $content = $inline->getContent(); 97 - $body[] = $this->formatText("{$file}:{$line} {$content}"); 98 - } 99 - $body[] = null; 100 - } 101 - 102 - $body[] = $this->renderRevisionDetailLink(); 103 - $revision = $this->getRevision(); 104 - if ($revision->getStatus() == DifferentialRevisionStatus::COMMITTED) { 105 - $rev_ref = $revision->getRevisionRef(); 106 - if ($rev_ref) { 107 - $body[] = " Detail URL: ".$rev_ref->getDetailURL(); 108 - } 109 - } 110 - $body[] = null; 111 - 112 - return implode("\n", $body); 113 - } 114 - }
+1 -1
src/applications/differential/mail/feedback/__init__.php src/applications/differential/mail/comment/__init__.php
··· 11 11 phutil_require_module('phabricator', 'applications/differential/mail/base'); 12 12 13 13 14 - phutil_require_source('DifferentialFeedbackMail.php'); 14 + phutil_require_source('DifferentialCommentMail.php');
+5
src/applications/differential/view/addcomment/DifferentialAddCommentView.php
··· 38 38 39 39 public function render() { 40 40 41 + $revision = $this->revision; 42 + 41 43 $actions = array(); 42 44 foreach ($this->actions as $action) { 43 45 $actions[$action] = DifferentialAction::getActionVerb($action); ··· 46 48 $form = new AphrontFormView(); 47 49 $form 48 50 ->setAction($this->actionURI) 51 + ->addHiddenInput('revision_id', $revision->getID()) 49 52 ->appendChild( 50 53 id(new AphrontFormSelectControl()) 51 54 ->setLabel('Action') 55 + ->setName('action') 52 56 ->setOptions($actions)) 53 57 ->appendChild( 54 58 id(new AphrontFormTextAreaControl()) 59 + ->setName('comment') 55 60 ->setLabel('Comment')) 56 61 ->appendChild( 57 62 id(new AphrontFormSubmitControl())