@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add PhabricatorAuthProviderConfigQuery

Summary: Ref T1536. See D6196. Code not called yet.

Test Plan: Static checks only.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T1536

Differential Revision: https://secure.phabricator.com/D6197

+130 -2
+9 -1
src/__phutil_library_map__.php
··· 822 822 'PhabricatorAuthLoginController' => 'applications/auth/controller/PhabricatorAuthLoginController.php', 823 823 'PhabricatorAuthProvider' => 'applications/auth/provider/PhabricatorAuthProvider.php', 824 824 'PhabricatorAuthProviderConfig' => 'applications/auth/storage/PhabricatorAuthProviderConfig.php', 825 + 'PhabricatorAuthProviderConfigQuery' => 'applications/auth/query/PhabricatorAuthProviderConfigQuery.php', 825 826 'PhabricatorAuthProviderConfigTransaction' => 'applications/auth/storage/PhabricatorAuthProviderConfigTransaction.php', 827 + 'PhabricatorAuthProviderConfigTransactionQuery' => 'applications/auth/query/PhabricatorAuthProviderConfigTransactionQuery.php', 826 828 'PhabricatorAuthProviderLDAP' => 'applications/auth/provider/PhabricatorAuthProviderLDAP.php', 827 829 'PhabricatorAuthProviderOAuth' => 'applications/auth/provider/PhabricatorAuthProviderOAuth.php', 828 830 'PhabricatorAuthProviderOAuthDisqus' => 'applications/auth/provider/PhabricatorAuthProviderOAuthDisqus.php', ··· 2688 2690 'PhabricatorAuthDAO' => 'PhabricatorLiskDAO', 2689 2691 'PhabricatorAuthLinkController' => 'PhabricatorAuthController', 2690 2692 'PhabricatorAuthLoginController' => 'PhabricatorAuthController', 2691 - 'PhabricatorAuthProviderConfig' => 'PhabricatorAuthDAO', 2693 + 'PhabricatorAuthProviderConfig' => 2694 + array( 2695 + 0 => 'PhabricatorAuthDAO', 2696 + 1 => 'PhabricatorPolicyInterface', 2697 + ), 2698 + 'PhabricatorAuthProviderConfigQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 2692 2699 'PhabricatorAuthProviderConfigTransaction' => 'PhabricatorApplicationTransaction', 2700 + 'PhabricatorAuthProviderConfigTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 2693 2701 'PhabricatorAuthProviderLDAP' => 'PhabricatorAuthProvider', 2694 2702 'PhabricatorAuthProviderOAuth' => 'PhabricatorAuthProvider', 2695 2703 'PhabricatorAuthProviderOAuthDisqus' => 'PhabricatorAuthProviderOAuth',
+86
src/applications/auth/query/PhabricatorAuthProviderConfigQuery.php
··· 1 + <?php 2 + 3 + final class PhabricatorAuthProviderConfigQuery 4 + extends PhabricatorCursorPagedPolicyAwareQuery { 5 + 6 + private $ids; 7 + private $phids; 8 + 9 + const STATUS_ALL = 'status:all'; 10 + const STATUS_ENABLED = 'status:enabled'; 11 + 12 + private $status = self::STATUS_ALL; 13 + 14 + public function withPHIDs(array $phids) { 15 + $this->phids = $phids; 16 + return $this; 17 + } 18 + 19 + public function withIDs(array $ids) { 20 + $this->ids = $ids; 21 + return $this; 22 + } 23 + 24 + public function withStatus($status) { 25 + $this->status = $status; 26 + return $this; 27 + } 28 + 29 + public static function getStatusOptions() { 30 + return array( 31 + self::STATUS_ALL => pht('All Providers'), 32 + self::STATUS_ENABLED => pht('Enabled Providers'), 33 + ); 34 + } 35 + 36 + protected function loadPage() { 37 + $table = new PhabricatorAuthProviderConfig(); 38 + $conn_r = $table->establishConnection('r'); 39 + 40 + $data = queryfx_all( 41 + $conn_r, 42 + 'SELECT * FROM %T %Q %Q %Q', 43 + $table->getTableName(), 44 + $this->buildWhereClause($conn_r), 45 + $this->buildOrderClause($conn_r), 46 + $this->buildLimitClause($conn_r)); 47 + 48 + return $table->loadAllFromArray($data); 49 + } 50 + 51 + protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { 52 + $where = array(); 53 + 54 + if ($this->ids) { 55 + $where[] = qsprintf( 56 + $conn_r, 57 + 'id IN (%Ld)', 58 + $this->ids); 59 + } 60 + 61 + if ($this->phids) { 62 + $where[] = qsprintf( 63 + $conn_r, 64 + 'phid IN (%Ls)', 65 + $this->phids); 66 + } 67 + 68 + $status = $this->status; 69 + switch ($status) { 70 + case self::STATUS_ALL: 71 + break; 72 + case self::STATUS_ENABLED: 73 + $where[] = qsprintf( 74 + $conn_r, 75 + 'isEnabled = 1'); 76 + break; 77 + default: 78 + throw new Exception("Unknown status '{$status}'!"); 79 + } 80 + 81 + $where[] = $this->buildPagingClause($conn_r); 82 + 83 + return $this->formatWhereClause($where); 84 + } 85 + 86 + }
+10
src/applications/auth/query/PhabricatorAuthProviderConfigTransactionQuery.php
··· 1 + <?php 2 + 3 + final class PhabricatorAuthProviderConfigTransactionQuery 4 + extends PhabricatorApplicationTransactionQuery { 5 + 6 + protected function getTemplateApplicationTransaction() { 7 + return new PhabricatorAuthProviderConfigTransaction(); 8 + } 9 + 10 + }
+25 -1
src/applications/auth/storage/PhabricatorAuthProviderConfig.php
··· 1 1 <?php 2 2 3 - final class PhabricatorAuthProviderConfig extends PhabricatorAuthDAO { 3 + final class PhabricatorAuthProviderConfig extends PhabricatorAuthDAO 4 + implements PhabricatorPolicyInterface { 4 5 5 6 protected $phid; 6 7 protected $providerClass; ··· 37 38 return $this; 38 39 } 39 40 41 + 42 + /* -( PhabricatorPolicyInterface )----------------------------------------- */ 43 + 44 + 45 + public function getCapabilities() { 46 + return array( 47 + PhabricatorPolicyCapability::CAN_VIEW, 48 + PhabricatorPolicyCapability::CAN_EDIT, 49 + ); 50 + } 51 + 52 + public function getPolicy($capability) { 53 + switch ($capability) { 54 + case PhabricatorPolicyCapability::CAN_VIEW: 55 + return PhabricatorPolicies::POLICY_USER; 56 + case PhabricatorPolicyCapability::CAN_EDIT: 57 + return PhabricatorPolicies::POLICY_ADMIN; 58 + } 59 + } 60 + 61 + public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { 62 + return false; 63 + } 40 64 41 65 }