diff options
Diffstat (limited to '')
-rw-r--r-- | admin/cat_modify.php | 80 |
1 files changed, 41 insertions, 39 deletions
diff --git a/admin/cat_modify.php b/admin/cat_modify.php index 90310527f..5f1971653 100644 --- a/admin/cat_modify.php +++ b/admin/cat_modify.php @@ -37,12 +37,32 @@ check_status(ACCESS_ADMINISTRATOR); //---------------------------------------------------------------- verification if ( !isset( $_GET['cat_id'] ) || !is_numeric( $_GET['cat_id'] ) ) { - $_GET['cat_id'] = '-1'; + trigger_error( 'missing cat_id param', E_USER_ERROR); } //--------------------------------------------------------- form criteria check if (isset($_POST['submit'])) { + $image_order = null; + if ( !isset($_POST['image_order_default']) ) + { + for ($i=1; $i<=3; $i++) + { + if ( !empty($_POST['order_field_'.$i]) ) + { + if (! empty($image_order) ) + { + $image_order .= ','; + } + $image_order .= $_POST['order_field_'.$i]; + if ($_POST['order_direction_'.$i]=='DESC') + { + $image_order .= ' DESC'; + } + } + } + } + $data = array( 'id' => $_GET['cat_id'], @@ -52,7 +72,8 @@ if (isset($_POST['submit'])) isset($_POST['uploadable']) ? $_POST['uploadable'] : 'false', 'comment' => $conf['allow_html_descriptions'] ? - @$_POST['comment'] : strip_tags(@$_POST['comment']) + @$_POST['comment'] : strip_tags(@$_POST['comment']), + 'image_order' => $image_order, ); mass_updates( @@ -64,57 +85,38 @@ if (isset($_POST['submit'])) array($data) ); - set_cat_visible(array($_GET['cat_id']), $_POST['visible']); - set_cat_status(array($_GET['cat_id']), $_POST['status']); + // retrieve cat infos before continuing (following updates are expensive) + $cat_info = get_cat_info($_GET['cat_id']); - if (isset($_POST['parent'])) + if (isset($_POST['image_order_subcats'])) { - move_categories( - array($_GET['cat_id']), - $_POST['parent'] - ); + $query = ' +UPDATE '.CATEGORIES_TABLE.' SET image_order='.(isset($image_order) ? 'NULL':"'$image_order'").' + WHERE uppercats LIKE "'.$cat_info['uppercats'].',%"'; + pwg_query($query); } - $image_order = ''; - if ( !isset($_POST['image_order_default']) ) + if ($cat_info['visible'] != get_boolean( $_POST['visible'] ) ) { - for ($i=1; $i<=3; $i++) - { - if ( !empty($_POST['order_field_'.$i]) ) - { - if (! empty($image_order) ) - { - $image_order .= ','; - } - $image_order .= $_POST['order_field_'.$i]; - if ($_POST['order_direction_'.$i]=='DESC') - { - $image_order .= ' DESC'; - } - } - } + set_cat_visible(array($_GET['cat_id']), $_POST['visible']); } - $image_order = empty($image_order) ? 'null' : "'$image_order'"; - $query = ' -UPDATE '.CATEGORIES_TABLE.' SET image_order='.$image_order.' -WHERE '; - if (isset($_POST['image_order_subcats'])) + if ($cat_info['status'] != get_boolean( $_POST['status'] ) ) { - $query .= 'uppercats REGEXP \'(^|,)'.$_GET['cat_id'].'(,|$)\''; + set_cat_status(array($_GET['cat_id']), $_POST['status']); } - else + + if (isset($_POST['parent']) and $cat_info['id_uppercat'] != $_POST['parent']) { - $query .= 'id='.$_GET['cat_id'].';'; + move_categories( array($_GET['cat_id']), $_POST['parent'] ); } - pwg_query($query); array_push($page['infos'], l10n('editcat_confirm')); } -else if (isset($_POST['set_random_representant'])) +elseif (isset($_POST['set_random_representant'])) { set_random_representant(array($_GET['cat_id'])); } -else if (isset($_POST['delete_representant'])) +elseif (isset($_POST['delete_representant'])) { $query = ' UPDATE '.CATEGORIES_TABLE.' @@ -123,7 +125,7 @@ UPDATE '.CATEGORIES_TABLE.' ;'; pwg_query($query); } -else if (isset($_POST['submitAdd'])) +elseif (isset($_POST['submitAdd'])) { $output_create = create_virtual_category( $_POST['virtual_name'], @@ -159,7 +161,7 @@ else if (isset($_POST['submitAdd'])) ); } } -else if (isset($_POST['submitDestinations']) +elseif (isset($_POST['submitDestinations']) and isset($_POST['destinations']) and count($_POST['destinations']) > 0) { |