Differential D15915 Diff 38331 src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
| Show First 20 Lines • Show All 697 Lines • ▼ Show 20 Lines | protected function populateTransaction( | ||||
| $xaction->setViewPolicy(PhabricatorPolicies::POLICY_PUBLIC); | $xaction->setViewPolicy(PhabricatorPolicies::POLICY_PUBLIC); | ||||
| if ($actor->isOmnipotent()) { | if ($actor->isOmnipotent()) { | ||||
| $xaction->setEditPolicy(PhabricatorPolicies::POLICY_NOONE); | $xaction->setEditPolicy(PhabricatorPolicies::POLICY_NOONE); | ||||
| } else { | } else { | ||||
| $xaction->setEditPolicy($this->getActingAsPHID()); | $xaction->setEditPolicy($this->getActingAsPHID()); | ||||
| } | } | ||||
| // If the transaction already has an explicit author PHID, allow it to | |||||
| // stand. This is used by applications like Owners that hook into the | |||||
| // post-apply change pipeline. | |||||
| if (!$xaction->getAuthorPHID()) { | |||||
| $xaction->setAuthorPHID($this->getActingAsPHID()); | $xaction->setAuthorPHID($this->getActingAsPHID()); | ||||
| } | |||||
| $xaction->setContentSource($this->getContentSource()); | $xaction->setContentSource($this->getContentSource()); | ||||
| $xaction->attachViewer($actor); | $xaction->attachViewer($actor); | ||||
| $xaction->attachObject($object); | $xaction->attachObject($object); | ||||
| if ($object->getPHID()) { | if ($object->getPHID()) { | ||||
| $xaction->setObjectPHID($object->getPHID()); | $xaction->setObjectPHID($object->getPHID()); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 237 Lines • ▼ Show 20 Lines | if ($this->getIsHeraldEditor()) { | ||||
| // Herald from executing when applying inverse edges. | // Herald from executing when applying inverse edges. | ||||
| } else if ($this->shouldApplyHeraldRules($object, $xactions)) { | } else if ($this->shouldApplyHeraldRules($object, $xactions)) { | ||||
| // We are not the Herald editor, so try to apply Herald rules. | // We are not the Herald editor, so try to apply Herald rules. | ||||
| $herald_xactions = $this->applyHeraldRules($object, $xactions); | $herald_xactions = $this->applyHeraldRules($object, $xactions); | ||||
| if ($herald_xactions) { | if ($herald_xactions) { | ||||
| $xscript_id = $this->getHeraldTranscript()->getID(); | $xscript_id = $this->getHeraldTranscript()->getID(); | ||||
| foreach ($herald_xactions as $herald_xaction) { | foreach ($herald_xactions as $herald_xaction) { | ||||
| // Don't set a transcript ID if this is a transaction from another | |||||
| // application or source, like Owners. | |||||
| if ($herald_xaction->getAuthorPHID()) { | |||||
| continue; | |||||
| } | |||||
| $herald_xaction->setMetadataValue('herald:transcriptID', $xscript_id); | $herald_xaction->setMetadataValue('herald:transcriptID', $xscript_id); | ||||
| } | } | ||||
| // NOTE: We're acting as the omnipotent user because rules deal with | // NOTE: We're acting as the omnipotent user because rules deal with | ||||
| // their own policy issues. We use a synthetic author PHID (the | // their own policy issues. We use a synthetic author PHID (the | ||||
| // Herald application) as the author of record, so that transactions | // Herald application) as the author of record, so that transactions | ||||
| // will render in a reasonable way ("Herald assigned this task ..."). | // will render in a reasonable way ("Herald assigned this task ..."). | ||||
| $herald_actor = PhabricatorUser::getOmnipotentUser(); | $herald_actor = PhabricatorUser::getOmnipotentUser(); | ||||
| ▲ Show 20 Lines • Show All 244 Lines • ▼ Show 20 Lines | private function validateEditParameters( | ||||
| assert_instances_of($xactions, 'PhabricatorApplicationTransaction'); | assert_instances_of($xactions, 'PhabricatorApplicationTransaction'); | ||||
| foreach ($xactions as $xaction) { | foreach ($xactions as $xaction) { | ||||
| if ($xaction->getPHID() || $xaction->getID()) { | if ($xaction->getPHID() || $xaction->getID()) { | ||||
| throw new PhabricatorApplicationTransactionStructureException( | throw new PhabricatorApplicationTransactionStructureException( | ||||
| $xaction, | $xaction, | ||||
| pht('You can not apply transactions which already have IDs/PHIDs!')); | pht('You can not apply transactions which already have IDs/PHIDs!')); | ||||
| } | } | ||||
| if ($xaction->getObjectPHID()) { | if ($xaction->getObjectPHID()) { | ||||
| throw new PhabricatorApplicationTransactionStructureException( | throw new PhabricatorApplicationTransactionStructureException( | ||||
| $xaction, | $xaction, | ||||
| pht( | pht( | ||||
| 'You can not apply transactions which already have %s!', | 'You can not apply transactions which already have %s!', | ||||
| 'objectPHIDs')); | 'objectPHIDs')); | ||||
| } | } | ||||
| if ($xaction->getAuthorPHID()) { | |||||
| throw new PhabricatorApplicationTransactionStructureException( | |||||
| $xaction, | |||||
| pht( | |||||
| 'You can not apply transactions which already have %s!', | |||||
| 'authorPHIDs')); | |||||
| } | |||||
| if ($xaction->getCommentPHID()) { | if ($xaction->getCommentPHID()) { | ||||
| throw new PhabricatorApplicationTransactionStructureException( | throw new PhabricatorApplicationTransactionStructureException( | ||||
| $xaction, | $xaction, | ||||
| pht( | pht( | ||||
| 'You can not apply transactions which already have %s!', | 'You can not apply transactions which already have %s!', | ||||
| 'commentPHIDs')); | 'commentPHIDs')); | ||||
| } | } | ||||
| if ($xaction->getCommentVersion() !== 0) { | if ($xaction->getCommentVersion() !== 0) { | ||||
| throw new PhabricatorApplicationTransactionStructureException( | throw new PhabricatorApplicationTransactionStructureException( | ||||
| $xaction, | $xaction, | ||||
| pht( | pht( | ||||
| 'You can not apply transactions which already have '. | 'You can not apply transactions which already have '. | ||||
| 'commentVersions!')); | 'commentVersions!')); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 2,289 Lines • Show Last 20 Lines | |||||