]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/link.php
Wordpress 2.5.1
[autoinstalls/wordpress.git] / wp-admin / link.php
1 <?php
2 require_once ('admin.php');
3
4 wp_reset_vars(array('action', 'cat_id', 'linkurl', 'name', 'image', 'description', 'visible', 'target', 'category', 'link_id', 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 'notes', 'linkcheck[]'));
5
6 if ( ! current_user_can('manage_links') )
7         wp_die( __('You do not have sufficient permissions to edit the links for this blog.') );
8
9 if ('' != $_POST['deletebookmarks'])
10         $action = 'deletebookmarks';
11 if ('' != $_POST['move'])
12         $action = 'move';
13 if ('' != $_POST['linkcheck'])
14         $linkcheck = $_POST[linkcheck];
15
16 $this_file = 'link-manager.php';
17
18 switch ($action) {
19         case 'deletebookmarks' :
20                 check_admin_referer('bulk-bookmarks');
21
22                 //for each link id (in $linkcheck[]) change category to selected value
23                 if (count($linkcheck) == 0) {
24                         wp_redirect($this_file);
25                         exit;
26                 }
27
28                 $deleted = 0;
29                 foreach ($linkcheck as $link_id) {
30                         $link_id = (int) $link_id;
31
32                         if ( wp_delete_link($link_id) )
33                                 $deleted++;
34                 }
35
36                 wp_redirect("$this_file?deleted=$deleted");
37                 exit;
38                 break;
39
40         case 'move' :
41                 check_admin_referer('bulk-bookmarks');
42
43                 //for each link id (in $linkcheck[]) change category to selected value
44                 if (count($linkcheck) == 0) {
45                         wp_redirect($this_file);
46                         exit;
47                 }
48                 $all_links = join(',', $linkcheck);
49                 // should now have an array of links we can change
50                 //$q = $wpdb->query("update $wpdb->links SET link_category='$category' WHERE link_id IN ($all_links)");
51
52                 wp_redirect($this_file);
53                 exit;
54                 break;
55
56         case 'add' :
57                 check_admin_referer('add-bookmark');
58
59                 add_link();
60
61                 wp_redirect( wp_get_referer() . '?added=true' );
62                 exit;
63                 break;
64
65         case 'save' :
66                 $link_id = (int) $_POST['link_id'];
67                 check_admin_referer('update-bookmark_' . $link_id);
68
69                 edit_link($link_id);
70
71                 wp_redirect($this_file);
72                 exit;
73                 break;
74
75         case 'delete' :
76                 $link_id = (int) $_GET['link_id'];
77                 check_admin_referer('delete-bookmark_' . $link_id);
78
79                 wp_delete_link($link_id);
80
81                 wp_redirect($this_file);
82                 exit;
83                 break;
84
85         case 'edit' :
86                 wp_enqueue_script('link');
87                 wp_enqueue_script('xfn');
88                 wp_enqueue_script('thickbox');
89
90                 $parent_file = 'edit.php';
91                 $submenu_file = 'link-manager.php';
92                 $title = __('Edit Link');
93
94                 $link_id = (int) $_GET['link_id'];
95
96                 if (!$link = get_link_to_edit($link_id))
97                         wp_die(__('Link not found.'));
98
99                 include_once ('admin-header.php');
100                 include ('edit-link-form.php');
101                 include ('admin-footer.php');
102                 break;
103
104         default :
105                 break;
106 }
107 ?>