Ticket #1220: preview_draft.diff
File preview_draft.diff, 5.6 KB (added by , 20 years ago) |
---|
-
wp-blog-header.php
167 167 $query_string = apply_filters('query_string', $query_string); 168 168 169 169 update_category_cache(); 170 get_currentuserinfo(); 170 171 171 172 // Call query posts to do the work. 172 173 $posts = & query_posts($query_string); -
wp-includes/functions-post.php
351 351 /* returns true if $user_id can edit $post_id */ 352 352 function user_can_edit_post($user_id, $post_id, $blog_id = 1) { 353 353 $author_data = get_userdata($user_id); 354 $post _data = get_postdata($post_id);355 $post_author_data = get_userdata($post _data['Author_ID']);354 $post = get_post($post_id); 355 $post_author_data = get_userdata($post->post_author); 356 356 357 if ( (($user_id == $post_author_data->ID) && !($post _data['post_status']== 'publish' && $author_data->user_level < 2))357 if ( (($user_id == $post_author_data->ID) && !($post->post_status == 'publish' && $author_data->user_level < 2)) 358 358 || ($author_data->user_level > $post_author_data->user_level) 359 359 || ($author_data->user_level >= 10) ) { 360 360 return true; -
wp-includes/classes.php
493 493 } 494 494 495 495 if ($this->is_page) { 496 $where .= ' AND (post_status = "static"'; 496 $where .= ' AND (post_status = "static")'; 497 } elseif ($this->is_single) { 498 $where .= ' AND (post_status != "static")'; 497 499 } else { 498 500 $where .= ' AND (post_status = "publish"'; 501 502 if (isset($user_ID) && ('' != intval($user_ID))) 503 $where .= " OR post_author = $user_ID AND post_status != 'draft' AND post_status != 'static')"; 504 else 505 $where .= ')'; 499 506 } 500 507 501 // Get private posts502 if (isset($user_ID) && ('' != intval($user_ID)))503 $where .= " OR post_author = $user_ID AND post_status != 'draft' AND post_status != 'static')";504 else505 $where .= ')';506 507 508 // Apply filters on where and join prior to paging so that any 508 509 // manipulations to them are reflected in the paging by day queries. 509 510 $where = apply_filters('posts_where', $where); … … 543 544 $orderby = apply_filters('posts_orderby', $orderby); 544 545 $request = " SELECT $distinct * FROM $wpdb->posts $join WHERE 1=1".$where." ORDER BY " . $orderby . " $limits"; 545 546 546 if ($q['preview']) { 547 $request = 'SELECT 1-1'; // dummy mysql query for the preview 548 // little funky fix for IEwin, rawk on that code 549 $is_winIE = ((preg_match('/MSIE/',$HTTP_USER_AGENT)) && (preg_match('/Win/',$HTTP_USER_AGENT))); 550 if (($is_winIE) && (!isset($IEWin_bookmarklet_fix))) { 551 $preview_content = preg_replace('/\%u([0-9A-F]{4,4})/e', "'&#'.base_convert('\\1',16,10).';'", $preview_content); 547 $this->posts = $wpdb->get_results($request); 548 549 // Check post status to determine if post should be displayed. 550 if ($this->is_single) { 551 if ('publish' != $this->posts[0]->post_status) { 552 if ( ! (isset($user_ID) && ('' != intval($user_ID))) ) { 553 // User must be logged in to view unpublished posts. 554 $this->posts = array(); 555 } else { 556 if ('draft' == $this->posts[0]->post_status) { 557 // User must have edit permissions on the draft to preview. 558 if (! user_can_edit_post($user_ID, $this->posts[0]->ID)) 559 $this->posts = array(); 560 } elseif ('private' == $this->posts[0]->post_status) { 561 if ($this->posts[0]->post_author != $user_ID) 562 $this->posts = array(); 563 } 564 } 552 565 } 553 566 } 554 567 555 $this->posts = $wpdb->get_results($request);556 568 $this->posts = apply_filters('the_posts', $this->posts); 557 569 $this->post_count = count($this->posts); 558 570 if ($this->post_count > 0) { -
wp-includes/template-functions-links.php
44 44 45 45 $permalink = get_settings('permalink_structure'); 46 46 47 if ('' != $permalink ) {47 if ('' != $permalink && 'draft' != $post->post_status) { 48 48 $unixtime = strtotime($post->post_date); 49 49 50 50 $category = ''; -
wp-includes/functions.php
856 856 857 857 // Setup global post data. 858 858 function setup_postdata($post) { 859 global $id, $postdata, $authordata, $day, $p review, $page, $pages, $multipage, $more, $numpages, $wp_query;859 global $id, $postdata, $authordata, $day, $page, $pages, $multipage, $more, $numpages, $wp_query; 860 860 global $pagenow; 861 861 862 if (!$preview) { 863 $id = $post->ID; 864 } else { 865 $id = 0; 866 $postdata = array ( 867 'ID' => 0, 868 'Author_ID' => $_GET['preview_userid'], 869 'Date' => $_GET['preview_date'], 870 'Content' => $_GET['preview_content'], 871 'Excerpt' => $_GET['preview_excerpt'], 872 'Title' => $_GET['preview_title'], 873 'Category' => $_GET['preview_category'], 874 'Notify' => 1 875 ); 876 } 862 $id = $post->ID; 863 877 864 $authordata = get_userdata($post->post_author); 878 865 879 866 $day = mysql2date('d.m.y', $post->post_date); … … 1158 1145 $comment_counts = $wpdb->get_results("SELECT ID, COUNT( comment_ID ) AS ccount 1159 1146 FROM $wpdb->posts 1160 1147 LEFT JOIN $wpdb->comments ON ( comment_post_ID = ID AND comment_approved = '1') 1161 WHERE post_status = 'publish' ANDID IN ($post_id_list)1148 WHERE ID IN ($post_id_list) 1162 1149 GROUP BY ID"); 1163 1150 1164 1151 if ($comment_counts) {