Skip to content

Commit

Permalink
Add stickied by/date for setting/unsetting of a sticky topic.
Browse files Browse the repository at this point in the history
  • Loading branch information
reecefowell committed Jun 25, 2012
1 parent c08716d commit 862db5f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Controller/TopicController.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,15 @@ public function stickyAction($topic_id)
throw new AccessDeniedException('You do not have access to this section.');
}

$user = $this->container->get('security.context')->getToken()->getUser();

$topic = $this->container->get('ccdn_forum_forum.topic.repository')->find($topic_id);

if ( ! $topic) {
throw new NotFoundHttpException('No such topic exists!');
}

$this->container->get('ccdn_forum_moderator.topic.manager')->sticky($topic)->flushNow();
$this->container->get('ccdn_forum_moderator.topic.manager')->sticky($topic, $user)->flushNow();

$this->container->get('session')->setFlash('success', $this->container->get('translator')->trans('flash.topic.sticky.success', array('%topic_title%' => $topic->getTitle()), 'CCDNForumModeratorBundle'));

Expand Down
6 changes: 5 additions & 1 deletion Manager/TopicManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ class TopicManager extends ForumBundle\Manager\TopicManager implements ManagerIn
* @param $topic
* @return $this
*/
public function sticky($topic)
public function sticky($topic, $user)
{
$topic->setIsSticky(true);
$topic->setStickiedBy($user);
$topic->setStickiedDate(new \DateTime());

$this->persist($topic);

Expand All @@ -52,6 +54,8 @@ public function sticky($topic)
public function unsticky($topic)
{
$topic->setIsSticky(false);
$topic->setStickiedBy(null);
$topic->setStickiedDate(null);

$this->persist($topic);

Expand Down

0 comments on commit 862db5f

Please sign in to comment.