Make WordPress Core

Changeset 279


Ignore:
Timestamp:
07/29/2003 04:45:19 PM (21 years ago)
Author:
mikelittle
Message:

Can now toggle visibility and move categories en masse

File:
1 edited

Legend:

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

    r278 r279  
    3333$title = 'Manage Links';
    3434
     35function category_dropdown($fieldname, $selected = 0) {
     36    global $wpdb, $tablelinkcategories;
     37   
     38    $results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $tablelinkcategories ORDER BY cat_id");
     39    echo '        <select name="'.$fieldname.'" size="1">'."\n";
     40    foreach ($results as $row) {
     41      echo "          <option value=\"".$row->cat_id."\"";
     42      if ($row->cat_id == $selected)
     43        echo " selected";
     44        echo ">".$row->cat_id.": ".$row->cat_name;
     45        if ($row->auto_toggle == 'Y')
     46            echo ' (auto toggle)';
     47        echo "</option>\n";
     48    }
     49    echo "        </select>\n";
     50}
     51
    3552function add_magic_quotes($array) {
    3653    foreach ($array as $k => $v) {
     
    5269                       'description', 'visible', 'target', 'category', 'link_id',
    5370                       'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel',
    54                        'notes', 'linkcheck');
     71                       'notes', 'linkcheck[]');
    5572for ($i=0; $i<count($b2varstoreset); $i += 1) {
    5673    $b2var = $b2varstoreset[$i];
     
    7491    $action = $action2;
    7592
     93//error_log("action=$action");
    7694switch ($action) {
    7795  case 'Assign':
     
    86104    //for each link id (in $linkcheck[]): if the current user level >= the
    87105    //userlevel of the owner of the link then we can proceed.
    88    
     106
     107    if (count($linkcheck) == 0) {
     108        header('Location: linkmanager.php');
     109        exit;
     110    }
    89111    $all_links = join(',', $linkcheck);
    90112    $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)");
     
    102124    break;
    103125  }
     126  case 'Visibility':
     127  {
     128    $standalone = 1;
     129    include_once('b2header.php');
     130       
     131    // check the current user's level first.
     132    if ($user_level < $minadminlevel)
     133      die ("Cheatin' uh ?");
     134   
     135    //for each link id (in $linkcheck[]): toggle the visibility
     136    if (count($linkcheck) == 0) {
     137        header('Location: linkmanager.php');
     138        exit;
     139    }
     140    $all_links = join(',', $linkcheck);
     141    $results = $wpdb->get_results("SELECT link_id, link_visible FROM $tablelinks WHERE link_id in ($all_links)");
     142    foreach ($results as $row) {
     143        if ($row->link_visible == 'Y') { // ok to proceed
     144            $ids_to_turnoff[] = $row->link_id;
     145        } else {
     146            $ids_to_turnon[] = $row->link_id;
     147        }
     148    }
     149
     150    // should now have two arrays of links to change
     151    if (count($ids_to_turnoff)) {
     152        $all_linksoff = join(',', $ids_to_turnoff);
     153        $q = $wpdb->query("update $tablelinks SET link_visible='N' WHERE link_id IN ($all_linksoff)");
     154    }
     155   
     156    if (count($ids_to_turnon)) {
     157        $all_linkson = join(',', $ids_to_turnon);
     158        $q = $wpdb->query("update $tablelinks SET link_visible='Y' WHERE link_id IN ($all_linkson)");
     159    }
     160
     161    header('Location: linkmanager.php');
     162    break;
     163  }
     164  case 'Move':
     165  {
     166    $standalone = 1;
     167    include_once('b2header.php');
     168    // check the current user's level first.
     169    if ($user_level < $minadminlevel)
     170      die ("Cheatin' uh ?");
     171   
     172    //for each link id (in $linkcheck[]) change category to selected value
     173    if (count($linkcheck) == 0) {
     174        header('Location: linkmanager.php');
     175        exit;
     176    }
     177    $all_links = join(',', $linkcheck);
     178    // should now have an array of links we can change
     179    $q = $wpdb->query("update $tablelinks SET link_category='$category' WHERE link_id IN ($all_links)");
     180
     181    header('Location: linkmanager.php');
     182    break;
     183  }
     184
    104185  case 'Add':
    105186  {
     
    312393      <td height="20" align="right"><label for="category">Category</label>:</td>
    313394      <td>
    314 <?php
    315     $results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $tablelinkcategories ORDER BY cat_id");
    316     echo "        <select name=\"category\" size=\"1\">\n";
    317     foreach ($results as $row) {
    318       echo "          <option value=\"".$row->cat_id."\"";
    319       if ($row->cat_id == $link_category)
    320         echo " selected";
    321         echo ">".$row->cat_id.": ".$row->cat_name;
    322         if ($row->auto_toggle == 'Y')
    323             echo ' (auto toggle)';
    324         echo "</option>\n";
    325     }
    326     echo "        </select>\n";
    327 ?>
     395<?php category_dropdown('category', $link_category); ?>
    328396      </td>
    329397    </tr>
     
    557625    </tr>
    558626</table>
     627</div>
     628
     629<div class="wrap">
    559630  <table width="100%" border="0" cellspacing="0" cellpadding="3">
     631    <tr><th colspan="4">Manage Multiple Links:</th></tr>
     632    <tr><td colspan="4">Use the checkboxes on the right to select multiple links and choose an action below:</td></tr>
    560633    <tr>
    561         <td>Assign ownership (of checked) to:
     634        <td>
     635          <input type="submit" name="action2" value="Assign" /> ownership to:
    562636<?php
    563637    $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";
     638    echo "          <select name=\"newowner\" size=\"1\">\n";
    565639    foreach ($results as $row) {
    566       echo "          <option value=\"".$row->ID."\"";
     640      echo "            <option value=\"".$row->ID."\"";
    567641      echo ">".$row->user_login;
    568642      echo "</option>\n";
    569643    }
    570     echo "        </select>\n";
    571 ?>
    572         <input type="submit" name="action2" value="Assign" />
     644    echo "          </select>\n";
     645?>
     646        </td>
     647        <td>
     648          Toggle <input type="submit" name="action2" value="Visibility" />
     649        </td>
     650        <td>
     651          <input type="submit" name="action2" value="Move" /> to category
     652<?php category_dropdown('category'); ?>
    573653        </td>
    574654        <td align="right">
    575           Toggle Checkboxes
    576           &nbsp;
    577           <input type="checkbox" name="unused" value="Check All" onclick="checkAll(document.getElementById('links'));" />
     655          <a href="#" onclick="checkAll(document.getElementById('links')); return false; ">Toggle Checkboxes</a>
    578656        </td>
    579657    </tr>
     
    647725        <td height="20" align="right"><label for="category">Category</label>:</td>
    648726        <td>
    649 <?php
    650     $results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $tablelinkcategories ORDER BY cat_id");
    651     echo "        <select name=\"category\" size=\"1\">\n";
    652     foreach ($results as $row) {
    653       echo "          <option value=\"".$row->cat_id."\"";
    654       if ($row->cat_id == $cat_id)
    655         echo " selected";
    656         echo ">".$row->cat_id.": ".$row->cat_name;
    657         if ($row->auto_toggle == 'Y')
    658             echo ' (auto toggle)';
    659         echo "</option>\n";
    660     }
    661     echo "        </select>\n";
    662 ?>
     727<?php category_dropdown('category'); ?>
    663728        </td>
    664729      </tr>
Note: See TracChangeset for help on using the changeset viewer.