@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.

at upstream/main 135 lines 3.5 kB view raw
1<?php 2 3final class PhabricatorOAuthServerClient 4 extends PhabricatorOAuthServerDAO 5 implements 6 PhabricatorPolicyInterface, 7 PhabricatorApplicationTransactionInterface, 8 PhabricatorDestructibleInterface { 9 10 protected $secret; 11 protected $name; 12 protected $redirectURI; 13 protected $creatorPHID; 14 protected $isTrusted; 15 protected $viewPolicy; 16 protected $editPolicy; 17 protected $isDisabled; 18 19 public function getEditURI() { 20 $id = $this->getID(); 21 return "/oauthserver/edit/{$id}/"; 22 } 23 24 public function getViewURI() { 25 $id = $this->getID(); 26 return "/oauthserver/client/view/{$id}/"; 27 } 28 29 public static function initializeNewClient(PhabricatorUser $actor) { 30 return id(new PhabricatorOAuthServerClient()) 31 ->setCreatorPHID($actor->getPHID()) 32 ->setSecret(Filesystem::readRandomCharacters(32)) 33 ->setViewPolicy(PhabricatorPolicies::POLICY_USER) 34 ->setEditPolicy($actor->getPHID()) 35 ->setIsDisabled(0) 36 ->setIsTrusted(0); 37 } 38 39 protected function getConfiguration() { 40 return array( 41 self::CONFIG_AUX_PHID => true, 42 self::CONFIG_COLUMN_SCHEMA => array( 43 'name' => 'text255', 44 'secret' => 'text32', 45 'redirectURI' => 'text255', 46 'isTrusted' => 'bool', 47 'isDisabled' => 'bool', 48 ), 49 self::CONFIG_KEY_SCHEMA => array( 50 'creatorPHID' => array( 51 'columns' => array('creatorPHID'), 52 ), 53 ), 54 ) + parent::getConfiguration(); 55 } 56 57 public function generatePHID() { 58 return PhabricatorPHID::generateNewPHID( 59 PhabricatorOAuthServerClientPHIDType::TYPECONST); 60 } 61 62 public function getURI() { 63 return urisprintf( 64 '/oauthserver/client/view/%d/', 65 $this->getID()); 66 } 67 68 69/* -( PhabricatorPolicyInterface )----------------------------------------- */ 70 71 72 public function getCapabilities() { 73 return array( 74 PhabricatorPolicyCapability::CAN_VIEW, 75 PhabricatorPolicyCapability::CAN_EDIT, 76 ); 77 } 78 79 public function getPolicy($capability) { 80 switch ($capability) { 81 case PhabricatorPolicyCapability::CAN_VIEW: 82 return $this->getViewPolicy(); 83 case PhabricatorPolicyCapability::CAN_EDIT: 84 return $this->getEditPolicy(); 85 } 86 } 87 88 public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { 89 return false; 90 } 91 92 93/* -( PhabricatorApplicationTransactionInterface )------------------------- */ 94 95 96 public function getApplicationTransactionEditor() { 97 return new PhabricatorOAuthServerEditor(); 98 } 99 100 public function getApplicationTransactionTemplate() { 101 return new PhabricatorOAuthServerTransaction(); 102 } 103 104 105/* -( PhabricatorDestructibleInterface )----------------------------------- */ 106 107 108 public function destroyObjectPermanently( 109 PhabricatorDestructionEngine $engine) { 110 111 $this->openTransaction(); 112 $this->delete(); 113 114 $authorizations = id(new PhabricatorOAuthClientAuthorization()) 115 ->loadAllWhere('clientPHID = %s', $this->getPHID()); 116 foreach ($authorizations as $authorization) { 117 $authorization->delete(); 118 } 119 120 $tokens = id(new PhabricatorOAuthServerAccessToken()) 121 ->loadAllWhere('clientPHID = %s', $this->getPHID()); 122 foreach ($tokens as $token) { 123 $token->delete(); 124 } 125 126 $codes = id(new PhabricatorOAuthServerAuthorizationCode()) 127 ->loadAllWhere('clientPHID = %s', $this->getPHID()); 128 foreach ($codes as $code) { 129 $code->delete(); 130 } 131 132 $this->saveTransaction(); 133 134 } 135}