summaryrefslogtreecommitdiffstats
path: root/wp-inst/wp-admin/admin-functions.php
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2005-07-18 09:16:34 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2005-07-18 09:16:34 +0000
commit3d22aa49e07b92dab07b1f9d6a8a66fb6ab20bdc (patch)
tree1bc483947163c7351f73b2c62a69ef774e021775 /wp-inst/wp-admin/admin-functions.php
parent9d3f6c7b7452785bd585424238dd29f9d7369480 (diff)
downloadwordpress-mu-3d22aa49e07b92dab07b1f9d6a8a66fb6ab20bdc.tar.gz
wordpress-mu-3d22aa49e07b92dab07b1f9d6a8a66fb6ab20bdc.tar.xz
wordpress-mu-3d22aa49e07b92dab07b1f9d6a8a66fb6ab20bdc.zip
Merge from WP Core.
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@31 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-inst/wp-admin/admin-functions.php')
-rw-r--r--wp-inst/wp-admin/admin-functions.php45
1 files changed, 26 insertions, 19 deletions
diff --git a/wp-inst/wp-admin/admin-functions.php b/wp-inst/wp-admin/admin-functions.php
index 2d0b0e6..94a515e 100644
--- a/wp-inst/wp-admin/admin-functions.php
+++ b/wp-inst/wp-admin/admin-functions.php
@@ -4,7 +4,7 @@
function write_post() {
global $user_ID;
- if ( !user_can_create_draft($user_ID) )
+ if ( ! current_user_can('edit_posts') )
die( __('You are not allowed to create posts or drafts on this blog.') );
// Rename.
@@ -21,20 +21,20 @@ function write_post() {
$_POST['post_author'] = (int) $_POST['user_ID'];
}
- if ( !user_can_edit_user($user_ID, $_POST['post_author']) )
+ if ( ($_POST['post_author'] != $_POST['user_ID']) && ! current_user_can('edit_others_posts') )
die( __('You cannot post as this user.') );
- if ( 'publish' == $_POST['post_status'] && (!user_can_create_post($user_ID)) )
- $_POST['post_status'] = 'draft';
-
// What to do based on which button they pressed
if ('' != $_POST['saveasdraft']) $_POST['post_status'] = 'draft';
if ('' != $_POST['saveasprivate']) $_POST['post_status'] = 'private';
if ('' != $_POST['publish']) $_POST['post_status'] = 'publish';
if ('' != $_POST['advanced']) $_POST['post_status'] = 'draft';
if ('' != $_POST['savepage']) $_POST['post_status'] = 'static';
-
- if (user_can_set_post_date($user_ID) && (!empty($_POST['edit_date']))) {
+
+ if ( 'publish' == $_POST['post_status'] && ! current_user_can('publish_posts') )
+ $_POST['post_status'] = 'draft';
+
+ if ( !empty($_POST['edit_date']) ) {
$aa = $_POST['aa'];
$mm = $_POST['mm'];
$jj = $_POST['jj'];
@@ -60,12 +60,9 @@ function write_post() {
function edit_post() {
global $user_ID;
- if ( !isset($blog_ID) )
- $blog_ID = 1;
-
$post_ID = (int) $_POST['post_ID'];
- if (!user_can_edit_post($user_ID, $post_ID, $blog_ID))
+ if ( ! current_user_can('edit_post', $post_ID) )
die( __('You are not allowed to edit this post.') );
// Rename.
@@ -83,10 +80,20 @@ function edit_post() {
$_POST['post_author'] = (int) $_POST['user_ID'];
}
- if ( !user_can_edit_user($user_ID, $_POST['post_author']) )
+ if ( ($_POST['post_author'] != $_POST['user_ID']) && ! current_user_can('edit_others_posts') )
die( __('You cannot post as this user.') );
- if (user_can_set_post_date($user_ID) && (!empty($_POST['edit_date']))) {
+ // What to do based on which button they pressed
+ if ('' != $_POST['saveasdraft']) $_POST['post_status'] = 'draft';
+ if ('' != $_POST['saveasprivate']) $_POST['post_status'] = 'private';
+ if ('' != $_POST['publish']) $_POST['post_status'] = 'publish';
+ if ('' != $_POST['advanced']) $_POST['post_status'] = 'draft';
+ if ('' != $_POST['savepage']) $_POST['post_status'] = 'static';
+
+ if ( 'publish' == $_POST['post_status'] && ! current_user_can('publish_posts') )
+ $_POST['post_status'] = 'draft';
+
+ if ( !empty($_POST['edit_date']) ) {
$aa = $_POST['aa'];
$mm = $_POST['mm'];
$jj = $_POST['jj'];
@@ -125,7 +132,7 @@ function edit_comment() {
$comment_ID = (int) $_POST['comment_ID'];
$comment_post_ID = (int) $_POST['comment_post_ID'];
- if (!user_can_edit_post_comments($user_ID, $comment_post_ID))
+ if ( ! current_user_can('edit_post', $comment_post_ID) )
die( __('You are not allowed to edit comments on this post, so you cannot edit this comment.') );
$_POST['comment_author'] = $_POST['newcomment_author'];
@@ -135,7 +142,7 @@ function edit_comment() {
$_POST['comment_content'] = $_POST['content'];
$_POST['comment_ID'] = (int) $_POST['comment_ID'];
- if (user_can_edit_post_date($user_ID, $post_ID) && (!empty($_POST['edit_date']))) {
+ if ( !empty($_POST['edit_date']) ) {
$aa = $_POST['aa'];
$mm = $_POST['mm'];
$jj = $_POST['jj'];
@@ -749,8 +756,8 @@ function update_meta($mid, $mkey, $mvalue) {
}
function touch_time($edit = 1, $for_post = 1) {
- global $month, $postdata, $commentdata;
- if ( $for_post && ('draft' == $postdata->post_status) ) {
+ global $month, $post, $comment;
+ if ( $for_post && ('draft' == $post->post_status) ) {
$checked = 'checked="checked" ';
$edit = false;
} else {
@@ -760,7 +767,7 @@ function touch_time($edit = 1, $for_post = 1) {
echo '<fieldset><legend><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp" '.$checked.'/> <label for="timestamp">' . __('Edit timestamp') . '</label></legend>';
$time_adj = time() + (get_settings('gmt_offset') * 3600);
- $post_date = ($for_post) ? $postdata->post_date : $commentdata['comment_date'];
+ $post_date = ($for_post) ? $post->post_date : $comment->comment_date;
$jj = ($edit) ? mysql2date('d', $post_date) : gmdate('d', $time_adj);
$mm = ($edit) ? mysql2date('m', $post_date) : gmdate('m', $time_adj);
$aa = ($edit) ? mysql2date('Y', $post_date) : gmdate('Y', $time_adj);
@@ -791,7 +798,7 @@ function touch_time($edit = 1, $for_post = 1) {
<?php _e('Existing timestamp'); ?>:
<?php
// We might need to readjust to display proper existing timestamp
- if ( $for_post && ('draft' == $postdata->post_status) ) {
+ if ( $for_post && ('draft' == $post->post_status) ) {
$jj = mysql2date('d', $post_date);
$mm = mysql2date('m', $post_date);
$aa = mysql2date('Y', $post_date);