Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14058232
D20520.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D20520.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -1581,6 +1581,7 @@
'HeraldTextFieldValue' => 'applications/herald/value/HeraldTextFieldValue.php',
'HeraldTokenizerFieldValue' => 'applications/herald/value/HeraldTokenizerFieldValue.php',
'HeraldTransactionQuery' => 'applications/herald/query/HeraldTransactionQuery.php',
+ 'HeraldTransactionsFieldGroup' => 'applications/herald/field/HeraldTransactionsFieldGroup.php',
'HeraldTranscript' => 'applications/herald/storage/transcript/HeraldTranscript.php',
'HeraldTranscriptController' => 'applications/herald/controller/HeraldTranscriptController.php',
'HeraldTranscriptDestructionEngineExtension' => 'applications/herald/engineextension/HeraldTranscriptDestructionEngineExtension.php',
@@ -5334,6 +5335,7 @@
'PhrictionDocumentPathHeraldField' => 'applications/phriction/herald/PhrictionDocumentPathHeraldField.php',
'PhrictionDocumentPolicyCodex' => 'applications/phriction/codex/PhrictionDocumentPolicyCodex.php',
'PhrictionDocumentPublishTransaction' => 'applications/phriction/xaction/PhrictionDocumentPublishTransaction.php',
+ 'PhrictionDocumentPublishedHeraldField' => 'applications/phriction/herald/PhrictionDocumentPublishedHeraldField.php',
'PhrictionDocumentQuery' => 'applications/phriction/query/PhrictionDocumentQuery.php',
'PhrictionDocumentSearchConduitAPIMethod' => 'applications/phriction/conduit/PhrictionDocumentSearchConduitAPIMethod.php',
'PhrictionDocumentSearchEngine' => 'applications/phriction/query/PhrictionDocumentSearchEngine.php',
@@ -7372,6 +7374,7 @@
'HeraldTextFieldValue' => 'HeraldFieldValue',
'HeraldTokenizerFieldValue' => 'HeraldFieldValue',
'HeraldTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
+ 'HeraldTransactionsFieldGroup' => 'HeraldFieldGroup',
'HeraldTranscript' => array(
'HeraldDAO',
'PhabricatorPolicyInterface',
@@ -11815,6 +11818,7 @@
'PhrictionDocumentPathHeraldField' => 'PhrictionDocumentHeraldField',
'PhrictionDocumentPolicyCodex' => 'PhabricatorPolicyCodex',
'PhrictionDocumentPublishTransaction' => 'PhrictionDocumentTransactionType',
+ 'PhrictionDocumentPublishedHeraldField' => 'PhrictionDocumentHeraldField',
'PhrictionDocumentQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhrictionDocumentSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod',
'PhrictionDocumentSearchEngine' => 'PhabricatorApplicationSearchEngine',
diff --git a/src/applications/herald/field/HeraldField.php b/src/applications/herald/field/HeraldField.php
--- a/src/applications/herald/field/HeraldField.php
+++ b/src/applications/herald/field/HeraldField.php
@@ -202,4 +202,20 @@
->execute();
}
+ final protected function hasAppliedTransactionOfType($type) {
+ $xactions = $this->getAdapter()->getAppliedTransactions();
+
+ if (!$xactions) {
+ return false;
+ }
+
+ foreach ($xactions as $xaction) {
+ if ($xaction->getTransactionType() === $type) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
}
diff --git a/src/applications/herald/field/HeraldTransactionsFieldGroup.php b/src/applications/herald/field/HeraldTransactionsFieldGroup.php
new file mode 100644
--- /dev/null
+++ b/src/applications/herald/field/HeraldTransactionsFieldGroup.php
@@ -0,0 +1,15 @@
+<?php
+
+final class HeraldTransactionsFieldGroup extends HeraldFieldGroup {
+
+ const FIELDGROUPKEY = 'transactions';
+
+ public function getGroupLabel() {
+ return pht('Transactions');
+ }
+
+ protected function getGroupOrder() {
+ return 2000;
+ }
+
+}
diff --git a/src/applications/phriction/herald/PhrictionDocumentPublishedHeraldField.php b/src/applications/phriction/herald/PhrictionDocumentPublishedHeraldField.php
new file mode 100644
--- /dev/null
+++ b/src/applications/phriction/herald/PhrictionDocumentPublishedHeraldField.php
@@ -0,0 +1,42 @@
+<?php
+
+final class PhrictionDocumentPublishedHeraldField
+ extends PhrictionDocumentHeraldField {
+
+ const FIELDCONST = 'phriction.document.published';
+
+ public function getHeraldFieldName() {
+ return pht('Published document changed');
+ }
+
+ public function getFieldGroupKey() {
+ return HeraldTransactionsFieldGroup::FIELDGROUPKEY;
+ }
+
+ public function getHeraldFieldValue($object) {
+ // The published document changes if we apply a "publish" transaction
+ // (which points the published document pointer at new content) or if we
+ // apply a "content" transaction.
+
+ // When a change affects only the draft document, it applies as a "draft"
+ // transaction.
+
+ $type_content = PhrictionDocumentContentTransaction::TRANSACTIONTYPE;
+ $type_publish = PhrictionDocumentPublishTransaction::TRANSACTIONTYPE;
+
+ if ($this->hasAppliedTransactionOfType($type_content)) {
+ return true;
+ }
+
+ if ($this->hasAppliedTransactionOfType($type_publish)) {
+ return true;
+ }
+
+ return false;
+ }
+
+ protected function getHeraldFieldStandardType() {
+ return self::STANDARD_BOOL;
+ }
+
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 18, 10:15 AM (1 d, 12 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6749025
Default Alt Text
D20520.diff (5 KB)
Attached To
Mode
D20520: Add a "Published document changed" rule to Herald for Phriction documents
Attached
Detach File
Event Timeline
Log In to Comment