Make posts 1:1 with blogs and implement policy controls

Summary:
This leaves the UI in a pretty rough state, but implements blog policy controls and queries, and 1:1 relationships between posts and blogs. Needs a bunch more cleanup but seemed like an okayish breaking point in terms of cohesiveness.

Posts have these rules:

  - Drafts are visible only to the author.
  - Published posts are visible to anyone who can see the blog they appear on.
  - Posts are only editable by the author.

...so we don't need any special policy UI or state to accommodate these rules.

Posts may have no blog if they're grandfathered in or you write a post to a blog and then lose the ability to see the blog. This is the messiest edge case -- specifically:

  - You write a post to blog A.
  - You publish the post.
  - I edit the "Visible To:" for blog A and set it to exclude you.

What we do in this case is let you see the post in "My Posts", but you can no longer see the blog and you'll see the post as not being part of a blog. We can maybe give you some UI to let you move it later or something.

Test Plan: Hit all (I think?) of the interfaces without issues. Definitely some UI problems still right now.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T1373

Differential Revision: https://secure.phabricator.com/D3694
This commit is contained in:
epriestley
2012-10-15 14:50:04 -07:00
parent dbcf2e44e8
commit a50b8e39b1
14 changed files with 181 additions and 197 deletions

View File

@@ -19,8 +19,7 @@
/**
* @group phame
*/
final class PhamePostViewController
extends PhameController {
final class PhamePostViewController extends PhameController {
private $postPHID;
private $phameTitle;
@@ -75,29 +74,21 @@ extends PhameController {
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$post_phid = null;
if ($this->getPostPHID()) {
$post_phid = $this->getPostPHID();
if (!$post_phid) {
$post = id(new PhamePostQuery())
->setViewer($user)
->withPHIDs(array($this->getPostPHID()))
->executeOne();
if (!$post) {
return new Aphront404Response();
}
$posts = id(new PhamePostQuery())
->withPHIDs(array($post_phid))
->execute();
$post = reset($posts);
if ($post) {
$this->setPhameTitle($post->getPhameTitle());
$blogger = PhabricatorObjectHandleData::loadOneHandle(
$post->getBloggerPHID(),
$user);
if (!$blogger) {
return new Aphront404Response();
}
}
$this->setPhameTitle($post->getPhameTitle());
$blogger = PhabricatorObjectHandleData::loadOneHandle(
$post->getBloggerPHID(),
$user);
} else if ($this->getBloggerName() && $this->getPhameTitle()) {
$phame_title = $this->getPhameTitle();
$phame_title = PhabricatorSlug::normalize($phame_title);
@@ -114,8 +105,9 @@ extends PhameController {
return new Aphront404Response();
}
$posts = id(new PhamePostQuery())
->withBloggerPHID($blogger->getPHID())
->withPhameTitle($phame_title)
->setViewer($user)
->withBloggerPHIDs(array($blogger->getPHID()))
->withPhameTitles(array($phame_title))
->execute();
$post = reset($posts);