Add wp-admin/includes/ms-deprecated.php. Deprecate wpmu_checkAvailableSpace. Introduce is_upload_space_available(). see #11762

git-svn-id: https://develop.svn.wordpress.org/trunk@12824 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2010-01-25 19:46:24 +00:00
parent c01fb90ff1
commit e0254c7917
5 changed files with 101 additions and 51 deletions

View File

@ -55,7 +55,9 @@ require_once(ABSPATH . WPINC . '/registration.php');
require_once(ABSPATH . 'wp-admin/includes/deprecated.php');
/** WordPress Multi-Site support API */
if ( is_multisite() )
if ( is_multisite() ) {
require_once(ABSPATH . 'wp-admin/includes/ms.php');
require_once(ABSPATH . 'wp-admin/includes/ms-deprecated.php');
}
?>

View File

@ -1,4 +1,12 @@
<?php
/**
* Deprecated admin functions from past WordPress versions. You shouldn't use these
* globals and functions and look for the alternatives instead. The functions
* and globals will be removed in a later version.
*
* @package WordPress
* @subpackage Deprecated
*/
/**
* Calculates the new dimentions for a downsampled image.

View File

@ -1397,9 +1397,14 @@ jQuery(document).ready(function($){
<?php } ?>
</div>
<?php do_action('pre-upload-ui'); ?>
<?php
// Check quota for this blog if multisite
if ( is_multisite() && !is_upload_space_available() )
wp_die( __('Sorry, you must delete files before you can upload any more.') );
<?php if ( $flash ) : ?>
do_action('pre-upload-ui');
if ( $flash ) : ?>
<script type="text/javascript">
//<![CDATA[
var swfu;
@ -2229,4 +2234,3 @@ add_action('media_upload_file', 'media_upload_file');
add_filter('media_upload_gallery', 'media_upload_gallery');
add_filter('media_upload_library', 'media_upload_library');

View File

@ -0,0 +1,31 @@
<?php
/**
* Deprecated multisite admin functions from past WordPress versions. You shouldn't use these
* globals and functions and look for the alternatives instead. The functions
* and globals will be removed in a later version.
*
* @package WordPress
* @subpackage Deprecated
*/
/**
* @deprecated 3.0
*/
function wpmu_menu() {
_deprecated_function(__FUNCTION__, '3.0', '' );
// deprecated. See #11763
}
/**
* Determines if the available space defined by the admin has been exceeded by the user. Dies if it has.
* @deprecated 3.0
*/
function wpmu_checkAvailableSpace() {
_deprecated_function(__FUNCTION__, '3.0', 'is_upload_space_available' );
if ( !is_upload_space_available() )
wp_die( __('Sorry, you must delete files before you can upload any more.') );
}
?>

View File

@ -355,22 +355,65 @@ function get_site_allowed_themes() {
return $allowed_themes;
}
function get_space_allowed() {
$spaceAllowed = get_option("blog_upload_space");
if ( $spaceAllowed == false )
$spaceAllowed = get_site_option("blog_upload_space");
if ( empty($spaceAllowed) || !is_numeric($spaceAllowed) )
$spaceAllowed = 50;
/**
* Determines if there is any upload space left in the current blog's quota.
*
* @return bool True if space is available, false otherwise.
*/
function is_upload_space_available() {
if ( get_site_option( 'upload_space_check_disabled' ) )
return true;
return $spaceAllowed;
$space_allowed = get_space_allowed();
$dir_name = trailingslashit( BLOGUPLOADDIR );
if ( !(is_dir($dir_name) && is_readable($dir_name)) )
return true;
$dir = dir($dir_name);
$size = 0;
while ( $file = $dir->read() ) {
if ( $file != '.' && $file != '..' ) {
if ( is_dir( $dir_name . $file) ) {
$size += get_dirsize($dir_name . $file);
} else {
$size += filesize($dir_name . $file);
}
}
}
$dir->close();
$size = $size / 1024 / 1024;
if ( ($space_allowed - $size) <= 0 )
return false;
return true;
}
/**
* Returns the upload quota for the current blog.
*
* @return int Quota
*/
function get_space_allowed() {
$space_allowed = get_option('blog_upload_space');
if ( $space_allowed == false )
$space_allowed = get_site_option('blog_upload_space');
if ( empty($space_allowed) || !is_numeric($space_allowed) )
$space_allowed = 50;
return $space_allowed;
}
function display_space_usage() {
$space = get_space_allowed();
$used = get_dirsize( BLOGUPLOADDIR )/1024/1024;
if ($used > $space) $percentused = '100';
else $percentused = ( $used / $space ) * 100;
if ( $used > $space )
$percentused = '100';
else
$percentused = ( $used / $space ) * 100;
if ( $space > 1000 ) {
$space = number_format( $space / 1024 );
@ -459,40 +502,6 @@ function refresh_user_details($id) {
return $id;
}
/*
Determines if the available space defined by the admin has been exceeded by the user
*/
function wpmu_checkAvailableSpace() {
if ( get_site_option( 'upload_space_check_disabled' ) ) {
return true;
}
$spaceAllowed = get_space_allowed();
$dirName = trailingslashit( BLOGUPLOADDIR );
if (!(is_dir($dirName) && is_readable($dirName)))
return;
$dir = dir($dirName);
$size = 0;
while($file = $dir->read()) {
if ($file != '.' && $file != '..') {
if (is_dir( $dirName . $file)) {
$size += get_dirsize($dirName . $file);
} else {
$size += filesize($dirName . $file);
}
}
}
$dir->close();
$size = $size / 1024 / 1024;
if ( ($spaceAllowed - $size) <= 0 ) {
wp_die( __('Sorry, you must delete files before you can upload any more.') );
}
}
add_action('pre-upload-ui','wpmu_checkAvailableSpace');
function format_code_lang( $code = '' ) {
$code = strtolower(substr($code, 0, 2));
$lang_codes = array('aa' => 'Afar', 'ab' => 'Abkhazian', 'af' => 'Afrikaans', 'ak' => 'Akan', 'sq' => 'Albanian', 'am' => 'Amharic', 'ar' => 'Arabic', 'an' => 'Aragonese', 'hy' => 'Armenian', 'as' => 'Assamese', 'av' => 'Avaric', 'ae' => 'Avestan', 'ay' => 'Aymara', 'az' => 'Azerbaijani', 'ba' => 'Bashkir', 'bm' => 'Bambara', 'eu' => 'Basque', 'be' => 'Belarusian', 'bn' => 'Bengali', 'bh' => 'Bihari', 'bi' => 'Bislama', 'bs' => 'Bosnian', 'br' => 'Breton', 'bg' => 'Bulgarian', 'my' => 'Burmese', 'ca' => 'Catalan; Valencian', 'ch' => 'Chamorro', 'ce' => 'Chechen', 'zh' => 'Chinese', 'cu' => 'Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian; Old Church Slavonic', 'cv' => 'Chuvash', 'kw' => 'Cornish', 'co' => 'Corsican', 'cr' => 'Cree', 'cs' => 'Czech', 'da' => 'Danish', 'dv' => 'Divehi; Dhivehi; Maldivian', 'nl' => 'Dutch; Flemish', 'dz' => 'Dzongkha', 'en' => 'English', 'eo' => 'Esperanto', 'et' => 'Estonian', 'ee' => 'Ewe', 'fo' => 'Faroese', 'fj' => 'Fijian', 'fi' => 'Finnish', 'fr' => 'French', 'fy' => 'Western Frisian', 'ff' => 'Fulah', 'ka' => 'Georgian', 'de' => 'German', 'gd' => 'Gaelic; Scottish Gaelic', 'ga' => 'Irish', 'gl' => 'Galician', 'gv' => 'Manx', 'el' => 'Greek, Modern', 'gn' => 'Guarani', 'gu' => 'Gujarati', 'ht' => 'Haitian; Haitian Creole', 'ha' => 'Hausa', 'he' => 'Hebrew', 'hz' => 'Herero', 'hi' => 'Hindi', 'ho' => 'Hiri Motu', 'hu' => 'Hungarian', 'ig' => 'Igbo', 'is' => 'Icelandic', 'io' => 'Ido', 'ii' => 'Sichuan Yi', 'iu' => 'Inuktitut', 'ie' => 'Interlingue', 'ia' => 'Interlingua (International Auxiliary Language Association)', 'id' => 'Indonesian', 'ik' => 'Inupiaq', 'it' => 'Italian', 'jv' => 'Javanese', 'ja' => 'Japanese', 'kl' => 'Kalaallisut; Greenlandic', 'kn' => 'Kannada', 'ks' => 'Kashmiri', 'kr' => 'Kanuri', 'kk' => 'Kazakh', 'km' => 'Central Khmer', 'ki' => 'Kikuyu; Gikuyu', 'rw' => 'Kinyarwanda', 'ky' => 'Kirghiz; Kyrgyz', 'kv' => 'Komi', 'kg' => 'Kongo', 'ko' => 'Korean', 'kj' => 'Kuanyama; Kwanyama', 'ku' => 'Kurdish', 'lo' => 'Lao', 'la' => 'Latin', 'lv' => 'Latvian', 'li' => 'Limburgan; Limburger; Limburgish', 'ln' => 'Lingala', 'lt' => 'Lithuanian', 'lb' => 'Luxembourgish; Letzeburgesch', 'lu' => 'Luba-Katanga', 'lg' => 'Ganda', 'mk' => 'Macedonian', 'mh' => 'Marshallese', 'ml' => 'Malayalam', 'mi' => 'Maori', 'mr' => 'Marathi', 'ms' => 'Malay', 'mg' => 'Malagasy', 'mt' => 'Maltese', 'mo' => 'Moldavian', 'mn' => 'Mongolian', 'na' => 'Nauru', 'nv' => 'Navajo; Navaho', 'nr' => 'Ndebele, South; South Ndebele', 'nd' => 'Ndebele, North; North Ndebele', 'ng' => 'Ndonga', 'ne' => 'Nepali', 'nn' => 'Norwegian Nynorsk; Nynorsk, Norwegian', 'nb' => 'Bokmål, Norwegian, Norwegian Bokmål', 'no' => 'Norwegian', 'ny' => 'Chichewa; Chewa; Nyanja', 'oc' => 'Occitan, Provençal', 'oj' => 'Ojibwa', 'or' => 'Oriya', 'om' => 'Oromo', 'os' => 'Ossetian; Ossetic', 'pa' => 'Panjabi; Punjabi', 'fa' => 'Persian', 'pi' => 'Pali', 'pl' => 'Polish', 'pt' => 'Portuguese', 'ps' => 'Pushto', 'qu' => 'Quechua', 'rm' => 'Romansh', 'ro' => 'Romanian', 'rn' => 'Rundi', 'ru' => 'Russian', 'sg' => 'Sango', 'sa' => 'Sanskrit', 'sr' => 'Serbian', 'hr' => 'Croatian', 'si' => 'Sinhala; Sinhalese', 'sk' => 'Slovak', 'sl' => 'Slovenian', 'se' => 'Northern Sami', 'sm' => 'Samoan', 'sn' => 'Shona', 'sd' => 'Sindhi', 'so' => 'Somali', 'st' => 'Sotho, Southern', 'es' => 'Spanish; Castilian', 'sc' => 'Sardinian', 'ss' => 'Swati', 'su' => 'Sundanese', 'sw' => 'Swahili', 'sv' => 'Swedish', 'ty' => 'Tahitian', 'ta' => 'Tamil', 'tt' => 'Tatar', 'te' => 'Telugu', 'tg' => 'Tajik', 'tl' => 'Tagalog', 'th' => 'Thai', 'bo' => 'Tibetan', 'ti' => 'Tigrinya', 'to' => 'Tonga (Tonga Islands)', 'tn' => 'Tswana', 'ts' => 'Tsonga', 'tk' => 'Turkmen', 'tr' => 'Turkish', 'tw' => 'Twi', 'ug' => 'Uighur; Uyghur', 'uk' => 'Ukrainian', 'ur' => 'Urdu', 'uz' => 'Uzbek', 've' => 'Venda', 'vi' => 'Vietnamese', 'vo' => 'Volapük', 'cy' => 'Welsh', 'wa' => 'Walloon', 'wo' => 'Wolof', 'xh' => 'Xhosa', 'yi' => 'Yiddish', 'yo' => 'Yoruba', 'za' => 'Zhuang; Chuang', 'zu' => 'Zulu');
@ -553,10 +562,6 @@ function redirect_user_to_blog() {
}
add_action( 'admin_page_access_denied', 'redirect_user_to_blog', 99 );
function wpmu_menu() {
// deprecated. See #11763
}
function mu_options( $options ) {
if ( defined( 'POST_BY_EMAIL' ) ) {
$writing = array( 'ping_sites' );