-$title = __('Manage Links');
-$this_file = $parent_file = 'link-manager.php';
-$list_js = true;
-
-$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[]');
-
-for ($i=0; $i<count($wpvarstoreset); $i += 1) {
- $wpvar = $wpvarstoreset[$i];
- if (!isset($$wpvar)) {
- if (empty($_POST["$wpvar"])) {
- if (empty($_GET["$wpvar"])) {
- $$wpvar = '';
- } else {
- $$wpvar = $_GET["$wpvar"];
- }
- } else {
- $$wpvar = $_POST["$wpvar"];
- }
- }
-}
-
-$links_show_cat_id = $_COOKIE['links_show_cat_id_' . COOKIEHASH];
-$links_show_order = $_COOKIE['links_show_order_' . COOKIEHASH];
-
-if ('' != $_POST['assign']) $action = 'assign';
-if ('' != $_POST['visibility']) $action = 'visibility';
-if ('' != $_POST['move']) $action = 'move';
-if ('' != $_POST['linkcheck']) $linkcheck = $_POST[linkcheck];
-
-switch ($action) {
- case 'assign':
- {
- check_admin_referer();
-
- // check the current user's level first.
- if ( !current_user_can('manage_links') )
- die (__("Cheatin' uh ?"));
-
- //for each link id (in $linkcheck[]): if the current user level >= the
- //userlevel of the owner of the link then we can proceed.
-
- if (count($linkcheck) == 0) {
- header('Location: ' . $this_file);
- exit;
- }
- $all_links = join(',', $linkcheck);
- $results = $wpdb->get_results("SELECT link_id, link_owner FROM $wpdb->links LEFT JOIN $wpdb->users ON link_owner = ID WHERE link_id in ($all_links)");
- foreach ($results as $row) {
- $ids_to_change[] = $row->link_id;
- }
-
- // should now have an array of links we can change
- $all_links = join(',', $ids_to_change);
- $q = $wpdb->query("update $wpdb->links SET link_owner='$newowner' WHERE link_id IN ($all_links)");
-
- header('Location: ' . $this_file);
- break;
- }
- case 'visibility':
- {
- check_admin_referer();
-
- // check the current user's level first.
- if ( !current_user_can('manage_links') )
- die (__("Cheatin' uh ?"));
-
- //for each link id (in $linkcheck[]): toggle the visibility
- if (count($linkcheck) == 0) {
- header('Location: ' . $this_file);
- exit;
- }
- $all_links = join(',', $linkcheck);
- $results = $wpdb->get_results("SELECT link_id, link_visible FROM $wpdb->links WHERE link_id in ($all_links)");
- foreach ($results as $row) {
- if ($row->link_visible == 'Y') { // ok to proceed
- $ids_to_turnoff[] = $row->link_id;
- } else {
- $ids_to_turnon[] = $row->link_id;
- }
- }