root/tags/1_0-rc1/wp-admin/link.php

Revision 599, 3.0 kB (checked in by donncha, 3 years ago)

WP Merge

Line 
1 <?php
2 require_once ('admin.php');
3
4 $wpvarstoreset = 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 for ($i = 0; $i < count($wpvarstoreset); $i += 1) {
7     $wpvar = $wpvarstoreset[$i];
8     if (!isset ($$wpvar)) {
9         if (empty ($_POST["$wpvar"])) {
10             if (empty ($_GET["$wpvar"])) {
11                 $$wpvar = '';
12             } else {
13                 $$wpvar = $_GET["$wpvar"];
14             }
15         } else {
16             $$wpvar = $_POST["$wpvar"];
17         }
18     }
19 }
20
21 if ('' != $_POST['deletebookmarks'])
22     $action = 'deletebookmarks';
23 if ('' != $_POST['move'])
24     $action = 'move';
25 if ('' != $_POST['linkcheck'])
26     $linkcheck = $_POST[linkcheck];
27
28 $this_file = 'link-manager.php';
29
30 switch ($action) {
31         case 'deletebookmarks' :
32         check_admin_referer('bulk-bookmarks');
33
34         // check the current user's level first.
35         if (!current_user_can('manage_links'))
36             die(__("Cheatin' uh ?"));
37
38         //for each link id (in $linkcheck[]) change category to selected value
39         if (count($linkcheck) == 0) {
40             wp_redirect($this_file);
41             exit;
42         }
43
44         $deleted = 0;
45         foreach ($linkcheck as $link_id) {
46             $link_id = (int) $link_id;
47             
48             if ( wp_delete_link($link_id) )
49                 $deleted++;
50         }
51
52         wp_redirect("$this_file?deleted=$deleted");
53         break;
54
55     case 'move' :
56         check_admin_referer('bulk-bookmarks');
57
58         // check the current user's level first.
59         if (!current_user_can('manage_links'))
60             die(__("Cheatin' uh ?"));
61
62         //for each link id (in $linkcheck[]) change category to selected value
63         if (count($linkcheck) == 0) {
64             wp_redirect($this_file);
65             exit;
66         }
67         $all_links = join(',', $linkcheck);
68         // should now have an array of links we can change
69         //$q = $wpdb->query("update $wpdb->links SET link_category='$category' WHERE link_id IN ($all_links)");
70
71         wp_redirect($this_file);
72         break;
73
74     case 'add' :
75         check_admin_referer('add-bookmark');
76
77         add_link();
78
79         wp_redirect(wp_get_referer().'?added=true');
80         break;
81
82     case 'save' :
83         $link_id = (int) $_POST['link_id'];
84         check_admin_referer('update-bookmark_' . $link_id);
85
86         edit_link($link_id);
87
88         wp_redirect($this_file);
89         exit;
90         break;
91
92     case 'delete' :
93         $link_id = (int) $_GET['link_id'];
94         check_admin_referer('delete-bookmark_' . $link_id);
95
96         if (!current_user_can('manage_links'))
97             die(__("Cheatin' uh ?"));
98
99         wp_delete_link($link_id);
100
101         wp_redirect($this_file);
102         break;
103
104     case 'edit' :
105         wp_enqueue_script( array('xfn', 'dbx-admin-key?pagenow=link.php') );
106         if ( current_user_can( 'manage_categories' ) )
107             wp_enqueue_script( 'ajaxcat' );
108         $parent_file = 'link-manager.php';
109         $submenu_file = 'link-manager.php';
110         $title = __('Edit Bookmark');
111         include_once ('admin-header.php');
112         if (!current_user_can('manage_links'))
113             die(__('You do not have sufficient permissions to edit the bookmarks for this blog.'));
114
115         $link_id = (int) $_GET['link_id'];
116
117         if (!$link = get_link_to_edit($link_id))
118             die(__('Link not found.'));
119
120         include ('edit-link-form.php');
121         break;
122
123     default :
124         break;
125 }
126
127 include ('admin-footer.php');
128 ?>
129
Note: See TracBrowser for help on using the browser.