Make WordPress Core

Changeset 2523


Ignore:
Timestamp:
04/09/2005 05:12:36 PM (20 years ago)
Author:
ryan
Message:

Remove old preview stuff. Allow draft posts to be displayed if the logged in user has edit permissions on the draft. Don't use cruft-free links for drafts since they might not have a slug. http://mosquito.wordpress.org/view.php?id=1220

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-blog-header.php

    r2512 r2523  
    8686 }
    8787
    88 $wpvarstoreset = array('m','p','posts','w', 'cat','withcomments','s','search','exact', 'sentence','preview','debug', 'calendar','page','paged','more','tb', 'pb','author','order','orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup');
     88$wpvarstoreset = array('m','p','posts','w', 'cat','withcomments','s','search','exact', 'sentence', 'debug', 'calendar','page','paged','more','tb', 'pb','author','order','orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup');
    8989
    9090$wpvarstoreset = apply_filters('query_vars', $wpvarstoreset);
     
    168168
    169169update_category_cache();
     170get_currentuserinfo();
    170171
    171172// Call query posts to do the work.
  • trunk/wp-includes/classes.php

    r2478 r2523  
    494494
    495495        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")';
    497499        } else {
    498500            $where .= ' AND (post_status = "publish"';
    499         }
    500 
    501         // Get private posts
    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 .= ')';
     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 .= ')';             
     506        }
    506507
    507508        // Apply filters on where and join prior to paging so that any
     
    544545        $request = " SELECT $distinct * FROM $wpdb->posts $join WHERE 1=1".$where." ORDER BY " . $orderby . " $limits";
    545546
    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);
    552             }
    553         }
    554 
    555547        $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                }
     565            }
     566        }
     567
    556568        $this->posts = apply_filters('the_posts', $this->posts);
    557569        $this->post_count = count($this->posts);
  • trunk/wp-includes/functions-post.php

    r2453 r2523  
    352352function user_can_edit_post($user_id, $post_id, $blog_id = 1) {
    353353    $author_data = get_userdata($user_id);
    354     $post_data   = get_postdata($post_id);
    355     $post_author_data = get_userdata($post_data['Author_ID']);
    356 
    357     if ( (($user_id == $post_author_data->ID) && !($post_data['post_status'] == 'publish' &&  $author_data->user_level < 2))
     354    $post = get_post($post_id);
     355    $post_author_data = get_userdata($post->post_author);
     356
     357    if ( (($user_id == $post_author_data->ID) && !($post->post_status == 'publish' &&  $author_data->user_level < 2))
    358358         || ($author_data->user_level > $post_author_data->user_level)
    359359         || ($author_data->user_level >= 10) ) {
  • trunk/wp-includes/functions.php

    r2516 r2523  
    857857// Setup global post data.
    858858function setup_postdata($post) {
    859   global $id, $postdata, $authordata, $day, $preview, $page, $pages, $multipage, $more, $numpages, $wp_query;
     859  global $id, $postdata, $authordata, $day, $page, $pages, $multipage, $more, $numpages, $wp_query;
    860860    global $pagenow;
    861861
    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
    877864    $authordata = get_userdata($post->post_author);
    878865
     
    11591146    FROM $wpdb->posts
    11601147    LEFT JOIN $wpdb->comments ON ( comment_post_ID = ID  AND comment_approved =  '1')
    1161     WHERE post_status =  'publish' AND ID IN ($post_id_list)
     1148    WHERE ID IN ($post_id_list)
    11621149    GROUP BY ID");
    11631150   
  • trunk/wp-includes/template-functions-links.php

    r2499 r2523  
    4545    $permalink = get_settings('permalink_structure');
    4646
    47     if ('' != $permalink) {
     47    if ('' != $permalink && 'draft' != $post->post_status) {
    4848        $unixtime = strtotime($post->post_date);
    4949
Note: See TracChangeset for help on using the changeset viewer.