Allow statistic and column editing for admin only

This commit is contained in:
Brian Miyaji
2014-01-20 14:49:20 +11:00
parent 12f3d9cf5a
commit f2641222ad
6 changed files with 71 additions and 48 deletions

View File

@@ -10,6 +10,10 @@ function sportspress_save_post( $post_id ) {
// Update leagues seasons to show
update_post_meta( $post_id, 'sp_leagues_seasons', sportspress_array_value( $_POST, 'sp_leagues_seasons', array() ) );
// Update player statistics array
if ( current_user_can( 'edit_sp_tables' ) )
update_post_meta( $post_id, 'sp_columns', sportspress_array_value( $_POST, 'sp_columns', array() ) );
break;
case ( 'sp_event' ):
@@ -88,7 +92,7 @@ function sportspress_save_post( $post_id ) {
case ( 'sp_player' ):
// Update seasons teams to show
update_post_meta( $post_id, 'sp_seasons_teams', sportspress_array_value( $_POST, 'sp_seasons_teams', array() ) );
update_post_meta( $post_id, 'sp_leagues', sportspress_array_value( $_POST, 'sp_leagues', array() ) );
// Update team array
sportspress_update_post_meta_recursive( $post_id, 'sp_team', sportspress_array_value( $_POST, 'sp_team', array() ) );
@@ -102,6 +106,10 @@ function sportspress_save_post( $post_id ) {
// Update player metrics array
update_post_meta( $post_id, 'sp_metrics', sportspress_array_value( $_POST, 'sp_metrics', array() ) );
// Update player statistics array
if ( current_user_can( 'edit_sp_teams' ) )
update_post_meta( $post_id, 'sp_statistics', sportspress_array_value( $_POST, 'sp_statistics', array() ) );
break;
case ( 'sp_staff' ):

View File

@@ -37,7 +37,7 @@ function sportspress_the_content( $content ) {
global $post;
sportspress_league_table( $post->ID );
$table = sportspress_league_table( $post->ID );
$content = $table . $content;

View File

@@ -109,9 +109,9 @@ function sportspress_player_stats_meta( $post ) {
<?php
endif;
list( $columns, $data, $seasons_teams ) = sportspress_get_player_statistics_data( $post->ID, $league->term_id, true );
list( $columns, $data, $placeholders, $merged, $seasons_teams ) = sportspress_get_player_statistics_data( $post->ID, $league->term_id, true );
sportspress_edit_player_statistics_table( $league->term_id, $columns, $data, $seasons_teams );
sportspress_edit_player_statistics_table( $league->term_id, $columns, $data, $placeholders, $merged, $seasons_teams, ! current_user_can( 'edit_sp_teams' ) );
endforeach;
}

View File

@@ -20,15 +20,15 @@ function sportspress_team_post_init() {
add_action( 'init', 'sportspress_team_post_init' );
function sportspress_team_meta_init( $post ) {
$leagues = (array)get_the_terms( $post->ID, 'sp_league' );
$seasons = (array)get_the_terms( $post->ID, 'sp_season' );
$leagues = get_the_terms( $post->ID, 'sp_league' );
$seasons = get_the_terms( $post->ID, 'sp_season' );
remove_meta_box( 'submitdiv', 'sp_team', 'side' );
add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', 'sp_team', 'side', 'high' );
remove_meta_box( 'postimagediv', 'sp_team', 'side' );
add_meta_box( 'postimagediv', __( 'Logo', 'sportspress' ), 'post_thumbnail_meta_box', 'sp_team', 'side', 'high' );
if ( $leagues && $leagues != array(0) && $seasons && $seasons != array(0) ):
if ( $leagues && $seasons ):
add_meta_box( 'sp_columnssdiv', __( 'Table Columns', 'sportspress' ), 'sportspress_team_columns_meta', 'sp_team', 'normal', 'high' );
endif;
}
@@ -61,9 +61,9 @@ function sportspress_team_columns_meta( $post ) {
<?php
endif;
list( $columns, $data, $leagues_seasons ) = sportspress_get_team_columns_data( $post->ID, $league_id, true );
list( $columns, $data, $placeholders, $merged, $leagues_seasons ) = sportspress_get_team_columns_data( $post->ID, $league_id, true );
sportspress_edit_team_columns_table( $league_id, $columns, $data, $leagues_seasons );
sportspress_edit_team_columns_table( $league_id, $columns, $data, $placeholders, $merged, $leagues_seasons, ! current_user_can( 'edit_sp_tables' ) );
endforeach;