Generate file attachment transactions for explicit Remarkup attachments on common...
[phabricator.git] / src / applications / system / action / PhabricatorSystemAction.php
blobb712dfca8cf31c77a83c605c28d86ac54561fabf
1 <?php
3 abstract class PhabricatorSystemAction extends Phobject {
5 final public function getActionConstant() {
6 return $this->getPhobjectClassConstant('TYPECONST', 32);
9 abstract public function getScoreThreshold();
11 public function shouldBlockActor($actor, $score) {
12 return ($score > $this->getScoreThreshold());
15 public function getLimitExplanation() {
16 return pht('You are performing too many actions too quickly.');
19 public function getRateExplanation($score) {
20 return pht(
21 'The maximum allowed rate for this action is %s. You are taking '.
22 'actions at a rate of %s.',
23 $this->formatRate($this->getScoreThreshold()),
24 $this->formatRate($score));
27 protected function formatRate($rate) {
28 if ($rate > 10) {
29 $str = pht('%d / second', $rate);
30 } else {
31 $rate *= 60;
32 if ($rate > 10) {
33 $str = pht('%d / minute', $rate);
34 } else {
35 $rate *= 60;
36 $str = pht('%d / hour', $rate);
40 return phutil_tag('strong', array(), $str);