2013-10-09 14:05:10 -07:00
|
|
|
<?php
|
|
|
|
|
2015-01-03 23:48:19 +11:00
|
|
|
final class PhabricatorLunarPhasePolicyRule extends PhabricatorPolicyRule {
|
2013-10-09 14:05:10 -07:00
|
|
|
|
2015-11-17 06:26:13 +11:00
|
|
|
const PHASE_FULL = 'full';
|
|
|
|
const PHASE_NEW = 'new';
|
2013-10-09 14:05:10 -07:00
|
|
|
const PHASE_WAXING = 'waxing';
|
|
|
|
const PHASE_WANING = 'waning';
|
|
|
|
|
|
|
|
public function getRuleDescription() {
|
|
|
|
return pht('when the moon');
|
|
|
|
}
|
|
|
|
|
2015-06-13 15:44:03 -07:00
|
|
|
public function applyRule(
|
|
|
|
PhabricatorUser $viewer,
|
|
|
|
$value,
|
|
|
|
PhabricatorPolicyInterface $object) {
|
|
|
|
|
2013-10-09 14:05:10 -07:00
|
|
|
$moon = new PhutilLunarPhase(PhabricatorTime::getNow());
|
|
|
|
|
|
|
|
switch ($value) {
|
|
|
|
case 'full':
|
|
|
|
return $moon->isFull();
|
|
|
|
case 'new':
|
|
|
|
return $moon->isNew();
|
|
|
|
case 'waxing':
|
|
|
|
return $moon->isWaxing();
|
|
|
|
case 'waning':
|
|
|
|
return $moon->isWaning();
|
2015-11-17 06:26:13 +11:00
|
|
|
default:
|
|
|
|
return false;
|
2013-10-09 14:05:10 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getValueControlType() {
|
|
|
|
return self::CONTROL_TYPE_SELECT;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getValueControlTemplate() {
|
|
|
|
return array(
|
|
|
|
'options' => array(
|
2015-11-17 06:26:13 +11:00
|
|
|
self::PHASE_FULL => pht('is full'),
|
|
|
|
self::PHASE_NEW => pht('is new'),
|
2013-10-09 14:05:10 -07:00
|
|
|
self::PHASE_WAXING => pht('is waxing'),
|
|
|
|
self::PHASE_WANING => pht('is waning'),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getRuleOrder() {
|
|
|
|
return 1000;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|