| 546 |
|
|
| 547 |
function saveOrder( &$cid ) { |
function saveOrder( &$cid ) { |
| 548 |
global $database; |
global $database; |
|
|
|
|
$total = count( $cid ); |
|
| 549 |
$order = mosGetParam( $_POST, 'order', array(0) ); |
$order = mosGetParam( $_POST, 'order', array(0) ); |
| 550 |
$row = new mosContent( $database ); |
$row = new mosMenu( $database ); |
| 551 |
$conditions = array(); |
$categories = array(); |
|
|
|
| 552 |
// update ordering values |
// update ordering values |
| 553 |
for ( $i=0; $i < $total; $i++ ) { |
foreach ($cid as $i=>$ciditem) { |
| 554 |
$row->load( $cid[$i] ); |
$row->load( $ciditem ); |
| 555 |
if ($row->ordering != $order[$i]) { |
if ($row->ordering != $order[$i]) { |
| 556 |
$row->ordering = $order[$i]; |
$row->ordering = $order[$i]; |
| 557 |
if (!$row->store()) { |
if (!$row->store()) { |
| 558 |
echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n"; |
echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n"; |
| 559 |
exit(); |
exit(); |
| 560 |
} // if |
} |
| 561 |
// remember to updateOrder this group |
// remember to updateOrder this group |
| 562 |
$condition = "catid='$row->catid' AND state >= 0"; |
$categories[$row->catid] = $row->id; |
| 563 |
$found = false; |
} |
| 564 |
foreach ( $conditions as $cond ) |
} |
|
if ($cond[1]==$condition) { |
|
|
$found = true; |
|
|
break; |
|
|
} // if |
|
|
if (!$found) $conditions[] = array($row->id, $condition); |
|
|
} // if |
|
|
} // for |
|
|
|
|
| 565 |
// execute updateOrder for each group |
// execute updateOrder for each group |
| 566 |
foreach ( $conditions as $cond ) { |
foreach ($categories as $catid=>$rowid) { |
| 567 |
$row->load( $cond[0] ); |
$row->updateOrder("catid = $catid AND state >= 0"); |
|
$row->updateOrder( $cond[1] ); |
|
| 568 |
} // foreach |
} // foreach |
| 569 |
|
|
| 570 |
$msg = T_('New ordering saved'); |
$msg = T_('New ordering saved'); |