Changeset 1635

Show
Ignore:
Timestamp:
11/15/06 04:41:16 (2 years ago)
Author:
spetersen
Message:

Fix for #455 in the Postgresql branch

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/postgresql/admin/channels.php

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