Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15461040
D10761.id25894.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D10761.id25894.diff
View Options
diff --git a/src/applications/phriction/controller/PhrictionDeleteController.php b/src/applications/phriction/controller/PhrictionDeleteController.php
--- a/src/applications/phriction/controller/PhrictionDeleteController.php
+++ b/src/applications/phriction/controller/PhrictionDeleteController.php
@@ -15,6 +15,7 @@
$document = id(new PhrictionDocumentQuery())
->setViewer($user)
->withIDs(array($this->id))
+ ->needContent(true)
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_EDIT,
@@ -32,15 +33,24 @@
PhrictionDocumentStatus::STATUS_STUB => true, // How could they?
);
if (isset($disallowed_states[$document->getStatus()])) {
- $e_text = pht('An already moved or deleted document can not be deleted');
+ $e_text = pht(
+ 'An already moved or deleted document can not be deleted.');
}
$document_uri = PhrictionDocument::getSlugURI($document->getSlug());
if (!$e_text && $request->isFormPost()) {
- $editor = id(PhrictionDocumentEditor::newForSlug($document->getSlug()))
+ $xactions = array();
+ $xactions[] = id(new PhrictionTransaction())
+ ->setTransactionType(PhrictionTransaction::TYPE_DELETE)
+ ->setNewValue(true);
+
+ $editor = id(new PhrictionTransactionEditor())
->setActor($user)
- ->delete();
+ ->setContentSourceFromRequest($request)
+ ->setContinueOnNoEffect(true)
+ ->applyTransactions($document, $xactions);
+
return id(new AphrontRedirectResponse())->setURI($document_uri);
}
diff --git a/src/applications/phriction/editor/PhrictionTransactionEditor.php b/src/applications/phriction/editor/PhrictionTransactionEditor.php
--- a/src/applications/phriction/editor/PhrictionTransactionEditor.php
+++ b/src/applications/phriction/editor/PhrictionTransactionEditor.php
@@ -48,6 +48,7 @@
$types[] = PhabricatorTransactions::TYPE_COMMENT;
$types[] = PhrictionTransaction::TYPE_TITLE;
$types[] = PhrictionTransaction::TYPE_CONTENT;
+ $types[] = PhrictionTransaction::TYPE_DELETE;
/* TODO
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
@@ -72,6 +73,8 @@
return null;
}
return $this->getOldContent()->getContent();
+ case PhrictionTransaction::TYPE_DELETE:
+ return null;
}
}
@@ -82,6 +85,7 @@
switch ($xaction->getTransactionType()) {
case PhrictionTransaction::TYPE_TITLE:
case PhrictionTransaction::TYPE_CONTENT:
+ case PhrictionTransaction::TYPE_DELETE:
return $xaction->getNewValue();
}
}
@@ -94,6 +98,7 @@
switch ($xaction->getTransactionType()) {
case PhrictionTransaction::TYPE_TITLE:
case PhrictionTransaction::TYPE_CONTENT:
+ case PhrictionTransaction::TYPE_DELETE:
return true;
}
}
@@ -131,6 +136,11 @@
case PhrictionTransaction::TYPE_CONTENT:
$this->getNewContent()->setContent($xaction->getNewValue());
break;
+ case PhrictionTransaction::TYPE_DELETE:
+ $this->getNewContent()->setContent('');
+ $this->getNewContent()->setChangeType(
+ PhrictionChangeType::CHANGE_DELETE);
+ break;
default:
break;
}
@@ -145,6 +155,7 @@
switch ($xaction->getTransactionType()) {
case PhrictionTransaction::TYPE_TITLE:
case PhrictionTransaction::TYPE_CONTENT:
+ case PhrictionTransaction::TYPE_DELETE:
$save_content = true;
break;
default:
@@ -213,6 +224,8 @@
pht("A document's title changes."),
PhrictionTransaction::MAILTAG_CONTENT =>
pht("A document's content changes."),
+ PhrictionTransaction::MAILTAG_DELETE =>
+ pht('A document is deleted.'),
);
}
@@ -279,14 +292,12 @@
private function buildNewContentTemplate(
PhrictionDocument $document) {
- $new_content = new PhrictionContent();
- $new_content->setSlug($document->getSlug());
- $new_content->setAuthorPHID($this->getActor()->getPHID());
- $new_content->setChangeType(PhrictionChangeType::CHANGE_EDIT);
-
- $new_content->setTitle($this->getOldContent()->getTitle());
- $new_content->setContent($this->getOldContent()->getContent());
-
+ $new_content = id(new PhrictionContent())
+ ->setSlug($document->getSlug())
+ ->setAuthorPHID($this->getActor()->getPHID())
+ ->setChangeType(PhrictionChangeType::CHANGE_EDIT)
+ ->setTitle($this->getOldContent()->getTitle())
+ ->setContent($this->getOldContent()->getContent());
if (strlen($this->getDescription())) {
$new_content->setDescription($this->getDescription());
}
diff --git a/src/applications/phriction/storage/PhrictionTransaction.php b/src/applications/phriction/storage/PhrictionTransaction.php
--- a/src/applications/phriction/storage/PhrictionTransaction.php
+++ b/src/applications/phriction/storage/PhrictionTransaction.php
@@ -5,9 +5,11 @@
const TYPE_TITLE = 'title';
const TYPE_CONTENT = 'content';
+ const TYPE_DELETE = 'delete';
const MAILTAG_TITLE = 'phriction-title';
const MAILTAG_CONTENT = 'phriction-content';
+ const MAILTAG_DELETE = 'phriction-delete';
public function getApplicationName() {
return 'phriction';
@@ -53,6 +55,8 @@
return 1.4;
case self::TYPE_CONTENT:
return 1.3;
+ case self::TYPE_DELETE:
+ return 1.5;
}
return parent::getActionStrength();
@@ -73,6 +77,9 @@
case self::TYPE_CONTENT:
return pht('Edited');
+ case self::TYPE_DELETE:
+ return pht('Deleted');
+
}
return parent::getActionName();
@@ -86,13 +93,14 @@
case self::TYPE_TITLE:
case self::TYPE_CONTENT:
return 'fa-pencil';
+ case self::TYPE_DELETE:
+ return 'fa-times';
}
return parent::getIcon();
}
-
public function getTitle() {
$author_phid = $this->getAuthorPHID();
@@ -117,6 +125,12 @@
'%s edited the document content.',
$this->renderHandleLink($author_phid));
+ case self::TYPE_DELETE:
+ return pht(
+ '%s deleted this document.',
+ $this->renderHandleLink($author_phid));
+
+
}
return parent::getTitle();
@@ -151,6 +165,12 @@
$this->renderHandleLink($author_phid),
$this->renderHandleLink($object_phid));
+ case self::TYPE_DELETE:
+ return pht(
+ '%s deleted %s.',
+ $this->renderHandleLink($author_phid),
+ $this->renderHandleLink($object_phid));
+
}
return parent::getTitleForFeed($story);
}
@@ -179,6 +199,10 @@
case self::TYPE_CONTENT:
$tags[] = self::MAILTAG_CONTENT;
break;
+ case self::TYPE_DELETE:
+ $tags[] = self::MAILTAG_DELETE;
+ break;
+
}
return $tags;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Apr 2, 4:36 AM (3 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7227200
Default Alt Text
D10761.id25894.diff (6 KB)
Attached To
Mode
D10761: Phriction - move delete to modern editor + transactions
Attached
Detach File
Event Timeline
Log In to Comment