Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15389968
D16104.id38751.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
16 KB
Referenced Files
None
Subscribers
None
D16104.id38751.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -3771,6 +3771,7 @@
'PhameLiveController' => 'applications/phame/controller/PhameLiveController.php',
'PhameNextPostView' => 'applications/phame/view/PhameNextPostView.php',
'PhamePost' => 'applications/phame/storage/PhamePost.php',
+ 'PhamePostArchiveController' => 'applications/phame/controller/post/PhamePostArchiveController.php',
'PhamePostCommentController' => 'applications/phame/controller/post/PhamePostCommentController.php',
'PhamePostController' => 'applications/phame/controller/post/PhamePostController.php',
'PhamePostEditConduitAPIMethod' => 'applications/phame/conduit/PhamePostEditConduitAPIMethod.php',
@@ -8627,6 +8628,7 @@
'PhabricatorTokenReceiverInterface',
'PhabricatorConduitResultInterface',
),
+ 'PhamePostArchiveController' => 'PhamePostController',
'PhamePostCommentController' => 'PhamePostController',
'PhamePostController' => 'PhameController',
'PhamePostEditConduitAPIMethod' => 'PhabricatorEditEngineAPIMethod',
diff --git a/src/applications/phame/application/PhabricatorPhameApplication.php b/src/applications/phame/application/PhabricatorPhameApplication.php
--- a/src/applications/phame/application/PhabricatorPhameApplication.php
+++ b/src/applications/phame/application/PhabricatorPhameApplication.php
@@ -55,6 +55,7 @@
'preview/' => 'PhabricatorMarkupPreviewController',
'framed/(?P<id>\d+)/' => 'PhamePostFramedController',
'move/(?P<id>\d+)/' => 'PhamePostMoveController',
+ 'archive/(?P<id>\d+)/' => 'PhamePostArchiveController',
'comment/(?P<id>[1-9]\d*)/' => 'PhamePostCommentController',
),
'blog/' => array(
diff --git a/src/applications/phame/constants/PhameConstants.php b/src/applications/phame/constants/PhameConstants.php
--- a/src/applications/phame/constants/PhameConstants.php
+++ b/src/applications/phame/constants/PhameConstants.php
@@ -2,13 +2,15 @@
final class PhameConstants extends Phobject {
- const VISIBILITY_DRAFT = 0;
+ const VISIBILITY_DRAFT = 0;
const VISIBILITY_PUBLISHED = 1;
+ const VISIBILITY_ARCHIVED = 2;
public static function getPhamePostStatusMap() {
return array(
self::VISIBILITY_PUBLISHED => pht('Published'),
self::VISIBILITY_DRAFT => pht('Draft'),
+ self::VISIBILITY_ARCHIVED => pht('Archived'),
);
}
@@ -16,6 +18,7 @@
$map = array(
self::VISIBILITY_PUBLISHED => pht('Published'),
self::VISIBILITY_DRAFT => pht('Draft'),
+ self::VISIBILITY_ARCHIVED => pht('Archived'),
);
return idx($map, $status, pht('Unknown'));
}
diff --git a/src/applications/phame/controller/PhameHomeController.php b/src/applications/phame/controller/PhameHomeController.php
--- a/src/applications/phame/controller/PhameHomeController.php
+++ b/src/applications/phame/controller/PhameHomeController.php
@@ -35,7 +35,7 @@
$posts = id(new PhamePostQuery())
->setViewer($viewer)
->withBlogPHIDs($blog_phids)
- ->withVisibility(PhameConstants::VISIBILITY_PUBLISHED)
+ ->withVisibility(array(PhameConstants::VISIBILITY_PUBLISHED))
->executeWithCursorPager($pager);
if ($posts) {
@@ -97,7 +97,7 @@
->setViewer($viewer)
->withBloggerPHIDs(array($viewer->getPHID()))
->withBlogPHIDs(mpull($blogs, 'getPHID'))
- ->withVisibility(PhameConstants::VISIBILITY_DRAFT)
+ ->withVisibility(array(PhameConstants::VISIBILITY_DRAFT))
->setLimit(5)
->execute();
diff --git a/src/applications/phame/controller/PhameLiveController.php b/src/applications/phame/controller/PhameLiveController.php
--- a/src/applications/phame/controller/PhameLiveController.php
+++ b/src/applications/phame/controller/PhameLiveController.php
@@ -97,7 +97,8 @@
// Only show published posts on external domains.
if ($is_external) {
- $post_query->withVisibility(PhameConstants::VISIBILITY_PUBLISHED);
+ $post_query->withVisibility(
+ array(PhameConstants::VISIBILITY_PUBLISHED));
}
$post = $post_query->executeOne();
diff --git a/src/applications/phame/controller/blog/PhameBlogFeedController.php b/src/applications/phame/controller/blog/PhameBlogFeedController.php
--- a/src/applications/phame/controller/blog/PhameBlogFeedController.php
+++ b/src/applications/phame/controller/blog/PhameBlogFeedController.php
@@ -21,7 +21,7 @@
$posts = id(new PhamePostQuery())
->setViewer($viewer)
->withBlogPHIDs(array($blog->getPHID()))
- ->withVisibility(PhameConstants::VISIBILITY_PUBLISHED)
+ ->withVisibility(array(PhameConstants::VISIBILITY_PUBLISHED))
->execute();
$blog_uri = PhabricatorEnv::getProductionURI(
diff --git a/src/applications/phame/controller/blog/PhameBlogViewController.php b/src/applications/phame/controller/blog/PhameBlogViewController.php
--- a/src/applications/phame/controller/blog/PhameBlogViewController.php
+++ b/src/applications/phame/controller/blog/PhameBlogViewController.php
@@ -19,10 +19,14 @@
$post_query = id(new PhamePostQuery())
->setViewer($viewer)
- ->withBlogPHIDs(array($blog->getPHID()));
+ ->withBlogPHIDs(array($blog->getPHID()))
+ ->withVisibility(array(
+ PhameConstants::VISIBILITY_PUBLISHED,
+ PhameConstants::VISIBILITY_DRAFT,
+ ));
if ($is_live) {
- $post_query->withVisibility(PhameConstants::VISIBILITY_PUBLISHED);
+ $post_query->withVisibility(array(PhameConstants::VISIBILITY_PUBLISHED));
}
$posts = $post_query->executeWithCursorPager($pager);
diff --git a/src/applications/phame/controller/post/PhamePostArchiveController.php b/src/applications/phame/controller/post/PhamePostArchiveController.php
new file mode 100644
--- /dev/null
+++ b/src/applications/phame/controller/post/PhamePostArchiveController.php
@@ -0,0 +1,56 @@
+<?php
+
+final class PhamePostArchiveController extends PhamePostController {
+
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $request->getViewer();
+
+ $id = $request->getURIData('id');
+ $post = id(new PhamePostQuery())
+ ->setViewer($viewer)
+ ->withIDs(array($id))
+ ->requireCapabilities(
+ array(
+ PhabricatorPolicyCapability::CAN_VIEW,
+ PhabricatorPolicyCapability::CAN_EDIT,
+ ))
+ ->executeOne();
+ if (!$post) {
+ return new Aphront404Response();
+ }
+
+ $cancel_uri = $post->getViewURI();
+
+ if ($request->isFormPost()) {
+ $xactions = array();
+
+ $new_value = PhameConstants::VISIBILITY_ARCHIVED;
+ $xactions[] = id(new PhamePostTransaction())
+ ->setTransactionType(PhamePostTransaction::TYPE_VISIBILITY)
+ ->setNewValue($new_value);
+
+ id(new PhamePostEditor())
+ ->setActor($viewer)
+ ->setContentSourceFromRequest($request)
+ ->setContinueOnNoEffect(true)
+ ->setContinueOnMissingFields(true)
+ ->applyTransactions($post, $xactions);
+
+ return id(new AphrontRedirectResponse())
+ ->setURI($cancel_uri);
+ }
+
+ $title = pht('Archive Post');
+ $body = pht(
+ 'This post will revert to archived status and no longer be visible '.
+ 'to other users or members of this blog.');
+ $button = pht('Archive Post');
+
+ return $this->newDialog()
+ ->setTitle($title)
+ ->appendParagraph($body)
+ ->addSubmitButton($button)
+ ->addCancelButton($cancel_uri);
+ }
+
+}
diff --git a/src/applications/phame/controller/post/PhamePostViewController.php b/src/applications/phame/controller/post/PhamePostViewController.php
--- a/src/applications/phame/controller/post/PhamePostViewController.php
+++ b/src/applications/phame/controller/post/PhamePostViewController.php
@@ -48,6 +48,16 @@
'Use "Publish" to publish this post.')));
}
+ if ($post->isArchived()) {
+ $document->appendChild(
+ id(new PHUIInfoView())
+ ->setSeverity(PHUIInfoView::SEVERITY_ERROR)
+ ->setTitle(pht('Archived Post'))
+ ->appendChild(
+ pht('Only you can see this archived post until you publish it. '.
+ 'Use "Publish" to publish this post.')));
+ }
+
if (!$post->getBlog()) {
$document->appendChild(
id(new PHUIInfoView())
@@ -92,6 +102,8 @@
$date = phabricator_datetime($post->getDatePublished(), $viewer);
if ($post->isDraft()) {
$subtitle = pht('Unpublished draft by %s.', $author);
+ } else if ($post->isArchived()) {
+ $subtitle = pht('Archived post by %s.', $author);
} else {
$subtitle = pht('Written by %s on %s.', $author, $date);
}
@@ -207,6 +219,21 @@
->setName(pht('Publish'))
->setDisabled(!$can_edit)
->setWorkflow(true));
+ $actions->addAction(
+ id(new PhabricatorActionView())
+ ->setIcon('fa-ban')
+ ->setHref($this->getApplicationURI('post/archive/'.$id.'/'))
+ ->setName(pht('Archive'))
+ ->setDisabled(!$can_edit)
+ ->setWorkflow(true));
+ } else if ($post->isArchived()) {
+ $actions->addAction(
+ id(new PhabricatorActionView())
+ ->setIcon('fa-eye')
+ ->setHref($this->getApplicationURI('post/publish/'.$id.'/'))
+ ->setName(pht('Publish'))
+ ->setDisabled(!$can_edit)
+ ->setWorkflow(true));
} else {
$actions->addAction(
id(new PhabricatorActionView())
@@ -215,6 +242,13 @@
->setName(pht('Unpublish'))
->setDisabled(!$can_edit)
->setWorkflow(true));
+ $actions->addAction(
+ id(new PhabricatorActionView())
+ ->setIcon('fa-ban')
+ ->setHref($this->getApplicationURI('post/archive/'.$id.'/'))
+ ->setName(pht('Archive'))
+ ->setDisabled(!$can_edit)
+ ->setWorkflow(true));
}
if ($post->isDraft()) {
@@ -223,12 +257,14 @@
$live_name = pht('View Live');
}
- $actions->addAction(
- id(new PhabricatorActionView())
- ->setUser($viewer)
- ->setIcon('fa-globe')
- ->setHref($post->getLiveURI())
- ->setName($live_name));
+ if (!$post->isArchived()) {
+ $actions->addAction(
+ id(new PhabricatorActionView())
+ ->setUser($viewer)
+ ->setIcon('fa-globe')
+ ->setHref($post->getLiveURI())
+ ->setName($live_name));
+ }
return $actions;
}
@@ -255,7 +291,7 @@
$query = id(new PhamePostQuery())
->setViewer($viewer)
- ->withVisibility(PhameConstants::VISIBILITY_PUBLISHED)
+ ->withVisibility(array(PhameConstants::VISIBILITY_PUBLISHED))
->withBlogPHIDs(array($post->getBlog()->getPHID()))
->setLimit(1);
diff --git a/src/applications/phame/editor/PhamePostEditor.php b/src/applications/phame/editor/PhamePostEditor.php
--- a/src/applications/phame/editor/PhamePostEditor.php
+++ b/src/applications/phame/editor/PhamePostEditor.php
@@ -66,6 +66,9 @@
case PhamePostTransaction::TYPE_VISIBILITY:
if ($xaction->getNewValue() == PhameConstants::VISIBILITY_DRAFT) {
$object->setDatePublished(0);
+ } else if ($xaction->getNewValue() ==
+ PhameConstants::VISIBILITY_ARCHIVED) {
+ $object->setDatePublished(0);
} else {
$object->setDatePublished(PhabricatorTime::getNow());
}
diff --git a/src/applications/phame/query/PhamePostQuery.php b/src/applications/phame/query/PhamePostQuery.php
--- a/src/applications/phame/query/PhamePostQuery.php
+++ b/src/applications/phame/query/PhamePostQuery.php
@@ -29,7 +29,7 @@
return $this;
}
- public function withVisibility($visibility) {
+ public function withVisibility(array $visibility) {
$this->visibility = $visibility;
return $this;
}
@@ -98,10 +98,10 @@
$this->bloggerPHIDs);
}
- if ($this->visibility !== null) {
+ if ($this->visibility) {
$where[] = qsprintf(
$conn,
- 'visibility = %d',
+ 'visibility IN (%Ld)',
$this->visibility);
}
diff --git a/src/applications/phame/query/PhamePostSearchEngine.php b/src/applications/phame/query/PhamePostSearchEngine.php
--- a/src/applications/phame/query/PhamePostSearchEngine.php
+++ b/src/applications/phame/query/PhamePostSearchEngine.php
@@ -19,7 +19,7 @@
$query = $this->newQuery();
if (strlen($map['visibility'])) {
- $query->withVisibility($map['visibility']);
+ $query->withVisibility(array($map['visibility']));
}
return $query;
@@ -35,6 +35,7 @@
'' => pht('All'),
PhameConstants::VISIBILITY_PUBLISHED => pht('Published'),
PhameConstants::VISIBILITY_DRAFT => pht('Draft'),
+ PhameConstants::VISIBILITY_ARCHIVED => pht('Archived'),
)),
);
}
@@ -48,6 +49,7 @@
'all' => pht('All Posts'),
'live' => pht('Published Posts'),
'draft' => pht('Draft Posts'),
+ 'archived' => pht('Archived Posts'),
);
return $names;
}
@@ -65,6 +67,9 @@
case 'draft':
return $query->setParameter(
'visibility', PhameConstants::VISIBILITY_DRAFT);
+ case 'archived':
+ return $query->setParameter(
+ 'visibility', PhameConstants::VISIBILITY_ARCHIVED);
}
return parent::buildSavedQueryFromBuiltin($query_key);
@@ -100,6 +105,10 @@
$item->setStatusIcon('fa-star-o grey');
$item->setDisabled(true);
$item->addIcon('none', pht('Draft Post'));
+ } else if ($post->isArchived()) {
+ $item->setStatusIcon('fa-ban grey');
+ $item->setDisabled(true);
+ $item->addIcon('none', pht('Archived Post'));
} else {
$date = $post->getDatePublished();
$item->setEpoch($date);
diff --git a/src/applications/phame/storage/PhamePost.php b/src/applications/phame/storage/PhamePost.php
--- a/src/applications/phame/storage/PhamePost.php
+++ b/src/applications/phame/storage/PhamePost.php
@@ -53,7 +53,8 @@
public function getLiveURI() {
$blog = $this->getBlog();
$is_draft = $this->isDraft();
- if (strlen($blog->getDomain()) && !$is_draft) {
+ $is_archived = $this->isArchived();
+ if (strlen($blog->getDomain()) && !$is_draft && !$is_archived) {
return $this->getExternalLiveURI();
} else {
return $this->getInternalLiveURI();
@@ -92,6 +93,10 @@
return ($this->getVisibility() == PhameConstants::VISIBILITY_DRAFT);
}
+ public function isArchived() {
+ return ($this->getVisibility() == PhameConstants::VISIBILITY_ARCHIVED);
+ }
+
protected function getConfiguration() {
return array(
self::CONFIG_AUX_PHID => true,
@@ -165,7 +170,7 @@
switch ($capability) {
case PhabricatorPolicyCapability::CAN_VIEW:
- if (!$this->isDraft() && $this->getBlog()) {
+ if (!$this->isDraft() && !$this->isArchived() && $this->getBlog()) {
return $this->getBlog()->getViewPolicy();
} else if ($this->getBlog()) {
return $this->getBlog()->getEditPolicy();
@@ -319,6 +324,8 @@
public function getFieldValuesForConduit() {
if ($this->isDraft()) {
$date_published = null;
+ } else if ($this->isArchived()) {
+ $date_published = null;
} else {
$date_published = (int)$this->getDatePublished();
}
diff --git a/src/applications/phame/storage/PhamePostTransaction.php b/src/applications/phame/storage/PhamePostTransaction.php
--- a/src/applications/phame/storage/PhamePostTransaction.php
+++ b/src/applications/phame/storage/PhamePostTransaction.php
@@ -73,6 +73,8 @@
case self::TYPE_VISIBILITY:
if ($new == PhameConstants::VISIBILITY_PUBLISHED) {
return 'fa-globe';
+ } else if ($new == PhameConstants::VISIBILITY_ARCHIVED) {
+ return 'fa-ban';
} else {
return 'fa-eye-slash';
}
@@ -144,6 +146,10 @@
return pht(
'%s marked this post as a draft.',
$this->renderHandleLink($author_phid));
+ } else if ($new == PhameConstants::VISIBILITY_ARCHIVED) {
+ return pht(
+ '%s archived this post.',
+ $this->renderHandleLink($author_phid));
} else {
return pht(
'%s published this post.',
@@ -201,6 +207,11 @@
'%s marked %s as a draft.',
$this->renderHandleLink($author_phid),
$this->renderHandleLink($object_phid));
+ } else if ($new == PhameConstants::VISIBILITY_ARCHIVED) {
+ return pht(
+ '%s marked %s as archived.',
+ $this->renderHandleLink($author_phid),
+ $this->renderHandleLink($object_phid));
} else {
return pht(
'%s published %s.',
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Mar 16, 5:48 AM (5 d, 8 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7387610
Default Alt Text
D16104.id38751.diff (16 KB)
Attached To
Mode
D16104: Ability to archive Phame Posts
Attached
Detach File
Event Timeline
Log In to Comment