2013-06-17 19:48:41 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorAuthProviderConfigTransaction
|
|
|
|
extends PhabricatorApplicationTransaction {
|
|
|
|
|
2013-06-17 19:52:38 +02:00
|
|
|
const TYPE_ENABLE = 'config:enable';
|
|
|
|
const TYPE_REGISTRATION = 'config:registration';
|
|
|
|
const TYPE_LINK = 'config:link';
|
|
|
|
const TYPE_UNLINK = 'config:unlink';
|
2014-06-09 20:36:49 +02:00
|
|
|
const TYPE_TRUST_EMAILS = 'config:trustEmails';
|
2013-06-17 19:52:38 +02:00
|
|
|
const TYPE_PROPERTY = 'config:property';
|
|
|
|
|
2013-06-18 19:02:34 +02:00
|
|
|
const PROPERTY_KEY = 'auth:property';
|
|
|
|
|
|
|
|
private $provider;
|
|
|
|
|
|
|
|
public function setProvider(PhabricatorAuthProvider $provider) {
|
|
|
|
$this->provider = $provider;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getProvider() {
|
|
|
|
return $this->provider;
|
|
|
|
}
|
|
|
|
|
2013-06-17 19:48:41 +02:00
|
|
|
public function getApplicationName() {
|
|
|
|
return 'auth';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getApplicationTransactionType() {
|
Transactions - deploy buildTransactionTimeline against a few more applications
Summary:
Ref T4712. Thus far, it seems that most "non-standard" things can be done pretty easily in the controller. Aside from deploying, this diff had to fix a few bugs / missing implementations of stuff.
(Notably, PhabricatorAuthProviderConfig, HeraldRule, PhabricatorSlowvotePoll, and AlmanacNetwork needed to implement PhabricatorApplicationTransactionInterface, PhabricatorAuthAuthProviderPHIDType had to be added, and a rendering bug in transactions of type PhabricatorOAuth2AuthProvider had to be fixed.)
Test Plan: Almanac - looked at binding, device, network, and service view controllers and verified timeline displayed properly. Herald - looked at a rule and verified timeline. Slowvote - looked at a vote and verified timeline. Auth - looked at an auth provider (Facebook) and verified proper display of transactions within timeline.
Reviewers: epriestley
Reviewed By: epriestley
Subscribers: Korvin, epriestley
Maniphest Tasks: T4712
Differential Revision: https://secure.phabricator.com/D10921
2014-12-02 23:33:59 +01:00
|
|
|
return PhabricatorAuthAuthProviderPHIDType::TYPECONST;
|
2013-06-17 19:48:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getApplicationTransactionCommentObject() {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2013-06-17 19:53:29 +02:00
|
|
|
public function getIcon() {
|
|
|
|
$old = $this->getOldValue();
|
|
|
|
$new = $this->getNewValue();
|
|
|
|
|
|
|
|
switch ($this->getTransactionType()) {
|
|
|
|
case self::TYPE_ENABLE:
|
|
|
|
if ($new) {
|
2014-04-22 17:25:54 +02:00
|
|
|
return 'fa-play';
|
2013-06-17 19:53:29 +02:00
|
|
|
} else {
|
2014-04-22 17:25:54 +02:00
|
|
|
return 'fa-pause';
|
2013-06-17 19:53:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent::getIcon();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getColor() {
|
|
|
|
$old = $this->getOldValue();
|
|
|
|
$new = $this->getNewValue();
|
|
|
|
|
|
|
|
switch ($this->getTransactionType()) {
|
|
|
|
case self::TYPE_ENABLE:
|
|
|
|
if ($new) {
|
|
|
|
return 'green';
|
|
|
|
} else {
|
|
|
|
return 'red';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent::getColor();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTitle() {
|
|
|
|
$author_phid = $this->getAuthorPHID();
|
|
|
|
|
|
|
|
$old = $this->getOldValue();
|
|
|
|
$new = $this->getNewValue();
|
|
|
|
|
|
|
|
switch ($this->getTransactionType()) {
|
|
|
|
case self::TYPE_ENABLE:
|
|
|
|
if ($old === null) {
|
|
|
|
return pht(
|
|
|
|
'%s created this provider.',
|
|
|
|
$this->renderHandleLink($author_phid));
|
|
|
|
} else if ($new) {
|
|
|
|
return pht(
|
|
|
|
'%s enabled this provider.',
|
|
|
|
$this->renderHandleLink($author_phid));
|
|
|
|
} else {
|
|
|
|
return pht(
|
|
|
|
'%s disabled this provider.',
|
|
|
|
$this->renderHandleLink($author_phid));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case self::TYPE_REGISTRATION:
|
|
|
|
if ($new) {
|
|
|
|
return pht(
|
|
|
|
'%s enabled registration.',
|
|
|
|
$this->renderHandleLink($author_phid));
|
|
|
|
} else {
|
|
|
|
return pht(
|
|
|
|
'%s disabled registration.',
|
|
|
|
$this->renderHandleLink($author_phid));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case self::TYPE_LINK:
|
|
|
|
if ($new) {
|
|
|
|
return pht(
|
|
|
|
'%s enabled accont linking.',
|
|
|
|
$this->renderHandleLink($author_phid));
|
|
|
|
} else {
|
|
|
|
return pht(
|
|
|
|
'%s disabled account linking.',
|
|
|
|
$this->renderHandleLink($author_phid));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case self::TYPE_UNLINK:
|
|
|
|
if ($new) {
|
|
|
|
return pht(
|
|
|
|
'%s enabled account unlinking.',
|
|
|
|
$this->renderHandleLink($author_phid));
|
|
|
|
} else {
|
|
|
|
return pht(
|
|
|
|
'%s disabled account unlinking.',
|
|
|
|
$this->renderHandleLink($author_phid));
|
|
|
|
}
|
|
|
|
break;
|
2014-05-16 23:14:06 +02:00
|
|
|
case self::TYPE_TRUST_EMAILS:
|
|
|
|
if ($new) {
|
|
|
|
return pht(
|
|
|
|
'%s enabled email trust.',
|
|
|
|
$this->renderHandleLink($author_phid));
|
|
|
|
} else {
|
|
|
|
return pht(
|
|
|
|
'%s disabled email trust.',
|
|
|
|
$this->renderHandleLink($author_phid));
|
|
|
|
}
|
|
|
|
break;
|
2013-06-17 19:53:29 +02:00
|
|
|
case self::TYPE_PROPERTY:
|
2013-06-18 19:02:34 +02:00
|
|
|
$provider = $this->getProvider();
|
|
|
|
if ($provider) {
|
|
|
|
$title = $provider->renderConfigPropertyTransactionTitle($this);
|
|
|
|
if (strlen($title)) {
|
|
|
|
return $title;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-17 19:53:29 +02:00
|
|
|
return pht(
|
|
|
|
'%s edited a property of this provider.',
|
|
|
|
$this->renderHandleLink($author_phid));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent::getTitle();
|
|
|
|
}
|
|
|
|
|
2013-06-17 19:48:41 +02:00
|
|
|
}
|