diff --git a/resources/sql/patches/20131121.passphraseedge.sql b/resources/sql/patches/20131121.passphraseedge.sql new file mode 100644 index 0000000000..38cfdb0453 --- /dev/null +++ b/resources/sql/patches/20131121.passphraseedge.sql @@ -0,0 +1,15 @@ +CREATE TABLE {$NAMESPACE}_passphrase.edge ( + src VARCHAR(64) NOT NULL COLLATE utf8_bin, + type VARCHAR(64) NOT NULL COLLATE utf8_bin, + dst VARCHAR(64) NOT NULL COLLATE utf8_bin, + dateCreated INT UNSIGNED NOT NULL, + seq INT UNSIGNED NOT NULL, + dataID INT UNSIGNED, + PRIMARY KEY (src, type, dst), + KEY (src, type, dateCreated, seq) +) ENGINE=InnoDB, COLLATE utf8_general_ci; + +CREATE TABLE {$NAMESPACE}_passphrase.edgedata ( + id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, + data LONGTEXT NOT NULL COLLATE utf8_bin +) ENGINE=InnoDB, COLLATE utf8_general_ci; diff --git a/src/applications/passphrase/controller/PassphraseCredentialViewController.php b/src/applications/passphrase/controller/PassphraseCredentialViewController.php index 3a4e9d6b9b..9499bbc553 100644 --- a/src/applications/passphrase/controller/PassphraseCredentialViewController.php +++ b/src/applications/passphrase/controller/PassphraseCredentialViewController.php @@ -151,6 +151,17 @@ final class PassphraseCredentialViewController extends PassphraseController { pht('Username'), $credential->getUsername()); + $used_by_phids = PhabricatorEdgeQuery::loadDestinationPHIDs( + $credential->getPHID(), + PhabricatorEdgeConfig::TYPE_CREDENTIAL_USED_BY_OBJECT); + + if ($used_by_phids) { + $this->loadHandles($used_by_phids); + $properties->addProperty( + pht('Used By'), + $this->renderHandlesForPHIDs($used_by_phids)); + } + $description = $credential->getDescription(); if (strlen($description)) { $properties->addSectionHeader( diff --git a/src/applications/passphrase/storage/PassphraseCredential.php b/src/applications/passphrase/storage/PassphraseCredential.php index 6339174d9a..880bf5f170 100644 --- a/src/applications/passphrase/storage/PassphraseCredential.php +++ b/src/applications/passphrase/storage/PassphraseCredential.php @@ -19,6 +19,7 @@ final class PassphraseCredential extends PassphraseDAO return id(new PassphraseCredential()) ->setName('') ->setUsername('') + ->setDescription('') ->setIsDestroyed(0) ->setViewPolicy($actor->getPHID()) ->setEditPolicy($actor->getPHID()); diff --git a/src/infrastructure/edges/constants/PhabricatorEdgeConfig.php b/src/infrastructure/edges/constants/PhabricatorEdgeConfig.php index 6929837304..16b33f373c 100644 --- a/src/infrastructure/edges/constants/PhabricatorEdgeConfig.php +++ b/src/infrastructure/edges/constants/PhabricatorEdgeConfig.php @@ -60,6 +60,9 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants { const TYPE_MOCK_HAS_TASK = 37; const TYPE_TASK_HAS_MOCK = 38; + const TYPE_OBJECT_USES_CREDENTIAL = 39; + const TYPE_CREDENTIAL_USED_BY_OBJECT = 40; + const TYPE_TEST_NO_CYCLE = 9000; const TYPE_PHOB_HAS_ASANATASK = 80001; @@ -71,6 +74,7 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants { const TYPE_PHOB_HAS_JIRAISSUE = 80004; const TYPE_JIRAISSUE_HAS_PHOB = 80005; + public static function getInverse($edge_type) { static $map = array( self::TYPE_TASK_HAS_COMMIT => self::TYPE_COMMIT_HAS_TASK, @@ -134,7 +138,10 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants { self::TYPE_REVIEWER_FOR_DREV => self::TYPE_DREV_HAS_REVIEWER, self::TYPE_PHOB_HAS_JIRAISSUE => self::TYPE_JIRAISSUE_HAS_PHOB, - self:: TYPE_JIRAISSUE_HAS_PHOB => self::TYPE_PHOB_HAS_JIRAISSUE + self::TYPE_JIRAISSUE_HAS_PHOB => self::TYPE_PHOB_HAS_JIRAISSUE, + + self::TYPE_OBJECT_USES_CREDENTIAL => self::TYPE_CREDENTIAL_USED_BY_OBJECT, + self::TYPE_CREDENTIAL_USED_BY_OBJECT => self::TYPE_OBJECT_USES_CREDENTIAL, ); return idx($map, $edge_type); diff --git a/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php b/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php index a8cdf2bc53..253633fddc 100644 --- a/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php +++ b/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php @@ -1772,6 +1772,10 @@ final class PhabricatorBuiltinPatchList extends PhabricatorSQLPatchList { 'type' => 'sql', 'name' => $this->getPatchPath('20131120.nuancesourcetype.sql'), ), + '20131121.passphraseedge.sql' => array( + 'type' => 'sql', + 'name' => $this->getPatchPath('20131121.passphraseedge.sql'), + ), ); } }