Changeset 276 for trunk/wp-admin/linkmanager.php
- Timestamp:
- 07/26/2003 11:52:36 PM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/linkmanager.php
r265 r276 52 52 $b2varstoreset = array('action','standalone','cat_id', 'linkurl', 'name', 'image', 53 53 'description', 'visible', 'target', 'category', 'link_id', 54 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 'notes'); 54 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 55 'notes'. 'linkcheck'); 55 56 for ($i=0; $i<count($b2varstoreset); $i += 1) { 56 57 $b2var = $b2varstoreset[$i]; … … 74 75 75 76 switch ($action) { 77 case 'Assign': 78 { 79 $standalone = 1; 80 include_once('b2header.php'); 81 82 // check the current user's level first. 83 if ($user_level < $minadminlevel) 84 die ("Cheatin' uh ?"); 85 86 //for each link id (in $linkcheck[]): if the current user level >= the 87 //userlevel of the owner of the link then we can proceed. 88 89 $all_links = join(',', $linkcheck); 90 $results = $wpdb->get_results("SELECT link_id, link_owner, user_level FROM $tablelinks LEFT JOIN $tableusers ON link_owner = ID WHERE link_id in ($all_links)"); 91 foreach ($results as $row) { 92 if ($user_level >= $row->user_level) { // ok to proceed 93 $ids_to_change[] = $row->link_id; 94 } 95 } 96 97 // should now have an array of links we can change 98 $all_links = join(',', $ids_to_change); 99 $q = $wpdb->query("update $tablelinks SET link_owner='$newowner' WHERE link_id IN ($all_links)"); 100 101 header('Location: linkmanager.php'); 102 break; 103 } 76 104 case 'Add': 77 105 { … … 369 397 if ($action != "popup") { 370 398 ?> 399 <script type="text/javascript"> 400 <!-- 401 function checkAll(form) 402 { 403 for (i = 0, n = form.elements.length; i < n; i++) { 404 if(form.elements[i].type == "checkbox") { 405 if(form.elements[i].checked == true) 406 form.elements[i].checked = false; 407 else 408 form.elements[i].checked = true; 409 } 410 } 411 } 412 //--> 413 </script> 371 414 372 415 <div class="wrap"> … … 433 476 <input type="hidden" name="order_by" value="<?php echo $order_by ?>" /> 434 477 <input type="hidden" name="cat_id" value="<?php echo $cat_id ?>" /> 435 <table width="100%" border="0" cellspacing="0" cellpadding=" 5">478 <table width="100%" border="0" cellspacing="0" cellpadding="3"> 436 479 <tr> 437 480 <th width="15%">Name</th> 438 481 <th>URL</th> 439 482 <th>Category</th> 440 <th>Rel ationship</th>483 <th>Rel</th> 441 484 <th>Image</th> 442 485 <th>Visible</th> 443 486 <th> </th> 444 487 <th> </th> 488 <th> </th> 445 489 </tr> 446 490 <?php 447 491 $sql = "SELECT link_url, link_name, link_image, link_description, link_visible, 448 link_category AS cat_id, cat_name AS category, $tableusers.user_login, link_id, 449 link_rating, link_rel 450 FROM $tablelinks 451 LEFT JOIN $tablelinkcategories ON $tablelinks.link_category = $tablelinkcategories.cat_id 452 LEFT JOIN $tableusers on $tableusers.ID = $tablelinks.link_owner "; 453 454 // have we got a where clause? 455 if (($use_adminlevels) || (isset($cat_id) && ($cat_id != 'All')) ) { 456 $sql .= " WHERE "; 457 } 458 // FIX ME This make higher level links invisible rather than just uneditable 459 if ($use_adminlevels) { 460 $sql .= " ($tableusers.user_level <= $user_level" 461 . " OR $tableusers.ID = $user_ID)"; 462 } 492 link_category AS cat_id, cat_name AS category, $tableusers.user_login, link_id, 493 link_rating, link_rel, $tableusers.user_level 494 FROM $tablelinks 495 LEFT JOIN $tablelinkcategories ON $tablelinks.link_category = $tablelinkcategories.cat_id 496 LEFT JOIN $tableusers ON $tableusers.ID = $tablelinks.link_owner "; 497 498 //$use_adminlevels = 0; 499 463 500 if (isset($cat_id) && ($cat_id != 'All')) { 464 501 // have we already started the where clause? 465 if ($use_adminlevels) { 466 $sql .= " AND "; 467 } 468 $sql .= " link_category = $cat_id "; 502 $sql .= " WHERE link_category = $cat_id "; 469 503 } 470 504 $sql .= ' ORDER BY link_' . $sqlorderby; … … 498 532 <td>$image</td> 499 533 <td>$visible</td> 534 LINKS; 535 $show_buttons = 1; // default 536 537 if ($use_adminlevels && ($link->user_level > $user_level)) { 538 $show_buttons = 0; 539 } 540 541 if ($show_buttons) { 542 echo <<<LINKS 500 543 <td><input type="submit" name="edit" onclick="document.forms['links'].link_id.value='$link->link_id'; document.forms['links'].action.value='linkedit'; " value="Edit" class="search" /></td> 501 544 <td><input type="submit" name="delete" onclick="document.forms['links'].link_id.value='$link->link_id'; document.forms['links'].action.value='Delete'; return confirm('You are about to delete this link.\\n \'Cancel\' to stop, \'OK\' to delete.'); " value="Delete" class="search" /></td> 502 </tr> 503 545 <td><input type="checkbox" name="linkcheck[]" value="$link->link_id" /><td> 504 546 LINKS; 547 } else { 548 echo <<<LINKS 549 <td> </td> 550 <td> </td> 551 <td> </td> 552 LINKS; 553 } 505 554 } 506 555 } 507 556 ?> 557 </tr> 558 </table> 559 <table width="100%" border="0" cellspacing="0" cellpadding="3"> 560 <tr> 561 <td>Assign ownership (of checked) to: 562 <?php 563 $results = $wpdb->get_results("SELECT ID, user_login FROM $tableusers WHERE user_level > 0 ORDER BY ID"); 564 echo " <select name=\"newowner\" size=\"1\">\n"; 565 foreach ($results as $row) { 566 echo " <option value=\"".$row->ID."\""; 567 echo ">".$row->user_login; 568 echo "</option>\n"; 569 } 570 echo " </select>\n"; 571 ?> 572 <input type="submit" name="action" value="Assign" /> 573 </td> 574 <td align="right"> 575 Toggle Checkboxes 576 577 <input type="checkbox" name="unused" value="Check All" onclick="checkAll(document.getElementById('links'));" /> 578 </td> 579 </tr> 508 580 </table> 509 581 </form>
Note: See TracChangeset
for help on using the changeset viewer.