Beispiel #1
0
 public function flagged_answers()
 {
     $answers = CommentFlag::groupBy('comment_id')->get();
     $data = array('flagged_answers' => $answers);
     return View::make('admin.sections.flagged_answers', $data);
 }
 public function delete_comment($id)
 {
     $comment = Comment::find($id);
     if (Auth::user()->id == $comment->user_id || Auth::user()->admin == 1) {
         $comment_votes = CommentVote::where('comment_id', '=', $id)->get();
         foreach ($comment_votes as $votes) {
             $votes->delete();
         }
         $comment_flags = CommentFlag::where('comment_id', '=', $id)->get();
         foreach ($comment_flags as $flag) {
             $flag->delete();
         }
         $comment->delete();
         return 1;
     } else {
         return 0;
     }
 }
Beispiel #3
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function delete($id)
 {
     $media = Media::find($id);
     if ($media->user_id == Auth::user()->id || Auth::user()->admin == 1) {
         $media_flags = MediaFlag::where('media_id', '=', $id)->get();
         foreach ($media_flags as $media_flag) {
             $media_flag->delete();
         }
         $media_likes = MediaLike::where('media_id', '=', $id)->get();
         foreach ($media_likes as $media_like) {
             $media_like->delete();
         }
         $comments = Comment::where('media_id', '=', $id)->get();
         foreach ($comments as $comment) {
             $comment_votes = CommentVote::where('comment_id', '=', $comment->id)->get();
             foreach ($comment_votes as $comment_vote) {
                 $comment_vote->delete();
             }
             $comment_flags = CommentFlag::where('comment_id', '=', $comment->id)->get();
             foreach ($comment_flags as $comment_flag) {
                 $comment_flag->delete();
             }
             $comment->delete();
         }
         // if the media type is a gif we need to remove the animation file too.
         if (strpos($media->pic_url, '.gif') > 0) {
             if (file_exists(Config::get('site.uploads_dir') . 'images/' . str_replace(".gif", "-animation.gif", $media->pic_url))) {
                 unlink(Config::get('site.uploads_dir') . 'images/' . str_replace(".gif", "-animation.gif", $media->pic_url));
             }
         }
         // remove the image
         if (file_exists(Config::get('site.uploads_dir') . 'images/' . $media->pic_url)) {
             unlink(Config::get('site.uploads_dir') . 'images/' . $media->pic_url);
         }
         $media->delete();
     }
     return Redirect::to('admin?section=media')->with(array('note' => Lang::get('lang.delete_success'), 'note_type' => 'success'));
 }
Beispiel #4
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function delete($id)
 {
     $media = Media::find($id);
     if ($media->user_id == Auth::user()->id || Auth::user()->admin == 1) {
         $media_flags = MediaFlag::where('media_id', '=', $id)->get();
         foreach ($media_flags as $media_flag) {
             $media_flag->delete();
         }
         $media_likes = MediaLike::where('media_id', '=', $id)->get();
         foreach ($media_likes as $media_like) {
             $media_like->delete();
         }
         $comments = Comment::where('media_id', '=', $id)->get();
         foreach ($comments as $comment) {
             $comment_votes = CommentVote::where('comment_id', '=', $comment->id)->get();
             foreach ($comment_votes as $comment_vote) {
                 $comment_vote->delete();
             }
             $comment_flags = CommentFlag::where('comment_id', '=', $comment->id)->get();
             foreach ($comment_flags as $comment_flag) {
                 $comment_flag->delete();
             }
             $comment->delete();
         }
         $arrayPicUrl = explode("/", $media->pic_url);
         // if the media type is a gif we need to remove the animation file too.
         if (strpos($media->pic_url, '.gif') > 0) {
             \Cloudinary\Uploader::destroy(Constant::FOLDER_CLOUDINARY . '/' . $arrayPicUrl[0] . '/' . pathinfo(str_replace(".gif", "-animation.gif", $media->pic_url), PATHINFO_FILENAME));
         }
         // remove the image
         \Cloudinary\Uploader::destroy(Constant::FOLDER_CLOUDINARY . '/' . $arrayPicUrl[0] . '/' . pathinfo($media->pic_url, PATHINFO_FILENAME));
         $media->delete();
     }
     return Redirect::to('admin?section=media')->with(array('note' => Lang::get('lang.delete_success'), 'note_type' => 'success'));
 }