Path: blob/master/src/applications/auth/storage/PhabricatorAuthProviderConfigTransaction.php
12256 views
<?php12final class PhabricatorAuthProviderConfigTransaction3extends PhabricatorApplicationTransaction {45const TYPE_ENABLE = 'config:enable';6const TYPE_LOGIN = 'config:login';7const TYPE_REGISTRATION = 'config:registration';8const TYPE_LINK = 'config:link';9const TYPE_UNLINK = 'config:unlink';10const TYPE_TRUST_EMAILS = 'config:trustEmails';11const TYPE_AUTO_LOGIN = 'config:autoLogin';12const TYPE_PROPERTY = 'config:property';1314const PROPERTY_KEY = 'auth:property';1516public function getProvider() {17return $this->getObject()->getProvider();18}1920public function getApplicationName() {21return 'auth';22}2324public function getApplicationTransactionType() {25return PhabricatorAuthAuthProviderPHIDType::TYPECONST;26}2728public function getIcon() {29$old = $this->getOldValue();30$new = $this->getNewValue();3132switch ($this->getTransactionType()) {33case self::TYPE_ENABLE:34if ($new) {35return 'fa-check';36} else {37return 'fa-ban';38}39}4041return parent::getIcon();42}4344public function getColor() {45$old = $this->getOldValue();46$new = $this->getNewValue();4748switch ($this->getTransactionType()) {49case self::TYPE_ENABLE:50if ($new) {51return 'green';52} else {53return 'indigo';54}55}5657return parent::getColor();58}5960public function getTitle() {61$author_phid = $this->getAuthorPHID();6263$old = $this->getOldValue();64$new = $this->getNewValue();6566switch ($this->getTransactionType()) {67case self::TYPE_ENABLE:68if ($old === null) {69return pht(70'%s created this provider.',71$this->renderHandleLink($author_phid));72} else if ($new) {73return pht(74'%s enabled this provider.',75$this->renderHandleLink($author_phid));76} else {77return pht(78'%s disabled this provider.',79$this->renderHandleLink($author_phid));80}81break;82case self::TYPE_LOGIN:83if ($new) {84return pht(85'%s enabled login.',86$this->renderHandleLink($author_phid));87} else {88return pht(89'%s disabled login.',90$this->renderHandleLink($author_phid));91}92break;93case self::TYPE_REGISTRATION:94if ($new) {95return pht(96'%s enabled registration.',97$this->renderHandleLink($author_phid));98} else {99return pht(100'%s disabled registration.',101$this->renderHandleLink($author_phid));102}103break;104case self::TYPE_LINK:105if ($new) {106return pht(107'%s enabled account linking.',108$this->renderHandleLink($author_phid));109} else {110return pht(111'%s disabled account linking.',112$this->renderHandleLink($author_phid));113}114break;115case self::TYPE_UNLINK:116if ($new) {117return pht(118'%s enabled account unlinking.',119$this->renderHandleLink($author_phid));120} else {121return pht(122'%s disabled account unlinking.',123$this->renderHandleLink($author_phid));124}125break;126case self::TYPE_TRUST_EMAILS:127if ($new) {128return pht(129'%s enabled email trust.',130$this->renderHandleLink($author_phid));131} else {132return pht(133'%s disabled email trust.',134$this->renderHandleLink($author_phid));135}136break;137case self::TYPE_AUTO_LOGIN:138if ($new) {139return pht(140'%s enabled auto login.',141$this->renderHandleLink($author_phid));142} else {143return pht(144'%s disabled auto login.',145$this->renderHandleLink($author_phid));146}147break;148case self::TYPE_PROPERTY:149$provider = $this->getProvider();150if ($provider) {151$title = $provider->renderConfigPropertyTransactionTitle($this);152if (strlen($title)) {153return $title;154}155}156157return pht(158'%s edited a property of this provider.',159$this->renderHandleLink($author_phid));160break;161}162163return parent::getTitle();164}165166}167168169