Make WordPress Core


Ignore:
Timestamp:
07/26/2003 11:52:36 PM (21 years ago)
Author:
mikelittle
Message:

Added the ability to assign ownership of links to another user.
Help updated.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/linkmanager.php

    r265 r276  
    5252$b2varstoreset = array('action','standalone','cat_id', 'linkurl', 'name', 'image',
    5353                       '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');
    5556for ($i=0; $i<count($b2varstoreset); $i += 1) {
    5657    $b2var = $b2varstoreset[$i];
     
    7475
    7576switch ($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  }
    76104  case 'Add':
    77105  {
     
    369397  if ($action != "popup") {
    370398?>
     399<script type="text/javascript">
     400<!--
     401function 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>
    371414
    372415<div class="wrap">
     
    433476    <input type="hidden" name="order_by" value="<?php echo $order_by ?>" />
    434477    <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">
    436479    <tr>
    437480      <th width="15%">Name</th>
    438481      <th>URL</th>
    439482      <th>Category</th>
    440       <th>Relationship</th>
     483      <th>Rel</th>
    441484      <th>Image</th>
    442485      <th>Visible</th>
    443486      <th>&nbsp;</th>
    444487      <th>&nbsp;</th>
     488      <th>&nbsp;</th>
    445489  </tr>
    446490<?php
    447491    $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
    463500    if (isset($cat_id) && ($cat_id != 'All')) {
    464501      // 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 ";
    469503    }
    470504    $sql .= ' ORDER BY link_' . $sqlorderby;
     
    498532        <td>$image</td>
    499533        <td>$visible</td>
     534LINKS;
     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
    500543        <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>
    501544        <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>
    504546LINKS;
     547            } else {
     548              echo <<<LINKS
     549        <td>&nbsp;</td>
     550        <td>&nbsp;</td>
     551        <td>&nbsp;</td>
     552LINKS;
     553            }
    505554        }
    506555    }
    507556?>
     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          &nbsp;
     577          <input type="checkbox" name="unused" value="Check All" onclick="checkAll(document.getElementById('links'));" />
     578        </td>
     579    </tr>
    508580</table>
    509581</form>
Note: See TracChangeset for help on using the changeset viewer.