diff options
| author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2006-02-14 12:09:11 +0000 |
|---|---|---|
| committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2006-02-14 12:09:11 +0000 |
| commit | 39854b3d3a80e4ac2bfee92a4b1210852baa7091 (patch) | |
| tree | 95125abe2a96d8b137949ce71bc33340a0c6e376 /wp-inst/wp-admin/admin-functions.php | |
| parent | 5cd626aede5b92cd056bc0e205ac9dedfd96ae05 (diff) | |
WP Merge - requires upgrading of db through wp-admin/upgrade.php!
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@524 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-inst/wp-admin/admin-functions.php')
| -rw-r--r-- | wp-inst/wp-admin/admin-functions.php | 109 |
1 files changed, 69 insertions, 40 deletions
diff --git a/wp-inst/wp-admin/admin-functions.php b/wp-inst/wp-admin/admin-functions.php index d17a6ac..61d0097 100644 --- a/wp-inst/wp-admin/admin-functions.php +++ b/wp-inst/wp-admin/admin-functions.php @@ -4,8 +4,13 @@ function write_post() { global $user_ID; - if (!current_user_can('edit_posts')) - die(__('You are not allowed to create posts or drafts on this blog.')); + if ( 'page' == $_POST['post_type'] ) { + if ( !current_user_can('edit_pages') ) + die(__('You are not allowed to create pages on this blog.')); + } else { + if ( !current_user_can('edit_posts') ) + die(__('You are not allowed to create posts or drafts on this blog.')); + } // Rename. $_POST['post_content'] = $_POST['content']; @@ -15,15 +20,25 @@ function write_post() { if (!empty ($_POST['post_author_override'])) { $_POST['post_author'] = (int) $_POST['post_author_override']; - } else + } else { if (!empty ($_POST['post_author'])) { $_POST['post_author'] = (int) $_POST['post_author']; } else { $_POST['post_author'] = (int) $_POST['user_ID']; } - if (($_POST['post_author'] != $_POST['user_ID']) && !current_user_can('edit_others_posts')) - die(__('You cannot post as this user.')); + } + + if ($_POST['post_author'] != $_POST['user_ID']) { + if ( 'page' == $_POST['post_type'] ) { + if ( !current_user_can('edit_others_pages') ) + die(__('You cannot create pages as this user.')); + } else { + if ( !current_user_can('edit_others_posts') ) + die(__('You cannot post as this user.')); + + } + } // What to do based on which button they pressed if ('' != $_POST['saveasdraft']) @@ -34,14 +49,14 @@ function write_post() { $_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 ('static' == $_POST['post_status'] && !current_user_can('edit_pages')) - die(__('This user cannot edit pages.')); + if ( 'page' == $_POST['post_type'] ) { + if ('publish' == $_POST['post_status'] && !current_user_can('publish_pages')) + $_POST['post_status'] = 'draft'; + } else { + if ('publish' == $_POST['post_status'] && !current_user_can('publish_posts')) + $_POST['post_status'] = 'draft'; + } if (!empty ($_POST['edit_date'])) { $aa = $_POST['aa']; @@ -123,8 +138,13 @@ function edit_post() { $post_ID = (int) $_POST['post_ID']; - if (!current_user_can('edit_post', $post_ID)) - die(__('You are not allowed to edit this post.')); + if ( 'page' == $_POST['post_type'] ) { + if ( !current_user_can('edit_page', $post_ID) ) + die(__('You are not allowed to edit this page.')); + } else { + if ( !current_user_can('edit_post', $post_ID) ) + die(__('You are not allowed to edit this post.')); + } // Rename. $_POST['ID'] = (int) $_POST['post_ID']; @@ -142,8 +162,16 @@ function edit_post() { $_POST['post_author'] = (int) $_POST['user_ID']; } - if (($_POST['post_author'] != $_POST['user_ID']) && !current_user_can('edit_others_posts')) - die(__('You cannot post as this user.')); + if ($_POST['post_author'] != $_POST['user_ID']) { + if ( 'page' == $_POST['post_type'] ) { + if ( !current_user_can('edit_others_pages') ) + die(__('You cannot edit pages as this user.')); + } else { + if ( !current_user_can('edit_others_posts') ) + die(__('You cannot edit posts as this user.')); + + } + } // What to do based on which button they pressed if ('' != $_POST['saveasdraft']) @@ -154,14 +182,14 @@ function edit_post() { $_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 ('static' == $_POST['post_status'] && !current_user_can('edit_pages')) - die(__('This user cannot edit pages.')); + if ( 'page' == $_POST['post_type'] ) { + if ('publish' == $_POST['post_status'] && !current_user_can('edit_published_pages')) + $_POST['post_status'] = 'draft'; + } else { + if ('publish' == $_POST['post_status'] && !current_user_can('edit_published_posts')) + $_POST['post_status'] = 'draft'; + } if (!isset ($_POST['comment_status'])) $_POST['comment_status'] = 'closed'; @@ -189,7 +217,7 @@ function edit_post() { foreach ($_POST['meta'] as $key => $value) update_meta($key, $value['key'], $value['value']); } - + if ($_POST['deletemeta']) { foreach ($_POST['deletemeta'] as $key => $value) delete_meta($key); @@ -254,7 +282,7 @@ function get_post_to_edit($id) { $post->post_title = format_to_edit($post->post_title); $post->post_title = apply_filters('title_edit_pre', $post->post_title); - if ($post->post_status == 'static') + if ($post->post_type == 'page') $post->page_template = get_post_meta($id, '_wp_page_template', true); return $post; @@ -436,13 +464,13 @@ function edit_user($user_id = 0) { function get_link_to_edit($link_id) { $link = get_link($link_id); - + $link->link_url = wp_specialchars($link->link_url, 1); $link->link_name = wp_specialchars($link->link_name, 1); $link->link_description = wp_specialchars($link->link_description); $link->link_notes = wp_specialchars($link->link_notes); $link->link_rss = wp_specialchars($link->link_rss); - + return $link; } @@ -451,17 +479,17 @@ function get_default_link_to_edit() { $link->link_url = wp_specialchars($_GET['linkurl'], 1); else $link->link_url = ''; - + if ( isset($_GET['name']) ) $link->link_name = wp_specialchars($_GET['name'], 1); else $link->link_name = ''; - + return $link; } function add_link() { - return edit_link(); + return edit_link(); } function edit_link($link_id = '') { @@ -474,7 +502,7 @@ function edit_link($link_id = '') { $_POST['link_image'] = wp_specialchars($_POST['link_image']); $_POST['link_rss'] = wp_specialchars($_POST['link_rss']); $auto_toggle = get_autotoggle($_POST['link_category']); - + // if we are in an auto toggle category and this one is visible then we // need to make the others invisible before we add this new one. // FIXME Add category toggle func. @@ -549,7 +577,7 @@ function get_nested_categories($default = 0, $parent = 0) { $result[$cat]['cat_name'] = get_the_category_by_ID($cat); } } - + usort($result, 'sort_cats'); return $result; @@ -582,12 +610,12 @@ function cat_rows($parent = 0, $level = 0, $categories = 0) { foreach ($categories as $category) { if ($category->category_parent == $parent) { $category->cat_name = wp_specialchars($category->cat_name); - $count = $wpdb->get_var("SELECT COUNT(post_id) FROM $wpdb->post2cat WHERE category_id = $category->cat_ID"); + //$count = $wpdb->get_var("SELECT COUNT(post_id) FROM $wpdb->post2cat WHERE category_id = $category->cat_ID"); $pad = str_repeat('— ', $level); if ( current_user_can('manage_categories') ) { $edit = "<a href='categories.php?action=edit&cat_ID=$category->cat_ID' class='edit'>".__('Edit')."</a></td>"; $default_cat_id = get_option('default_category'); - + if ($category->cat_ID != $default_cat_id) $edit .= "<td><a href='categories.php?action=delete&cat_ID=$category->cat_ID' onclick=\"return deleteSomething( 'cat', $category->cat_ID, '".sprintf(__("You are about to delete the category "%s". All of its posts will go to the default category.\\n"OK" to delete, "Cancel" to stop."), wp_specialchars($category->cat_name, 1))."' );\" class='delete'>".__('Delete')."</a>"; else @@ -599,9 +627,10 @@ function cat_rows($parent = 0, $level = 0, $categories = 0) { $class = ('alternate' == $class) ? '' : 'alternate'; echo "<tr id='cat-$category->cat_ID' class='$class'><th scope='row'>$category->cat_ID</th><td>$pad $category->cat_name</td> <td>$category->category_description</td> - <td>$count</td> + <td>$category->category_count</td> <td>$edit</td> </tr>"; + //<td>$count</td> cat_rows($category->cat_ID, $level +1, $categories); } } @@ -613,7 +642,7 @@ function cat_rows($parent = 0, $level = 0, $categories = 0) { function page_rows($parent = 0, $level = 0, $pages = 0) { global $wpdb, $class, $post; if (!$pages) - $pages = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_status = 'static' ORDER BY menu_order"); + $pages = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_type = 'page' ORDER BY menu_order"); if ($pages) { foreach ($pages as $post) { @@ -671,7 +700,7 @@ function wp_dropdown_cats($currentcat = 0, $currentparent = 0, $parent = 0, $lev function link_category_dropdown($fieldname, $selected = 0) { global $wpdb; - + $results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $wpdb->linkcategories ORDER BY cat_id"); echo "\n<select name='$fieldname' size='1'>\n"; foreach ($results as $row) { @@ -1176,7 +1205,7 @@ function page_template_dropdown($default = '') { function parent_dropdown($default = 0, $parent = 0, $level = 0) { global $wpdb, $post_ID; - $items = $wpdb->get_results("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = $parent AND post_status = 'static' ORDER BY menu_order"); + $items = $wpdb->get_results("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = $parent AND post_type = 'page' ORDER BY menu_order"); if ($items) { foreach ($items as $item) { @@ -1806,7 +1835,7 @@ o.submit(); <input type="button" value="<?php _e('Cancel'); ?>" onclick="cancelUpload()" /> </div> </form> -<?php +<?php } function wp_import_handle_upload() { @@ -1848,7 +1877,7 @@ function the_attachment_links($id = false) { $id = (int) $id; $post = & get_post($id); - if ( $post->post_status != 'attachment' ) + if ( $post->post_type != 'attachment' ) return false; $icon = get_attachment_icon($post->ID); |
