Make deleting a blog a little easier to recover from
Summary: We currently orphan posts when you delete a blog. Fixes some visibility and permission errors when that happens. Also... should allow you to archive posts. Test Plan: Delete a blog, visit a post I made, still can see it. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Maniphest Tasks: T9360 Differential Revision: https://secure.phabricator.com/D14457
This commit is contained in:
		| @@ -17,9 +17,15 @@ final class PhamePostViewController extends PhamePostController { | |||||||
|     $blog = $post->getBlog(); |     $blog = $post->getBlog(); | ||||||
|  |  | ||||||
|     $crumbs = $this->buildApplicationCrumbs(); |     $crumbs = $this->buildApplicationCrumbs(); | ||||||
|  |     if ($blog) { | ||||||
|       $crumbs->addTextCrumb( |       $crumbs->addTextCrumb( | ||||||
|         $blog->getName(), |         $blog->getName(), | ||||||
|         $this->getApplicationURI('blog/view/'.$blog->getID().'/')); |         $this->getApplicationURI('blog/view/'.$blog->getID().'/')); | ||||||
|  |     } else { | ||||||
|  |       $crumbs->addTextCrumb( | ||||||
|  |         pht('[No Blog]'), | ||||||
|  |         null); | ||||||
|  |     } | ||||||
|     $crumbs->addTextCrumb( |     $crumbs->addTextCrumb( | ||||||
|       $post->getTitle(), |       $post->getTitle(), | ||||||
|       $this->getApplicationURI('post/view/'.$post->getID().'/')); |       $this->getApplicationURI('post/view/'.$post->getID().'/')); | ||||||
|   | |||||||
| @@ -81,15 +81,20 @@ final class PhamePostSearchEngine | |||||||
|  |  | ||||||
|     foreach ($posts as $post) { |     foreach ($posts as $post) { | ||||||
|       $id = $post->getID(); |       $id = $post->getID(); | ||||||
|       $blog = $viewer->renderHandle($post->getBlogPHID())->render(); |       $blog = $post->getBlog(); | ||||||
|  |       if ($blog) { | ||||||
|  |         $blog_name = $viewer->renderHandle($post->getBlogPHID())->render(); | ||||||
|  |         $blog_name = pht('Blog: %s', $blog_name); | ||||||
|  |       } else { | ||||||
|  |         $blog_name = pht('[No Blog]'); | ||||||
|  |       } | ||||||
|       $item = id(new PHUIObjectItemView()) |       $item = id(new PHUIObjectItemView()) | ||||||
|         ->setUser($viewer) |         ->setUser($viewer) | ||||||
|         ->setObject($post) |         ->setObject($post) | ||||||
|         ->setHeader($post->getTitle()) |         ->setHeader($post->getTitle()) | ||||||
|         ->setStatusIcon('fa-star') |         ->setStatusIcon('fa-star') | ||||||
|         ->setHref($this->getApplicationURI("/post/view/{$id}/")) |         ->setHref($this->getApplicationURI("/post/view/{$id}/")) | ||||||
|         ->addAttribute( |         ->addAttribute($blog_name); | ||||||
|           pht('Blog: %s', $blog)); |  | ||||||
|       if ($post->isDraft()) { |       if ($post->isDraft()) { | ||||||
|         $item->setStatusIcon('fa-star-o grey'); |         $item->setStatusIcon('fa-star-o grey'); | ||||||
|         $item->setDisabled(true); |         $item->setDisabled(true); | ||||||
|   | |||||||
| @@ -169,6 +169,8 @@ final class PhamePost extends PhameDAO | |||||||
|           return $this->getBlog()->getViewPolicy(); |           return $this->getBlog()->getViewPolicy(); | ||||||
|         } else if ($this->getBlog()) { |         } else if ($this->getBlog()) { | ||||||
|           return $this->getBlog()->getEditPolicy(); |           return $this->getBlog()->getEditPolicy(); | ||||||
|  |         } else { | ||||||
|  |           return PhabricatorPolicies::POLICY_NOONE; | ||||||
|         } |         } | ||||||
|         break; |         break; | ||||||
|       case PhabricatorPolicyCapability::CAN_EDIT: |       case PhabricatorPolicyCapability::CAN_EDIT: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Chad Little
					Chad Little