WordPress.org

Plugin Directory

Changeset 631105


Ignore:
Timestamp:
11/28/12 08:22:43 (17 months ago)
Author:
ssamture
Message:

MH Board 1.2.3 released.
Permission Improvement

Location:
mh-board/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • mh-board/trunk/admin/mh-board-permission.php

    r627983 r631105  
    66    $categories = get_terms('board_cat',array('hide_empty'=>0)); 
    77    foreach($categories as $category){ 
    8         register_setting( 'mh-board-permission-'.$category->term_id, 'mh_board_permission_'.$category->term_id ); 
     8        register_setting( 'mh-board-permission-'.$category->term_id, 'mh_board_permission_'.$category->term_id,'mh_board_permission_validate' ); 
    99    } 
     10} 
     11function mh_board_permission_validate($input){ 
     12    global $wp_roles; 
     13 
     14    if (!isset($wp_roles)) { 
     15        $wp_roles = new WP_Roles(); 
     16    }  
     17 
     18    $ure_roles = $wp_roles->roles; 
     19    if (is_array($ure_roles)) { 
     20        asort($ure_roles); 
     21    } 
     22     
     23    foreach($ure_roles as $key => $value){ 
     24        $input[$key]['read'] = isset($input[$key]['read']) ? 'on' : 'off'; 
     25        $input[$key]['write'] = isset($input[$key]['write']) ? 'on' : 'off'; 
     26    } 
     27    return $input; 
    1028} 
    1129function mh_board_permission(){ 
     
    4866    <?php 
    4967        if(sizeof($mh_board_per_o) > 0 ){ 
    50         $mh_board_per[$key]['read'] = empty($mh_board_per_o[$key]['read'])? '' : $mh_board_per_o[$key]['read']; 
    51         $mh_board_per[$key]['write'] = empty($mh_board_per_o[$key]['write'])? '' : $mh_board_per_o[$key]['write']; 
     68        $mh_board_per[$key]['read'] = empty($mh_board_per_o[$key]['read'])? 'on' : $mh_board_per_o[$key]['read']; 
     69        $mh_board_per[$key]['write'] = empty($mh_board_per_o[$key]['write'])? 'on' : $mh_board_per_o[$key]['write']; 
    5270        }else{ 
    5371        $mh_board_per[$key]['read'] = empty($mh_board_per_o[$key]['read'])? 'on' : $mh_board_per_o[$key]['read']; 
     
    6381    <?php 
    6482        if(sizeof($mh_board_per_o) > 0 ){ 
    65         $mh_board_per['guest']['read'] = empty($mh_board_per_o['guest']['read'])? '' : $mh_board_per_o['guest']['read']; 
    66         $mh_board_per['guest']['write'] = empty($mh_board_per_o['guest']['write'])? '' : $mh_board_per_o['guest']['write']; 
     83        $mh_board_per['guest']['read'] = empty($mh_board_per_o['guest']['read'])? 'on' : $mh_board_per_o['guest']['read']; 
     84        $mh_board_per['guest']['write'] = empty($mh_board_per_o['guest']['write'])? 'on' : $mh_board_per_o['guest']['write']; 
    6785        }else{ 
    6886        $mh_board_per['guest']['read'] = empty($mh_board_per_o['guest']['read'])? 'on' : $mh_board_per_o['guest']['read']; 
  • mh-board/trunk/includes/mh-functions.php

    r628370 r631105  
    349349add_action('mh_board_read_permission','mh_board_read_permission'); 
    350350function mh_board_read_permission(){ 
    351     global $post; 
     351    global $post,$mh_board_options; 
    352352    $category =@ wp_get_object_terms($post->ID,'board_cat'); 
    353353 
    354354    $mh_board_per_o = get_option('mh_board_permission_'.$category[0]->term_id); 
    355  
    356     $mh_board_permission = empty($mh_board_per_o[mh_get_user_role()]['read']) ? false : true; 
    357     if(!$mh_board_permission){ 
    358         wp_die(__('Access Denied','mhboard')); 
     355    $mh_board_options['permission']  = true; 
     356    if($mh_board_per_o[mh_get_user_role()]['read'] == 'off'){ 
     357        $mh_board_options['permission']  = false; 
    359358    } 
    360359} 
    361360add_action('mh_board_write_permission','mh_board_write_permission'); 
    362361function mh_board_write_permission(){ 
    363     global $post; 
     362    global $post,$mh_board_options; 
    364363     
    365364    if(isset($_GET['board_cat'])){ 
     
    367366     
    368367        $mh_board_per_o = get_option('mh_board_permission_'.$category->term_id); 
    369      
    370         $mh_board_permission = empty($mh_board_per_o[mh_get_user_role()]['write']) ? false : true; 
    371         if(!$mh_board_permission){ 
    372             wp_die(__('Access Denied','mhboard')); 
     368        $mh_board_options['permission'] = true; 
     369        if($mh_board_per_o[mh_get_user_role()]['write'] == 'off'){ 
     370            $mh_board_options['permission'] = false; 
    373371        } 
    374372    } 
  • mh-board/trunk/mh-board.php

    r628426 r631105  
    1616 * Author:      MinHyeong Lim 
    1717 * Author URI:  http://ssamture.net 
    18  * Version:     1.2.2 
     18 * Version:     1.2.3 
    1919 * Text Domain: mhboard 
    2020 * Domain Path: /mhb-languages/ 
    2121 */ 
    22 define('MH_BOARD_VERSION','1.2.2'); 
     22define('MH_BOARD_VERSION','1.2.3'); 
    2323define('MH_BOARD_UPDATE_URL','http://ssamture.net/mh_board.xml'); 
    2424ini_set('memory_limit', -1); 
  • mh-board/trunk/readme.txt

    r628426 r631105  
    4242 
    4343== Changelog == 
     44 
     45= 1.2.3 = 
     46* Upgrade : Permission improvement. 
    4447 
    4548= 1.2.2 = 
  • mh-board/trunk/templates/default/mhboard-archive.php

    r627983 r631105  
    202202        $para = '&board_cat='.$board_cat; 
    203203    } 
    204     $redirect_url = '&redirect_url='.urlencode($_SERVER['REDIRECT_URL']); 
     204    $redirect_url = '&redirect_url='.urlencode(@$_SERVER['REDIRECT_URL']); 
    205205    ?> 
    206206    <?php if($guestwrite == '1' || is_user_logged_in()):?> 
  • mh-board/trunk/templates/default/mhboard-single.php

    r627983 r631105  
    11<?php  
     2global $mh_board,$category,$mh_board_options; 
    23do_action('mh_board_read_permission'); 
    3 global $mh_board,$category; 
    4 $mh_board_options = get_option('mh_board_options'); 
     4if(!$mh_board_options['permission']){ 
     5    echo __('Access Denied','mhboard'); 
     6    return false; 
     7} 
    58if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); 
    69?> 
  • mh-board/trunk/templates/default/mhboard-write.php

    r628370 r631105  
    11<?php 
    22global $mh_board,$mh_board_options; 
     3add_filter('wp_tilte','mhb_wp_title',10, 3); 
     4function mhb_wp_title($title = '', $sep = '&raquo;', $seplocation = '' ){ 
     5    return apply_filters( 'mhb_wp_title', __('Write','mhboard'), $sep, $seplocation ); 
     6} 
    37if(isset($_GET['board_cat'])){ 
    48    do_action('mh_board_write_permission'); 
     9    if(!$mh_board_options['permission']){ 
     10        echo __('Access Denied','mhboard'); 
     11        return false; 
     12    } 
    513} 
     14 
    615$mh_default_category = $mh_board_options['mh_default_category']; 
    716 
     
    118127                foreach($categories as $category){ 
    119128                    $mh_board_per_o = get_option('mh_board_permission_'.$category->term_id); 
    120                     $mh_board_permission = empty($mh_board_per_o[mh_get_user_role()]['write']) ? false : true; 
    121                     if($mh_board_permission): 
     129                     
     130                    if($mh_board_per_o[mh_get_user_role()]['write'] == 'on'): 
    122131                    ?> 
    123132                    <option value="<?php echo $category->term_id;?>"<?php if($mh_default_category == $category->term_id){echo " selected";}?>><?php echo $category->name;?></option> 
Note: See TracChangeset for help on using the changeset viewer.