Changeset 3514

Show
Ignore:
Timestamp:
02/12/06 07:41:56 (3 years ago)
Author:
ryan
Message:

Post status = future. #2426

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-admin/upgrade-functions.php

    r3513 r3514  
    3434        upgrade_160(); 
    3535 
    36     if ( $wp_current_db_version < 3513
     36    if ( $wp_current_db_version < 3514
    3737        upgrade_210(); 
    3838 
  • trunk/wp-admin/upgrade-schema.php

    r3513 r3514  
    107107  post_category int(4) NOT NULL default '0', 
    108108  post_excerpt text NOT NULL, 
    109   post_status enum('publish','draft','private','static','object','attachment','inherit') NOT NULL default 'publish', 
     109  post_status enum('publish','draft','private','static','object','attachment','inherit','future') NOT NULL default 'publish', 
    110110  comment_status enum('open','closed','registered_only') NOT NULL default 'open', 
    111111  ping_status enum('open','closed') NOT NULL default 'open', 
  • trunk/wp-includes/classes.php

    r3511 r3514  
    572572        } 
    573573 
    574         $now = gmdate('Y-m-d H:i:59'); 
     574        //$now = gmdate('Y-m-d H:i:59'); 
    575575         
    576576        //only select past-dated posts, except if a logged in user is viewing a single: then, if they 
    577577        //can edit the post, we let them through 
    578         if ($pagenow != 'post.php' && $pagenow != 'edit.php' && !($this->is_single && $user_ID)) { 
    579           $where .= " AND post_date_gmt <= '$now'"; 
    580           $distinct = 'DISTINCT'; 
    581        
     578        //if ($pagenow != 'post.php' && $pagenow != 'edit.php' && !($this->is_single && $user_ID)) { 
     579        //    $where .= " AND post_date_gmt <= '$now'"; 
     580        //    $distinct = 'DISTINCT'; 
     581        //
    582582 
    583583        if ( $this->is_attachment ) { 
     
    590590            $where .= ' AND (post_type = "post" AND post_status = "publish"'; 
    591591 
    592             if (isset($user_ID) && ('' != intval($user_ID))) 
     592            if ( $pagenow == 'post.php' || $pagenow == 'edit.php' ) 
     593                $where .= " OR post_status = 'future'"; 
     594            else 
     595                $distinct = 'DISTINCT'; 
     596     
     597            if ( is_user_logged_in() ) 
    593598                $where .= " OR post_author = $user_ID AND post_status = 'private')"; 
    594599            else 
     
    642647        if ($this->is_single || $this->is_page) { 
    643648            $status = get_post_status($this->posts[0]); 
     649            //$type = get_post_type($this->posts[0]); 
    644650            if ( ('publish' != $status) ) { 
    645651                if ( ! is_user_logged_in() ) { 
     
    655661                            $this->posts[0]->post_date = current_time('mysql'); 
    656662                        } 
     663                    }  else if ('future' == $status) { 
     664                        $this->is_preview = true; 
     665                        if (!current_user_can('edit_post', $this->posts[0]->ID)) { 
     666                            $this->posts = array ( ); 
     667                        } 
    657668                    } else { 
    658669                        if (! current_user_can('read_post', $this->posts[0]->ID)) 
    659670                            $this->posts = array(); 
    660                     } 
    661                 } 
    662             } else { 
    663                 if (mysql2date('U', $this->posts[0]->post_date_gmt) > mysql2date('U', $now)) { //it's future dated 
    664                     $this->is_preview = true; 
    665                     if (!current_user_can('edit_post', $this->posts[0]->ID)) { 
    666                         $this->posts = array ( ); 
    667671                    } 
    668672                } 
  • trunk/wp-includes/default-filters.php

    r3009 r3514  
    8585add_action('publish_post', 'generic_ping'); 
    8686add_action('wp_head', 'rsd_link'); 
     87add_action('publish_future_post', 'wp_publish_post', 10, 1); 
    8788 
    8889?> 
  • trunk/wp-includes/functions-post.php

    r3511 r3514  
    7272            $post_date_gmt = get_gmt_from_date($post_date); 
    7373    } 
     74 
     75    if ( 'publish' == $post_status && (mysql2date('U', $post_date_gmt) > time()) ) 
     76        $post_status = 'future'; 
    7477 
    7578    if ( empty($comment_status) ) { 
     
    204207                add_post_meta($post_ID, '_wp_page_template',  $page_template, true); 
    205208    } 
     209 
     210    if ( 'future' == $post_status ) 
     211        wp_schedule_event(mysql2date('U', $post_date_gmt), 'once', 'publish_future_post', $post_ID); 
    206212 
    207213    do_action('save_post', $post_ID); 
     
    456462} 
    457463 
     464function wp_publish_post($post_id) { 
     465    $post = get_post($post_id); 
     466 
     467    if ( empty($post) ) 
     468        return; 
     469 
     470    if ( 'publish' == $post->post_status ) 
     471        return; 
     472 
     473    return wp_update_post(array('post_status' => 'publish', 'ID' => $post_id));  
     474} 
     475 
    458476function wp_get_post_cats($blogid = '1', $post_ID = 0) { 
    459477    global $wpdb; 
  • trunk/wp-includes/functions.php

    r3512 r3514  
    111111    $add_seconds_blog = get_settings('gmt_offset') * 3600; 
    112112    $add_seconds_server = date('Z'); 
    113     $now = current_time('mysql', 1); 
    114113    if ( !isset($cache_lastpostdate[$timezone]) ) { 
    115114        switch(strtolower($timezone)) { 
    116115            case 'gmt': 
    117                 $lastpostdate = $wpdb->get_var("SELECT post_date_gmt FROM $wpdb->posts WHERE post_date_gmt <= '$now' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1"); 
     116                $lastpostdate = $wpdb->get_var("SELECT post_date_gmt FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1"); 
    118117                break; 
    119118            case 'blog': 
    120                 $lastpostdate = $wpdb->get_var("SELECT post_date FROM $wpdb->posts WHERE post_date_gmt <= '$now' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1"); 
     119                $lastpostdate = $wpdb->get_var("SELECT post_date FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1"); 
    121120                break; 
    122121            case 'server': 
    123                 $lastpostdate = $wpdb->get_var("SELECT DATE_ADD(post_date_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_date_gmt <= '$now' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1"); 
     122                $lastpostdate = $wpdb->get_var("SELECT DATE_ADD(post_date_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1"); 
    124123                break; 
    125124        } 
     
    135134    $add_seconds_blog = get_settings('gmt_offset') * 3600; 
    136135    $add_seconds_server = date('Z'); 
    137     $now = current_time('mysql', 1); 
    138136    if ( !isset($cache_lastpostmodified[$timezone]) ) { 
    139137        switch(strtolower($timezone)) { 
    140138            case 'gmt': 
    141                 $lastpostmodified = $wpdb->get_var("SELECT post_modified_gmt FROM $wpdb->posts WHERE post_modified_gmt <= '$now' AND post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1"); 
     139                $lastpostmodified = $wpdb->get_var("SELECT post_modified_gmt FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1"); 
    142140                break; 
    143141            case 'blog': 
    144                 $lastpostmodified = $wpdb->get_var("SELECT post_modified FROM $wpdb->posts WHERE post_modified_gmt <= '$now' AND post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1"); 
     142                $lastpostmodified = $wpdb->get_var("SELECT post_modified FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1"); 
    145143                break; 
    146144            case 'server': 
    147                 $lastpostmodified = $wpdb->get_var("SELECT DATE_ADD(post_modified_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_modified_gmt <= '$now' AND post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1"); 
     145                $lastpostmodified = $wpdb->get_var("SELECT DATE_ADD(post_modified_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1"); 
    148146                break; 
    149147        } 
     
    13511349        $r['order'] = 'DESC'; 
    13521350 
    1353     $now = current_time('mysql'); 
    1354  
    13551351    $posts = $wpdb->get_results( 
    13561352        "SELECT DISTINCT * FROM $wpdb->posts " . 
    13571353        ( empty( $r['category'] ) ? "" : ", $wpdb->post2cat " ) . 
    1358         " WHERE post_date <= '$now' AND (post_type = 'post' AND post_status = 'publish') ". 
     1354        " WHERE (post_type = 'post' AND post_status = 'publish') ". 
    13591355        ( empty( $r['category'] ) ? "" : "AND $wpdb->posts.ID = $wpdb->post2cat.post_id AND $wpdb->post2cat.category_id = " . $r['category']. " " ) . 
    13601356        " GROUP BY $wpdb->posts.ID ORDER BY " . $r['orderby'] . " " . $r['order'] . " LIMIT " . $r['offset'] . ',' . $r['numberposts'] ); 
  • trunk/wp-includes/template-functions-general.php

    r3510 r3514  
    328328    $add_minutes = intval(60 * (get_settings('gmt_offset') - $add_hours)); 
    329329 
    330     $now = current_time('mysql'); 
    331  
    332330    if ( 'monthly' == $type ) { 
    333         $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts WHERE post_date < '$now' AND post_date != '0000-00-00 00:00:00' AND post_type = 'post' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit); 
     331        $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit); 
    334332        if ( $arcresults ) { 
    335333            $afterafter = $after; 
     
    346344        } 
    347345    } elseif ( 'daily' == $type ) { 
    348         $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth` FROM $wpdb->posts WHERE post_date < '$now' AND post_date != '0000-00-00 00:00:00' AND post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC" . $limit); 
     346        $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth` FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC" . $limit); 
    349347        if ( $arcresults ) { 
    350348            foreach ( $arcresults as $arcresult ) { 
     
    357355    } elseif ( 'weekly' == $type ) { 
    358356        $start_of_week = get_settings('start_of_week'); 
    359         $arcresults = $wpdb->get_results("SELECT DISTINCT WEEK(post_date, $start_of_week) AS `week`, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd FROM $wpdb->posts WHERE post_date < '$now' AND post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC" . $limit); 
     357        $arcresults = $wpdb->get_results("SELECT DISTINCT WEEK(post_date, $start_of_week) AS `week`, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC" . $limit); 
    360358        $arc_w_last = ''; 
    361359        if ( $arcresults ) { 
     
    374372        } 
    375373    } elseif ( 'postbypost' == $type ) { 
    376         $arcresults = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_date < '$now' AND post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC" . $limit); 
     374        $arcresults = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC" . $limit); 
    377375        if ( $arcresults ) { 
    378376            foreach ( $arcresults as $arcresult ) { 
  • trunk/wp-includes/template-functions-links.php

    r3510 r3514  
    295295    } 
    296296 
    297     $now = current_time('mysql'); 
    298      
    299     return @$wpdb->get_row("SELECT ID,post_title FROM $wpdb->posts $join WHERE post_date > '$current_post_date' AND post_date < '$now' AND post_type = 'post' AND post_status = 'publish' $posts_in_ex_cats_sql AND ID != $post->ID ORDER BY post_date ASC LIMIT 1"); 
     297    return @$wpdb->get_row("SELECT ID,post_title FROM $wpdb->posts $join WHERE post_date > '$current_post_date' AND post_type = 'post' AND post_status = 'publish' $posts_in_ex_cats_sql AND ID != $post->ID ORDER BY post_date ASC LIMIT 1"); 
    300298} 
    301299 
  • trunk/wp-includes/version.php

    r3513 r3514  
    44 
    55$wp_version = '2.1-aplha1'; 
    6 $wp_db_version = 3513
     6$wp_db_version = 3514
    77 
    88?> 
  • trunk/wp-settings.php

    r3499 r3514  
    218218function shutdown_action_hook() { 
    219219    do_action('shutdown'); 
     220    wp_cron(); 
    220221    wp_cache_close(); 
    221222}