Changeset 1678

Show
Ignore:
Timestamp:
01/20/07 23:32:31 (20 months ago)
Author:
spetersen
Message:

Fix for Ticket #455 in Trunk (re-ordering of feeds).

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/gregarius/admin/channels.php

    r1654 r1678  
    653653        $res = rss_query("select parent,position from " . getTable("channels") ." where id=$id"); 
    654654        list($parent,$position) = rss_fetch_row($res); 
    655         $res = rss_query( 
    656                    "select id, position from " .getTable("channels") 
    657                    ." where parent=$parent and id != $id order by abs($position-position) limit 2" 
    658                ); 
    659  
    660         // Let's look for a lower/higher position than the one we got. 
    661         $switch_with_position=$position; 
    662  
    663         while (list($oid,$oposition) = rss_fetch_row($res)) { 
    664             if ( 
    665                 // found none yet? 
    666                 ($switch_with_position == $position) && 
    667                 ( 
    668                     // move up: we look for a lower position 
    669                     ($_REQUEST['action'] == CST_ADMIN_MOVE_UP_ACTION && $oposition < $switch_with_position) 
    670                     || 
    671                     // move up: we look for a higher position 
    672                     ($_REQUEST['action'] == CST_ADMIN_MOVE_DOWN_ACTION && $oposition > $switch_with_position) 
    673                 ) 
    674             ) { 
    675                 $switch_with_position = $oposition; 
    676                 $switch_with_id = $oid; 
    677             } 
    678         } 
    679         // right, lets! 
    680         if ($switch_with_position != $position) { 
    681             rss_query( "update " .getTable("channels") ." set position = $switch_with_position where id=$id" ); 
    682             rss_query( "update " .getTable("channels") ." set position = $position where id=$switch_with_id" ); 
    683             rss_invalidate_cache(); 
    684         } 
    685         $ret__ = CST_ADMIN_DOMAIN_CHANNEL; 
    686         break; 
    687  
     655 
     656        if ($_REQUEST['action'] == CST_ADMIN_MOVE_UP_ACTION ) { 
     657            $res = rss_query( 
     658                "select id, position from " .getTable("channels") 
     659                ." where parent=$parent and id != $id and position<$position "  
     660                ." order by abs($position-position) limit 1" 
     661            ); 
     662        } else { 
     663            $res = rss_query( 
     664                "select id, position from " .getTable("channels") 
     665                ." where parent=$parent and id != $id and position>$position "  
     666                ." order by abs($position-position) limit 1" 
     667            ); 
     668        } 
     669 
     670        list($switch_with_id,$switch_with_position) = rss_fetch_row($res); 
     671 
     672        //If this is already the first or last item in a folder we won't get any results from the query above 
     673        if ($switch_with_position != "") { 
     674            // right, lets! 
     675            if ($switch_with_position != $position) { 
     676                rss_query( "update " .getTable("channels") ." set position = $switch_with_position where id=$id" ); 
     677                rss_query( "update " .getTable("channels") ." set position = $position where id=$switch_with_id" ); 
     678                rss_invalidate_cache(); 
     679            } 
     680        } 
     681        $ret__ = CST_ADMIN_DOMAIN_CHANNEL; 
     682        break; 
    688683 
    689684    case CST_ADMIN_MULTIEDIT: