Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15423785
D16104.id38743.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
12 KB
Referenced Files
None
Subscribers
None
D16104.id38743.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()) {
@@ -255,7 +289,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/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;
@@ -48,6 +48,7 @@
'all' => pht('All Posts'),
'live' => pht('Published Posts'),
'draft' => pht('Draft Posts'),
+ 'archived' => pht('Archived Posts'),
);
return $names;
}
@@ -65,6 +66,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 +104,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
@@ -92,6 +92,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,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mar 23 2025, 6:16 PM (4 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7718824
Default Alt Text
D16104.id38743.diff (12 KB)
Attached To
Mode
D16104: Ability to archive Phame Posts
Attached
Detach File
Event Timeline
Log In to Comment