~ubuntu-branches/ubuntu/wily/phabricator/wily-proposed

« back to all changes in this revision

Viewing changes to phabricator/src/applications/audit/controller/PhabricatorAuditPreviewController.php

  • Committer: Package Import Robot
  • Author(s): Richard Sellam
  • Date: 2015-08-03 23:28:35 UTC
  • mfrom: (0.39.1) (0.38.1) (0.27.3) (2.1.10 sid)
  • Revision ID: package-import@ubuntu.com-20150803232835-qnomusa964oxnywb
Tags: 0~git20150803-1
* New snapshot release (closes: #789760)
* renamed arcanist bash-completion file (closes: #791632)
* depends on same version for libphutil (closes: #794462)
* added php5-mysqlnd alternative depends (closes: #792136)

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
final class PhabricatorAuditPreviewController
4
4
  extends PhabricatorAuditController {
5
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);
 
6
  public function handleRequest(AphrontRequest $request) {
 
7
    $viewer = $request->getViewer();
 
8
    $id = $request->getURIData('id');
 
9
 
 
10
    $commit = id(new PhabricatorRepositoryCommit())->load($id);
17
11
    if (!$commit) {
18
12
      return new Aphront404Response();
19
13
    }
23
17
    $action = $request->getStr('action');
24
18
    if ($action != PhabricatorAuditActionConstants::COMMENT) {
25
19
      $action_xaction = id(new PhabricatorAuditTransaction())
26
 
        ->setAuthorPHID($user->getPHID())
 
20
        ->setAuthorPHID($viewer->getPHID())
27
21
        ->setObjectPHID($commit->getPHID())
28
22
        ->setTransactionType(PhabricatorAuditActionConstants::ACTION)
29
23
        ->setNewValue($action);
52
46
    $content = $request->getStr('content');
53
47
    if (strlen($content)) {
54
48
      $xactions[] = id(new PhabricatorAuditTransaction())
55
 
        ->setAuthorPHID($user->getPHID())
 
49
        ->setAuthorPHID($viewer->getPHID())
56
50
        ->setObjectPHID($commit->getPHID())
57
51
        ->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
58
52
        ->attachComment(
72
66
 
73
67
    $view = id(new PhabricatorAuditTransactionView())
74
68
      ->setIsPreview(true)
75
 
      ->setUser($user)
 
69
      ->setUser($viewer)
76
70
      ->setObjectPHID($commit->getPHID())
77
71
      ->setTransactions($xactions);
78
72
 
79
73
    id(new PhabricatorDraft())
80
 
      ->setAuthorPHID($user->getPHID())
81
 
      ->setDraftKey('diffusion-audit-'.$this->id)
 
74
      ->setAuthorPHID($viewer->getPHID())
 
75
      ->setDraftKey('diffusion-audit-'.$id)
82
76
      ->setDraft($content)
83
77
      ->replaceOrDelete();
84
78