예제 #1
0
 public function getDestroy($id)
 {
     if (Session::get('user_level') < Config::get('cms.deleteComments')) {
         return Redirect::to(_l(URL::action('AdminHomeController@getIndex')))->with('message', Lang::get('admin.notPermitted'))->with('notif', 'warning');
     }
     try {
         $comment = MemeComment::onlyTrashed()->findOrFail($id);
         $comment->forceDelete();
         return Redirect::to(_l(URL::action('MemeCommentController@getTrashed')))->with('message', Lang::get('admin.commentDeleted'))->with('notif', 'success');
     } catch (Exception $e) {
         return Redirect::to(_l(URL::action('MemeCommentController@getTrashed')))->with('message', Lang::get('admin.noSuchComment'))->with('notif', 'danger');
     }
 }
예제 #2
0
 public function postCreateMemeComment($id)
 {
     try {
         $comment = new MemeComment();
         $news = MemeInstance::findOrFail($id);
         if (Input::get('createdAt')) {
             $comment->created_at = date("Y-m-d H:i:s", strtotime(Input::get('createdAt')));
         } else {
             $comment->created_at = date("Y-m-d H:i:s", strtotime('now'));
         }
         $comment->comment_content = Input::get('commentContent');
         $akismet = new Akismet('http://www.puskice.org/', '5fa6e0236f7b');
         $akismet->setCommentAuthor($comment->username);
         $akismet->setCommentAuthorEmail($comment->email);
         $akismet->setCommentAuthorURL("");
         $akismet->setCommentContent($comment->comment_content);
         $akismet->setPermalink('http://www.puskice.org/meme/' . $news->id . '-' . $news->permalink);
         if ($akismet->isCommentSpam()) {
             $comment->deleted_at = date('Y-m-d H:i:s', strtotime('now'));
         }
         if (Input::get('user_id')) {
             $comment->published = 1;
         } else {
             $comment->published = 0;
         }
         if (Input::get('user_id')) {
             $user = User::find(Input::get('user_id'));
             $comment->username = $user->username;
             $comment->email = $user->email;
         } else {
             $comment->username = Input::get('username');
             $comment->email = Input::get('email');
         }
         if (Input::get('user_id')) {
             $comment->user_id = Input::get('user_id');
         } else {
             $comment->user_id = 0;
         }
         $comment->news_id = $id;
         $comment->ip_address = Puskice::getIP();
         $comment->save();
         if ($comment->deleted_at == null) {
             $user = array('email' => '*****@*****.**', 'name' => 'Info tim');
             // the data that will be passed into the mail view blade template
             $data = array('url' => "http://www.puskice.org//" . Config::get('settings.admin_url') . "/meme-comments/edit/" . $comment->id, 'approve_url' => "http://www.puskice.org//" . Config::get('settings.admin_url') . "/meme-comments/publish/" . $comment->id, 'delete_url' => "http://www.puskice.org//" . Config::get('settings.admin_url') . "/meme-comments/trash/" . $comment->id, 'username' => $comment->username, 'email' => $comment->email, 'title' => $news->title, 'news' => 1, 'news_id' => $news->id, 'content' => $comment->comment_content);
             // use Mail::send function to send email passing the data and using the $user variable in the closure
             Mail::send('emails.new_comment', $data, function ($message) use($user) {
                 $message->from('*****@*****.**', "Puškice cenzura");
                 $message->to('*****@*****.**', 'Info tim Puškice')->subject('Novi meme komentar čeka moderaciju');
             });
         }
         return Response::json(array('status' => 'success', 'message' => __("Ваш коментар је успешно прослеђен")));
     } catch (Exception $e) {
         return Response::json(array('status' => 'fail'));
     }
 }