Exemplo n.º 1
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'));
 }
Exemplo n.º 2
0
$media_url = URL::to('media') . '/' . $item->slug;
?>
		
			<div id="below_media">
				<div class="social-icons">
					<ul class="socialcount socialcount-large" data-url="{{ $media_url }}" style="width:100%; position:relative; right:0px">
						<li class="facebook"><a href="https://www.facebook.com/sharer/sharer.php?u={{ $media_url }}" target="_blank" title="{{ Lang::get('lang.share_facebook') }}" onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=no,scrollbars=no,height=400,width=600');return false;"><span class="fa fa-facebook"></span><span class="count">{{ Lang::get('lang.like') }}</span></a></li>
						<li class="twitter" data-share-text="{{ $media->title }}"><a href="https://twitter.com/intent/tweet?url={{ $media_url }}&text={{ $media->title }}" data-url="{{ $media_url }}" title="{{ Lang::get('lang.share_twitter') }}" onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=no,scrollbars=no,height=400,width=600');return false;"><span class="fa fa-twitter" data-url="{{ $media_url }}"></span><span class="count">{{ Lang::get('lang.tweet') }}</span></a></li>
						<li class="googleplus"><a href="https://plus.google.com/share?url={{ $media_url }}" target="_blank" title="{{ Lang::get('lang.share_google') }}" onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=no,scrollbars=no,height=400,width=600');return false;"><span class="fa fa-google-plus"></span><span class="count">{{ Lang::get('lang.plus_one') }}</span></a></li>
						<li class="pinterest"><a href="//www.pinterest.com/pin/create/button/?url={{ $media_url }}&media={{ Config::get('site.uploads_dir') . '/images/' . $media->pic_url }}&description={{ $media->title }}" title="{{ Lang::get('lang.pin_it') }}" target="_blank" onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=no,scrollbars=no,height=400,width=600');return false;"><span class="fa fa-pinterest"></span><span class="count">{{ Lang::get('lang.pin_it') }}</span></a></li>
					</ul>
				</div>

				@if(!Auth::guest())
					<?php 
$flagged = MediaFlag::where('user_id', '=', Auth::user()->id)->where('media_id', '=', $media->id)->first();
?>
					<div class="media-flag pull-right border-radius @if(isset($flagged->id)) active @endif" data-id="{{ $media->id }}" style="margin-top:5px;"><i class="fa fa-flag"></i> <span class="media-flag-desc">@if(isset($flagged->id)){{ Lang::get('lang.flagged') }}@else{{ Lang::get('lang.flag_this') }}@endif</span></div>
				@endif

				@if(isset($item->link_url) && $item->link_url != '')
					<a href="{{ $item->link_url }}" target="_blank" class="label label-success" style="margin-top:6px;"><i class="fa fa-globe"></i> {{ Lang::get('lang.source') }}</a>
				@endif

				@if(!Auth::guest() && (Auth::user()->admin == 1 || Auth::user()->id == $item->user_id))
				
				<div class="edit-delete">
					<a href="#_" data-href="{{ URL::to('media/delete') . '/' . $item->id }}" onclick="confirm_delete(this)" class="label label-danger"><i class="icon-trash"></i> {{ Lang::get('lang.delete') }}</a>
					<a href="#_" data-toggle="modal" data-target="#edit-modal" class="label label-warning"><i class="icon-edit"></i> {{ Lang::get('lang.edit') }}</a>
				</div>
				@endif
Exemplo n.º 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();
         }
         $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'));
 }