Differential D15195 Diff 36687 src/applications/project/editor/PhabricatorProjectTransactionEditor.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/project/editor/PhabricatorProjectTransactionEditor.php
| Show First 20 Lines • Show All 213 Lines • ▼ Show 20 Lines | protected function validateAllTransactions( | ||||
| } | } | ||||
| $is_milestone = $this->getIsMilestone(); | $is_milestone = $this->getIsMilestone(); | ||||
| $is_parent = $object->getHasSubprojects(); | $is_parent = $object->getHasSubprojects(); | ||||
| foreach ($xactions as $xaction) { | foreach ($xactions as $xaction) { | ||||
| switch ($xaction->getTransactionType()) { | switch ($xaction->getTransactionType()) { | ||||
| case PhabricatorProjectTransaction::TYPE_MEMBERS: | case PhabricatorTransactions::TYPE_EDGE: | ||||
| $type = $xaction->getMetadataValue('edge:type'); | |||||
| if ($type != PhabricatorProjectProjectHasMemberEdgeType::EDGECONST) { | |||||
| break; | |||||
| } | |||||
| if ($is_parent) { | if ($is_parent) { | ||||
| $errors[] = new PhabricatorApplicationTransactionValidationError( | $errors[] = new PhabricatorApplicationTransactionValidationError( | ||||
| $xaction->getTransactionType(), | $xaction->getTransactionType(), | ||||
| pht('Invalid'), | pht('Invalid'), | ||||
| pht( | pht( | ||||
| 'You can not change members of a project with subprojects '. | 'You can not change members of a project with subprojects '. | ||||
| 'directly. Members of any subproject are automatically '. | 'directly. Members of any subproject are automatically '. | ||||
| 'members of the parent project.'), | 'members of the parent project.'), | ||||
| ▲ Show 20 Lines • Show All 556 Lines • ▼ Show 20 Lines | protected function expandTransactions( | ||||
| PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
| array $xactions) { | array $xactions) { | ||||
| $actor = $this->getActor(); | $actor = $this->getActor(); | ||||
| $actor_phid = $actor->getPHID(); | $actor_phid = $actor->getPHID(); | ||||
| $results = parent::expandTransactions($object, $xactions); | $results = parent::expandTransactions($object, $xactions); | ||||
| // Automatically add the author as a member when they create a project | |||||
| // if they're using the web interface. | |||||
| $content_source = $this->getContentSource(); | |||||
| $source_web = PhabricatorContentSource::SOURCE_WEB; | |||||
| $is_web = ($content_source->getSource() === $source_web); | |||||
| if ($this->getIsNewObject() && $is_web) { | |||||
| if ($actor_phid) { | |||||
| $type_member = PhabricatorProjectProjectHasMemberEdgeType::EDGECONST; | |||||
| $results[] = id(new PhabricatorProjectTransaction()) | |||||
| ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) | |||||
| ->setMetadataValue('edge:type', $type_member) | |||||
| ->setNewValue( | |||||
| array( | |||||
| '+' => array($actor_phid => $actor_phid), | |||||
| )); | |||||
| } | |||||
| } | |||||
| $is_milestone = $object->isMilestone(); | $is_milestone = $object->isMilestone(); | ||||
| foreach ($xactions as $xaction) { | foreach ($xactions as $xaction) { | ||||
| switch ($xaction->getTransactionType()) { | switch ($xaction->getTransactionType()) { | ||||
| case PhabricatorProjectTransaction::TYPE_MILESTONE: | case PhabricatorProjectTransaction::TYPE_MILESTONE: | ||||
| if ($xaction->getNewValue() !== null) { | if ($xaction->getNewValue() !== null) { | ||||
| $is_milestone = true; | $is_milestone = true; | ||||
| } | } | ||||
| break; | break; | ||||
| ▲ Show 20 Lines • Show All 51 Lines • Show Last 20 Lines | |||||