Permalink
Browse files

enable and disable post

  • Loading branch information...
chemix committed Jun 22, 2014
1 parent d379b0d commit 2c92ac3844a94fd671d339b3ee8d396969a63031
Showing with 50 additions and 4 deletions.
  1. +32 −2 app/model/FacebookWallposts.php
  2. +16 −0 app/presenters/AdminPresenter.php
  3. +2 −2 app/templates/Admin/default.latte
@@ -15,7 +15,6 @@
use Tracy\Debugger;
class FacebookWallposts extends Object
{
@@ -30,7 +29,6 @@ class FacebookWallposts extends Object
protected $facebook;
public function __construct(Context $database, Facebook $facebook)
{
$this->database = $database;
@@ -53,6 +51,37 @@ public function getAllPosts()
->fetchAll();
}
/**
* enable post
*
* @param $postId string
* @return bool
*/
public function enablePost($postId)
{
$this->database->table('facebook_wallposts')
->where('id', $postId)
->update(array('status' => '1'));
return TRUE;
}
/**
* disable post
*
* @param $postId string
* @return bool
*/
public function disablePost($postId)
{
$this->database->table('facebook_wallposts')
->where('id', $postId)
->update(array('status' => '0'));
return TRUE;
}
public function importPostFromFacebook()
{
try {
@@ -61,6 +90,7 @@ public function importPostFromFacebook()
} catch (FacebookApiException $ex) {
Debugger::log($ex->getMessage(), 'facebook');
return array();
}
@@ -22,4 +22,20 @@ public function renderDefault()
$this->template->wallPosts = $this->wallposts->getAllPosts();
}
public function actionEnablePost($postId)
{
if ($this->wallposts->enablePost($postId)){
$this->flashMessage('Post enabled');
}
$this->redirect('default');
}
public function actionDisablePost($postId)
{
if ($this->wallposts->disablePost($postId)){
$this->flashMessage('Post disabled');
}
$this->redirect('default');
}
}
@@ -29,9 +29,9 @@
<li><small>{$post->id}</small></li>
<li><small>{$post->created_time}</small></li>
{if $post->status == '1'}
<li><a href="#" class="button alert">disable</a></li>
<li><a n:href="Admin:disablePost $post->id" class="button alert">disable</a></li>
{else}
<li><a href="#" class="button">enable</a></li>
<li><a n:href="Admin:enablePost $post->id" class="button">enable</a></li>
{/if}
</ul>
</div>

0 comments on commit 2c92ac3

Please sign in to comment.