mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-30 02:32:42 +01:00
Add a "Published document changed" rule to Herald for Phriction documents
Summary: Depends on D20519. Ref T13283. See PHI1202. Add a new rule which triggers when the current/most-recent transaction group includes a "content" or "publish" transaction, which means the published document content has changed. Test Plan: - Wrote a Herald rule using this field. - Created a document (rule matched). - Edited a document (rule matched). - Edited a document, saving as a draft (no match). - Edited a draft, updating it (no match). - Published a draft docuemnt (rule matched). Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13283 Differential Revision: https://secure.phabricator.com/D20520
This commit is contained in:
parent
bf2f3991d2
commit
e5fe4dffe1
4 changed files with 77 additions and 0 deletions
|
@ -1581,6 +1581,7 @@ phutil_register_library_map(array(
|
||||||
'HeraldTextFieldValue' => 'applications/herald/value/HeraldTextFieldValue.php',
|
'HeraldTextFieldValue' => 'applications/herald/value/HeraldTextFieldValue.php',
|
||||||
'HeraldTokenizerFieldValue' => 'applications/herald/value/HeraldTokenizerFieldValue.php',
|
'HeraldTokenizerFieldValue' => 'applications/herald/value/HeraldTokenizerFieldValue.php',
|
||||||
'HeraldTransactionQuery' => 'applications/herald/query/HeraldTransactionQuery.php',
|
'HeraldTransactionQuery' => 'applications/herald/query/HeraldTransactionQuery.php',
|
||||||
|
'HeraldTransactionsFieldGroup' => 'applications/herald/field/HeraldTransactionsFieldGroup.php',
|
||||||
'HeraldTranscript' => 'applications/herald/storage/transcript/HeraldTranscript.php',
|
'HeraldTranscript' => 'applications/herald/storage/transcript/HeraldTranscript.php',
|
||||||
'HeraldTranscriptController' => 'applications/herald/controller/HeraldTranscriptController.php',
|
'HeraldTranscriptController' => 'applications/herald/controller/HeraldTranscriptController.php',
|
||||||
'HeraldTranscriptDestructionEngineExtension' => 'applications/herald/engineextension/HeraldTranscriptDestructionEngineExtension.php',
|
'HeraldTranscriptDestructionEngineExtension' => 'applications/herald/engineextension/HeraldTranscriptDestructionEngineExtension.php',
|
||||||
|
@ -5334,6 +5335,7 @@ phutil_register_library_map(array(
|
||||||
'PhrictionDocumentPathHeraldField' => 'applications/phriction/herald/PhrictionDocumentPathHeraldField.php',
|
'PhrictionDocumentPathHeraldField' => 'applications/phriction/herald/PhrictionDocumentPathHeraldField.php',
|
||||||
'PhrictionDocumentPolicyCodex' => 'applications/phriction/codex/PhrictionDocumentPolicyCodex.php',
|
'PhrictionDocumentPolicyCodex' => 'applications/phriction/codex/PhrictionDocumentPolicyCodex.php',
|
||||||
'PhrictionDocumentPublishTransaction' => 'applications/phriction/xaction/PhrictionDocumentPublishTransaction.php',
|
'PhrictionDocumentPublishTransaction' => 'applications/phriction/xaction/PhrictionDocumentPublishTransaction.php',
|
||||||
|
'PhrictionDocumentPublishedHeraldField' => 'applications/phriction/herald/PhrictionDocumentPublishedHeraldField.php',
|
||||||
'PhrictionDocumentQuery' => 'applications/phriction/query/PhrictionDocumentQuery.php',
|
'PhrictionDocumentQuery' => 'applications/phriction/query/PhrictionDocumentQuery.php',
|
||||||
'PhrictionDocumentSearchConduitAPIMethod' => 'applications/phriction/conduit/PhrictionDocumentSearchConduitAPIMethod.php',
|
'PhrictionDocumentSearchConduitAPIMethod' => 'applications/phriction/conduit/PhrictionDocumentSearchConduitAPIMethod.php',
|
||||||
'PhrictionDocumentSearchEngine' => 'applications/phriction/query/PhrictionDocumentSearchEngine.php',
|
'PhrictionDocumentSearchEngine' => 'applications/phriction/query/PhrictionDocumentSearchEngine.php',
|
||||||
|
@ -7372,6 +7374,7 @@ phutil_register_library_map(array(
|
||||||
'HeraldTextFieldValue' => 'HeraldFieldValue',
|
'HeraldTextFieldValue' => 'HeraldFieldValue',
|
||||||
'HeraldTokenizerFieldValue' => 'HeraldFieldValue',
|
'HeraldTokenizerFieldValue' => 'HeraldFieldValue',
|
||||||
'HeraldTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
|
'HeraldTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
|
||||||
|
'HeraldTransactionsFieldGroup' => 'HeraldFieldGroup',
|
||||||
'HeraldTranscript' => array(
|
'HeraldTranscript' => array(
|
||||||
'HeraldDAO',
|
'HeraldDAO',
|
||||||
'PhabricatorPolicyInterface',
|
'PhabricatorPolicyInterface',
|
||||||
|
@ -11815,6 +11818,7 @@ phutil_register_library_map(array(
|
||||||
'PhrictionDocumentPathHeraldField' => 'PhrictionDocumentHeraldField',
|
'PhrictionDocumentPathHeraldField' => 'PhrictionDocumentHeraldField',
|
||||||
'PhrictionDocumentPolicyCodex' => 'PhabricatorPolicyCodex',
|
'PhrictionDocumentPolicyCodex' => 'PhabricatorPolicyCodex',
|
||||||
'PhrictionDocumentPublishTransaction' => 'PhrictionDocumentTransactionType',
|
'PhrictionDocumentPublishTransaction' => 'PhrictionDocumentTransactionType',
|
||||||
|
'PhrictionDocumentPublishedHeraldField' => 'PhrictionDocumentHeraldField',
|
||||||
'PhrictionDocumentQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
'PhrictionDocumentQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||||
'PhrictionDocumentSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod',
|
'PhrictionDocumentSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod',
|
||||||
'PhrictionDocumentSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
'PhrictionDocumentSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||||
|
|
|
@ -202,4 +202,20 @@ abstract class HeraldField extends Phobject {
|
||||||
->execute();
|
->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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class HeraldTransactionsFieldGroup extends HeraldFieldGroup {
|
||||||
|
|
||||||
|
const FIELDGROUPKEY = 'transactions';
|
||||||
|
|
||||||
|
public function getGroupLabel() {
|
||||||
|
return pht('Transactions');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getGroupOrder() {
|
||||||
|
return 2000;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue