Wordpress 2.6.2-scripts
[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
89                 $parent_file = 'edit.php';
90                 $submenu_file = 'link-manager.php';
91                 $title = __('Edit Link');
92
93                 $link_id = (int) $_GET['link_id'];
94
95                 if (!$link = get_link_to_edit($link_id))
96                         wp_die(__('Link not found.'));
97
98                 include_once ('admin-header.php');
99                 include ('edit-link-form.php');
100                 include ('admin-footer.php');
101                 break;
102
103         default :
104                 break;
105 }
106 ?>