Page MenuHomePhabricator

D19550.id46747.diff
No OneTemporary

D19550.id46747.diff

diff --git a/src/applications/project/engine/PhabricatorProjectEditEngine.php b/src/applications/project/engine/PhabricatorProjectEditEngine.php
--- a/src/applications/project/engine/PhabricatorProjectEditEngine.php
+++ b/src/applications/project/engine/PhabricatorProjectEditEngine.php
@@ -51,7 +51,11 @@
}
protected function newEditableObject() {
- return PhabricatorProject::initializeNewProject($this->getViewer());
+ $parent = nonempty($this->parentProject, $this->milestoneProject);
+
+ return PhabricatorProject::initializeNewProject(
+ $this->getViewer(),
+ $parent);
}
protected function newObjectQuery() {
@@ -112,6 +116,7 @@
PhabricatorTransactions::TYPE_VIEW_POLICY,
PhabricatorTransactions::TYPE_EDIT_POLICY,
PhabricatorTransactions::TYPE_JOIN_POLICY,
+ PhabricatorTransactions::TYPE_SPACE,
PhabricatorProjectIconTransaction::TRANSACTIONTYPE,
PhabricatorProjectColorTransaction::TRANSACTIONTYPE,
);
diff --git a/src/applications/project/storage/PhabricatorProject.php b/src/applications/project/storage/PhabricatorProject.php
--- a/src/applications/project/storage/PhabricatorProject.php
+++ b/src/applications/project/storage/PhabricatorProject.php
@@ -61,7 +61,10 @@
const ITEM_MILESTONES = 'project.milestones';
const ITEM_SUBPROJECTS = 'project.subprojects';
- public static function initializeNewProject(PhabricatorUser $actor) {
+ public static function initializeNewProject(
+ PhabricatorUser $actor,
+ PhabricatorProject $parent = null) {
+
$app = id(new PhabricatorApplicationQuery())
->setViewer(PhabricatorUser::getOmnipotentUser())
->withClasses(array('PhabricatorProjectApplication'))
@@ -74,6 +77,14 @@
$join_policy = $app->getPolicy(
ProjectDefaultJoinCapability::CAPABILITY);
+ // If this is the child of some other project, default the Space to the
+ // Space of the parent.
+ if ($parent) {
+ $space_phid = $parent->getSpacePHID();
+ } else {
+ $space_phid = $actor->getDefaultSpacePHID();
+ }
+
$default_icon = PhabricatorProjectIconSet::getDefaultIconKey();
$default_color = PhabricatorProjectIconSet::getDefaultColorKey();
@@ -84,7 +95,7 @@
->setViewPolicy($view_policy)
->setEditPolicy($edit_policy)
->setJoinPolicy($join_policy)
- ->setSpacePHID($actor->getDefaultSpacePHID())
+ ->setSpacePHID($space_phid)
->setIsMembershipLocked(0)
->attachMemberPHIDs(array())
->attachSlugs(array())
@@ -704,6 +715,9 @@
public function getSpacePHID() {
+ if ($this->isMilestone()) {
+ return $this->getParentProject()->getSpacePHID();
+ }
return $this->spacePHID;
}

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 13, 4:57 PM (22 h, 42 m ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6728599
Default Alt Text
D19550.id46747.diff (2 KB)

Event Timeline