summaryrefslogtreecommitdiffstats
path: root/wp-inst
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2005-12-15 11:32:08 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2005-12-15 11:32:08 +0000
commite683170d3363121819b9136323b5fd0454f6de79 (patch)
tree30d13e36eceb078e7d686a751cd7ff18772459b0 /wp-inst
parent919598da01b953b4948eab9dbbc12769ce702f5c (diff)
downloadwordpress-mu-e683170d3363121819b9136323b5fd0454f6de79.tar.gz
wordpress-mu-e683170d3363121819b9136323b5fd0454f6de79.tar.xz
wordpress-mu-e683170d3363121819b9136323b5fd0454f6de79.zip
WP Merge
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@468 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-inst')
-rw-r--r--wp-inst/wp-admin/inline-uploading.php194
-rw-r--r--wp-inst/wp-admin/users.php11
-rw-r--r--wp-inst/wp-content/themes/default/attachment.php18
-rw-r--r--wp-inst/wp-content/themes/default/style.css18
-rw-r--r--wp-inst/wp-includes/capabilities.php26
-rw-r--r--wp-inst/wp-includes/classes.php28
-rw-r--r--wp-inst/wp-includes/functions-post.php22
-rw-r--r--wp-inst/wp-includes/functions.php18
-rw-r--r--wp-inst/wp-includes/pluggable-functions.php6
-rw-r--r--wp-inst/wp-includes/template-functions-links.php11
-rw-r--r--wp-inst/wp-includes/template-functions-post.php120
-rw-r--r--wp-inst/wp-includes/version.php2
12 files changed, 368 insertions, 106 deletions
diff --git a/wp-inst/wp-admin/inline-uploading.php b/wp-inst/wp-admin/inline-uploading.php
index 26f86ee..053746c 100644
--- a/wp-inst/wp-admin/inline-uploading.php
+++ b/wp-inst/wp-admin/inline-uploading.php
@@ -25,20 +25,15 @@ for ($i=0; $i<count($wpvarstoreset); $i += 1) {
$post = (int) $post;
$images_width = 1;
-function get_udims($width, $height) {
- if ( $height <= 96 && $width <= 128 )
- return array($width, $height);
- elseif ( $width / $height > 4 / 3 )
- return array(128, (int) ($height / $width * 128));
- else
- return array((int) ($width / $height * 96), 96);
-}
-
switch($action) {
+case 'links':
+// Do not pass GO.
+break;
+
case 'delete':
if ( !current_user_can('edit_post', (int) $attachment) )
-die(__('You are not allowed to delete this attachment.').' <a href="'.basename(__FILE__)."?post=$post&amp;all=$all&amp;action=upload\">".__('Go back').'</a>');
+ die(__('You are not allowed to delete this attachment.').' <a href="'.basename(__FILE__)."?post=$post&amp;all=$all&amp;action=upload\">".__('Go back').'</a>');
wp_delete_attachment($attachment);
@@ -55,9 +50,10 @@ if( isset( $file[ 'error' ] ) == false )
$file[ 'error' ] = apply_filters( "check_uploaded_file", $file[ 'error' ] );
if ( isset($file['error']) )
- die($file['error'] . '<a href="' . basename(__FILE__) . '?action=upload&post="' . $post . '">'.__('Back to Image Uploading').'</a>');
+ die($file['error'] . '<br /><a href="' . basename(__FILE__) . '?action=upload&post=' . $post . '">'.__('Back to Image Uploading').'</a>');
$url = $file['url'];
+$type = $file['type'];
$file = $file['file'];
$filename = basename($file);
@@ -67,7 +63,7 @@ $attachment = array(
'post_content' => $descr,
'post_status' => 'attachment',
'post_parent' => $post,
- 'post_mime_type' => $_FILES['image']['type'],
+ 'post_mime_type' => $type,
'guid' => $url
);
@@ -82,21 +78,28 @@ if ( preg_match('!^image/!', $attachment['post_mime_type']) ) {
list($uwidth, $uheight) = get_udims($imagedata['width'], $imagedata['height']);
$imagedata['hwstring_small'] = "height='$uheight' width='$uwidth'";
$imagedata['file'] = $file;
- $imagedata['thumb'] = "thumb-$filename";
add_post_meta($id, '_wp_attachment_metadata', $imagedata);
if ( $imagedata['width'] * $imagedata['height'] < 3 * 1024 * 1024 ) {
if ( $imagedata['width'] > 128 && $imagedata['width'] >= $imagedata['height'] * 4 / 3 )
- $error = wp_create_thumbnail($file, 128);
+ $thumb = wp_create_thumbnail($file, 128);
elseif ( $imagedata['height'] > 96 )
- $error = wp_create_thumbnail($file, 96);
+ $thumb = wp_create_thumbnail($file, 96);
+
+ if ( @file_exists($thumb) ) {
+ $newdata = $imagedata;
+ $newdata['thumb'] = basename($thumb);
+ update_post_meta($id, '_wp_attachment_metadata', $newdata, $imagedata);
+ } else {
+ $error = $thumb;
+ }
}
} else {
add_post_meta($id, '_wp_attachment_metadata', array());
}
-header("Location: ".basename(__FILE__)."?post=$post&all=$all&action=view&last=true");
+header("Location: ".basename(__FILE__)."?post=$post&all=$all&action=view&start=0");
die();
case 'upload':
@@ -111,7 +114,7 @@ case 'view':
$num = 5;
$double = $num * 2;
-if ( $post && empty($all) ) {
+if ( $post && (empty($all) || $all == 'false') ) {
$and_post = "AND post_parent = '$post'";
$current_2 = ' class="current"';
} else {
@@ -165,6 +168,9 @@ if ( count($attachments) > 0 ) {
$__linked_to_file = __('Linked to File');
$__using_thumbnail = __('Using Thumbnail');
$__using_original = __('Using Original');
+ $__using_title = __('Using Title');
+ $__using_filename = __('Using Filename');
+ $__using_icon = __('Using Icon');
$__no_thumbnail = '<del>'.__('No Thumbnail').'</del>';
$__send_to_editor = __('Send to editor');
$__close = __('Close Options');
@@ -176,12 +182,18 @@ linkedtopage = '$__linked_to_page';
linkedtofile = '$__linked_to_file';
usingthumbnail = '$__using_thumbnail';
usingoriginal = '$__using_original';
+usingtitle = '$__using_title';
+usingfilename = '$__using_filename';
+usingicon = '$__using_icon';
var aa = new Array();
var ab = new Array();
var imga = new Array();
var imgb = new Array();
var srca = new Array();
var srcb = new Array();
+var title = new Array();
+var filename = new Array();
+var icon = new Array();
";
foreach ( $attachments as $key => $attachment ) {
$ID = $attachment['ID'];
@@ -195,6 +207,10 @@ var srcb = new Array();
add_post_meta($ID, '_wp_attachment_metadata', $meta);
}
$attachment = array_merge($attachment, $meta);
+ $noscript = "<noscript>
+ <div class='caption'><a href=\"".basename(__FILE__)."?action=links&amp;attachment={$ID}&amp;post={$post}&amp;all={$all}&amp;start={$start}\">Choose Links</a></div>
+ </noscript>
+";
$send_delete_cancel = "<a onclick=\"sendToEditor({$ID});return false;\" href=\"javascript:void()\">$__send_to_editor</a>
<a onclick=\"return confirm('$__confirmdelete')\" href=\"".basename(__FILE__)."?action=delete&amp;attachment={$ID}&amp;all=$all&amp;start=$start&amp;post=$post\">$__delete</a>
<a onclick=\"popup.style.display='none';return false;\" href=\"javascript:void()\">$__close</a>
@@ -228,6 +244,7 @@ imgb[{$ID}] = '<img id=\"image{$ID}\" src=\"{$image['guid']}\" alt=\"{$image['po
<div id='div{$ID}' class='imagewrap' onclick=\"doPopup({$ID});\">
<img id=\"image{$ID}\" src=\"$src\" alt=\"{$image['post_title']}\" $height_width />
</div>
+ {$noscript}
</div>
";
$popups .= "<div id='popup{$ID}' class='popup'>
@@ -237,18 +254,27 @@ imgb[{$ID}] = '<img id=\"image{$ID}\" src=\"{$image['guid']}\" alt=\"{$image['po
</div>
";
} else {
- $script .= "aa[{$ID}] = '<a id=\"{$ID}\" rel=\"attachment\" href=\"$href\" onclick=\"doPopup({$ID});return false;\" title=\"{$attachment['post_title']}\">{$attachment['post_title']}</a>';
-ab[{$ID}] = '<a id=\"{$ID}\" href=\"{$attachment['guid']}\" onclick=\"doPopup({$ID});return false;\" title=\"{$attachment['post_title']}\">{$attachment['post_title']}</a>';
+ $title = $attachment['post_title'];
+ $filename = basename($attachment['guid']);
+ $icon = get_attachment_icon($ID);
+ $toggle_icon = "<a id=\"I{$ID}\" onclick=\"toggleOtherIcon({$ID});return false;\" href=\"javascript:void()\">$__using_title</a>";
+ $script .= "aa[{$ID}] = '<a id=\"{$ID}\" rel=\"attachment\" href=\"$href\" onclick=\"doPopup({$ID});return false;\" title=\"{$title}\">{$attachment['post_title']}</a>';
+ab[{$ID}] = '<a id=\"{$ID}\" href=\"{$filename}\" onclick=\"doPopup({$ID});return false;\" title=\"{$title}\">{$attachment['post_title']}</a>';
+title[{$ID}] = '{$attachment['post_title']}';
+filename[{$ID}] = '{$filename}';
+icon[{$ID}] = '{$icon}';
";
$html .= "<div id='target{$ID}' class='attwrap left'>
- <div id='div{$ID}' class='otherwrap' onmousedown=\"selectLink({$ID})\" onclick=\"doPopup({$ID});return false;\">
+ <div id='div{$ID}' class='otherwrap usingtext' onmousedown=\"selectLink({$ID})\" onclick=\"doPopup({$ID});return false;\">
<a id=\"{$ID}\" href=\"{$attachment['guid']}\" onmousedown=\"selectLink({$ID});\" onclick=\"return false;\">{$attachment['post_title']}</a>
</div>
+ {$noscript}
</div>
";
$popups .= "<div id='popup{$ID}' class='popup'>
- <div class='filetype'>File Type: ".str_replace('/',"/\n",$attachment['post_mime_type'])."</div>
+ <div class='filetype'>".__('File Type:').' '.str_replace('/',"/\n",$attachment['post_mime_type'])."</div>
<a id=\"L{$ID}\" onclick=\"toggleOtherLink({$ID});return false;\" href=\"javascript:void()\">$__linked_to_file</a>
+ {$toggle_icon}
{$send_delete_cancel}
</div>
";
@@ -323,6 +349,8 @@ function toggleLink(n) {
function toggleOtherLink(n) {
od=document.getElementById('div'+n);
ol=document.getElementById('L'+n);
+ oi=document.getElementById(n);
+ ih=oi.innerHTML;
if ( ol.innerHTML == linkedtofile ) {
od.innerHTML = aa[n];
ol.innerHTML = linkedtopage;
@@ -330,6 +358,8 @@ function toggleOtherLink(n) {
od.innerHTML = ab[n];
ol.innerHTML = linkedtofile;
}
+ oi=document.getElementById(n);
+ oi.innerHTML = ih;
}
function toggleImage(n) {
o = document.getElementById('image'+n);
@@ -342,6 +372,25 @@ function toggleImage(n) {
oi.innerHTML = usingthumbnail;
}
}
+function toggleOtherIcon(n) {
+ od = document.getElementById('div'+n);
+ o = document.getElementById(n);
+ oi = document.getElementById('I'+n);
+ if ( oi.innerHTML == usingtitle ) {
+ o.innerHTML = filename[n];
+ oi.innerHTML = usingfilename;
+ } else if ( oi.innerHTML == usingfilename && icon[n] != '' ) {
+ o.innerHTML = icon[n];
+ oi.innerHTML = usingicon;
+ } else {
+ o.innerHTML = title[n];
+ oi.innerHTML = usingtitle;
+ }
+ if ( oi.innerHTML == usingicon )
+ od.className = 'otherwrap usingicon';
+ else
+ od.className = 'otherwrap usingtext';
+}
var win = window.opener ? window.opener : window.dialogArguments;
if (!win) win = top;
@@ -362,6 +411,11 @@ function sendToEditor(n) {
}
</script>
<style type="text/css">
+<?php if ( $action == 'links' ) : ?>
+* html { overflow-x: hidden; }
+<?php else : ?>
+* html { overflow-y: hidden; }
+<?php endif; ?>
body {
font: 13px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana;
border: none;
@@ -382,8 +436,6 @@ form {
clear: both;
margin: 0px;
padding: 15px 15px;
- height: 96px;
-/* white-space: nowrap;*/
width: <?php echo $images_width; ?>px;
}
#images img {
@@ -391,32 +443,42 @@ form {
}
<?php echo $style; ?>
.attwrap, .attwrap * {
- overflow: none;
margin: 0px;
padding: 0px;
border: 0px;
}
.imagewrap {
margin-right: 5px;
- height: 96px;
overflow: hidden;
- float: left;
+ width: 128px;
}
.otherwrap {
margin-right: 5px;
- height: 90px;
overflow: hidden;
background-color: #f9fcfe;
- float: left;
- padding: 3px;
}
.otherwrap a {
display: block;
- width: 122px;
}
.otherwrap a, .otherwrap a:hover, .otherwrap a:active, .otherwrap a:visited {
color: blue;
}
+.usingicon {
+ padding: 0px;
+ height: 96px;
+ text-align: center;
+ width: 128px;
+}
+.usingicon a {
+}
+.usingtext {
+ padding: 3px;
+ height: 90px;
+ text-align: left;
+ width: 122px;
+}
+.usingtext a {
+}
.filetype {
font-size: 80%;
border-bottom: 3px double #89a
@@ -480,9 +542,12 @@ form {
margin-left: 40px;
}
#title, #descr {
- width: 100%;
+ width: 99%;
margin-top: 1px;
}
+th {
+ width: 4.5em;
+}
#descr {
height: 36px;
}
@@ -492,12 +557,15 @@ form {
}
.popup {
margin: 4px 4px;
- padding: 3px;
+ padding: 1px;
position: absolute;
width: 114px;
- height: 82px;
display: none;
- background-color: rgb(223, 232, 241);
+ background-color: rgb(240, 240, 238);
+ border-top: 2px solid #fff;
+ border-right: 2px solid #ddd;
+ border-bottom: 2px solid #ddd;
+ border-left: 2px solid #fff;
text-align: center;
}
.imagewrap .popup {
@@ -518,19 +586,56 @@ form {
background-color: #fff;
color: #000;
}
+.caption {
+ text-align: center;
+}
+#submit {
+ margin: 1px;
+ width: 99%;
+}
+#submit input, #submit input:focus {
+ background: url( images/fade-butt.png );
+ border: 3px double #999;
+ border-left-color: #ccc;
+ border-top-color: #ccc;
+ color: #333;
+ padding: 0.25em;
+}
+
+#submit input:active {
+ background: #f4f4f4;
+ border: 3px double #ccc;
+ border-left-color: #999;
+ border-top-color: #999;
+}
+.zerosize {
+ width: 0px;
+ height: 0px;
+ overflow: hidden;
+ position: absolute;
+}
+#links {
+ margin: 3px 8px;
+ line-height: 2em;
+
+}
+#links textarea {
+ width: 95%;
+ height: 4.5em;
+}
</style>
</head>
<body>
<ul id="upload-menu">
-<li<?php echo $current_1; ?>><a href="<?php echo basename(__FILE__); ?>?action=upload&amp;post=<?php echo $post; ?>&amp;all=<?php echo $all; ?>"><?php _e('Upload'); ?></a></li>
+<li<?php echo $current_1; ?>><a href="<?php echo basename(__FILE__); ?>?action=upload&amp;post=<?php echo $post; ?>&amp;all=<?php echo $all; ?>&amp;start=<?php echo $start; ?>"><?php _e('Upload'); ?></a></li>
<?php if ( $attachments = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE post_parent = '$post'") ) { ?>
-<li<?php echo $current_2; ?>><a href="<?php echo basename(__FILE__); ?>?action=view&amp;post=<?php echo $post; ?>"><?php _e('Browse'); ?></a></li>
+<li<?php echo $current_2; ?>><a href="<?php echo basename(__FILE__); ?>?action=view&amp;post=<?php echo $post; ?>&amp;all=false"><?php _e('Browse'); ?></a></li>
<?php } ?>
<?php if ($wpdb->get_var("SELECT count(ID) FROM $wpdb->posts WHERE post_status = 'attachment'")) { ?>
<li<?php echo $current_3; ?>><a href="<?php echo basename(__FILE__); ?>?action=view&amp;post=<?php echo $post; ?>&amp;all=true"><?php _e('Browse All'); ?></a></li>
<?php } ?>
<li> </li>
-<?php if ( $action != 'upload' ) { ?>
+<?php if ( $action == 'view' ) { ?>
<?php if ( false !== $back ) : ?>
<li class="spacer"><a href="<?php echo basename(__FILE__); ?>?action=<?php echo $action; ?>&amp;post=<?php echo $post; ?>&amp;all=<?php echo $all; ?>&amp;start=0" title="<?php _e('First'); ?>">|&laquo;</a></li>
<li><a href="<?php echo basename(__FILE__); ?>?action=<?php echo $action; ?>&amp;post=<?php echo $post; ?>&amp;all=<?php echo $all; ?>&amp;start=<?php echo $back; ?>"">&laquo; <?php _e('Back'); ?></a></li>
@@ -563,15 +668,15 @@ form {
<form enctype="multipart/form-data" id="uploadForm" method="POST" action="<?php echo basename(__FILE__); ?>">
<table style="width:99%;">
<tr>
-<th scope="row" style="width: 4.5em;text-align: right;"><label for="upload"><?php _e('File:'); ?></label></th>
+<th scope="row" align="right"><label for="upload"><?php _e('File:'); ?></label></th>
<td><input type="file" id="upload" name="image" /></td>
</tr>
<tr>
-<th scope="row" style="text-align: right;"><label for="title"><?php _e('Title:'); ?></label></th>
+<th scope="row" align="right"><label for="title"><?php _e('Title:'); ?></label></th>
<td><input type="text" id="title" name="imgtitle" /></td>
</tr>
<tr>
-<th scope="row" style="text-align: right;"><label for="descr"><?php _e('Description:'); ?></label></th>
+<th scope="row" align="right"><label for="descr"><?php _e('Description:'); ?></label></th>
<td><input type="textarea" name="descr" id="descr" value="" /></td>
</tr>
<tr id="buttons">
@@ -580,14 +685,23 @@ form {
<input type="hidden" name="action" value="save" />
<input type="hidden" name="post" value="<?php echo $post; ?>" />
<input type="hidden" name="all" value="<?php echo $all; ?>" />
+<input type="hidden" name="start" value="<?php echo $start; ?>" />
+<div id="submit">
<input type="submit" value="<?php _e('Upload'); ?>" />
+<?php if ( !empty($all) ) : ?>
<input type="button" value="<?php _e('Cancel'); ?>" onclick="cancelUpload()" />
+<?php endif; ?>
+</div>
</td>
</tr>
</table>
</div>
</form>
<?php } ?>
+<?php elseif ( $action == 'links' ) : ?>
+<div id="links">
+<?php the_attachment_links($attachment); ?>
+</div>
<?php endif; ?>
</body>
</html>
diff --git a/wp-inst/wp-admin/users.php b/wp-inst/wp-admin/users.php
index c0f20b9..cc55573 100644
--- a/wp-inst/wp-admin/users.php
+++ b/wp-inst/wp-admin/users.php
@@ -41,11 +41,7 @@ case 'dodelete':
check_admin_referer();
- if( is_site_admin() == false ) {
- header('Location: users.php?update=del');
- exit;
- }
- if ( empty($_POST['users']) ) {
+ if (empty($_POST['users'])) {
header('Location: users.php');
}
@@ -76,11 +72,6 @@ break;
case 'delete':
- if( is_site_admin() == false ) {
- header('Location: users.php');
- exit;
- }
-
check_admin_referer();
if (empty($_POST['users'])) {
diff --git a/wp-inst/wp-content/themes/default/attachment.php b/wp-inst/wp-content/themes/default/attachment.php
index 6a31a61..559a8e4 100644
--- a/wp-inst/wp-content/themes/default/attachment.php
+++ b/wp-inst/wp-content/themes/default/attachment.php
@@ -11,22 +11,8 @@
<div class="post" id="post-<?php the_ID(); ?>">
<h2><a href="<?php echo get_permalink($post->post_parent); ?>" rev="attachment"><?php echo get_the_title($post->post_parent); ?></a> &raquo; <a href="<?php echo get_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a></h2>
<div class="entrytext">
-<?php $type = explode('/', $post->post_mime_type);
- switch ( $type[0] ) {
- case 'image' :
- $meta = get_post_meta($post->ID, '_wp_attachment_metadata', true);
- if ($meta['width'] > 450) : ?>
- <p><a href="<?php echo $post->guid; ?>" title="<?php echo $post->post_title.': '.$meta['width'].'x'.$meta['height'] ?>"><img class="centered" src="<?php echo $post->guid; ?>" alt="<?php the_title(); ?>" style="width:450px;" /></a></p>
-<?php else : ?>
- <p><img class="centered" src="<?php echo $post->guid; ?>" alt="<?php the_title(); ?>" /></p>
-<?php endif;
- break;
- default :
-?>
- <p><a href="<?php echo $post->guid; ?>"><?php echo basename($post->guid); ?></a></p>
-<?php
- }
-?>
+ <p class="<?php $link = get_the_attachment_link($post->ID, true, array(450, 800)); /* Doing this now populates the imagesize stuff */ echo $post->iconsize[0] <= 128 ? 'small' : ''; ?>attachment"><?php echo get_the_attachment_link($post->ID, true, array(450, 800)); ?><br /><?php echo basename($post->guid); ?></p>
+
<?php the_content('<p class="serif">Read the rest of this entry &raquo;</p>'); ?>
<?php link_pages('<p><strong>Pages:</strong> ', '</p>', 'number'); ?>
diff --git a/wp-inst/wp-content/themes/default/style.css b/wp-inst/wp-content/themes/default/style.css
index 820c993..8d5a730 100644
--- a/wp-inst/wp-content/themes/default/style.css
+++ b/wp-inst/wp-content/themes/default/style.css
@@ -263,7 +263,23 @@ body {
.widecolumn .postmetadata {
margin: 30px 0;
}
-
+
+.widecolumn .smallattachment {
+ text-align: center;
+ float: left;
+ width: 128px;
+ margin: 5px 5px 5px 0px;
+}
+
+.widecolumn .attachment {
+ text-align: center;
+ margin: 5px 0px;
+}
+
+.postmetadata {
+ clear: left;
+}
+
#footer {
padding: 0 0 0 1px;
margin: 0 auto;
diff --git a/wp-inst/wp-includes/capabilities.php b/wp-inst/wp-includes/capabilities.php
index 2782df1..1c33503 100644
--- a/wp-inst/wp-includes/capabilities.php
+++ b/wp-inst/wp-includes/capabilities.php
@@ -97,8 +97,9 @@ class WP_Role {
}
function has_cap($cap) {
- if ( !empty($this->capabilities[$cap]) )
- return $this->capabilities[$cap];
+ $capabilities = apply_filters('role_has_cap', $this->capabilities, $cap, $this->name);
+ if ( !empty($capabilities[$cap]) )
+ return $capabilities[$cap];
else
return false;
}
@@ -116,6 +117,9 @@ class WP_User {
function WP_User($id) {
global $wp_roles, $table_prefix;
+ if ( empty($id) )
+ return;
+
if ( is_numeric($id) ) {
$this->data = get_userdata($id);
} else {
@@ -215,9 +219,10 @@ class WP_User {
$args = array_merge(array($cap, $this->id), $args);
$caps = call_user_func_array('map_meta_cap', $args);
// Must have ALL requested caps
+ $capabilities = apply_filters('user_has_cap', $this->allcaps, $caps, $args);
foreach ($caps as $cap) {
//echo "Checking cap $cap<br/>";
- if(empty($this->allcaps[$cap]) || !$this->allcaps[$cap])
+ if(empty($capabilities[$cap]) || !$capabilities[$cap])
return false;
}
@@ -267,6 +272,21 @@ function map_meta_cap($cap, $user_id) {
$caps[] = 'edit_published_posts';
}
break;
+ case 'read_post':
+ $post = get_post($args[0]);
+
+ if ( 'private' != $post->post_status ) {
+ $caps[] = 'read';
+ break;
+ }
+
+ $author_data = get_userdata($user_id);
+ $post_author_data = get_userdata($post->post_author);
+ if ($user_id == $post_author_data->ID)
+ $caps[] = 'read';
+ else
+ $caps[] = 'read_private_posts';
+ break;
default:
// If no meta caps match, return the original cap.
$caps[] = $cap;
diff --git a/wp-inst/wp-includes/classes.php b/wp-inst/wp-includes/classes.php
index d4fcc07..b7b31b6 100644
--- a/wp-inst/wp-includes/classes.php
+++ b/wp-inst/wp-includes/classes.php
@@ -97,12 +97,10 @@ class WP_Query {
if ( '' != $qv['subpost_id'] )
$qv['attachment_id'] = $qv['subpost_id'];
- if ( ('' != $qv['attachment']) || $qv['attachment_id'] ) {
+ if ( ('' != $qv['attachment']) || (int) $qv['attachment_id'] ) {
$this->is_single = true;
$this->is_attachment = true;
- }
-
- if ('' != $qv['name']) {
+ } elseif ('' != $qv['name']) {
$this->is_single = true;
} elseif ( $qv['p'] ) {
$this->is_single = true;
@@ -115,6 +113,14 @@ class WP_Query {
$this->is_single = false;
} elseif (!empty($qv['s'])) {
$this->is_search = true;
+ switch ($qv['show_post_type']) {
+ case 'page' :
+ $this->is_page = true;
+ break;
+ case 'attachment' :
+ $this->is_attachment = true;
+ break;
+ }
} else {
// Look for archive queries. Dates, categories, authors.
@@ -198,6 +204,10 @@ class WP_Query {
if ( ($this->is_date || $this->is_author || $this->is_category)) {
$this->is_archive = true;
}
+
+ if ( 'attachment' == $qv['show_post_type'] ) {
+ $this->is_attachment = true;
+ }
}
if ('' != $qv['feed']) {
@@ -643,8 +653,8 @@ class WP_Query {
} else {
$this->is_preview = true;
}
- } elseif ('private' == $status) {
- if ($this->posts[0]->post_author != $user_ID)
+ } else {
+ if (! current_user_can('read_post', $this->posts[0]->ID))
$this->posts = array();
}
}
@@ -658,13 +668,13 @@ class WP_Query {
}
}
+ update_post_caches($this->posts);
+
$this->posts = apply_filters('the_posts', $this->posts);
$this->post_count = count($this->posts);
if ($this->post_count > 0) {
$this->post = $this->posts[0];
}
-
- update_post_caches($this->posts);
// Save any changes made to the query vars.
$this->query_vars = $q;
@@ -1413,7 +1423,7 @@ class WP_Rewrite {
class WP {
var $public_query_vars = 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', 'attachment', 'attachment_id', 'subpost', 'subpost_id');
- var $private_query_vars = array('posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging');
+ var $private_query_vars = array('posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging', 'show_post_type');
var $query_vars;
var $query_string;
diff --git a/wp-inst/wp-includes/functions-post.php b/wp-inst/wp-includes/functions-post.php
index 91e1ac1..38c7540 100644
--- a/wp-inst/wp-includes/functions-post.php
+++ b/wp-inst/wp-includes/functions-post.php
@@ -208,12 +208,12 @@ function wp_insert_post($postarr = array()) {
return $post_ID;
}
-function wp_insert_attachment($object, $file, $post_parent = 0) {
+function wp_insert_attachment($object, $file = false, $post_parent = 0) {
global $wpdb, $user_ID;
if ( is_object($object) )
$object = get_object_vars($object);
-
+
// Export array as variables
extract($object);
@@ -320,7 +320,8 @@ function wp_insert_attachment($object, $file, $post_parent = 0) {
wp_set_post_cats('', $post_ID, $post_category);
- add_post_meta($post_ID, '_wp_attached_file', $file);
+ if ( $file )
+ add_post_meta($post_ID, '_wp_attached_file', $file);
clean_post_cache($post_ID);
@@ -343,7 +344,7 @@ function wp_delete_attachment($postid) {
if ( 'attachment' != $post->post_status )
return false;
- $meta = get_post_meta($postid, 'imagedata', true);
+ $meta = get_post_meta($postid, '_wp_attachment_metadata', true);
$file = get_post_meta($postid, '_wp_attached_file', true);
$wpdb->query("DELETE FROM $wpdb->posts WHERE ID = $postid");
@@ -354,8 +355,11 @@ function wp_delete_attachment($postid) {
$wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = $postid");
- if ( ! empty($meta['file']) )
- @ unlink($meta['file']);
+ if ( ! empty($meta['thumb']) ) {
+ // Don't delete the thumb if another attachment uses it
+ if (! $foo = $wpdb->get_row("SELECT meta_id FROM $wpdb->postmeta WHERE meta_key = '_wp_attachment_metadata' AND meta_value LIKE '%".$wpdb->escape($meta['thumb'])."%' AND post_id <> $postid"))
+ @ unlink(str_replace(basename($file), $meta['thumb'], $file));
+ }
if ( ! empty($file) )
@ unlink($file);
@@ -429,6 +433,9 @@ function wp_update_post($postarr = array()) {
$postarr['post_date_gmt'] = '';
}
+ if ($postarr['post_status'] == 'attachment')
+ return wp_insert_attachment($postarr);
+
return wp_insert_post($postarr);
}
@@ -511,6 +518,9 @@ function wp_delete_post($postid = 0) {
if ( !$post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = $postid") )
return $post;
+ if ( 'attachment' == $post->post_status )
+ return wp_delete_attachment($postid);
+
do_action('delete_post', $postid);
if ( 'publish' == $post->post_status) {
diff --git a/wp-inst/wp-includes/functions.php b/wp-inst/wp-includes/functions.php
index e2b3b78..f9d2eeb 100644
--- a/wp-inst/wp-includes/functions.php
+++ b/wp-inst/wp-includes/functions.php
@@ -305,12 +305,18 @@ function get_option($option) {
return get_settings($option);
}
-function get_user_option( $option ) {
+function get_user_option( $option, $user = 0 ) {
global $wpdb, $current_user;
- if ( isset( $current_user->{$wpdb->prefix . $option} ) ) // Blog specific
- return $current_user->{$wpdb->prefix . $option};
- elseif ( isset( $current_user->{$option} ) ) // User specific and cross-blog
- return $current_user->{$option};
+
+ if ( empty($user) )
+ $user = $current_user;
+ else
+ $user = get_userdata($user);
+
+ if ( isset( $user->{$wpdb->prefix . $option} ) ) // Blog specific
+ return $user->{$wpdb->prefix . $option};
+ elseif ( isset( $user->{$option} ) ) // User specific and cross-blog
+ return $user->{$option};
else // Blog global
return get_option( $option );
}
@@ -502,7 +508,7 @@ function update_post_meta($post_id, $key, $value, $prev_value = '') {
$original_prev = $prev_value;
if ( is_array($prev_value) || is_object($prev_value) )
- $prev_value = serialize($value);
+ $prev_value = $wpdb->escape(serialize($prev_value));
if (! $wpdb->get_var("SELECT meta_key FROM $wpdb->postmeta WHERE meta_key
= '$key' AND post_id = '$post_id'") ) {
diff --git a/wp-inst/wp-includes/pluggable-functions.php b/wp-inst/wp-includes/pluggable-functions.php
index 3314794..aa53b1b 100644
--- a/wp-inst/wp-includes/pluggable-functions.php
+++ b/wp-inst/wp-includes/pluggable-functions.php
@@ -8,9 +8,11 @@ if ( !function_exists('get_currentuserinfo') ) :
function get_currentuserinfo() {
global $user_login, $userdata, $user_level, $user_ID, $user_email, $user_url, $user_pass_md5, $user_identity, $current_user;
- if ( !isset($_COOKIE[USER_COOKIE]))
+ if ( empty($_COOKIE[USER_COOKIE]) || empty($_COOKIE[PASS_COOKIE]) ||
+ !wp_login($_COOKIE[USER_COOKIE], $_COOKIE[PASS_COOKIE], true) ) {
+ $current_user = new WP_User(0);
return false;
-
+ }
$user_login = $_COOKIE[USER_COOKIE];
$userdata = get_userdatabylogin($user_login);
$user_level = $userdata->user_level;
diff --git a/wp-inst/wp-includes/template-functions-links.php b/wp-inst/wp-includes/template-functions-links.php
index a4e37d5..0f97db9 100644
--- a/wp-inst/wp-includes/template-functions-links.php
+++ b/wp-inst/wp-includes/template-functions-links.php
@@ -209,11 +209,16 @@ function edit_post_link($link = 'Edit This', $before = '', $after = '') {
get_currentuserinfo();
- if ( !user_can_edit_post($user_ID, $post->ID) || is_attachment() ) {
+ if ( !user_can_edit_post($user_ID, $post->ID) ) {
return;
}
- $location = get_settings('siteurl') . "/wp-admin/post.php?action=edit&amp;post=$post->ID";
+ if ( is_attachment() )
+ $file = 'attachments';
+ else
+ $file = 'post';
+
+ $location = get_settings('siteurl') . "/wp-admin/{$file}.php?action=edit&amp;post=$post->ID";
echo $before . "<a href=\"$location\">$link</a>" . $after;
}
@@ -465,8 +470,6 @@ function next_posts_link($label='Next Page &raquo;', $max_page=0) {
preg_match('#FROM\s(.*)\sGROUP BY#siU', $request, $matches);
$fromwhere = $matches[1];
$numposts = $wpdb->get_var("SELECT COUNT(DISTINCT ID) FROM $fromwhere");
- if( $posts_per_page == 0 )
- $posts_per_page = 10;
$max_page = $max_num_pages = ceil($numposts / $posts_per_page);
}
}
diff --git a/wp-inst/wp-includes/template-functions-post.php b/wp-inst/wp-includes/template-functions-post.php
index be4d977..c851947 100644
--- a/wp-inst/wp-includes/template-functions-post.php
+++ b/wp-inst/wp-includes/template-functions-post.php
@@ -439,22 +439,126 @@ function _page_level_out($parent, $page_tree, $args, $depth = 0, $echo = true) {
return $output;
}
-function prepend_attachment($content) {
- global $post;
+function the_attachment_link($id = 0, $fullsize = false, $max_dims = false) {
+ echo get_the_attachment_link($id, $fullsize, $max_dims);
+}
- $p = '<p class="attachment">';
+function get_the_attachment_link($id = 0, $fullsize = false, $max_dims = false) {
+ $id = (int) $id;
+ $_post = & get_post($id);
+
+ if ( ('attachment' != $_post->post_status) || ('' == $_post->guid) )
+ return __('Missing Attachment');
+
+ if (! empty($_post->guid) ) {
+ $innerHTML = get_attachment_innerHTML($_post->ID, $fullsize, $max_dims);
+
+ return "<a href=\"{$_post->guid}\" title=\"{$_post->post_title}\" >{$innerHTML}</a>";
- if ( '' != $post->guid ) {
- if ( substr($post->post_mime_type, 0, 6) == 'image/' )
- $p .= '<a href="' . $post->guid . '" title="Click for full-size image" ><img class="attachmentimage" src="' . $post->guid . '" alt="' . $post->post_title . '" /></a>';
- else
- $p .= __('Attachment') . ' (' . $post->post_mime_type . ')';
} else {
$p .= __('Missing attachment');
}
+ return $p;
+}
+
+function get_attachment_icon($id = 0, $fullsize = false, $max_dims = false) {
+ $id = (int) $id;
+ $post = & get_post($id);
+
+ $mime = $post->post_mime_type;
+
+ $imagedata = get_post_meta($post->ID, '_wp_attachment_metadata', true);
+
+ $file = get_post_meta($post->ID, '_wp_attached_file', true);
+
+ if ( !$fullsize && !empty($imagedata['thumb'])
+ && ($thumbfile = str_replace(basename($file), $imagedata['thumb'], $file))
+ && file_exists($thumbfile) ) {
+
+ // We have a thumbnail desired, specified and existing
+
+ $src = str_replace(basename($post->guid), $imagedata['thumb'], $post->guid);
+ $src_file = $thumbfile;
+ $class = 'attachmentthumb';
+
+ } elseif ( substr($mime, 0, 6) == 'image/'
+ && file_exists($file) ) {
+
+ // We have an image without a thumbnail
+
+ $src = $post->guid;
+ $src_file = & $file;
+ $class = 'attachmentimage';
+ } elseif (! empty($mime) ) {
+
+ // No thumb, no image. We'll look for a mime-related icon instead.
+ $icon_dir = apply_filters('icon_dir', get_template_directory().'/images');
+ $icon_dir_uri = apply_filters('icon_dir_uri', get_template_directory_uri().'/images');
+
+ $types = array(substr($mime, 0, strpos($mime, '/')), substr($mime, strpos($mime, '/') + 1), str_replace('/', '_', $mime));
+ $exts = array('jpg', 'gif', 'png');
+ foreach ($types as $type) {
+ foreach ($exts as $ext) {
+ $src_file = "$icon_dir/$type.$ext";
+ if ( file_exists($src_file) ) {
+ $src = "$icon_dir_uri/$type.$ext";
+ break 2;
+ }
+ }
+ }
+ }
+
+ if (! isset($src) )
+ return false;
+
+ // Do we need to constrain the image?
+ if ( ($max_dims = apply_filters('attachment_max_dims', $max_dims)) && file_exists($src_file) ) {
+
+ $imagesize = getimagesize($src_file);
+
+ if (($imagesize[0] > $max_dims[0]) || $imagesize[1] > $max_dims[1] ) {
+ $actual_aspect = $imagesize[0] / $imagesize[1];
+ $desired_aspect = $max_dims[0] / $max_dims[1];
+
+ if ( $actual_aspect >= $desired_aspect ) {
+ $height = $actual_aspect * $max_dims[0];
+ $constraint = "width=\"{$max_dims[0]}\" ";
+ $post->iconsize = array($max_dims[0], $height);
+ } else {
+ $width = $max_dims[1] / $actual_aspect;
+ $constraint = "height=\"{$max_dims[1]}\" ";
+ $post->iconsize = array($width, $max_dims[1]);
+ }
+ } else {
+ $post->iconsize = array($imagesize[0], $imagesize[1]);
+ }
+ }
+
+ $icon = "<img src=\"{$src}\" title=\"{$post->post_title}\" {$constraint}/>";
+ return apply_filters('attachment_icon', $icon, $post->ID);
+}
+
+function get_attachment_innerHTML($id = 0, $fullsize = false, $max_dims = false) {
+ $id = (int) $id;
+
+ if ( $innerHTML = get_attachment_icon($id, $fullsize, $max_dims))
+ return $innerHTML;
+
+ $post = & get_post($id);
+
+ $innerHTML = $post->post_title;
+
+ return apply_filters('attachment_innerHTML', $innerHTML, $post->ID);
+}
+
+function prepend_attachment($content) {
+ $p = '<p class="attachment">';
+ $p .= get_the_attachment_link(false, true, array(400, 300));
$p .= '</p>';
+ $p = apply_filters('prepend_attachment', $p);
return "$p\n$content";
}
+
?>
diff --git a/wp-inst/wp-includes/version.php b/wp-inst/wp-includes/version.php
index 6df6626..95aac8f 100644
--- a/wp-inst/wp-includes/version.php
+++ b/wp-inst/wp-includes/version.php
@@ -3,6 +3,6 @@
// This just holds the version number, in a separate file so we can bump it without cluttering the SVN
$wp_version = 'MU'; // Let's just avoid confusion
-$wp_db_version = 3243;
+$wp_db_version = 3308;
?>