Changeset 1498050
- Timestamp:
- 09/19/2016 10:20:58 AM (10 years ago)
- Location:
- idea-board/trunk
- Files:
-
- 23 edited
- 1 moved
-
idea-board-functions.php (modified) (2 diffs)
-
idea-board.php (modified) (1 diff)
-
languages/idea-board-ko_KR.mo (modified) (previous)
-
languages/idea-board-ko_KR.po (modified) (2 diffs)
-
languages/idea-board.mo (modified) (previous)
-
languages/idea-board.po (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
-
src/ideapeople/board/Button.php (modified) (2 diffs)
-
src/ideapeople/board/CommonUtils.php (modified) (1 diff)
-
src/ideapeople/board/Plugin.php (modified) (5 diffs)
-
src/ideapeople/board/Post.php (modified) (3 diffs)
-
src/ideapeople/board/PostSort.php (modified) (2 diffs)
-
src/ideapeople/board/PostView.php (modified) (1 diff)
-
src/ideapeople/board/Query.php (modified) (4 diffs)
-
src/ideapeople/board/action/CommentAction.php (modified) (9 diffs)
-
src/ideapeople/board/action/PostAction.php (modified) (9 diffs)
-
src/ideapeople/board/setting/Setting.php (modified) (2 diffs)
-
src/ideapeople/board/view/CommentView.php (modified) (1 diff)
-
src/ideapeople/board/view/ListView.php (modified) (1 diff)
-
src/ideapeople/board/view/SingleView.php (modified) (1 diff)
-
src/ideapeople/util/wp/PostHierarchyOrderGenerator.php (moved) (moved from idea-board/trunk/src/ideapeople/util/wp/PostOrderGenerator.php) (5 diffs)
-
views/admin/setting.php (modified) (2 diffs)
-
views/skin/board/basic/comment_edit.php (modified) (2 diffs)
-
views/skin/board/basic/comments.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
idea-board/trunk/idea-board-functions.php
r1497894 r1498050 7 7 use ideapeople\board\notification\EmailNotification; 8 8 use ideapeople\board\PluginConfig; 9 use ideapeople\board\Post; 9 10 use ideapeople\board\setting\Setting; 10 11 … … 111 112 112 113 add_action( 'admin_init', 'idea_board_do_activation_redirect' ); 114 115 function 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 4 4 Plugin URI: http://www.ideapeople.co.kr 5 5 Description: This plugin helps you to add simply a forum for WordPress 6 Version: 0. 2.7.16 Version: 0.3 7 7 Author: ideapeople 8 8 Author URI: http://www.ideapeople.co.kr -
idea-board/trunk/languages/idea-board-ko_KR.po
r1497903 r1498050 4 4 "Report-Msgid-Bugs-To: http://www.ideapeople.co.kr\n" 5 5 "POT-Creation-Date: 2016-08-12 22:51+0900\n" 6 "PO-Revision-Date: 2016-09-19 1 4:14+0900\n"6 "PO-Revision-Date: 2016-09-19 19:14+0900\n" 7 7 "Last-Translator: IdeaPeople<>\n" 8 8 "Language-Team: ideapeople <ideapeople@ideapeople.co.kr>\n" … … 323 323 msgid "It operates wordpress permalink structure will be activated" 324 324 msgstr "워드프레스 고유주소가 기본이 아니라면 동작합니다" 325 326 msgid "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>" 327 msgstr "게시판을 업데이트 기준 정렬로 사용합니다. (일반적인 포럼의 형태)<em>게시판을 업데이트 기준정렬로 사용하면 답글은 작성할수 없고 댓글만 작성할수 있습니다.<br/>체크를 해제하면 최근 작성한 기준으로 글이 정렬되고 답글이 활성화 됩니다</em>" 328 329 msgctxt "comments title" 330 msgid "One thought on “%2$s”" 331 msgid_plural "%1$s thoughts on “%2$s”" 332 msgstr[0] "“%2$s”에 대한 %1$s개의 생각" 333 msgstr[1] "" -
idea-board/trunk/languages/idea-board.po
r1497903 r1498050 4 4 "Report-Msgid-Bugs-To: http://www.ideapeople.co.kr\n" 5 5 "POT-Creation-Date: 2016-08-12 22:51+0900\n" 6 "PO-Revision-Date: 2016-09-19 1 4:14+0900\n"6 "PO-Revision-Date: 2016-09-19 19:14+0900\n" 7 7 "Last-Translator: IdeaPeople<>\n" 8 8 "Language-Team: ideapeople <ideapeople@ideapeople.co.kr>\n" … … 323 323 msgid "It operates wordpress permalink structure will be activated" 324 324 msgstr "" 325 326 msgid "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>" 327 msgstr "" 328 329 msgctxt "comments title" 330 msgid "One thought on “%2$s”" 331 msgid_plural "%1$s thoughts on “%2$s”" 332 msgstr[0] "" 333 msgstr[1] "" -
idea-board/trunk/readme.txt
r1497916 r1498050 12 12 13 13 This plugin helps you to add a simple forum to WordPress. 14 It is currently in beta deployment progress.15 14 Using the WordPress custom post type designed to enable a variety of plug-compatible. 16 15 … … 75 74 == Changelog == 76 75 76 = 0.3 = 77 * bug fix , Forum sort 78 77 79 = 0.2.7.1 = 78 80 * css bug fix -
idea-board/trunk/src/ideapeople/board/Button.php
r1497894 r1498050 9 9 namespace ideapeople\board; 10 10 11 use ideapeople\board\setting\Setting; 12 11 13 class Button { 12 14 public static function reply_button( $post = null ) { 15 if ( Setting::get_use_forum( null, false ) ) { 16 return null; 17 } 18 13 19 return self::button( 'reply', 'reply', 'Reply', Link::reply_link( $post ), $post ); 14 20 } … … 33 39 34 40 public static function read_button( $post = null ) { 41 $post = get_post( $post ); 42 35 43 return self::button( 'read', 'read', 'Read', get_permalink( $post->ID ), $post ); 36 44 } -
idea-board/trunk/src/ideapeople/board/CommonUtils.php
r1497894 r1498050 37 37 if ( $post = get_post( $post ) ) { 38 38 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 } 40 44 } 41 45 } -
idea-board/trunk/src/ideapeople/board/Plugin.php
r1497894 r1498050 18 18 use ideapeople\board\validator\ViewValidator; 19 19 use ideapeople\util\wp\PluginLoader; 20 use ideapeople\util\wp\Post OrderGenerator;20 use ideapeople\util\wp\PostHierarchyOrderGenerator; 21 21 use ideapeople\util\wp\WpNoprivUploader; 22 22 use WP_Session; … … 34 34 35 35 /** 36 * @var Post OrderGenerator36 * @var PostHierarchyOrderGenerator 37 37 */ 38 38 public $post_order_generator; … … 107 107 $this->custom_loader->add_filter( 'pre_cap_check_edit_view', $viewInterceptor, 'pre_cap_check_edit_view', 10, 2 ); 108 108 $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' );112 109 113 110 $comment_action = new CommentAction(); … … 150 147 $this->loader->add_filter( 'the_content', $auto_insert_page, 'auto_insert' ); 151 148 152 $sort = new PostSort();153 $this->loader->add_filter( 'idea_post_order_pre', $sort, 'sort_notice' );154 155 149 $post = new Post(); 156 150 $this->loader->add_filter( 'the_author', $post, 'get_the_author_nicename' ); … … 187 181 188 182 public function register_global() { 189 $this->post_order_generator = new Post OrderGenerator( 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' ); 190 184 191 185 $this->nopriv_uploader = new WpNoprivUploader( 'idea_board_upload', 'idea_upload_file', PluginConfig::$plugin_url ); -
idea-board/trunk/src/ideapeople/board/Post.php
r1497894 r1498050 10 10 11 11 use ideapeople\board\action\FileAction; 12 use ideapeople\board\setting\Setting; 12 13 use ideapeople\util\html\HtmlUtils; 13 14 use ideapeople\util\http\Request; 15 use ideapeople\util\wp\MetaUtils; 14 16 use ideapeople\util\wp\PasswordUtils; 15 use ideapeople\util\wp\Post OrderGenerator;17 use ideapeople\util\wp\PostHierarchyOrderGenerator; 16 18 use ideapeople\util\wp\PostUtils; 17 19 use ideapeople\util\wp\TermUtils; … … 331 333 public static function get_depth( $post = null ) { 332 334 /** 333 * @var $idea_board_post_order_generator Post OrderGenerator335 * @var $idea_board_post_order_generator PostHierarchyOrderGenerator 334 336 */ 335 337 global $idea_board_post_order_generator; … … 426 428 return $protected; 427 429 } 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 } 428 577 } -
idea-board/trunk/src/ideapeople/board/PostSort.php
r1497849 r1498050 10 10 11 11 12 use ideapeople\board\setting\Setting; 13 use ideapeople\util\wp\PostHierarchyOrderGenerator; 14 12 15 class 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 13 45 /** 14 46 * 공지사항 정렬 기능 추가 … … 18 50 * @return array 19 51 */ 20 function sort_notice( $queries ) {52 function sort_notice( &$queries ) { 21 53 global $wpdb; 22 54 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) "; 24 56 25 57 return $queries; 26 58 } 27 59 28 function sort_forum() { 60 //가장 최근에 댓글이 등록된글이 최상위로 올라온다 61 //가장 최근에 등록된 글이 상위로 올라온다. 62 function sort_forum( &$queries ) { 63 global $wpdb; 29 64 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; 30 68 } 31 69 } -
idea-board/trunk/src/ideapeople/board/PostView.php
r1496664 r1498050 12 12 use ideapeople\board\setting\Setting; 13 13 use ideapeople\board\view\CommentView; 14 use ideapeople\board\view\DeleteView;15 14 use ideapeople\board\view\EditView; 16 15 use ideapeople\board\view\ErrorView; -
idea-board/trunk/src/ideapeople/board/Query.php
r1497903 r1498050 9 9 10 10 11 use ideapeople\ util\wp\WpQuerySearch;11 use ideapeople\board\setting\Setting; 12 12 use WP_Query; 13 use wpdb;14 13 15 14 class Query extends WP_Query { 15 public $start_no; 16 17 16 18 public function __construct( $query = '' ) { 19 $post_sort = new PostSort(); 20 21 add_filter( 'posts_orderby', array( $post_sort, 'sort' ) ); 22 17 23 $query = wp_parse_args( $query, array( 18 24 'post_type' => PluginConfig::$board_post_type, … … 31 37 ) 32 38 ), 33 34 39 ) ); 35 40 … … 37 42 38 43 $this->start_no = $this->generateStartNo( get_query_var( 'paged' ), $query[ 'posts_per_page' ] ); 44 45 remove_filter( 'posts_orderby', array( $post_sort, 'sort' ) ); 39 46 } 40 47 … … 81 88 public static function get_single_post( $args = array() ) { 82 89 $args = wp_parse_args( $args, array( 83 'board' => '',90 'board' => Setting::get_board()->name, 84 91 'p' => '', 85 'paged' => 0 92 'paged' => 0, 93 'pname' => get_query_var( 'pname', false ) 86 94 ) ); 95 96 if ( $args[ 'pname' ] ) { 97 $args[ 'post_name__in' ] = array( $args[ 'pname' ] ); 98 } 87 99 88 100 $post = null; -
idea-board/trunk/src/ideapeople/board/action/CommentAction.php
r1497423 r1498050 29 29 30 30 public function password_check() { 31 $password = $_POST[ 'comment_password'];31 $password = $_POST[ 'comment_password' ]; 32 32 33 33 if ( is_user_logged_in() ) { … … 40 40 41 41 public function preprocess_comment( $comment ) { 42 $post = get_post( $comment[ 'comment_post_ID'] );42 $post = get_post( $comment[ 'comment_post_ID' ] ); 43 43 44 44 if ( $post->post_type != PluginConfig::$board_post_type ) { … … 77 77 public function handle_comment_delete( $comment_ID ) { 78 78 if ( empty( $comment_ID ) ) { 79 $comment_ID = &$_GET[ 'comment_ID'];79 $comment_ID = &$_GET[ 'comment_ID' ]; 80 80 } 81 81 … … 110 110 $comment_password = false; 111 111 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' ]; 132 132 } 133 133 … … 190 190 191 191 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 ) 194 194 ) { 195 195 kses_remove_filters(); … … 214 214 } 215 215 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' ) ) { 217 217 return new WP_Error( 'comment_author_column_length', __( '<strong>ERROR</strong>: your name is too long.' ), 200 ); 218 218 } 219 219 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 ) ) { 221 221 return new WP_Error( 'comment_author_email_column_length', __( '<strong>ERROR</strong>: your email address is too long.' ), 200 ); 222 222 } 223 223 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 ) ) { 225 225 return new WP_Error( 'comment_author_url_column_length', __( '<strong>ERROR</strong>: your url is too long.' ), 200 ); 226 226 } … … 228 228 if ( '' == $comment_content ) { 229 229 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' ) ) { 231 231 return new WP_Error( 'comment_content_column_length', __( '<strong>ERROR</strong>: your comment is too long.' ), 200 ); 232 232 } … … 245 245 $mode = false; 246 246 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' ]; 251 251 252 252 if ( Capability::is_board_admin() ) { … … 283 283 } 284 284 285 Post::update_latest_post( $comment_post_ID ); 286 285 287 do_action( 'idea_board_action_comment_edit_after', $comment_data, $comment_id, $board, $mode ); 286 288 287 wp_redirect( get_permalink( $post->ID) . '#comment-' . $comment_id );289 wp_redirect( wp_get_referer() . '#comment-' . $comment_id ); 288 290 289 291 die; -
idea-board/trunk/src/ideapeople/board/action/PostAction.php
r1497894 r1498050 43 43 ) ); 44 44 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; 48 52 49 53 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' ] ); 51 55 } 52 56 … … 54 58 55 59 $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' ]; 57 61 $return_url = Request::get_parameter( 'return_url', null ); 58 62 $nonce = $post_data[ PluginConfig::$idea_board_edit_nonce_name ]; … … 63 67 64 68 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' ] ) ) { 66 70 wp_die(); 67 71 } 68 72 } 69 73 70 if ( isset( $post_data[ 'mode'] ) ) {71 $mode = $post_data[ 'mode'];74 if ( isset( $post_data[ 'mode' ] ) ) { 75 $mode = $post_data[ 'mode' ]; 72 76 } else { 73 77 if ( empty( $post_id ) || $post_id == - 1 ) { … … 78 82 } 79 83 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 ); 83 85 84 86 if ( ! $board ) { … … 92 94 switch ( $mode ) { 93 95 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 ); 98 100 } 99 101 … … 103 105 case 'update': 104 106 if ( Capability::is_board_admin() ) { 105 unset( $post_data[ 'post_author'] );107 unset( $post_data[ 'post_author' ] ); 106 108 } 107 109 … … 137 139 public function post_update_private_meta( $board_term, $post_id ) { 138 140 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' ] ); 140 142 PostUtils::insert_or_update_meta( $post_id, 'idea_board_term', $board_term ); 143 144 Post::update_latest_post( $post_id ); 141 145 } 142 146 } … … 211 215 } 212 216 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 229 217 public function update_idea_post( $post_id ) { 230 218 $post = get_post( $post_id ); … … 234 222 } 235 223 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 ]; 242 229 $this->post_update_private_meta( $tax[ count( $tax ) - 1 ], $post_id ); 243 230 } -
idea-board/trunk/src/ideapeople/board/setting/Setting.php
r1497604 r1498050 39 39 'board_noti_post_comment_author', 40 40 'board_noti_comment_comment_author', 41 'board_use_forum' 41 42 ) ); 42 43 … … 292 293 return self::get_meta( 'board_noti_post_admin', $board_term, $defaultValue ); 293 294 } 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 } 294 299 } -
idea-board/trunk/src/ideapeople/board/view/CommentView.php
r1497894 r1498050 23 23 public function render( $model = null ) { 24 24 $post = Query::get_single_post( array( 25 'board' => Setting::get_board()->name,26 25 'p' => get_query_var( 'pid', 1 ) 27 26 ) ); -
idea-board/trunk/src/ideapeople/board/view/ListView.php
r1496664 r1498050 28 28 ) ); 29 29 30 $GLOBALS[ 'wp_query'] = $query;30 $GLOBALS[ 'wp_query' ] = $query; 31 31 32 32 $this->addAttribute( 'query', $query ); -
idea-board/trunk/src/ideapeople/board/view/SingleView.php
r1497894 r1498050 23 23 public function render( $model = null ) { 24 24 $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' ) 28 26 ) ); 29 27 -
idea-board/trunk/src/ideapeople/util/wp/PostHierarchyOrderGenerator.php
r1498049 r1498050 16 16 * @package ideapeople\util\wp 17 17 * 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' );21 18 * $this->loader->add_filter( 'the_title', $orderGenerator, 'the_title', 10, 2 ); 22 19 */ 23 class Post OrderGenerator {20 class PostHierarchyOrderGenerator { 24 21 public $grp_key; 25 22 public $ord_key; … … 40 37 $this->ord_key = $ord_key; 41 38 $this->depth_key = $depth_key; 39 40 add_action( 'save_post_' . $post_type, array( $this, 'update_post_order' ) ); 42 41 } 43 42 … … 137 136 } 138 137 139 public function sort_order_by() {140 add_filter( 'posts_orderby_request', array( $this, 'posts_orderby_request' ), 10, 2 );141 }142 143 138 /** 144 139 * @param $request … … 162 157 } 163 158 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() ); 172 160 173 161 $q = join( " , ", $queries ); … … 175 163 return $q; 176 164 } 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 } 177 174 } -
idea-board/trunk/views/admin/setting.php
r1497894 r1498050 52 52 </label> 53 53 </p> 54 54 55 <p> 55 56 <label for="board_use_page" class="block"> … … 67 68 </label> 68 69 </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> 69 79 </td> 70 80 </tr> -
idea-board/trunk/views/skin/board/basic/comment_edit.php
r1497894 r1498050 1 1 <?php 2 use ideapeople\board\Button; 2 3 use ideapeople\board\Comment; 3 4 use ideapeople\util\http\Request; … … 14 15 ), get_query_var( 'pid' ) ); 15 16 17 echo Button::read_button( $comment->comment_post_ID ); 16 18 ?> 19 17 20 <script> 18 21 (function ($) { -
idea-board/trunk/views/skin/board/basic/comments.php
r1497903 r1498050 40 40 <h2 class="idea-board-comments-title"> 41 41 <?php 42 printf( _nx( 'One thought on “%2$s”', '%1$s thoughts on “%2$s”', get_comments_number(), 'comments title' ), 43 number_format_i18n( get_comments_number() ), get_the_title() ); 42 printf( _nx( 'One thought on “%2$s”', '%1$s thoughts on “%2$s”', get_comments_number(), 'comments title', 'idea-board' ), number_format_i18n( get_comments_number() ), get_the_title() ); 44 43 ?> 45 44 </h2>
Note: See TracChangeset
for help on using the changeset viewer.