Changeset View
Changeset View
Standalone View
Standalone View
src/applications/repository/editor/PhabricatorRepositoryEditor.php
| Show All 38 Lines | public function getTransactionTypes() { | ||||
| $types[] = PhabricatorRepositoryTransaction::TYPE_PUSH_POLICY; | $types[] = PhabricatorRepositoryTransaction::TYPE_PUSH_POLICY; | ||||
| $types[] = PhabricatorRepositoryTransaction::TYPE_CREDENTIAL; | $types[] = PhabricatorRepositoryTransaction::TYPE_CREDENTIAL; | ||||
| $types[] = PhabricatorRepositoryTransaction::TYPE_DANGEROUS; | $types[] = PhabricatorRepositoryTransaction::TYPE_DANGEROUS; | ||||
| $types[] = PhabricatorRepositoryTransaction::TYPE_CLONE_NAME; | $types[] = PhabricatorRepositoryTransaction::TYPE_CLONE_NAME; | ||||
| $types[] = PhabricatorRepositoryTransaction::TYPE_SERVICE; | $types[] = PhabricatorRepositoryTransaction::TYPE_SERVICE; | ||||
| $types[] = PhabricatorRepositoryTransaction::TYPE_SYMBOLS_LANGUAGE; | $types[] = PhabricatorRepositoryTransaction::TYPE_SYMBOLS_LANGUAGE; | ||||
| $types[] = PhabricatorRepositoryTransaction::TYPE_SYMBOLS_SOURCES; | $types[] = PhabricatorRepositoryTransaction::TYPE_SYMBOLS_SOURCES; | ||||
| $types[] = PhabricatorRepositoryTransaction::TYPE_STAGING_URI; | $types[] = PhabricatorRepositoryTransaction::TYPE_STAGING_URI; | ||||
| $types[] = PhabricatorRepositoryTransaction::TYPE_AUTOMATION_BLUEPRINTS; | |||||
| $types[] = PhabricatorTransactions::TYPE_EDGE; | $types[] = PhabricatorTransactions::TYPE_EDGE; | ||||
| $types[] = PhabricatorTransactions::TYPE_VIEW_POLICY; | $types[] = PhabricatorTransactions::TYPE_VIEW_POLICY; | ||||
| $types[] = PhabricatorTransactions::TYPE_EDIT_POLICY; | $types[] = PhabricatorTransactions::TYPE_EDIT_POLICY; | ||||
| return $types; | return $types; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | switch ($xaction->getTransactionType()) { | ||||
| case PhabricatorRepositoryTransaction::TYPE_SERVICE: | case PhabricatorRepositoryTransaction::TYPE_SERVICE: | ||||
| return $object->getAlmanacServicePHID(); | return $object->getAlmanacServicePHID(); | ||||
| case PhabricatorRepositoryTransaction::TYPE_SYMBOLS_LANGUAGE: | case PhabricatorRepositoryTransaction::TYPE_SYMBOLS_LANGUAGE: | ||||
| return $object->getSymbolLanguages(); | return $object->getSymbolLanguages(); | ||||
| case PhabricatorRepositoryTransaction::TYPE_SYMBOLS_SOURCES: | case PhabricatorRepositoryTransaction::TYPE_SYMBOLS_SOURCES: | ||||
| return $object->getSymbolSources(); | return $object->getSymbolSources(); | ||||
| case PhabricatorRepositoryTransaction::TYPE_STAGING_URI: | case PhabricatorRepositoryTransaction::TYPE_STAGING_URI: | ||||
| return $object->getDetail('staging-uri'); | return $object->getDetail('staging-uri'); | ||||
| case PhabricatorRepositoryTransaction::TYPE_AUTOMATION_BLUEPRINTS: | |||||
| return $object->getDetail('automation.blueprintPHIDs', array()); | |||||
| } | } | ||||
| } | } | ||||
| protected function getCustomTransactionNewValue( | protected function getCustomTransactionNewValue( | ||||
| PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
| PhabricatorApplicationTransaction $xaction) { | PhabricatorApplicationTransaction $xaction) { | ||||
| switch ($xaction->getTransactionType()) { | switch ($xaction->getTransactionType()) { | ||||
| Show All 20 Lines | switch ($xaction->getTransactionType()) { | ||||
| case PhabricatorRepositoryTransaction::TYPE_PUSH_POLICY: | case PhabricatorRepositoryTransaction::TYPE_PUSH_POLICY: | ||||
| case PhabricatorRepositoryTransaction::TYPE_CREDENTIAL: | case PhabricatorRepositoryTransaction::TYPE_CREDENTIAL: | ||||
| case PhabricatorRepositoryTransaction::TYPE_DANGEROUS: | case PhabricatorRepositoryTransaction::TYPE_DANGEROUS: | ||||
| case PhabricatorRepositoryTransaction::TYPE_CLONE_NAME: | case PhabricatorRepositoryTransaction::TYPE_CLONE_NAME: | ||||
| case PhabricatorRepositoryTransaction::TYPE_SERVICE: | case PhabricatorRepositoryTransaction::TYPE_SERVICE: | ||||
| case PhabricatorRepositoryTransaction::TYPE_SYMBOLS_LANGUAGE: | case PhabricatorRepositoryTransaction::TYPE_SYMBOLS_LANGUAGE: | ||||
| case PhabricatorRepositoryTransaction::TYPE_SYMBOLS_SOURCES: | case PhabricatorRepositoryTransaction::TYPE_SYMBOLS_SOURCES: | ||||
| case PhabricatorRepositoryTransaction::TYPE_STAGING_URI: | case PhabricatorRepositoryTransaction::TYPE_STAGING_URI: | ||||
| case PhabricatorRepositoryTransaction::TYPE_AUTOMATION_BLUEPRINTS: | |||||
| return $xaction->getNewValue(); | return $xaction->getNewValue(); | ||||
| case PhabricatorRepositoryTransaction::TYPE_NOTIFY: | case PhabricatorRepositoryTransaction::TYPE_NOTIFY: | ||||
| case PhabricatorRepositoryTransaction::TYPE_AUTOCLOSE: | case PhabricatorRepositoryTransaction::TYPE_AUTOCLOSE: | ||||
| return (int)$xaction->getNewValue(); | return (int)$xaction->getNewValue(); | ||||
| } | } | ||||
| } | } | ||||
| protected function applyCustomInternalTransaction( | protected function applyCustomInternalTransaction( | ||||
| ▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | switch ($xaction->getTransactionType()) { | ||||
| $object->setDetail('symbol-languages', $xaction->getNewValue()); | $object->setDetail('symbol-languages', $xaction->getNewValue()); | ||||
| return; | return; | ||||
| case PhabricatorRepositoryTransaction::TYPE_SYMBOLS_SOURCES: | case PhabricatorRepositoryTransaction::TYPE_SYMBOLS_SOURCES: | ||||
| $object->setDetail('symbol-sources', $xaction->getNewValue()); | $object->setDetail('symbol-sources', $xaction->getNewValue()); | ||||
| return; | return; | ||||
| case PhabricatorRepositoryTransaction::TYPE_STAGING_URI: | case PhabricatorRepositoryTransaction::TYPE_STAGING_URI: | ||||
| $object->setDetail('staging-uri', $xaction->getNewValue()); | $object->setDetail('staging-uri', $xaction->getNewValue()); | ||||
| return; | return; | ||||
| case PhabricatorRepositoryTransaction::TYPE_AUTOMATION_BLUEPRINTS: | |||||
| $object->setDetail( | |||||
| 'automation.blueprintPHIDs', | |||||
| $xaction->getNewValue()); | |||||
| return; | |||||
| case PhabricatorRepositoryTransaction::TYPE_ENCODING: | case PhabricatorRepositoryTransaction::TYPE_ENCODING: | ||||
| // Make sure the encoding is valid by converting to UTF-8. This tests | // Make sure the encoding is valid by converting to UTF-8. This tests | ||||
| // that the user has mbstring installed, and also that they didn't type | // that the user has mbstring installed, and also that they didn't type | ||||
| // a garbage encoding name. Note that we're converting from UTF-8 to | // a garbage encoding name. Note that we're converting from UTF-8 to | ||||
| // the target encoding, because mbstring is fine with converting from | // the target encoding, because mbstring is fine with converting from | ||||
| // a nonsense encoding. | // a nonsense encoding. | ||||
| $encoding = $xaction->getNewValue(); | $encoding = $xaction->getNewValue(); | ||||
| if (strlen($encoding)) { | if (strlen($encoding)) { | ||||
| Show All 34 Lines | switch ($xaction->getTransactionType()) { | ||||
| } | } | ||||
| if ($new_phid) { | if ($new_phid) { | ||||
| $editor->addEdge($src_phid, $edge_type, $new_phid); | $editor->addEdge($src_phid, $edge_type, $new_phid); | ||||
| } | } | ||||
| $editor->save(); | $editor->save(); | ||||
| break; | break; | ||||
| case PhabricatorRepositoryTransaction::TYPE_AUTOMATION_BLUEPRINTS: | |||||
| DrydockAuthorization::applyAuthorizationChanges( | |||||
| $this->getActor(), | |||||
| $object->getPHID(), | |||||
| $xaction->getOldValue(), | |||||
| $xaction->getNewValue()); | |||||
| break; | |||||
| } | } | ||||
| } | } | ||||
| protected function mergeTransactions( | |||||
| PhabricatorApplicationTransaction $u, | |||||
| PhabricatorApplicationTransaction $v) { | |||||
| $type = $u->getTransactionType(); | |||||
| switch ($type) {} | |||||
| return parent::mergeTransactions($u, $v); | |||||
| } | |||||
| protected function transactionHasEffect( | |||||
| PhabricatorLiskDAO $object, | |||||
| PhabricatorApplicationTransaction $xaction) { | |||||
| $old = $xaction->getOldValue(); | |||||
| $new = $xaction->getNewValue(); | |||||
| $type = $xaction->getTransactionType(); | |||||
| switch ($type) {} | |||||
| return parent::transactionHasEffect($object, $xaction); | |||||
| } | |||||
| protected function requireCapabilities( | protected function requireCapabilities( | ||||
| PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
| PhabricatorApplicationTransaction $xaction) { | PhabricatorApplicationTransaction $xaction) { | ||||
| switch ($xaction->getTransactionType()) { | switch ($xaction->getTransactionType()) { | ||||
| case PhabricatorRepositoryTransaction::TYPE_ACTIVATE: | case PhabricatorRepositoryTransaction::TYPE_ACTIVATE: | ||||
| case PhabricatorRepositoryTransaction::TYPE_NAME: | case PhabricatorRepositoryTransaction::TYPE_NAME: | ||||
| case PhabricatorRepositoryTransaction::TYPE_DESCRIPTION: | case PhabricatorRepositoryTransaction::TYPE_DESCRIPTION: | ||||
| Show All 19 Lines | switch ($xaction->getTransactionType()) { | ||||
| case PhabricatorRepositoryTransaction::TYPE_PUSH_POLICY: | case PhabricatorRepositoryTransaction::TYPE_PUSH_POLICY: | ||||
| case PhabricatorRepositoryTransaction::TYPE_CREDENTIAL: | case PhabricatorRepositoryTransaction::TYPE_CREDENTIAL: | ||||
| case PhabricatorRepositoryTransaction::TYPE_DANGEROUS: | case PhabricatorRepositoryTransaction::TYPE_DANGEROUS: | ||||
| case PhabricatorRepositoryTransaction::TYPE_CLONE_NAME: | case PhabricatorRepositoryTransaction::TYPE_CLONE_NAME: | ||||
| case PhabricatorRepositoryTransaction::TYPE_SERVICE: | case PhabricatorRepositoryTransaction::TYPE_SERVICE: | ||||
| case PhabricatorRepositoryTransaction::TYPE_SYMBOLS_SOURCES: | case PhabricatorRepositoryTransaction::TYPE_SYMBOLS_SOURCES: | ||||
| case PhabricatorRepositoryTransaction::TYPE_SYMBOLS_LANGUAGE: | case PhabricatorRepositoryTransaction::TYPE_SYMBOLS_LANGUAGE: | ||||
| case PhabricatorRepositoryTransaction::TYPE_STAGING_URI: | case PhabricatorRepositoryTransaction::TYPE_STAGING_URI: | ||||
| case PhabricatorRepositoryTransaction::TYPE_AUTOMATION_BLUEPRINTS: | |||||
| PhabricatorPolicyFilter::requireCapability( | PhabricatorPolicyFilter::requireCapability( | ||||
| $this->requireActor(), | $this->requireActor(), | ||||
| $object, | $object, | ||||
| PhabricatorPolicyCapability::CAN_EDIT); | PhabricatorPolicyCapability::CAN_EDIT); | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | switch ($type) { | ||||
| pht('Invalid'), | pht('Invalid'), | ||||
| pht( | pht( | ||||
| 'The selected credential does not exist, or you do not have '. | 'The selected credential does not exist, or you do not have '. | ||||
| 'permission to use it.'), | 'permission to use it.'), | ||||
| $xaction); | $xaction); | ||||
| } | } | ||||
| } | } | ||||
| break; | break; | ||||
| case PhabricatorRepositoryTransaction::TYPE_AUTOMATION_BLUEPRINTS: | |||||
| foreach ($xactions as $xaction) { | |||||
| $old = nonempty($xaction->getOldValue(), array()); | |||||
| $new = nonempty($xaction->getNewValue(), array()); | |||||
| $add = array_diff($new, $old); | |||||
| $invalid = PhabricatorObjectQuery::loadInvalidPHIDsForViewer( | |||||
| $this->getActor(), | |||||
| $add); | |||||
| if ($invalid) { | |||||
| $errors[] = new PhabricatorApplicationTransactionValidationError( | |||||
| $type, | |||||
| pht('Invalid'), | |||||
| pht( | |||||
| 'Some of the selected automation blueprints are invalid '. | |||||
| 'or restricted: %s.', | |||||
| implode(', ', $invalid)), | |||||
| $xaction); | |||||
| } | |||||
| } | |||||
| break; | |||||
| } | } | ||||
| return $errors; | return $errors; | ||||
| } | } | ||||
| } | } | ||||