diff --git a/upload/includes/classes/video.class.php b/upload/includes/classes/video.class.php index 657dc469..2e7131bb 100644 --- a/upload/includes/classes/video.class.php +++ b/upload/includes/classes/video.class.php @@ -1055,6 +1055,10 @@ class CBvideo extends CBCategory 'users' => $cb_columns->object('users')->temp_change('featured','user_featured')->get_columns() ); + if (!isset($fields['video_users'])) { + $fields[] = 'video_users'; + } + $fields = tbl_fields( $fields ); if(!$params['count_only'] && !$params['show_related']) diff --git a/upload/includes/functions_user.php b/upload/includes/functions_user.php index 06d432d8..3f93c7d6 100644 --- a/upload/includes/functions_user.php +++ b/upload/includes/functions_user.php @@ -100,3 +100,40 @@ } } + /** + * Returns playable video for user's channel page + * @param : { array } { $userVideos } { an array user videos } + * @return : { string / boolean } { video key if found a video matches pattern else false } + * @since : November 17th, 2016 ClipBucket 2.8.2 + * @author : Saqib Razzaq + */ + + function userMainVideo($userVideos) { + global $userquery; + if (is_array($userVideos)) { + $userid = $userquery->userid; + foreach ($userVideos as $key => $video) { + $vBroadcast = trim($video['broadcast']); + switch ($vBroadcast) { + case 'private': + if (is_numeric($userid)) { + $allowedUsers = explode(',', $video['video_users']); + if (in_array($userid, $allowedUsers)) { + return $video; + } + } + break; + case 'logged': + if (is_numeric($userid)) { + return $video; + } + break; + case 'public': + return $video['videokey']; + break; + } + + } + } + } + diff --git a/upload/styles/cb_28/layout/view_channel.html b/upload/styles/cb_28/layout/view_channel.html index 5496f0f8..03ea9ce0 100644 --- a/upload/styles/cb_28/layout/view_channel.html +++ b/upload/styles/cb_28/layout/view_channel.html @@ -3,12 +3,16 @@ {lang code='channel' assign='object_type'} {$loadMoreLang ={lang code="load_more"}} {$uservideos=get_videos(["user"=>$user.userid, "order"=>"date_added DESC","limit" =>9])} -{if $uservideos} -{$first_video = $cbvid->get_video($uservideos.0.videokey)} -{/if} {$total_videos = $user.total_videos} {$total_photos = $user.total_photos} + +{if $uservideos} + {$mainVideo = userMainVideo($uservideos)} + {$first_video = $cbvid->get_video($mainVideo)} +{/if} + +
{include file="$style_dir/blocks/view_channel/channel_header.html"} diff --git a/upload/view_channel.php b/upload/view_channel.php index 44fa9919..91c899c9 100644 --- a/upload/view_channel.php +++ b/upload/view_channel.php @@ -66,14 +66,6 @@ if($udetails) $profile = $userquery->get_user_profile($udetails['userid']); Assign('u_control', $profile); -// making sure user can see his private vid tab -//$user_cond = $userquery->userid != $udetails['userid']; -//Assign('u_cond', $user_cond); - - $firstVideo = isset($videos[0]) ? $videos[0] : false; - $firstVideo = $cbvid->get_video($firstVideo['videoid']); - //echo "hm"; - Assign('firstVideo', $firstVideo); //Checking Profile permissions $perms = $p['show_profile'];