user_info['user_id'], $group_id); if($group->group_info["group_user_id"]!=$user->user_info["user_id"]){ // DISPLAY ERROR PAGE IF USER IS NOT LOGGED IN AND ADMIN SETTING REQUIRES REGISTRATION if( !$user->user_exists && !$setting['setting_permission_video'] ) { if($owner->user_info["user_id"]!=$user->user_info["user_id"]){ $page = "error"; $smarty->assign('error_header', 639); $smarty->assign('error_message', 656); $smarty->assign('error_submit', 641); include "footer.php"; } } } // DISPLAY ERROR PAGE IF NO OWNER /*if( !$owner->user_exists ) { $page = "error"; $smarty->assign('error_header', 639); $smarty->assign('error_message', 828); $smarty->assign('error_submit', 641); include "footer.php"; }*/ // MAKE SURE VIDEO EXISTS $video_query = $database->database_query("SELECT * FROM se_group_videos WHERE video_id='$video_id' AND video_group_id='{$group_id}' AND video_admin_approved=1 LIMIT 1"); /*if($database->database_num_rows($video_query) != 1) { if($owner->user_info["user_id"]!=$user->user_info["user_id"]){ header("Location: ".$url->url_create('profile', $owner->user_info['user_username'])); exit(); } }*/ $video_info = $database->database_fetch_assoc($video_query); // CHECK PRIVACY if($owner->user_info["user_id"]!=$user->user_info["user_id"]){ $privacy_max = $owner->user_privacy_max($user); if(!($video_info[video_privacy] & $privacy_max)) { $page = "error"; $smarty->assign('error_header', 639); $smarty->assign('error_message', 5500148); $smarty->assign('error_submit', 641); include "footer.php"; }} $groupdir = $group->group_dir(); // INSTANTIATE VIDEO AND SET VIDEO VARS $video = new se_video($owner->user_info['user_id']); $video_info['video_dir'] = $video->video_dir(); // ENSURE VIDEOS ARE ENABLED FOR THIS USER if($group->group_info["group_user_id"]!=$user->user_info["user_id"]){ if ((($video_info['video_type'] == 0) && (!$owner->level_info['level_video_allow'])) || (($video_info['video_type'] == 1) )) { /*header("Location: ".$url->url_create('profile', $owner->user_info['user_username'])); exit();*/ } } if((!$user->level_info['level_video_allow'])) { header("Location: ".$url->url_create('profile', $user->user_info['user_username'])); exit(); } $video_info['video_rating_full'] = floor($video_info['video_cache_rating']); $video_info['video_rating_part'] = (($video_info['video_cache_rating']-$video_info['video_rating_full']) == 0) ? 0 : 1; $video_info['video_rating_none'] = 5-$video_info['video_rating_full']-$video_info['video_rating_part']; $video_info['video_rating_total'] = $database->database_num_rows($database->database_query("SELECT NULL FROM groupvideoratings WHERE video_id='{$video_info['video_id']}'")); // GET VIDEO COMMENT PRIVACY $allowed_to_comment = ($privacy_max & $video_info['video_comments']); // CHECK IF USER IS ALLOWED TO RATE $allowed_to_rate = 1; if($database->database_num_rows($database->database_query("SELECT NULL FROM groupvideoratings WHERE video_id='{$video_info['video_id']}' AND user_id='{$user->user_info['user_id']}'")) != 0 || !$user->user_exists) { $allowed_to_rate = 0; } if($task == "media_delete") { if($group->user_rank == 2 || $group->user_rank == 1){ $media_path = $group->group_dir($group->group_info['group_id'])."video_".$video_info['video_id'].".flv"; if(file_exists($media_path)) { @unlink($media_path); } $media_path = $group->group_dir($group->group_info['group_id'])."video_".$video_info['video_id'].".mp4"; if(file_exists($media_path)) { @unlink($media_path); } $thumb_path = $group->group_dir($group->group_info['group_id'])."video_".$video_info['video_id']."_thumb.jpg"; if(file_exists($thumb_path)) { @unlink($thumb_path); } //$action_thumb_path = $url->url_base.substr($group->group_dir($group->group_info['group_id']), 2).$media_info['groupmedia_id']."_thumb.jpg"; // DELETE ACTION MEDIA IF NECESSARY $database->database_query("DELETE FROM se_group_videos WHERE video_id = '".$video_info["video_id"]."'"); // SEND USER TO NEXT PHOTO header("Location: group.php?group_id=".$group_id); exit(); }} elseif( $task == "edit" ) {if($group->user_rank == 2 || $group->user_rank == 1){ $video_id = $_POST['video_id']; $video_title = censor($_POST['video_title']); $video_desc = censor(str_replace("\r\n", "
", $_POST['video_desc'])); $video_search = $_POST['video_search']; $video_privacy = $_POST['video_privacy']; $video_comments = $_POST['video_comments']; // MAKE SURE SUBMITTED PRIVACY OPTIONS ARE ALLOWED, IF NOT, SET TO EVERYONE if(!in_array($video_privacy, $level_video_privacy)) { $video_privacy = $level_video_privacy[0]; } if(!in_array($video_comments, $level_video_comments)) { $video_comments = $level_video_comments[0]; } $database->database_query("UPDATE se_group_videos SET video_title='$video_title', video_desc='$video_desc' WHERE video_id='$video_id' AND video_user_id='{$user->user_info['user_id']}'"); $video_info["video_title"]=$video_title; $video_info["video_desc"]=$video_desc; }} // RATE VIDEO elseif($task == "rate_do") { $rating = (int) $_POST['rating']; if($allowed_to_rate) { if($rating <= 5 && $rating >= 1) { $database->database_query("INSERT INTO groupvideoratings (video_id, user_id, rating) VALUES ('{$video_info['video_id']}', '{$user->user_info['user_id']}', '{$rating}')"); // GET AVERAGE RATING / NUM VOTES FOR BAYESIAN WEIGHTED RATING $avg = $database->database_fetch_assoc($database->database_query("SELECT avg(video_cache_rating) AS average_rating, avg(video_cache_rating_total) AS average_total FROM se_group_videos WHERE video_cache_rating_total<>'0'")); // GET TOTAL RATING $new_rating = ($video_info['video_cache_rating']*$video_info['video_rating_total']+$rating)/($video_info['video_rating_total']+1); $new_total = $video_info['video_rating_total']+1; $new_rating_weighted = ( ($avg['average_total'] * $avg['average_rating']) + ($new_total * $new_rating) ) / ($avg['average_total'] + $new_total); // SET NEW CACHED RATINGS $database->database_query("UPDATE se_group_videos SET video_cache_rating='{$new_rating}', video_cache_rating_weighted='{$new_rating_weighted}', video_cache_rating_total='{$new_total}' WHERE video_id='{$video_info['video_id']}'"); $allowed_to_rate = 0; $video_info['video_rating_full'] = floor($new_rating); $video_info['video_rating_part'] = (($new_rating-$video_info['video_rating_full']) == 0) ? 0 : 1; $video_info['video_rating_none'] = 5-$video_info['video_rating_full']-$video_info['video_rating_part']; $video_info['video_rating_total'] = $new_total; } } $response_array = array( 'allowed_to_rate' => (bool) $allowed_to_rate, 'rating_full' => (int) $video_info['video_rating_full'], 'rating_part' => (int) $video_info['video_rating_part'], 'rating_none' => (int) $video_info['video_rating_none'], 'rating_total' => (int) $video_info['video_rating_total'] ); // OUTPUT JSON echo json_encode($response_array); exit(); } // GET USER'S VIDEOS FOR CAROUSEL $total_videos = $video->group_video_total($group_id); //$video_array = $video->video_list(0, $video->video_total(), "video_id DESC", "(video_is_converted='1')", 1); $video_array = $video->group_video_list(0, 10, "video_id DESC", $group_id, 1); // GET VIDEO COMMENTS // UPDATE VIDEO VIEWS if($user->user_info['user_id'] != $owner->user_info['user_id']) { $video_views_new = $video_info['video_views'] + 1; $database->database_query("UPDATE se_group_videos SET video_views='{$video_views_new}' WHERE video_id='{$video_info['video_id']}' LIMIT 1"); } // UPDATE NOTIFICATIONS if($user->user_info['user_id'] == $owner->user_info['user_id']) { $database->database_query("DELETE FROM se_notifys USING se_notifys LEFT JOIN se_notifytypes ON se_notifys.notify_notifytype_id=se_notifytypes.notifytype_id WHERE se_notifys.notify_user_id='{$owner->user_info['user_id']}' AND se_notifytypes.notifytype_name='videocomment' AND notify_object_id='{$video_info['video_id']}'"); } $commentcount = mysql_result(mysql_query("SELECT COUNT(*) FROM groupvideocomments WHERE object_id='".$video_id."'"),0); function grabcomments() { global $url, $video_id; $query = mysql_query("SELECT * FROM groupvideocomments WHERE object_id='".$video_id."' ORDER BY id DESC"); while($row=mysql_fetch_array($query)) { $owner1=new SEUser(Array($row["authoruser_id"])); ?>
">" class="photo" width="75" border="0">
database_query("DELETE FROM favorites WHERE user='".$user->user_info["user_id"]."' AND type='groupvideo' AND owner='".$group_id."' AND objectid='".$video_id."'"); } if($fave==="addto"){ $query=mysql_query("SELECT * FROM favorites WHERE user='".$user->user_info["user_id"]."' AND type='groupvideo' AND owner='".$group_id."' AND objectid='".$video_id."'"); if(mysql_num_rows($query)==0){ $database->database_query("INSERT INTO favorites SET user='".$user->user_info["user_id"]."', type='groupvideo', owner='".$group_id."', objectid='".$video_id."'"); } } $query=mysql_query("SELECT * FROM favorites WHERE user='".$user->user_info["user_id"]."' AND type='groupvideo' AND owner='".$group_id."' AND objectid='".$video_id."'"); if(mysql_num_rows($query)>0){$smarty->assign('favorites1', 1);} // SET GLOBAL PAGE TITLE $global_page_title[0] = 5500151; $global_page_title[1] = $owner->user_displayname; $global_page_title[2] = $video_info['video_title']; $global_page_description[0] = 5500102; $total_videos1=$total_videos; $global_page_description[1] = $video_info['video_desc']; $smarty->assign_by_ref('total_videos1', $total_videos1); $smarty->assign_by_ref('total_videos', $total_videos); // ASSIGN VARIABLES AND DISPLAY VIDEO PAGE $smarty->assign('group', $group); $smarty->assign('groupdir', $groupdir); $smarty->assign('commentcount', $commentcount); $smarty->assign('video_info', $video_info); $smarty->assign('total_comments', $total_comments); $smarty->assign('allowed_to_comment', $allowed_to_comment); $smarty->assign('allowed_to_rate', $allowed_to_rate); $smarty->assign('videos', $video_array); include "footer.php"; ?>