PhabricatorAuditStatusConstants.php 2.78 KB
Newer Older
1
2
<?php

Joshua Spence's avatar
Joshua Spence committed
3
final class PhabricatorAuditStatusConstants extends Phobject {
4

5
6
7
8
9
10
  const NONE                    = '';
  const AUDIT_NOT_REQUIRED      = 'audit-not-required';
  const AUDIT_REQUIRED          = 'audit-required';
  const CONCERNED               = 'concerned';
  const ACCEPTED                = 'accepted';
  const AUDIT_REQUESTED         = 'requested';
11
12
  const RESIGNED                = 'resigned';
  const CLOSED                  = 'closed';
13
  const CC                      = 'cc';
14
15

  public static function getStatusNameMap() {
Chad Little's avatar
Chad Little committed
16
17
18
19
20
21
22
23
24
25
    $map = array(
      self::NONE                => pht('Not Applicable'),
      self::AUDIT_NOT_REQUIRED  => pht('Audit Not Required'),
      self::AUDIT_REQUIRED      => pht('Audit Required'),
      self::CONCERNED           => pht('Concern Raised'),
      self::ACCEPTED            => pht('Accepted'),
      self::AUDIT_REQUESTED     => pht('Audit Requested'),
      self::RESIGNED            => pht('Resigned'),
      self::CLOSED              => pht('Closed'),
      self::CC                  => pht("Was CC'd"),
26
27
28
29
30
    );

    return $map;
  }

31
32
33
34
35
36
37
  public static function getActionRequiredStatusConstants() {
    return array(
      self::AUDIT_REQUIRED,
      self::AUDIT_REQUESTED,
    );
  }

epriestley's avatar
epriestley committed
38
  public static function getStatusName($code) {
Chad Little's avatar
Chad Little committed
39
40
41
42
43
44
    return idx(self::getStatusNameMap(), $code, pht('Unknown'));
  }

  public static function getStatusColor($code) {
    switch ($code) {
      case self::CONCERNED:
Chad Little's avatar
Chad Little committed
45
        $color = 'red';
Chad Little's avatar
Chad Little committed
46
47
        break;
      case self::AUDIT_REQUIRED:
48
      case self::AUDIT_REQUESTED:
Chad Little's avatar
Chad Little committed
49
        $color = 'orange';
Chad Little's avatar
Chad Little committed
50
        break;
Bob Trahan's avatar
Bob Trahan committed
51
52
53
      case self::ACCEPTED:
        $color = 'green';
        break;
54
55
56
57
58
59
60
      case self::AUDIT_NOT_REQUIRED:
        $color = 'blue';
        break;
      case self::RESIGNED:
      case self::CLOSED:
        $color = 'dark';
        break;
Chad Little's avatar
Chad Little committed
61
      default:
62
        $color = 'bluegrey';
Chad Little's avatar
Chad Little committed
63
64
65
        break;
    }
    return $color;
epriestley's avatar
epriestley committed
66
67
  }

68
69
  public static function getStatusIcon($code) {
    switch ($code) {
70
71
      case self::AUDIT_NOT_REQUIRED:
      case self::RESIGNED:
72
73
        $icon = PHUIStatusItemView::ICON_OPEN;
        break;
74
75
      case self::AUDIT_REQUIRED:
      case self::AUDIT_REQUESTED:
76
77
        $icon = PHUIStatusItemView::ICON_WARNING;
        break;
78
      case self::CONCERNED:
79
80
        $icon = PHUIStatusItemView::ICON_REJECT;
        break;
81
82
      case self::ACCEPTED:
      case self::CLOSED:
83
84
85
86
87
88
89
90
91
        $icon = PHUIStatusItemView::ICON_ACCEPT;
        break;
      default:
        $icon = PHUIStatusItemView::ICON_QUESTION;
        break;
    }
    return $icon;
  }

92
93
94
95
96
97
98
99
100
101
102
103
  public static function getOpenStatusConstants() {
    return array(
      self::AUDIT_REQUIRED,
      self::AUDIT_REQUESTED,
      self::CONCERNED,
    );
  }

  public static function isOpenStatus($status) {
    return in_array($status, self::getOpenStatusConstants());
  }

104
}