@@ 3958-3972 (lines=15) @@ | ||
3955 | $num = Database :: num_rows($res); |
|
3956 | // First check the order is correct, globally (might be wrong because |
|
3957 | // of versions < 1.8.4) |
|
3958 | if ($num > 0) { |
|
3959 | $i = 1; |
|
3960 | while ($row = Database :: fetch_array($res)) { |
|
3961 | if ($row['display_order'] != $i) { // If we find a gap in the order, we need to fix it. |
|
3962 | $need_fix = true; |
|
3963 | $sql_u = "UPDATE $lp_table SET display_order = $i |
|
3964 | WHERE c_id = ".$course_id." AND id = " . $row['id']; |
|
3965 | Database::query($sql_u); |
|
3966 | } |
|
3967 | $row['display_order'] = $i; |
|
3968 | $lps[$row['id']] = $row; |
|
3969 | $lp_order[$i] = $row['id']; |
|
3970 | $i++; |
|
3971 | } |
|
3972 | } |
|
3973 | if ($num > 1) { // If there's only one element, no need to sort. |
|
3974 | $order = $lps[$lp_id]['display_order']; |
|
3975 | if ($order > 1) { // If it's the first element, no need to move up. |
|
@@ 4007-4022 (lines=16) @@ | ||
4004 | $max = 0; |
|
4005 | // First check the order is correct, globally (might be wrong because |
|
4006 | // of versions < 1.8.4). |
|
4007 | if ($num > 0) { |
|
4008 | $i = 1; |
|
4009 | while ($row = Database :: fetch_array($res)) { |
|
4010 | $max = $i; |
|
4011 | if ($row['display_order'] != $i) { // If we find a gap in the order, we need to fix it. |
|
4012 | $need_fix = true; |
|
4013 | $sql_u = "UPDATE $lp_table SET display_order = $i |
|
4014 | WHERE c_id = ".$course_id." AND id = " . $row['id']; |
|
4015 | Database::query($sql_u); |
|
4016 | } |
|
4017 | $row['display_order'] = $i; |
|
4018 | $lps[$row['id']] = $row; |
|
4019 | $lp_order[$i] = $row['id']; |
|
4020 | $i++; |
|
4021 | } |
|
4022 | } |
|
4023 | if ($num > 1) { // If there's only one element, no need to sort. |
|
4024 | $order = $lps[$lp_id]['display_order']; |
|
4025 | if ($order < $max) { // If it's the first element, no need to move up. |