aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--admin/cat_modify.php80
-rw-r--r--admin/template/yoga/admin/cat_modify.tpl2
-rw-r--r--plugins/admin_multi_view/controller.php5
3 files changed, 46 insertions, 41 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)
{
diff --git a/admin/template/yoga/admin/cat_modify.tpl b/admin/template/yoga/admin/cat_modify.tpl
index b3b67afd8..aeac221e6 100644
--- a/admin/template/yoga/admin/cat_modify.tpl
+++ b/admin/template/yoga/admin/cat_modify.tpl
@@ -70,7 +70,7 @@
<tr>
<td><strong>{'lock'|@translate}</strong>
<td>
- {html_radios name='visible' values='false,true'|@explode output='No,Yes'|@explode|translate selected=$CAT_VISIBLE}
+ {html_radios name='visible' values='true,false'|@explode output='No,Yes'|@explode|translate selected=$CAT_VISIBLE}
</td>
</tr>
<tr>
diff --git a/plugins/admin_multi_view/controller.php b/plugins/admin_multi_view/controller.php
index 861df63a7..80098b962 100644
--- a/plugins/admin_multi_view/controller.php
+++ b/plugins/admin_multi_view/controller.php
@@ -30,7 +30,10 @@ if ( isset($_GET['view_as']) )
{
if ( is_adviser() and $user['id']!=$_GET['view_as'] and $conf['guest_id']!=$_GET['view_as'])
die('security error');
- pwg_set_session_var( 'multiview_as', (int)$_GET['view_as'] );
+ if ($user['id']===$_GET['view_as'])
+ pwg_unset_session_var( 'multiview_as' );
+ else
+ pwg_set_session_var( 'multiview_as', (int)$_GET['view_as'] );
// user change resets theme/lang
pwg_unset_session_var( 'multiview_theme' );
pwg_unset_session_var( 'multiview_lang' );