Make WordPress Core

Changeset 12697


Ignore:
Timestamp:
01/11/2010 09:49:40 PM (17 years ago)
Author:
wpmuguru
Message:

merge in multisite login, wp-includes, See #11644

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/author-template.php

    r12680 r12697  
    270270
    271271        /** @todo Move select to get_authors(). */
    272         $authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login <> 'admin' " : '') . "ORDER BY display_name");
     272        if( is_multisite() ) {
     273                $users = get_users_of_blog();
     274                $author_ids = array();
     275                foreach ( (array) $users as $user ) {
     276                        $author_ids[] = $user->user_id;
     277                }
     278                if ( count($author_ids) > 0  ) {
     279                        $author_ids=implode(',', $author_ids );
     280                        $authors = $wpdb->get_results( "SELECT ID, user_nicename from $wpdb->users WHERE ID IN($author_ids) " . ($exclude_admin ? "AND user_login <> 'admin' " : '') . "ORDER BY display_name" );
     281                } else {
     282                        $authors = array();
     283                }
     284        } else {
     285                $authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login <> 'admin' " : '') . "ORDER BY display_name");
     286        }
    273287
    274288        $author_count = array();
  • trunk/wp-includes/capabilities.php

    r12650 r12697  
    988988        $current_user = wp_get_current_user();
    989989
     990        if( is_multisite() && is_super_admin() )
     991                return true;
     992
    990993        if ( empty( $current_user ) )
    991994                return false;
  • trunk/wp-includes/functions.php

    r12686 r12697  
    328328
    329329        // prevent non-existent options from triggering multiple queries
    330         $notoptions = wp_cache_get( 'notoptions', 'options' );
    331         if ( isset( $notoptions[$setting] ) )
    332                 return $default;
     330        if ( defined( 'WP_INSTALLING' ) && is_multisite() ) {
     331                $notoptions = array();
     332        } else {
     333                $notoptions = wp_cache_get( 'notoptions', 'options' );
     334                if ( isset( $notoptions[$setting] ) )
     335                        return $default;
     336        }
    333337
    334338        $alloptions = wp_load_alloptions();
     
    412416        global $wpdb;
    413417
    414         $alloptions = wp_cache_get( 'alloptions', 'options' );
     418        if ( !defined( 'WP_INSTALLING' ) || !is_multisite() )
     419                $alloptions = wp_cache_get( 'alloptions', 'options' );
    415420
    416421        if ( !$alloptions ) {
     
    422427                foreach ( (array) $alloptions_db as $o )
    423428                        $alloptions[$o->option_name] = $o->option_value;
    424                 wp_cache_add( 'alloptions', $alloptions, 'options' );
     429                if ( !defined( 'WP_INSTALLING' ) || !is_multisite() )
     430                        wp_cache_add( 'alloptions', $alloptions, 'options' );
    425431        }
    426432        return $alloptions;
     
    624630        global $_wp_using_ext_object_cache, $wpdb;
    625631
     632        if( is_multisite() )
     633                do_action( 'delete_transient_' . $transient );
     634
    626635        if ( $_wp_using_ext_object_cache ) {
    627636                return wp_cache_delete($transient, 'transient');
     
    690699function set_transient($transient, $value, $expiration = 0) {
    691700        global $_wp_using_ext_object_cache, $wpdb;
     701
     702        if( is_multisite() )
     703                $value = apply_filters( 'pre_set_transient_' . $transient, $value );
    692704
    693705        if ( $_wp_using_ext_object_cache ) {
     
    21742186        if ( $upload['error'] !== false )
    21752187                return $upload;
     2188
     2189        if( is_multisite() ) {
     2190                /* WPMU check file before writing it */
     2191                $upload_bits_error = apply_filters( 'wp_upload_bits', array( 'name' => $name, 'bits' => $bits, 'time' => $time ) );
     2192                if( is_array( $upload_bits_error ) == false ) {
     2193                        $upload[ 'error' ] = $upload_bits_error;
     2194                        return $upload;
     2195                }
     2196        }
    21762197
    21772198        $filename = wp_unique_filename( $upload['path'], $name );
  • trunk/wp-includes/post.php

    r12682 r12697  
    30773077                        if ( 0 === strpos($file, $uploads['basedir']) ) //Check that the upload base exists in the file location
    30783078                                $url = str_replace($uploads['basedir'], $uploads['baseurl'], $file); //replace file location with url location
    3079                         elseif ( false !== strpos($file, 'wp-content/uploads') )
    3080                                 $url = $uploads['baseurl'] . substr( $file, strpos($file, 'wp-content/uploads') + 18 );
    3081                         else
    3082                                 $url = $uploads['baseurl'] . "/$file"; //Its a newly uploaded file, therefor $file is relative to the basedir.
     3079                        elseif ( !is_multisite() ) {
     3080                                if ( false !== strpos($file, 'wp-content/uploads') )
     3081                                        $url = $uploads['baseurl'] . substr( $file, strpos($file, 'wp-content/uploads') + 18 );
     3082                                else
     3083                                        $url = $uploads['baseurl'] . "/$file"; //Its a newly uploaded file, therefor $file is relative to the basedir.
     3084                        }
    30833085                }
    30843086        }
  • trunk/wp-includes/rewrite.php

    r12598 r12697  
    17251725                        return '';
    17261726                }
    1727                
    1728                 $rules = '';
    1729                 $extra_indent = '';
    1730                 if ( $add_parent_tags ) {
    1731                         $rules .= "<configuration>".$end_of_line;
    1732                         $rules .= $indent."<system.webServer>".$end_of_line;
    1733                         $rules .= $indent.$indent."<rewrite>".$end_of_line;
    1734                         $rules .= $indent.$indent.$indent."<rules>".$end_of_line;
    1735                         $extra_indent = $indent.$indent.$indent.$indent;
    1736                 }
    1737                
    1738                 $rules .= $extra_indent."<rule name=\"wordpress\" patternSyntax=\"Wildcard\">".$end_of_line;
    1739                 $rules .= $extra_indent.$indent."<match url=\"*\" />".$end_of_line;
    1740                 $rules .= $extra_indent.$indent.$indent."<conditions>".$end_of_line;
    1741                 $rules .= $extra_indent.$indent.$indent.$indent."<add input=\"{REQUEST_FILENAME}\" matchType=\"IsFile\" negate=\"true\" />".$end_of_line;
    1742                 $rules .= $extra_indent.$indent.$indent.$indent."<add input=\"{REQUEST_FILENAME}\" matchType=\"IsDirectory\" negate=\"true\" />".$end_of_line;
    1743                 $rules .= $extra_indent.$indent.$indent."</conditions>".$end_of_line;
    1744                 $rules .= $extra_indent.$indent."<action type=\"Rewrite\" url=\"index.php\" />".$end_of_line;
    1745                 $rules .= $extra_indent."</rule>";
    1746                
    1747                 if ( $add_parent_tags ) {
    1748                         $rules .= $end_of_line.$indent.$indent.$indent."</rules>".$end_of_line;
    1749                         $rules .= $indent.$indent."</rewrite>".$end_of_line;
    1750                         $rules .= $indent."</system.webServer>".$end_of_line;
    1751                         $rules .= "</configuration>";
    1752                 }
     1727
     1728                if( !is_multisite() ) {
     1729                        $rules = '';
     1730                        $extra_indent = '';
     1731                        if ( $add_parent_tags ) {
     1732                                $rules .= "<configuration>".$end_of_line;
     1733                                $rules .= $indent."<system.webServer>".$end_of_line;
     1734                                $rules .= $indent.$indent."<rewrite>".$end_of_line;
     1735                                $rules .= $indent.$indent.$indent."<rules>".$end_of_line;
     1736                                $extra_indent = $indent.$indent.$indent.$indent;
     1737                        }
     1738
     1739                        $rules .= $extra_indent."<rule name=\"wordpress\" patternSyntax=\"Wildcard\">".$end_of_line;
     1740                        $rules .= $extra_indent.$indent."<match url=\"*\" />".$end_of_line;
     1741                        $rules .= $extra_indent.$indent.$indent."<conditions>".$end_of_line;
     1742                        $rules .= $extra_indent.$indent.$indent.$indent."<add input=\"{REQUEST_FILENAME}\" matchType=\"IsFile\" negate=\"true\" />".$end_of_line;
     1743                        $rules .= $extra_indent.$indent.$indent.$indent."<add input=\"{REQUEST_FILENAME}\" matchType=\"IsDirectory\" negate=\"true\" />".$end_of_line;
     1744                        $rules .= $extra_indent.$indent.$indent."</conditions>".$end_of_line;
     1745                        $rules .= $extra_indent.$indent."<action type=\"Rewrite\" url=\"index.php\" />".$end_of_line;
     1746                        $rules .= $extra_indent."</rule>";
     1747
     1748                        if ( $add_parent_tags ) {
     1749                                $rules .= $end_of_line.$indent.$indent.$indent."</rules>".$end_of_line;
     1750                                $rules .= $indent.$indent."</rewrite>".$end_of_line;
     1751                                $rules .= $indent."</system.webServer>".$end_of_line;
     1752                                $rules .= "</configuration>";
     1753                        }
     1754                } else {
     1755                        $rules = '<rule name="wordpress - strip index.php" stopProcessing="false">
     1756                            <match url="^index.php/(.*)$" />
     1757                            <action type="Rewrite" url="{R:1}" />
     1758                        </rule>
     1759                        <rule name="wordpress - 1" stopProcessing="true">
     1760                            <match url="^(.*/)?files/$" />
     1761                            <action type="Rewrite" url="index.php" />
     1762                        </rule>
     1763                        <rule name="wordpress - 2" stopProcessing="true">
     1764                            <match url="^(.*/)?files/(.*)" />
     1765                            <conditions>
     1766                                <add input="{REQUEST_URI}" negate="true" pattern=".*wp-content/plugins.*"/>
     1767                            </conditions>
     1768                            <action type="Rewrite" url="wp-content/blogs.php?file={R:2}" appendQueryString="false" />
     1769                        </rule>
     1770                        <rule name="wordpress - 3" stopProcessing="true">
     1771                            <match url="^(.+)$" />
     1772                            <conditions>
     1773                                <add input="{REQUEST_URI}" pattern="^.*/wp-admin$" />
     1774                            </conditions>
     1775                            <action type="Redirect" url="{R:1}/" redirectType="Permanent" />
     1776                        </rule>
     1777                        <rule name="wordpress - 4" stopProcessing="true">
     1778                            <match url="."/>
     1779                            <conditions logicalGrouping="MatchAny">
     1780                                <add input="{REQUEST_FILENAME}" matchType="IsFile" pattern="" />
     1781                                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" pattern="" />
     1782                            </conditions>
     1783                            <action type="None" />
     1784                        </rule>
     1785                        <rule name="wordpress - 5" stopProcessing="true">
     1786                            <match url="^([_0-9a-zA-Z-]+/)?(wp-.*)" />
     1787                            <action type="Rewrite" url="{R:2}" />
     1788                        </rule>
     1789                        <rule name="wordpress - 6" stopProcessing="true">
     1790                            <match url="^([_0-9a-zA-Z-]+/)?(.*\.php)$" />
     1791                            <action type="Rewrite" url="{R:2}" />
     1792                        </rule>
     1793                        <rule name="wordpress - 7" stopProcessing="true">
     1794                            <match url="." />
     1795                            <action type="Rewrite" url="index.php" />
     1796                        </rule>';
     1797                }
    17531798
    17541799                $rules = apply_filters('iis7_url_rewrite_rules', $rules);
  • trunk/wp-includes/taxonomy.php

    r12693 r12697  
    14181418
    14191419        if ( ! $term_id = is_term($slug) ) {
    1420                 if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) )
    1421                         return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error);
    1422                 $term_id = (int) $wpdb->insert_id;
     1420                if ( !is_multisite() ) {
     1421                        if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) )
     1422                                return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error);
     1423                        $term_id = (int) $wpdb->insert_id;
     1424                } else {
     1425                        $maxterm = $wpdb->get_var( "SELECT max(term_id) FROM {$wpdb->terms}" );
     1426                        $term_id = mt_rand( $maxterm+100, $maxterm+4000 );
     1427                        if ( false === $wpdb->insert( $wpdb->terms, compact( 'term_id', 'name', 'slug', 'term_group' ) ) )
     1428                                return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error);
     1429                }
    14231430        } else if ( is_taxonomy_hierarchical($taxonomy) && !empty($parent) ) {
    14241431                // If the taxonomy supports hierarchy and the term has a parent, make the slug unique
    14251432                // by incorporating parent slugs.
    1426                 $slug = wp_unique_term_slug($slug, (object) $args);
    1427                 if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) )
    1428                         return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error);
    1429                 $term_id = (int) $wpdb->insert_id;
     1433                $slug = wp_unique_term_slug($slug, (object) $args);
     1434                if( !is_multisite() ) {
     1435                        if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) )
     1436                                return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error);
     1437                        $term_id = (int) $wpdb->insert_id;
     1438                } else {
     1439                        $maxterm = $wpdb->get_var( "SELECT max(term_id) FROM {$wpdb->terms}" );
     1440                        $term_id = mt_rand( $maxterm+100, $maxterm+4000 );
     1441                        if ( false === $wpdb->insert( $wpdb->terms, compact( 'term_id','name', 'slug', 'term_group' ) ) )
     1442                                return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error);
     1443                }
    14301444        }
    14311445
  • trunk/wp-includes/user.php

    r12616 r12697  
    280280        if ( empty($id) )
    281281                $id = (int) $blog_id;
    282         $users = $wpdb->get_results( "SELECT user_id, user_id AS ID, user_login, display_name, user_email, meta_value FROM $wpdb->users, $wpdb->usermeta WHERE {$wpdb->users}.ID = {$wpdb->usermeta}.user_id AND meta_key = '{$wpdb->prefix}capabilities' ORDER BY {$wpdb->usermeta}.user_id" );
     282        $blog_prefix = $wpdb->get_blog_prefix($id);
     283        $users = $wpdb->get_results( "SELECT user_id, user_id AS ID, user_login, display_name, user_email, meta_value FROM $wpdb->users, $wpdb->usermeta WHERE {$wpdb->users}.ID = {$wpdb->usermeta}.user_id AND meta_key = '{$blog_prefix}capabilities' ORDER BY {$wpdb->usermeta}.user_id" );
    283284        return $users;
    284285}
  • trunk/wp-login.php

    r12666 r12697  
    4040 */
    4141function login_header($title = 'Log In', $message = '', $wp_error = '') {
    42         global $error, $is_iphone, $interim_login;
     42        global $error, $is_iphone, $interim_login, $current_site;
    4343
    4444        // Don't index any of these forms
     
    7575</head>
    7676<body class="login">
    77 
     77<?php   if( !is_multisite() ) { ?>
    7878<div id="login"><h1><a href="<?php echo apply_filters('login_headerurl', 'http://wordpress.org/'); ?>" title="<?php echo apply_filters('login_headertitle', __('Powered by WordPress')); ?>"><?php bloginfo('name'); ?></a></h1>
    79 <?php
     79<?php   } else { ?>
     80<div id="login"><h1><a href="<?php echo apply_filters('login_headerurl', 'http://' . $current_site->domain . $current_site->path ); ?>" title="<?php echo apply_filters('login_headertitle', $current_site->site_name ); ?>"><span class="hide"><?php bloginfo('name'); ?></span></a></h1>
     81<?php   }
     82
    8083        $message = apply_filters('login_message', $message);
    8184        if ( !empty( $message ) ) echo $message . "\n";
     
    114117 */
    115118function retrieve_password() {
    116         global $wpdb;
     119        global $wpdb, $current_site;
    117120
    118121        $errors = new WP_Error();
     
    163166        }
    164167        $message = __('Someone has asked to reset the password for the following site and username.') . "\r\n\r\n";
    165         $message .= get_option('siteurl') . "\r\n\r\n";
     168        if( !is_multisite() ) {
     169                $message .= get_option('siteurl') . "\r\n\r\n";
     170        } else {
     171                $message .= 'http://' . trailingslashit( $current_site->domain . $current_site->path ) . "\r\n\r\n";
     172        }
    166173        $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
    167174        $message .= __('To reset your password visit the following address, otherwise just ignore this email and nothing will happen.') . "\r\n\r\n";
    168         $message .= site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login), 'login') . "\r\n";
     175        if( !is_multisite() ) {
     176                $message .= site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login), 'login') . "\r\n";
     177        } else {
     178                $message .= 'http://' . trailingslashit( $current_site->domain . $current_site->path ) . "wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login) . "\r\n";
     179        }
    169180
    170181        // The blogname option is escaped with esc_html on the way into the database in sanitize_option
     
    399410
    400411case 'register' :
     412        if( is_multisite() ) {
     413                // WPMU doesn't use this
     414                wp_redirect( apply_filters( 'wp_signup_location', get_bloginfo('wpurl') . '/wp-signup.php' ) );
     415                exit;
     416        }
    401417        if ( !get_option('users_can_register') ) {
    402418                wp_redirect('wp-login.php?registration=disabled');
Note: See TracChangeset for help on using the changeset viewer.