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

« back to all changes in this revision

Viewing changes to phabricator/src/applications/spaces/storage/PhabricatorSpacesNamespaceTransaction.php

  • Committer: Package Import Robot
  • Author(s): Richard Sellam
  • Date: 2015-06-13 10:52:10 UTC
  • mfrom: (0.35.1) (0.34.1) (0.27.2) (9.1.2 wily)
  • Revision ID: package-import@ubuntu.com-20150613105210-jysis8natyi5l3np
Tags: 0~git20150613-1
* New snapshot release (closes: #787805)
* fixed typo in logrotate script (closes: #787645)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
final class PhabricatorSpacesNamespaceTransaction
 
4
  extends PhabricatorApplicationTransaction {
 
5
 
 
6
  const TYPE_NAME = 'spaces:name';
 
7
  const TYPE_DEFAULT = 'spaces:default';
 
8
  const TYPE_DESCRIPTION = 'spaces:description';
 
9
  const TYPE_ARCHIVE = 'spaces:archive';
 
10
 
 
11
  public function getApplicationName() {
 
12
    return 'spaces';
 
13
  }
 
14
 
 
15
  public function getApplicationTransactionType() {
 
16
    return PhabricatorSpacesNamespacePHIDType::TYPECONST;
 
17
  }
 
18
 
 
19
  public function getApplicationTransactionCommentObject() {
 
20
    return null;
 
21
  }
 
22
 
 
23
  public function shouldHide() {
 
24
    $old = $this->getOldValue();
 
25
 
 
26
    switch ($this->getTransactionType()) {
 
27
      case self::TYPE_DESCRIPTION:
 
28
        return ($old === null);
 
29
    }
 
30
 
 
31
    return parent::shouldHide();
 
32
  }
 
33
 
 
34
  public function hasChangeDetails() {
 
35
    switch ($this->getTransactionType()) {
 
36
      case self::TYPE_DESCRIPTION:
 
37
        return true;
 
38
    }
 
39
 
 
40
    return parent::hasChangeDetails();
 
41
  }
 
42
 
 
43
  public function getRemarkupBlocks() {
 
44
    $blocks = parent::getRemarkupBlocks();
 
45
 
 
46
    switch ($this->getTransactionType()) {
 
47
      case self::TYPE_DESCRIPTION:
 
48
        $blocks[] = $this->getNewValue();
 
49
        break;
 
50
    }
 
51
 
 
52
    return $blocks;
 
53
  }
 
54
 
 
55
  public function getTitle() {
 
56
    $old = $this->getOldValue();
 
57
    $new = $this->getNewValue();
 
58
 
 
59
    $author_phid = $this->getAuthorPHID();
 
60
 
 
61
    switch ($this->getTransactionType()) {
 
62
      case self::TYPE_NAME:
 
63
        if ($old === null) {
 
64
          return pht(
 
65
            '%s created this space.',
 
66
            $this->renderHandleLink($author_phid));
 
67
        } else {
 
68
          return pht(
 
69
            '%s renamed this space from "%s" to "%s".',
 
70
            $this->renderHandleLink($author_phid),
 
71
            $old,
 
72
            $new);
 
73
        }
 
74
      case self::TYPE_DESCRIPTION:
 
75
        return pht(
 
76
          '%s updated the description for this space.',
 
77
            $this->renderHandleLink($author_phid));
 
78
      case self::TYPE_DEFAULT:
 
79
        return pht(
 
80
          '%s made this the default space.',
 
81
          $this->renderHandleLink($author_phid));
 
82
      case self::TYPE_ARCHIVE:
 
83
        if ($new) {
 
84
          return pht(
 
85
            '%s archived this space.',
 
86
            $this->renderHandleLink($author_phid));
 
87
        } else {
 
88
          return pht(
 
89
            '%s activated this space.',
 
90
            $this->renderHandleLink($author_phid));
 
91
        }
 
92
    }
 
93
 
 
94
    return parent::getTitle();
 
95
  }
 
96
 
 
97
}