[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhabricatorAuditPreviewController 4 extends PhabricatorAuditController { 5 6 private $id; 7 8 public function willProcessRequest(array $data) { 9 $this->id = $data['id']; 10 } 11 12 public function processRequest() { 13 $request = $this->getRequest(); 14 $user = $request->getUser(); 15 16 $commit = id(new PhabricatorRepositoryCommit())->load($this->id); 17 if (!$commit) { 18 return new Aphront404Response(); 19 } 20 21 $xactions = array(); 22 23 $action = $request->getStr('action'); 24 if ($action != PhabricatorAuditActionConstants::COMMENT) { 25 $action_xaction = id(new PhabricatorAuditTransaction()) 26 ->setAuthorPHID($user->getPHID()) 27 ->setObjectPHID($commit->getPHID()) 28 ->setTransactionType(PhabricatorAuditActionConstants::ACTION) 29 ->setNewValue($action); 30 31 $auditors = $request->getStrList('auditors'); 32 if ($action == PhabricatorAuditActionConstants::ADD_AUDITORS && 33 $auditors) { 34 $action_xaction->setTransactionType($action); 35 $action_xaction->setNewValue(array_fuse($auditors)); 36 } 37 38 $ccs = $request->getStrList('ccs'); 39 if ($action == PhabricatorAuditActionConstants::ADD_CCS && $ccs) { 40 $action_xaction->setTransactionType( 41 PhabricatorTransactions::TYPE_SUBSCRIBERS); 42 43 // NOTE: This doesn't get processed before use, so just provide fake 44 // values. 45 $action_xaction->setOldValue(array()); 46 $action_xaction->setNewValue($ccs); 47 } 48 49 $xactions[] = $action_xaction; 50 } 51 52 $content = $request->getStr('content'); 53 if (strlen($content)) { 54 $xactions[] = id(new PhabricatorAuditTransaction()) 55 ->setAuthorPHID($user->getPHID()) 56 ->setObjectPHID($commit->getPHID()) 57 ->setTransactionType(PhabricatorTransactions::TYPE_COMMENT) 58 ->attachComment( 59 id(new PhabricatorAuditTransactionComment()) 60 ->setContent($content)); 61 } 62 63 $phids = array(); 64 foreach ($xactions as $xaction) { 65 $phids[] = $xaction->getRequiredHandlePHIDs(); 66 } 67 $phids = array_mergev($phids); 68 $handles = $this->loadViewerHandles($phids); 69 foreach ($xactions as $xaction) { 70 $xaction->setHandles($handles); 71 } 72 73 $view = id(new PhabricatorAuditTransactionView()) 74 ->setIsPreview(true) 75 ->setUser($user) 76 ->setObjectPHID($commit->getPHID()) 77 ->setTransactions($xactions); 78 79 id(new PhabricatorDraft()) 80 ->setAuthorPHID($user->getPHID()) 81 ->setDraftKey('diffusion-audit-'.$this->id) 82 ->setDraft($content) 83 ->replaceOrDelete(); 84 85 return id(new AphrontAjaxResponse())->setContent(hsprintf('%s', $view)); 86 } 87 88 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |