Path: blob/master/src/applications/differential/storage/DifferentialReviewer.php
12256 views
<?php12final class DifferentialReviewer3extends DifferentialDAO {45protected $revisionPHID;6protected $reviewerPHID;7protected $reviewerStatus;8protected $lastActionDiffPHID;9protected $lastCommentDiffPHID;10protected $lastActorPHID;11protected $voidedPHID;12protected $options = array();1314private $authority = array();15private $changesets = self::ATTACHABLE;1617protected function getConfiguration() {18return array(19self::CONFIG_SERIALIZATION => array(20'options' => self::SERIALIZATION_JSON,21),22self::CONFIG_COLUMN_SCHEMA => array(23'reviewerStatus' => 'text64',24'lastActionDiffPHID' => 'phid?',25'lastCommentDiffPHID' => 'phid?',26'lastActorPHID' => 'phid?',27'voidedPHID' => 'phid?',28),29self::CONFIG_KEY_SCHEMA => array(30'key_revision' => array(31'columns' => array('revisionPHID', 'reviewerPHID'),32'unique' => true,33),34'key_reviewer' => array(35'columns' => array('reviewerPHID', 'revisionPHID'),36),37),38) + parent::getConfiguration();39}4041public function isUser() {42$user_type = PhabricatorPeopleUserPHIDType::TYPECONST;43return (phid_get_type($this->getReviewerPHID()) == $user_type);44}4546public function isPackage() {47$package_type = PhabricatorOwnersPackagePHIDType::TYPECONST;48return (phid_get_type($this->getReviewerPHID()) == $package_type);49}5051public function attachAuthority(PhabricatorUser $user, $has_authority) {52$this->authority[$user->getCacheFragment()] = $has_authority;53return $this;54}5556public function hasAuthority(PhabricatorUser $viewer) {57$cache_fragment = $viewer->getCacheFragment();58return $this->assertAttachedKey($this->authority, $cache_fragment);59}6061public function attachChangesets(array $changesets) {62$this->changesets = $changesets;63return $this;64}6566public function getChangesets() {67return $this->assertAttached($this->changesets);68}6970public function setOption($key, $value) {71$this->options[$key] = $value;72return $this;73}7475public function getOption($key, $default = null) {76return idx($this->options, $key, $default);77}7879public function isResigned() {80$status_resigned = DifferentialReviewerStatus::STATUS_RESIGNED;81return ($this->getReviewerStatus() == $status_resigned);82}8384public function isBlocking() {85$status_blocking = DifferentialReviewerStatus::STATUS_BLOCKING;86return ($this->getReviewerStatus() == $status_blocking);87}8889public function isRejected($diff_phid) {90$status_rejected = DifferentialReviewerStatus::STATUS_REJECTED;9192if ($this->getReviewerStatus() != $status_rejected) {93return false;94}9596if ($this->getVoidedPHID()) {97return false;98}99100if ($this->isCurrentAction($diff_phid)) {101return true;102}103104return false;105}106107108public function isAccepted($diff_phid) {109$status_accepted = DifferentialReviewerStatus::STATUS_ACCEPTED;110111if ($this->getReviewerStatus() != $status_accepted) {112return false;113}114115// If this accept has been voided (for example, but a reviewer using116// "Request Review"), don't count it as a real "Accept" even if it is117// against the current diff PHID.118if ($this->getVoidedPHID()) {119return false;120}121122if ($this->isCurrentAction($diff_phid)) {123return true;124}125126$sticky_key = 'differential.sticky-accept';127$is_sticky = PhabricatorEnv::getEnvConfig($sticky_key);128129if ($is_sticky) {130return true;131}132133return false;134}135136private function isCurrentAction($diff_phid) {137if (!$diff_phid) {138return true;139}140141$action_phid = $this->getLastActionDiffPHID();142143if (!$action_phid) {144return true;145}146147if ($action_phid == $diff_phid) {148return true;149}150151return false;152}153154}155156157