Esempio n. 1
0
 public function action_delete()
 {
     $result = array('status' => false, 'error' => array());
     try {
         $input = Input::post();
         if (empty($input) || empty($input['id'])) {
             throw new Exception('You must specify a blog to delete.');
         }
         $blog = Model_Blog::find($input['id']);
         if (!$blog) {
             throw new Exception('Blog not found.');
         }
         if (!\Access::can('delete_any_blog', $this->user) && (!\Access::can('delete_own_blog', $this->user) || !Model_Agency_Contact::is_confirmed($blog->user_id, $this->user))) {
             throw new Exception('You are not authorized to delete this blog');
         }
         try {
             $blog->delete();
             $result['status'] = true;
         } catch (\Orm\ValidationFailed $ex) {
             $result['error'] = $ex->getMessage();
         } catch (Exception $ex) {
             $msg = $ex->getMessage();
             $result['error'] = $msg ? $msg : 'Oops, something went wrong.';
         }
     } catch (Exception $ex) {
         $result['error'] = $ex->getMessage();
     }
     return $this->response($result);
 }
Esempio n. 2
0
 public function action_detail()
 {
     $this->setJavascript('responesive_tabs.js');
     $this->setJavascript('fb_comment.js');
     $aryDataTemplate['data'] = array();
     $id = Input::param('id');
     if ($id) {
         $data = Model_Blog::find($id);
         $aryDataTemplate['data'] = $data;
         $this->setPageTitle($data[BLOG_TITLE]);
     }
     $this->template->content = View_Smarty::forge('blog/detail.tpl', $aryDataTemplate);
 }
Esempio n. 3
0
 public function action_delete($id = null)
 {
     is_null($id) and Response::redirect('blog');
     if ($blog = Model_Blog::find($id)) {
         $blog->delete();
         Session::set_flash('success', 'Deleted blog #' . $id);
     } else {
         Session::set_flash('error', 'Could not delete blog #' . $id);
     }
     Response::redirect('blog');
 }
Esempio n. 4
0
 public function action_undoFeatured($id = null)
 {
     is_null($id) and Response::redirect('blog');
     $blog = Model_Blog::find($id);
     if ($blog) {
         $blog->blog_featured = 0;
         if ($blog->save()) {
             Session::set_flash('success', 'Blog #' . $id . ' is now featured.');
         } else {
             Session::set_flash('error', 'Could not make blog #' . $id . ' featured.');
         }
     }
     Response::redirect('blog');
 }