| 1 |
<?php |
<?php |
| 2 |
/** |
/** |
| 3 |
* @version $Id: admin.categories.php,v 1.1 2005/07/22 01:52:06 eddieajau Exp $ |
* @package Mambo Open Source |
|
* @package Mambo |
|
| 4 |
* @subpackage Categories |
* @subpackage Categories |
| 5 |
* @copyright (C) 2000 - 2005 Miro International Pty Ltd |
* @copyright (C) 2005 - 2006 Mambo Foundation Inc. |
| 6 |
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL |
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL |
| 7 |
|
* |
| 8 |
|
* Mambo was originally developed by Miro (www.miro.com.au) in 2000. Miro assigned the copyright in Mambo to The Mambo Foundation in 2005 to ensure |
| 9 |
|
* that Mambo remained free Open Source software owned and managed by the community. |
| 10 |
* Mambo is Free Software |
* Mambo is Free Software |
| 11 |
*/ |
*/ |
| 12 |
|
|
| 838 |
|
|
| 839 |
function saveOrder( &$cid, $section ) { |
function saveOrder( &$cid, $section ) { |
| 840 |
global $database; |
global $database; |
|
|
|
|
$total = count( $cid ); |
|
| 841 |
$order = mosGetParam( $_POST, 'order', array(0) ); |
$order = mosGetParam( $_POST, 'order', array(0) ); |
| 842 |
$row = new mosCategory( $database ); |
$row = new mosCategory( $database ); |
| 843 |
$conditions = array(); |
$sections = array(); |
|
|
|
| 844 |
// update ordering values |
// update ordering values |
| 845 |
for( $i=0; $i < $total; $i++ ) { |
foreach ($cid as $i=>$ciditem) { |
| 846 |
$row->load( $cid[$i] ); |
$row->load( $ciditem ); |
| 847 |
if ($row->ordering != $order[$i]) { |
if ($row->ordering != $order[$i]) { |
| 848 |
$row->ordering = $order[$i]; |
$row->ordering = $order[$i]; |
| 849 |
if (!$row->store()) { |
if (!$row->store()) { |
| 850 |
echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n"; |
echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n"; |
| 851 |
exit(); |
exit(); |
| 852 |
} // if |
} |
| 853 |
// remember to updateOrder this group |
// remember to updateOrder this group |
| 854 |
$condition = "section='$row->section'"; |
$sections[$row->section] = $row->id; |
| 855 |
$found = false; |
} |
| 856 |
foreach ( $conditions as $cond ) |
} |
|
if ($cond[1]==$condition) { |
|
|
$found = true; |
|
|
break; |
|
|
} // if |
|
|
if (!$found) $conditions[] = array($row->id, $condition); |
|
|
} // if |
|
|
} // for |
|
|
|
|
| 857 |
// execute updateOrder for each group |
// execute updateOrder for each group |
| 858 |
foreach ( $conditions as $cond ) { |
foreach ($sections as $section=>$rowid) { |
| 859 |
$row->load( $cond[0] ); |
$row->updateOrder("section='$section'"); |
|
$row->updateOrder( $cond[1] ); |
|
| 860 |
} // foreach |
} // foreach |
|
|
|
| 861 |
$msg = T_('New ordering saved'); |
$msg = T_('New ordering saved'); |
| 862 |
mosRedirect( 'index2.php?option=com_categories§ion='. $section, $msg ); |
mosRedirect( 'index2.php?option=com_categories§ion='. $section, $msg ); |
| 863 |
} // saveOrder |
} // saveOrder |