https://www.icyphoenix.com/viewtopic.php?f=35&t=4958&p=33480#p33480 ----------------------------------- DWho Sun 26 Oct, 2008 14:12 Permissions Help ----------------------------------- Hi I am testing a MOD that allows users to upload youtube and similar videos to categories... it is based on smarters album mod but allows users to just add to catergories no personal cats.. Anyway I am attempting to allow the users to edit there upload view the page view file... I have come so far with the permissions that allows the admin to edit the file on that page... but for normal members it does not show... here is the file... [spoiler]sql_query($sql)) ) { message_die(GENERAL_ERROR, $lang['vc_error_video_info'], '', __LINE__, __FILE__, $sql); } while( $row = $db->sql_fetchrow($result) ) { $vc_user_access = vc_user_access($row['video_id'], $row, 1, 0, 0, 0, 0, 0); // VIEW if ($vc_user_access['view'] == 1) { if( $row['video_id'] == $video_id ) { $auth_data = vc_user_access($video_id, $row, 1, 1, 1, 1, 1, 1); // ALL } } } // ------------------------------------ // Check permissions // ------------------------------------ if( !$auth_data['view'] ) { if ( !$userdata['session_logged_in'] ) { redirect(append_sid(LOGIN_MG . '?redirect=dm_vc_page.' . $phpEx . '&video_id=' . $video_id)); exit; } else { message_die(GENERAL_ERROR, $lang['Not_Authorised']); } } // ------------------------------------ // END check permissions // ------------------------------------ // ------------------------------------ // Build Auth List // ------------------------------------ $auth_key = array_keys($auth_data); $auth_list = ''; for ($i = 0; $i < (count($auth_data) - 1); $i++) // ignore MODERATOR in this loop { // ------------------------------------ // we should skip a loop if RATE and COMMENT is disabled // ------------------------------------ if( ( ($vc_config['rate'] == 0) and ($auth_key[$i] == 'rate') ) or ( ($vc_config['comment'] == 0) and ($auth_key[$i] == 'comment') ) ) { continue; } $auth_list .= ($auth_data[$auth_key[$i]] == 1) ? $lang['Music_'. $auth_key[$i] .'_can'] : $lang['VC_'. $auth_key[$i] .'_cannot']; $auth_list .= '
'; } // ------------------------------------ // Add Moderator Control Panel here // ------------------------------------ if( ($userdata['user_level'] == ADMIN) or ($auth_data['moderator'] == 1) ) { $auth_list .= sprintf($lang['VC_moderate_can'], '', ''); } // ------------------------------------ // END Auth List // ------------------------------------ // ------------------------------------ // Previous & Next // ------------------------------------ if( isset($_GET['mode']) ) { if( ($_GET['mode'] == 'next') or ($_GET['mode'] == 'previous') ) { $sql = "SELECT video_id, video_cat_id, video_user_id FROM ". VC_TABLE ." WHERE video_id = $video_id"; if( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, $lang['vc_error_video_info'], '', __LINE__, __FILE__, $sql); } $row = $db->sql_fetchrow($result); if( empty($row) ) { message_die(GENERAL_ERROR, 'Bad video_id'); } $sql = "SELECT new.video_id, new.video_time FROM ". VC_TABLE ." AS new, ". VC_TABLE ." AS cur WHERE cur.video_id = $video_id AND new.video_id <> cur.video_id AND new.video_cat_id = cur.video_cat_id"; $sql .= ($_GET['mode'] == 'next') ? " AND new.video_time >= cur.video_time" : " AND new.video_time <= cur.video_time"; $sql .= ($_GET['mode'] == 'next') ? " ORDER BY video_time ASC LIMIT 1" : " ORDER BY video_time DESC LIMIT 1"; if( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, $lang['vc_error_video_info'], '', __LINE__, __FILE__, $sql); } $row = $db->sql_fetchrow($result); if( empty($row) ) { message_die(GENERAL_ERROR, $lang['Video_not_exist']); } $video_id = $row['video_id']; // NEW video_id } } // ------------------------------------ // Get this video info // ------------------------------------ $sql = "SELECT s.*, u.user_id, u.username, r.rate_video_id, AVG(r.rate_point) AS rating, COUNT(DISTINCT c.comment_id) AS comments FROM ". VC_TABLE ." AS s LEFT JOIN ". USERS_TABLE ." AS u ON s.video_user_id = u.user_id LEFT JOIN ". VC_RATE_TABLE ." AS r ON s.video_id = r.rate_video_id LEFT JOIN ". VC_COMMENT_TABLE ." AS c ON s.video_id = c.comment_video_id WHERE video_id = '$video_id' GROUP BY s.video_id"; if( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, $lang['vc_error_video_info'], '', __LINE__, __FILE__, $sql); } $thisvideo = $db->sql_fetchrow($result); $cat_id = $thisvideo['video_cat_id']; $user_id = $thisvideo['video_user_id']; if(!$thisvideo['comments']) { $thisvideo['comments'] = $lang['No_comment']; } else { $thisvideo['comments'] = round($thisvideo['comments'], 2); } if ( $thisvideo['video_desc'] == '') { $template->assign_block_vars('switch_no_lyrics_block', array()); } else { $template->assign_block_vars('switch_lyrics_block', array()); } if( empty($thisvideo) ) { message_die(GENERAL_ERROR, $lang['Video_not_exist']); } if ( $thisvideo['video_imagename'] == '' ) { $img_id = $video_image_default; } else { $img_id = ( $video_image_path . $thisvideo['video_imagename'] ); } $video_filetype = 'youtube'; $video_url = $thisvideo['video_url']; // ------------------------------------ // Get the current Category Info // ------------------------------------ $sql = "SELECT * FROM ". VC_CAT_TABLE ." WHERE cat_id = '$cat_id'"; if( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, $lang['vc_error_cat_info'], '', __LINE__, __FILE__, $sql); } $thiscat = $db->sql_fetchrow($result); if (empty($thiscat)) { message_die(GENERAL_ERROR, $lang['Category_not_exist']); } // ------------------------------------ // Check video Approval // ------------------------------------ if ($userdata['user_level'] != ADMIN) { if( ($thiscat['cat_approval'] == ADMIN) or (($thiscat['cat_approval'] == MOD) and !$vc_user_access['moderator']) ) { if ($thisvideo['video_approval'] != 1) { message_die(GENERAL_ERROR, $lang['Not_Authorised']); } } } // ------------------------------------ // Increase view counter // ------------------------------------ $sql = "UPDATE ". VC_TABLE ." SET video_view_count = video_view_count + 1 WHERE video_id = '$video_id'"; if( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, $lang['vc_error_video_upd'], '', __LINE__, __FILE__, $sql); } // ------------------------------------ // Show Info box // ------------------------------------ if( $vc_config['show_info'] == 1) { $template->assign_block_vars('switch_show_info', array()); } // ------------------------------------ // End Show Info box // ------------------------------------ //---------------------------------------------------------- // Main work here... //---------------------------------------------------------- // // Start output of page // $page_title = $lang['VC']; include($phpbb_root_path . 'includes/page_header.'.$phpEx); $template->set_filenames(array( 'body' => 'dm_vc_page_body.tpl') ); if( ($thisvideo['video_user_id'] == VC_GUEST) or ($thisvideo['username'] == '') ) { $poster = ($thisvideo['video_username'] == '') ? $lang['Guest'] : $thisvideo['video_username']; } else { $poster = ''. $thisvideo['username'] .''; } if ($vc_config['show_listen_block'] == 1) { $template->assign_block_vars('switch_show_listen_block', array()); } $template->assign_vars(array( 'L_VC' => $lang['VC'], 'L_VC_ONLINE' => sprintf($lang['VC_Online'],$vc_config['version']), 'L_VC_VIEW_EXPLAIN' => $lang['Video_view_explain'], 'L_LISTEN_TO' => $lang['Video_listen_to'], 'CAT_TITLE' => $thiscat['cat_title'], 'U_VIEW_CAT' => append_sid("dm_vc_cat.$phpEx?cat_id=$cat_id"), 'L_VC_HEADER' => $lang['VC_Header'], 'L_VC_HEADER_EXPLAIN' => $lang['VC_Header_Explain'], 'L_SEARCH_VIDEOS' => $lang['Search_video'], 'SEARCH_VIDEO_IMG' => $images['search_video'], 'VIDEO_IMG' => $images['video'], 'L_VIDEO_IMAGE' => $lang['Video_image'], 'L_VIDEO_IMAGE_SHOW' => $lang['Video_image_show'], 'L_CLICK_IMAGE_TITLE' => $lang['Click_image_title'], 'EDIT' => ( ($auth_data['moderator']) || ($userdata['_video_user_id'] == $thisvideo['video_user_id']) ) ? '' . $lang['Edit_video'] . '' : '', 'U_VIDEO' => append_sid("dm_vc_page.$phpEx?video_id=$video_id"), 'U_SHOW_VIDEO' => append_sid("dm_vc_show.$phpEx?video_id=$video_id"), 'L_SHOW_VIDEO' => $lang['show_video'], 'U_IMG' => append_sid("$img_id"), 'S_VC_SEARCH_ACTION' => append_sid("dm_vc_search.$phpEx"), 'VIDEO_TITLE' => $thisvideo['video_title'], 'VIDEO_URL' => $thisvideo['video_url'], 'VIDEO_DESC' => nl2br($thisvideo['video_desc']), 'SINGER' => $thisvideo['video_singer'], 'VIDEO_DURATION' => $thisvideo['video_duration'], 'L_VIDEO_DURATION' => $lang['Video_duration'], 'POSTER' => $poster, 'VIDEO_TIME' => create_date($board_config['default_dateformat'], $thisvideo['video_time'], $board_config['board_timezone']), 'VIDEO_VIEW' => $thisvideo['video_view_count'], 'VIDEO_DOWNLOAD' => $thisvideo['video_download_count'], 'VIDEO_RATING' => ($thisvideo['rating'] != 0) ? round($thisvideo['rating'], 2) : $lang['Not_rated'], 'VIDEO_COMMENTS' => $thisvideo['comments'], 'U_RATE' => append_sid("dm_vc_rate.$phpEx?video_id=$video_id"), 'U_COMMENT' => append_sid("dm_vc_comment.$phpEx?video_id=$video_id"), 'U_VC_DOWNLOAD' => $thisvideo['video_download_link'], 'U_NEXT' => append_sid("dm_vc_page.$phpEx?video_id=$video_id&mode=next"), 'U_PREVIOUS' => append_sid("dm_vc_page.$phpEx?video_id=$video_id&mode=previous"), 'L_NEXT' => $lang['Next'], 'L_PREVIOUS' => $lang['Previous'], 'L_FROM' => $lang['from'], 'L_RATING' => $lang['Rating'], 'L_VIDEO_TITLE' => $lang['Video_Title'], 'L_VIDEO_DESC' => $lang['Video_Desc'], 'L_SINGER' => $lang['Singer'], 'L_POSTER' => $lang['Poster'], 'L_POSTED' => $lang['Posted'], 'L_VIEW' => $lang['View'], 'L_VC_DOWNLOAD' => $lang['Download'], 'L_COPYRIGHT' => sprintf($lang['VC_copyright'],$vc_config['version']), 'L_COMMENTS' => $lang['Comments']) ); if ($vc_config['rate']) { $template->assign_block_vars('rate_switch', array()); } if ($vc_config['comment']) { $template->assign_block_vars('comment_switch', array()); } if ( empty($thisvideo['video_download_link'] )) { $template->assign_block_vars('no_download_switch', array()); } else { $template->assign_block_vars('download_switch', array()); } // ------------------------------------ // Video Collection // ------------------------------------ if ( $video_filetype == 'youtube' ) { $template->assign_block_vars('youtube', array()); } // ------------------------------------ // Generate the page // ------------------------------------ $template->pparse('body'); include($phpbb_root_path . 'includes/page_tail.'.$phpEx); ?>[/spoiler] I wondered if anyone could show me where I went wrong... users can edit their file form the cat page..(this is where I took the code from) but some users might not see there where to edit the file... thanks for looking and any help that anyone could give... :mrgreen: :mrgreen: