Plugin Directory

Changeset 1498050


Ignore:
Timestamp:
09/19/2016 10:20:58 AM (10 years ago)
Author:
oternet
Message:

bug fix

Location:
idea-board/trunk
Files:
23 edited
1 moved

Legend:

Unmodified
Added
Removed
  • idea-board/trunk/idea-board-functions.php

    r1497894 r1498050  
    77use ideapeople\board\notification\EmailNotification;
    88use ideapeople\board\PluginConfig;
     9use ideapeople\board\Post;
    910use ideapeople\board\setting\Setting;
    1011
     
    111112
    112113add_action( 'admin_init', 'idea_board_do_activation_redirect' );
     114
     115function idea_board_sanitize_board( $post_data = array() ) {
     116    $board_term = false;
     117
     118    if ( is_array( $post_data[ 'tax_input' ] ) && $post_data[ 'tax_input' ][ PluginConfig::$board_tax ][ 0 ] ) {
     119        $board_term = get_term_by( 'term_taxonomy_id', $post_data[ 'tax_input' ][ PluginConfig::$board_tax ][ 0 ], PluginConfig::$board_tax );
     120    } else {
     121        if ( isset( $post_data[ 'pid' ] ) ) {
     122            $board_term = Setting::get_board_from_post( $post_data[ 'pid' ] );
     123        } else if ( isset( $post_data[ 'ID' ] ) ) {
     124            $board_term = Setting::get_board_from_post( $post_data[ 'ID' ] );
     125        }
     126    }
     127
     128    return $board_term;
     129}
  • idea-board/trunk/idea-board.php

    r1497916 r1498050  
    44Plugin URI: http://www.ideapeople.co.kr
    55Description: This plugin helps you to add simply a forum for WordPress
    6 Version: 0.2.7.1
     6Version: 0.3
    77Author: ideapeople
    88Author URI: http://www.ideapeople.co.kr
  • idea-board/trunk/languages/idea-board-ko_KR.po

    r1497903 r1498050  
    44"Report-Msgid-Bugs-To: http://www.ideapeople.co.kr\n"
    55"POT-Creation-Date: 2016-08-12 22:51+0900\n"
    6 "PO-Revision-Date: 2016-09-19 14:14+0900\n"
     6"PO-Revision-Date: 2016-09-19 19:14+0900\n"
    77"Last-Translator: IdeaPeople<>\n"
    88"Language-Team: ideapeople <ideapeople@ideapeople.co.kr>\n"
     
    323323msgid "It operates wordpress permalink structure will be activated"
    324324msgstr "워드프레스 고유주소가 기본이 아니라면 동작합니다"
     325
     326msgid "Use the bulletin board to update the reference alignment. (In the form of a general forum)<em>If you use a bulletin board Updates Sort reply can not be created, you can create only comment.<br/>If you uncheck this recent article is aligned with standards written reply will be activated</em>"
     327msgstr "게시판을 업데이트 기준 정렬로 사용합니다. (일반적인 포럼의 형태)<em>게시판을 업데이트 기준정렬로 사용하면 답글은 작성할수 없고 댓글만 작성할수 있습니다.<br/>체크를 해제하면 최근 작성한 기준으로 글이 정렬되고 답글이 활성화 됩니다</em>"
     328
     329msgctxt "comments title"
     330msgid "One thought on &ldquo;%2$s&rdquo;"
     331msgid_plural "%1$s thoughts on &ldquo;%2$s&rdquo;"
     332msgstr[0] "&ldquo;%2$s&rdquo;에 대한 %1$s개의 생각"
     333msgstr[1] ""
  • idea-board/trunk/languages/idea-board.po

    r1497903 r1498050  
    44"Report-Msgid-Bugs-To: http://www.ideapeople.co.kr\n"
    55"POT-Creation-Date: 2016-08-12 22:51+0900\n"
    6 "PO-Revision-Date: 2016-09-19 14:14+0900\n"
     6"PO-Revision-Date: 2016-09-19 19:14+0900\n"
    77"Last-Translator: IdeaPeople<>\n"
    88"Language-Team: ideapeople <ideapeople@ideapeople.co.kr>\n"
     
    323323msgid "It operates wordpress permalink structure will be activated"
    324324msgstr ""
     325
     326msgid "Use the bulletin board to update the reference alignment. (In the form of a general forum)<em>If you use a bulletin board Updates Sort reply can not be created, you can create only comment.<br/>If you uncheck this recent article is aligned with standards written reply will be activated</em>"
     327msgstr ""
     328
     329msgctxt "comments title"
     330msgid "One thought on &ldquo;%2$s&rdquo;"
     331msgid_plural "%1$s thoughts on &ldquo;%2$s&rdquo;"
     332msgstr[0] ""
     333msgstr[1] ""
  • idea-board/trunk/readme.txt

    r1497916 r1498050  
    1212
    1313This plugin helps you to add a simple forum to WordPress.
    14 It is currently in beta deployment progress.
    1514Using the WordPress custom post type designed to enable a variety of plug-compatible.
    1615
     
    7574== Changelog ==
    7675
     76= 0.3 =
     77* bug fix , Forum sort
     78
    7779= 0.2.7.1 =
    7880* css bug fix
  • idea-board/trunk/src/ideapeople/board/Button.php

    r1497894 r1498050  
    99namespace ideapeople\board;
    1010
     11use ideapeople\board\setting\Setting;
     12
    1113class Button {
    1214    public static function reply_button( $post = null ) {
     15        if ( Setting::get_use_forum( null, false ) ) {
     16            return null;
     17        }
     18
    1319        return self::button( 'reply', 'reply', 'Reply', Link::reply_link( $post ), $post );
    1420    }
     
    3339
    3440    public static function read_button( $post = null ) {
     41        $post = get_post( $post );
     42
    3543        return self::button( 'read', 'read', 'Read', get_permalink( $post->ID ), $post );
    3644    }
  • idea-board/trunk/src/ideapeople/board/CommonUtils.php

    r1497894 r1498050  
    3737        if ( $post = get_post( $post ) ) {
    3838            if ( $post->post_type == PluginConfig::$board_post_type && $post->ID ) {
    39                 return Post::get_board_page( $post->ID );
     39                $v = Post::get_board_page( $post->ID );
     40
     41                if ( $v->post_type != PluginConfig::$board_post_type ) {
     42                    return $v;
     43                }
    4044            }
    4145        }
  • idea-board/trunk/src/ideapeople/board/Plugin.php

    r1497894 r1498050  
    1818use ideapeople\board\validator\ViewValidator;
    1919use ideapeople\util\wp\PluginLoader;
    20 use ideapeople\util\wp\PostOrderGenerator;
     20use ideapeople\util\wp\PostHierarchyOrderGenerator;
    2121use ideapeople\util\wp\WpNoprivUploader;
    2222use WP_Session;
     
    3434
    3535    /**
    36      * @var PostOrderGenerator
     36     * @var PostHierarchyOrderGenerator
    3737     */
    3838    public $post_order_generator;
     
    107107        $this->custom_loader->add_filter( 'pre_cap_check_edit_view', $viewInterceptor, 'pre_cap_check_edit_view', 10, 2 );
    108108        $this->custom_loader->add_filter( 'pre_cap_check_comment_view', $viewInterceptor, 'pre_cap_check_comment_view', 10, 3 );
    109 
    110         $this->loader->add_filter( 'posts_orderby_request', $this->post_order_generator, 'posts_orderby_request', 10, 2 );
    111         $this->loader->add_action( 'save_post_' . PluginConfig::$board_post_type, $this->post_order_generator, 'update_post_order' );
    112109
    113110        $comment_action = new CommentAction();
     
    150147        $this->loader->add_filter( 'the_content', $auto_insert_page, 'auto_insert' );
    151148
    152         $sort = new PostSort();
    153         $this->loader->add_filter( 'idea_post_order_pre', $sort, 'sort_notice' );
    154 
    155149        $post = new Post();
    156150        $this->loader->add_filter( 'the_author', $post, 'get_the_author_nicename' );
     
    187181
    188182    public function register_global() {
    189         $this->post_order_generator = new PostOrderGenerator( PluginConfig::$board_post_type, 'idea_board_grp', 'idea_board_ord', 'idea_board_depth' );
     183        $this->post_order_generator = new PostHierarchyOrderGenerator( PluginConfig::$board_post_type, 'idea_board_grp', 'idea_board_ord', 'idea_board_depth' );
    190184
    191185        $this->nopriv_uploader = new WpNoprivUploader( 'idea_board_upload', 'idea_upload_file', PluginConfig::$plugin_url );
  • idea-board/trunk/src/ideapeople/board/Post.php

    r1497894 r1498050  
    1010
    1111use ideapeople\board\action\FileAction;
     12use ideapeople\board\setting\Setting;
    1213use ideapeople\util\html\HtmlUtils;
    1314use ideapeople\util\http\Request;
     15use ideapeople\util\wp\MetaUtils;
    1416use ideapeople\util\wp\PasswordUtils;
    15 use ideapeople\util\wp\PostOrderGenerator;
     17use ideapeople\util\wp\PostHierarchyOrderGenerator;
    1618use ideapeople\util\wp\PostUtils;
    1719use ideapeople\util\wp\TermUtils;
     
    331333    public static function get_depth( $post = null ) {
    332334        /**
    333          * @var $idea_board_post_order_generator PostOrderGenerator
     335         * @var $idea_board_post_order_generator PostHierarchyOrderGenerator
    334336         */
    335337        global $idea_board_post_order_generator;
     
    426428        return $protected;
    427429    }
     430
     431    public static function delete_post( $post_data = null ) {
     432        $post_data = wp_parse_args( array(
     433            'mode' => 'delete'
     434        ), $post_data );
     435
     436        $result = self::edit_post( $post_data );
     437
     438        return $result;
     439    }
     440
     441    public static function sanitize_post_id( $post_data = null ) {
     442        if ( is_array( $post_data ) ) {
     443            $post_id = ! empty( $post_data[ 'ID' ] ) ? $post_data[ 'ID' ] : $post_data[ 'pid' ];
     444        } else if ( is_int( $post_data ) ) {
     445            $post_id = $post_data;
     446        } else {
     447            $post_id = 0;
     448        }
     449
     450        return $post_id;
     451    }
     452
     453    public static function update_post( $post_data = null ) {
     454        $error = new \WP_Error();
     455
     456        $post_data = wp_parse_args( array(
     457            'mode' => 'update'
     458        ), $post_data );
     459
     460        $post_id = self::sanitize_post_id( $post_data );
     461        $post    = self::get_post( $post_id );
     462
     463        if ( $post->post_author != 0 && get_current_user_id() != $post->post_author ) {
     464            $error->add( 'auth_error', '수정 권한 없음' );
     465
     466            return $error;
     467        }
     468
     469        if ( Post::password_required( $post ) ) {
     470            $error->add( 'required_password', '패스워드 필요함' );
     471
     472            return $error;
     473        }
     474
     475        $result = self::edit_post( $post_data );
     476
     477        return $result;
     478    }
     479
     480    public static function insert_post( $post_data = null ) {
     481        $post_data = wp_parse_args( array(
     482            'mode' => 'insert'
     483        ), $post_data );
     484
     485        $result = self::edit_post( $post_data );
     486
     487        return $result;
     488    }
     489
     490    public static function edit_post( &$post_data = null ) {
     491        $error = new \WP_Error();
     492
     493        if ( empty( $post_data ) ) {
     494            $post_data = &$_POST;
     495        }
     496
     497        $post_data = wp_parse_args( $post_data, array(
     498            'post_content' => Request::get_parameter( 'idea_board_post_content' ),
     499            'post_parent'  => Request::get_parameter( 'parent', 0 )
     500        ) );
     501
     502        $post_data[ 'post_type' ]   = PluginConfig::$board_post_type;
     503        $post_data[ 'post_author' ] = ! is_user_logged_in() ? - 1 : null;
     504        $post_data[ 'post_status' ] = 'publish';
     505
     506        if ( ! Capability::is_board_admin() ) {
     507            $post_data[ 'post_content' ] = strip_shortcodes( $post_data[ 'post_content' ] );
     508        }
     509
     510        $post_id = ! empty( $post_data[ 'ID' ] ) ? $post_data[ 'ID' ] : $post_data[ 'pid' ];
     511
     512        $board = idea_board_sanitize_board( $post_data );
     513
     514        if ( ! $board ) {
     515            $error->add( 'board_required', '게시판이 존재하지 않습니다.' );
     516
     517            return $error;
     518        }
     519
     520        $nonce        = $post_data[ PluginConfig::$idea_board_edit_nonce_name ];
     521        $nonce_action = PluginConfig::$idea_board_edit_nonce_action;
     522
     523        if ( ! $nonce && wp_verify_nonce( $nonce, $nonce_action ) ) {
     524            $error->add( 'nonce_check_fail', 'nonce_check_fail' );
     525
     526            return $error;
     527        }
     528
     529        if ( ! is_user_logged_in() ) {
     530            if ( ! isset( $post_data[ 'post_password' ] ) && empty( $post_data[ 'post_password' ] ) ) {
     531                $error->add( 'post_password', '비회원은 패스워드 필수 입력' );
     532
     533                return $error;
     534            }
     535        }
     536
     537        if ( isset( $post_data[ 'mode' ] ) ) {
     538            $mode = $post_data[ 'mode' ];
     539        } else {
     540            if ( empty( $post_id ) || $post_id == - 1 ) {
     541                $mode = 'insert';
     542            } else {
     543                $mode = 'update';
     544            }
     545        }
     546
     547        switch ( $mode ) {
     548            case 'insert':
     549                unset( $post_data[ 'ID' ] );
     550
     551                if ( empty( $post_data[ 'comment_status' ] ) ) {
     552                    $post_data[ 'comment_status' ] = Setting::get_default_comment_status( $board->term_id );
     553                }
     554
     555                $post_id = wp_insert_post( $post_data, $error );
     556
     557                break;
     558            case 'update':
     559                $post_id = wp_update_post( $post_data, $error );
     560
     561                break;
     562            case 'delete':
     563                $post_id = wp_trash_post( $post_id );
     564                break;
     565        }
     566
     567        return $post_id;
     568    }
     569
     570    public static function update_latest_post( $post = null ) {
     571        $post = self::get_post( $post );
     572
     573        $today = mysql2date( 'Y-m-d H:i:s', date( 'Y-m-d H:i:s' ) );
     574
     575        PostUtils::insert_or_update_meta( $post->ID, 'idea_board_latest_update', $today, true );
     576    }
    428577}
  • idea-board/trunk/src/ideapeople/board/PostSort.php

    r1497849 r1498050  
    1010
    1111
     12use ideapeople\board\setting\Setting;
     13use ideapeople\util\wp\PostHierarchyOrderGenerator;
     14
    1215class PostSort {
     16    function sort( $query ) {
     17        global $page, $post_type;
     18
     19        $queries = array();
     20
     21        $this->sort_notice( $queries );
     22
     23        if ( Setting::get_use_forum( null, false ) ) {
     24            $this->sort_forum( $queries );
     25        } else {
     26            $this->sort_hierarchy( $queries );
     27        }
     28
     29        $query = join( ',', $queries );
     30
     31        return apply_filters( 'idea_board_sort_query', $query );
     32    }
     33
     34    function sort_hierarchy( &$queries ) {
     35        /**
     36         * @var $idea_board_post_order_generator PostHierarchyOrderGenerator
     37         */
     38        global $idea_board_post_order_generator;
     39
     40        $queries = $idea_board_post_order_generator->get_order_by_query( $queries );
     41
     42        return $queries;
     43    }
     44
    1345    /**
    1446     * 공지사항 정렬 기능 추가
     
    1850     * @return array
    1951     */
    20     function sort_notice( $queries ) {
     52    function sort_notice( &$queries ) {
    2153        global $wpdb;
    2254
    23         $queries[] = "CONVERT((SELECT meta_value FROM {$wpdb->postmeta} WHERE meta_key = 'idea_board_is_notice' AND post_id = wp_posts.ID),DECIMAL)";
     55        $queries[] = " CONVERT((SELECT meta_value FROM {$wpdb->postmeta} WHERE meta_key = 'idea_board_is_notice' AND post_id = wp_posts.ID),DECIMAL) ";
    2456
    2557        return $queries;
    2658    }
    2759
    28     function sort_forum() {
     60    //가장 최근에 댓글이 등록된글이 최상위로 올라온다
     61    //가장 최근에 등록된 글이 상위로 올라온다.
     62    function sort_forum( &$queries ) {
     63        global $wpdb;
    2964
     65        $queries[] = " CONVERT((SELECT meta_value FROM {$wpdb->postmeta} WHERE meta_key = 'idea_board_latest_update' AND post_id = wp_posts.ID),DATETIME) DESC";
     66
     67        return $queries;
    3068    }
    3169}
  • idea-board/trunk/src/ideapeople/board/PostView.php

    r1496664 r1498050  
    1212use ideapeople\board\setting\Setting;
    1313use ideapeople\board\view\CommentView;
    14 use ideapeople\board\view\DeleteView;
    1514use ideapeople\board\view\EditView;
    1615use ideapeople\board\view\ErrorView;
  • idea-board/trunk/src/ideapeople/board/Query.php

    r1497903 r1498050  
    99
    1010
    11 use ideapeople\util\wp\WpQuerySearch;
     11use ideapeople\board\setting\Setting;
    1212use WP_Query;
    13 use wpdb;
    1413
    1514class Query extends WP_Query {
     15    public $start_no;
     16
     17
    1618    public function __construct( $query = '' ) {
     19        $post_sort = new PostSort();
     20
     21        add_filter( 'posts_orderby', array( $post_sort, 'sort' ) );
     22
    1723        $query = wp_parse_args( $query, array(
    1824            'post_type'      => PluginConfig::$board_post_type,
     
    3137                )
    3238            ),
    33 
    3439        ) );
    3540
     
    3742
    3843        $this->start_no = $this->generateStartNo( get_query_var( 'paged' ), $query[ 'posts_per_page' ] );
     44
     45        remove_filter( 'posts_orderby', array( $post_sort, 'sort' ) );
    3946    }
    4047
     
    8188    public static function get_single_post( $args = array() ) {
    8289        $args = wp_parse_args( $args, array(
    83             'board' => '',
     90            'board' => Setting::get_board()->name,
    8491            'p'     => '',
    85             'paged' => 0
     92            'paged' => 0,
     93            'pname' => get_query_var( 'pname', false )
    8694        ) );
     95
     96        if ( $args[ 'pname' ] ) {
     97            $args[ 'post_name__in' ] = array( $args[ 'pname' ] );
     98        }
    8799
    88100        $post = null;
  • idea-board/trunk/src/ideapeople/board/action/CommentAction.php

    r1497423 r1498050  
    2929
    3030    public function password_check() {
    31         $password = $_POST['comment_password'];
     31        $password = $_POST[ 'comment_password' ];
    3232
    3333        if ( is_user_logged_in() ) {
     
    4040
    4141    public function preprocess_comment( $comment ) {
    42         $post = get_post( $comment['comment_post_ID'] );
     42        $post = get_post( $comment[ 'comment_post_ID' ] );
    4343
    4444        if ( $post->post_type != PluginConfig::$board_post_type ) {
     
    7777    public function handle_comment_delete( $comment_ID ) {
    7878        if ( empty( $comment_ID ) ) {
    79             $comment_ID = &$_GET['comment_ID'];
     79            $comment_ID = &$_GET[ 'comment_ID' ];
    8080        }
    8181
     
    110110        $comment_password = false;
    111111
    112         if ( isset( $comment_data['comment_post_ID'] ) ) {
    113             $comment_post_ID = (int) $comment_data['comment_post_ID'];
    114         }
    115         if ( isset( $comment_data['author'] ) && is_string( $comment_data['author'] ) ) {
    116             $comment_author = trim( strip_tags( $comment_data['author'] ) );
    117         }
    118         if ( isset( $comment_data['email'] ) && is_string( $comment_data['email'] ) ) {
    119             $comment_author_email = trim( $comment_data['email'] );
    120         }
    121         if ( isset( $comment_data['url'] ) && is_string( $comment_data['url'] ) ) {
    122             $comment_author_url = trim( $comment_data['url'] );
    123         }
    124         if ( isset( $comment_data['comment'] ) && is_string( $comment_data['comment'] ) ) {
    125             $comment_content = trim( $comment_data['comment'] );
    126         }
    127         if ( isset( $comment_data['comment_parent'] ) ) {
    128             $comment_parent = absint( $comment_data['comment_parent'] );
    129         }
    130         if ( isset( $comment_data['comment_password'] ) ) {
    131             $comment_password = $comment_data['comment_password'];
     112        if ( isset( $comment_data[ 'comment_post_ID' ] ) ) {
     113            $comment_post_ID = (int) $comment_data[ 'comment_post_ID' ];
     114        }
     115        if ( isset( $comment_data[ 'author' ] ) && is_string( $comment_data[ 'author' ] ) ) {
     116            $comment_author = trim( strip_tags( $comment_data[ 'author' ] ) );
     117        }
     118        if ( isset( $comment_data[ 'email' ] ) && is_string( $comment_data[ 'email' ] ) ) {
     119            $comment_author_email = trim( $comment_data[ 'email' ] );
     120        }
     121        if ( isset( $comment_data[ 'url' ] ) && is_string( $comment_data[ 'url' ] ) ) {
     122            $comment_author_url = trim( $comment_data[ 'url' ] );
     123        }
     124        if ( isset( $comment_data[ 'comment' ] ) && is_string( $comment_data[ 'comment' ] ) ) {
     125            $comment_content = trim( $comment_data[ 'comment' ] );
     126        }
     127        if ( isset( $comment_data[ 'comment_parent' ] ) ) {
     128            $comment_parent = absint( $comment_data[ 'comment_parent' ] );
     129        }
     130        if ( isset( $comment_data[ 'comment_password' ] ) ) {
     131            $comment_password = $comment_data[ 'comment_password' ];
    132132        }
    133133
     
    190190
    191191            if ( current_user_can( 'unfiltered_html' ) ) {
    192                 if ( ! isset( $comment_data['_wp_unfiltered_html_comment'] )
    193                      || ! wp_verify_nonce( $comment_data['_wp_unfiltered_html_comment'], 'unfiltered-html-comment_' . $comment_post_ID )
     192                if ( ! isset( $comment_data[ '_wp_unfiltered_html_comment' ] )
     193                     || ! wp_verify_nonce( $comment_data[ '_wp_unfiltered_html_comment' ], 'unfiltered-html-comment_' . $comment_post_ID )
    194194                ) {
    195195                    kses_remove_filters();
     
    214214        }
    215215
    216         if ( isset( $comment_author ) && $max_lengths['comment_author'] < mb_strlen( $comment_author, '8bit' ) ) {
     216        if ( isset( $comment_author ) && $max_lengths[ 'comment_author' ] < mb_strlen( $comment_author, '8bit' ) ) {
    217217            return new WP_Error( 'comment_author_column_length', __( '<strong>ERROR</strong>: your name is too long.' ), 200 );
    218218        }
    219219
    220         if ( isset( $comment_author_email ) && $max_lengths['comment_author_email'] < strlen( $comment_author_email ) ) {
     220        if ( isset( $comment_author_email ) && $max_lengths[ 'comment_author_email' ] < strlen( $comment_author_email ) ) {
    221221            return new WP_Error( 'comment_author_email_column_length', __( '<strong>ERROR</strong>: your email address is too long.' ), 200 );
    222222        }
    223223
    224         if ( isset( $comment_author_url ) && $max_lengths['comment_author_url'] < strlen( $comment_author_url ) ) {
     224        if ( isset( $comment_author_url ) && $max_lengths[ 'comment_author_url' ] < strlen( $comment_author_url ) ) {
    225225            return new WP_Error( 'comment_author_url_column_length', __( '<strong>ERROR</strong>: your url is too long.' ), 200 );
    226226        }
     
    228228        if ( '' == $comment_content ) {
    229229            return new WP_Error( 'require_valid_comment', __( '<strong>ERROR</strong>: please type a comment.' ), 200 );
    230         } elseif ( $max_lengths['comment_content'] < mb_strlen( $comment_content, '8bit' ) ) {
     230        } elseif ( $max_lengths[ 'comment_content' ] < mb_strlen( $comment_content, '8bit' ) ) {
    231231            return new WP_Error( 'comment_content_column_length', __( '<strong>ERROR</strong>: your comment is too long.' ), 200 );
    232232        }
     
    245245        $mode = false;
    246246
    247         if ( isset( $_POST['comment_ID'] ) && ! empty( $_POST['comment_ID'] ) ) {
    248             $commentdata['comment_ID'] = $_POST['comment_ID'];
    249 
    250             $comment_id = $_POST['comment_ID'];
     247        if ( isset( $_POST[ 'comment_ID' ] ) && ! empty( $_POST[ 'comment_ID' ] ) ) {
     248            $commentdata[ 'comment_ID' ] = $_POST[ 'comment_ID' ];
     249
     250            $comment_id = $_POST[ 'comment_ID' ];
    251251
    252252            if ( Capability::is_board_admin() ) {
     
    283283        }
    284284
     285        Post::update_latest_post( $comment_post_ID );
     286
    285287        do_action( 'idea_board_action_comment_edit_after', $comment_data, $comment_id, $board, $mode );
    286288
    287         wp_redirect( get_permalink( $post->ID ) . '#comment-' . $comment_id );
     289        wp_redirect( wp_get_referer() . '#comment-' . $comment_id );
    288290
    289291        die;
  • idea-board/trunk/src/ideapeople/board/action/PostAction.php

    r1497894 r1498050  
    4343        ) );
    4444
    45         $post_data['post_type']   = PluginConfig::$board_post_type;
    46         $post_data['post_status'] = 'publish';
    47         $post_data['post_author'] = ! is_user_logged_in() ? - 1 : null;
     45        if ( Setting::get_use_forum( null, false ) && $post_data[ 'post_parent' ] ) {
     46            wp_die( 'Forum will not be registered to comment. ' );
     47        }
     48
     49        $post_data[ 'post_type' ]   = PluginConfig::$board_post_type;
     50        $post_data[ 'post_status' ] = 'publish';
     51        $post_data[ 'post_author' ] = ! is_user_logged_in() ? - 1 : null;
    4852
    4953        if ( ! Capability::is_board_admin() ) {
    50             $post_data['post_content'] = strip_shortcodes( $post_data['post_content'] );
     54            $post_data[ 'post_content' ] = strip_shortcodes( $post_data[ 'post_content' ] );
    5155        }
    5256
     
    5458
    5559        $error      = new \WP_Error();
    56         $post_id    = ! empty( $post_data['ID'] ) ? $post_data['ID'] : $post_data['pid'];
     60        $post_id    = ! empty( $post_data[ 'ID' ] ) ? $post_data[ 'ID' ] : $post_data[ 'pid' ];
    5761        $return_url = Request::get_parameter( 'return_url', null );
    5862        $nonce      = $post_data[ PluginConfig::$idea_board_edit_nonce_name ];
     
    6367
    6468        if ( ! is_user_logged_in() ) {
    65             if ( ! isset( $post_data['post_password'] ) && empty( $post_data['post_password'] ) ) {
     69            if ( ! isset( $post_data[ 'post_password' ] ) && empty( $post_data[ 'post_password' ] ) ) {
    6670                wp_die();
    6771            }
    6872        }
    6973
    70         if ( isset( $post_data['mode'] ) ) {
    71             $mode = $post_data['mode'];
     74        if ( isset( $post_data[ 'mode' ] ) ) {
     75            $mode = $post_data[ 'mode' ];
    7276        } else {
    7377            if ( empty( $post_id ) || $post_id == - 1 ) {
     
    7882        }
    7983
    80         $board_term = $this->get_board_term( $post_data );
    81 
    82         $board = Setting::get_board( $board_term->term_id );
     84        $board = idea_board_sanitize_board( $post_data );
    8385
    8486        if ( ! $board ) {
     
    9294        switch ( $mode ) {
    9395            case 'insert':
    94                 unset( $post_data['ID'] );
    95 
    96                 if ( empty( $post_data['comment_status'] ) ) {
    97                     $post_data['comment_status'] = Setting::get_default_comment_status( $board->term_id );
     96                unset( $post_data[ 'ID' ] );
     97
     98                if ( empty( $post_data[ 'comment_status' ] ) ) {
     99                    $post_data[ 'comment_status' ] = Setting::get_default_comment_status( $board->term_id );
    98100                }
    99101
     
    103105            case 'update':
    104106                if ( Capability::is_board_admin() ) {
    105                     unset( $post_data['post_author'] );
     107                    unset( $post_data[ 'post_author' ] );
    106108                }
    107109
     
    137139    public function post_update_private_meta( $board_term, $post_id ) {
    138140        if ( $post_id ) {
    139             PostUtils::insert_or_update_meta( $post_id, 'idea_board_remote_ip', $_SERVER['REMOTE_ADDR'] );
     141            PostUtils::insert_or_update_meta( $post_id, 'idea_board_remote_ip', $_SERVER[ 'REMOTE_ADDR' ] );
    140142            PostUtils::insert_or_update_meta( $post_id, 'idea_board_term', $board_term );
     143
     144            Post::update_latest_post( $post_id );
    141145        }
    142146    }
     
    211215    }
    212216
    213     public function get_board_term( $post_data = array() ) {
    214         $board_term = false;
    215 
    216         if ( is_array( $post_data['tax_input'] ) && $post_data['tax_input'][ PluginConfig::$board_tax ][0] ) {
    217             $board_term = get_term_by( 'term_taxonomy_id', $post_data['tax_input'][ PluginConfig::$board_tax ][0], PluginConfig::$board_tax );
    218         } else {
    219             if ( isset( $post_data['pid'] ) ) {
    220                 $board_term = Setting::get_board_from_post( $post_data['pid'] );
    221             } else if ( isset( $post_data['ID'] ) ) {
    222                 $board_term = Setting::get_board_from_post( $post_data['ID'] );
    223             }
    224         }
    225 
    226         return $board_term;
    227     }
    228 
    229217    public function update_idea_post( $post_id ) {
    230218        $post = get_post( $post_id );
     
    234222        }
    235223
    236         $this->post_update_tax( $post_id, @$this->post_data['tax_input'] );
    237 
    238         $this->post_update_public_meta( $post_id, @$this->post_data['meta_input'] );
    239 
    240         if ( is_array( $this->post_data ) && isset( $this->post_data['tax_input'] ) ) {
    241             $tax = $this->post_data['tax_input'][ PluginConfig::$board_tax ];
     224        $this->post_update_tax( $post_id, @$this->post_data[ 'tax_input' ] );
     225        $this->post_update_public_meta( $post_id, @$this->post_data[ 'meta_input' ] );
     226
     227        if ( is_array( $this->post_data ) && isset( $this->post_data[ 'tax_input' ] ) ) {
     228            $tax = $this->post_data[ 'tax_input' ][ PluginConfig::$board_tax ];
    242229            $this->post_update_private_meta( $tax[ count( $tax ) - 1 ], $post_id );
    243230        }
  • idea-board/trunk/src/ideapeople/board/setting/Setting.php

    r1497604 r1498050  
    3939            'board_noti_post_comment_author',
    4040            'board_noti_comment_comment_author',
     41            'board_use_forum'
    4142        ) );
    4243
     
    292293        return self::get_meta( 'board_noti_post_admin', $board_term, $defaultValue );
    293294    }
     295
     296    public static function get_use_forum( $board_term = null, $defaultValue = null ) {
     297        return self::get_meta( 'board_use_forum', $board_term, $defaultValue );
     298    }
    294299}
  • idea-board/trunk/src/ideapeople/board/view/CommentView.php

    r1497894 r1498050  
    2323    public function render( $model = null ) {
    2424        $post = Query::get_single_post( array(
    25             'board' => Setting::get_board()->name,
    2625            'p'     => get_query_var( 'pid', 1 )
    2726        ) );
  • idea-board/trunk/src/ideapeople/board/view/ListView.php

    r1496664 r1498050  
    2828        ) );
    2929
    30         $GLOBALS['wp_query'] = $query;
     30        $GLOBALS[ 'wp_query' ] = $query;
    3131
    3232        $this->addAttribute( 'query', $query );
  • idea-board/trunk/src/ideapeople/board/view/SingleView.php

    r1497894 r1498050  
    2323    public function render( $model = null ) {
    2424        $post = Query::get_single_post( array(
    25             'board'         => Setting::get_board()->name,
    26             'p'             => get_query_var( 'pid' ),
    27             'post_name__in' => array( get_query_var( 'pname', null ) )
     25            'p' => get_query_var( 'pid' )
    2826        ) );
    2927
  • idea-board/trunk/src/ideapeople/util/wp/PostHierarchyOrderGenerator.php

    r1498049 r1498050  
    1616 * @package ideapeople\util\wp
    1717 *
    18  * $orderGenerator = GlobalObject::orderGenerator();
    19  * $this->loader->add_filter( 'posts_orderby_request', $orderGenerator, 'posts_orderby_request', 10, 2 );
    20  * $this->loader->add_action( 'save_post_' . $post_type, $orderGenerator, 'update_post_order' );
    2118 * $this->loader->add_filter( 'the_title', $orderGenerator, 'the_title', 10, 2 );
    2219 */
    23 class PostOrderGenerator {
     20class PostHierarchyOrderGenerator {
    2421    public $grp_key;
    2522    public $ord_key;
     
    4037        $this->ord_key   = $ord_key;
    4138        $this->depth_key = $depth_key;
     39
     40        add_action( 'save_post_' . $post_type, array( $this, 'update_post_order' ) );
    4241    }
    4342
     
    137136    }
    138137
    139     public function sort_order_by() {
    140         add_filter( 'posts_orderby_request', array( $this, 'posts_orderby_request' ), 10, 2 );
    141     }
    142 
    143138    /**
    144139     * @param $request
     
    162157        }
    163158
    164         $queries = array();
    165 
    166         $queries = apply_filters( 'idea_post_order_pre', $queries, $query );
    167 
    168         $queries[] = "CONVERT((SELECT meta_value FROM {$wpdb->postmeta} WHERE meta_key = '{$this->grp_key}' AND post_id = wp_posts.ID),DECIMAL)";
    169         $queries[] = "CONVERT((SELECT meta_value FROM {$wpdb->postmeta} WHERE meta_key = '{$this->ord_key}' AND post_id = wp_posts.ID),DECIMAL)";
    170 
    171         $queries = apply_filters( 'idea_post_order_after', $queries, $query );
     159        $queries = $this->get_order_by_query( array() );
    172160
    173161        $q = join( " , ", $queries );
     
    175163        return $q;
    176164    }
     165
     166    public function get_order_by_query( $queries ) {
     167        global $wpdb;
     168
     169        $queries[] = " CONVERT((SELECT meta_value FROM {$wpdb->postmeta} WHERE meta_key = '{$this->grp_key}' AND post_id = wp_posts.ID),DECIMAL) ";
     170        $queries[] = " CONVERT((SELECT meta_value FROM {$wpdb->postmeta} WHERE meta_key = '{$this->ord_key}' AND post_id = wp_posts.ID),DECIMAL) ";
     171
     172        return $queries;
     173    }
    177174}
  • idea-board/trunk/views/admin/setting.php

    r1497894 r1498050  
    5252                </label>
    5353            </p>
     54
    5455            <p>
    5556                <label for="board_use_page" class="block">
     
    6768                </label>
    6869            </p>
     70
     71            <p>
     72                <label for="board_use_forum">
     73                    <input type="checkbox" name="board_use_forum" id="board_use_forum" value="1"
     74                        <?php echo Setting::get_use_forum( $board->term_id, false ) ? 'checked' : '' ?> />
     75
     76                    <?php _e_idea_board( 'Use the bulletin board to update the reference alignment. (In the form of a general forum)<em>If you use a bulletin board Updates Sort reply can not be created, you can create only comment.<br/>If you uncheck this recent article is aligned with standards written reply will be activated</em>' ); ?>
     77                </label>
     78            </p>
    6979        </td>
    7080    </tr>
  • idea-board/trunk/views/skin/board/basic/comment_edit.php

    r1497894 r1498050  
    11<?php
     2use ideapeople\board\Button;
    23use ideapeople\board\Comment;
    34use ideapeople\util\http\Request;
     
    1415), get_query_var( 'pid' ) );
    1516
     17echo Button::read_button( $comment->comment_post_ID );
    1618?>
     19
    1720<script>
    1821    (function ($) {
  • idea-board/trunk/views/skin/board/basic/comments.php

    r1497903 r1498050  
    4040        <h2 class="idea-board-comments-title">
    4141            <?php
    42             printf( _nx( 'One thought on &ldquo;%2$s&rdquo;', '%1$s thoughts on &ldquo;%2$s&rdquo;', get_comments_number(), 'comments title' ),
    43                 number_format_i18n( get_comments_number() ), get_the_title() );
     42            printf( _nx( 'One thought on &ldquo;%2$s&rdquo;', '%1$s thoughts on &ldquo;%2$s&rdquo;', get_comments_number(), 'comments title', 'idea-board' ), number_format_i18n( get_comments_number() ), get_the_title() );
    4443            ?>
    4544        </h2>
Note: See TracChangeset for help on using the changeset viewer.