diff --git a/src/applications/phriction/controller/PhrictionEditController.php b/src/applications/phriction/controller/PhrictionEditController.php --- a/src/applications/phriction/controller/PhrictionEditController.php +++ b/src/applications/phriction/controller/PhrictionEditController.php @@ -97,6 +97,10 @@ $content_text = $content->getContent(); $is_draft_mode = ($document->getContent()->getVersion() != $max_version); + $default_view = $document->getViewPolicy(); + $default_edit = $document->getEditPolicy(); + $default_space = $document->getSpacePHID(); + if ($request->isFormPost()) { if ($is_new) { $save_as_draft = false; @@ -122,6 +126,11 @@ $xactions = array(); + if ($is_new) { + $xactions[] = id(new PhrictionTransaction()) + ->setTransactionType(PhabricatorTransactions::TYPE_CREATE); + } + $xactions[] = id(new PhrictionTransaction()) ->setTransactionType(PhrictionDocumentTitleTransaction::TRANSACTIONTYPE) ->setNewValue($title); @@ -130,13 +139,16 @@ ->setNewValue($content_text); $xactions[] = id(new PhrictionTransaction()) ->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY) - ->setNewValue($v_view); + ->setNewValue($v_view) + ->setIsDefaultTransaction($is_new && ($v_view === $default_view)); $xactions[] = id(new PhrictionTransaction()) ->setTransactionType(PhabricatorTransactions::TYPE_EDIT_POLICY) - ->setNewValue($v_edit); + ->setNewValue($v_edit) + ->setIsDefaultTransaction($is_new && ($v_edit === $default_edit)); $xactions[] = id(new PhrictionTransaction()) ->setTransactionType(PhabricatorTransactions::TYPE_SPACE) - ->setNewValue($v_space); + ->setNewValue($v_space) + ->setIsDefaultTransaction($is_new && ($v_space === $default_space)); $xactions[] = id(new PhrictionTransaction()) ->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS) ->setNewValue(array('=' => $v_cc)); diff --git a/src/applications/phriction/storage/PhrictionDocument.php b/src/applications/phriction/storage/PhrictionDocument.php --- a/src/applications/phriction/storage/PhrictionDocument.php +++ b/src/applications/phriction/storage/PhrictionDocument.php @@ -78,10 +78,13 @@ } if ($parent_doc) { + $space_phid = PhabricatorSpacesNamespaceQuery::getObjectSpacePHID( + $parent_doc); + $document ->setViewPolicy($parent_doc->getViewPolicy()) ->setEditPolicy($parent_doc->getEditPolicy()) - ->setSpacePHID($parent_doc->getSpacePHID()); + ->setSpacePHID($space_phid); } else { $default_view_policy = PhabricatorPolicies::getMostOpenPolicy(); $document