]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/list-manipulation.php
90604bd4ee017e39d419d2b6d9a975ee9ab89d40
[autoinstalls/wordpress.git] / wp-admin / list-manipulation.php
1 <?php
2 require_once('../wp-config.php');
3 require_once('admin-functions.php');
4 require_once('admin-db.php');
5
6 get_currentuserinfo();
7 if ( !is_user_logged_in() )
8         die('-1');
9
10 function grab_results() {
11         global $ajax_results;
12         $ajax_results = func_get_arg(0);
13 }
14
15 function get_out_now() { exit; }
16 add_action('shutdown', 'get_out_now', -1);
17
18 //      check_admin_referer();
19
20 switch ( $_POST['action'] ) :
21 case 'delete-link' :
22         $id = (int) $_POST['id'];
23         if ( !current_user_can('manage_links') )
24                 die ('-1');
25
26         if ( wp_delete_link($id) ) 
27                 die('1');
28         else    die('0');
29         break;
30 case 'delete-post' :
31 case 'delete-page' :
32         $id = (int) $_POST['id'];
33         if ( !current_user_can('edit_post', $id) )      {
34                 die('-1');
35         }
36
37         if ( wp_delete_post($id) ) {
38                 die('1');
39         } else  die('0');
40         break;
41 case 'delete-cat' :
42         if ( !current_user_can('manage_categories') )
43                 die ('-1');
44
45         $id = (int) $_POST['id'];
46         $cat_name = get_catname($cat_ID);
47
48         if ( wp_delete_category($id) )
49                 die('1');
50         else    die('0');
51         break;
52 case 'delete-comment' :
53         $id = (int) $_POST['id'];
54
55         if ( !$comment = get_comment($id) )
56                 die('0');
57         if ( !current_user_can('edit_post', $comment->comment_post_ID) )        
58                 die('-1');
59
60         if ( wp_delete_comment($comment->comment_ID) ) {
61                 die('1');
62         } else {
63                 die('0');
64         }
65         break;
66 case 'delete-link-category' :
67         $id = (int) $_POST['id'];
68         if ( 1 == $id )
69                 die('0');
70         if ( !current_user_can('manage_links') )
71                 die('-1');
72
73         if ( $wpdb->query("DELETE FROM $wpdb->linkcategories WHERE cat_id='$id'") ) {
74                 $wpdb->query("UPDATE $wpdb->links SET link_category=1 WHERE link_category='$id'");
75                 die('1');
76         } else {
77                 die('0');
78         }
79         break;
80 endswitch;              
81 ?>