Changeset 2490


Ignore:
Timestamp:
Aug 28, 2008, 10:05:39 PM (16 years ago)
Author:
rvelices
Message:
  • fix an issue on category modify (lock/unlock display was reversed) and improved queries on submit
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/cat_modify.php

    r2324 r2490  
    3838if ( !isset( $_GET['cat_id'] ) || !is_numeric( $_GET['cat_id'] ) )
    3939{
    40   $_GET['cat_id'] = '-1';
     40  trigger_error( 'missing cat_id param', E_USER_ERROR);
    4141}
    4242
     
    4444if (isset($_POST['submit']))
    4545{
    46   $data =
    47     array(
    48       'id' => $_GET['cat_id'],
    49       'name' => @$_POST['name'],
    50       'commentable' => $_POST['commentable'],
    51       'uploadable' =>
    52         isset($_POST['uploadable']) ? $_POST['uploadable'] : 'false',
    53       'comment' =>
    54         $conf['allow_html_descriptions'] ?
    55           @$_POST['comment'] : strip_tags(@$_POST['comment'])
    56       );
    57 
    58   mass_updates(
    59     CATEGORIES_TABLE,
    60     array(
    61       'primary' => array('id'),
    62       'update' => array_diff(array_keys($data), array('id'))
    63       ),
    64     array($data)
    65     );
    66 
    67   set_cat_visible(array($_GET['cat_id']), $_POST['visible']);
    68   set_cat_status(array($_GET['cat_id']), $_POST['status']);
    69 
    70   if (isset($_POST['parent']))
    71   {
    72     move_categories(
    73       array($_GET['cat_id']),
    74       $_POST['parent']
    75       );
    76   }
    77 
    78   $image_order = '';
     46  $image_order = null;
    7947  if ( !isset($_POST['image_order_default']) )
    8048  {
     
    9563    }
    9664  }
    97   $image_order = empty($image_order) ? 'null' : "'$image_order'";
    98   $query = '
    99 UPDATE '.CATEGORIES_TABLE.' SET image_order='.$image_order.'
    100 WHERE ';
     65
     66  $data =
     67    array(
     68      'id' => $_GET['cat_id'],
     69      'name' => @$_POST['name'],
     70      'commentable' => $_POST['commentable'],
     71      'uploadable' =>
     72        isset($_POST['uploadable']) ? $_POST['uploadable'] : 'false',
     73      'comment' =>
     74        $conf['allow_html_descriptions'] ?
     75          @$_POST['comment'] : strip_tags(@$_POST['comment']),
     76      'image_order' => $image_order,
     77      );
     78
     79  mass_updates(
     80    CATEGORIES_TABLE,
     81    array(
     82      'primary' => array('id'),
     83      'update' => array_diff(array_keys($data), array('id'))
     84      ),
     85    array($data)
     86    );
     87
     88  // retrieve cat infos before continuing (following updates are expensive)
     89  $cat_info = get_cat_info($_GET['cat_id']);
     90
    10191  if (isset($_POST['image_order_subcats']))
    10292  {
    103     $query .= 'uppercats REGEXP \'(^|,)'.$_GET['cat_id'].'(,|$)\'';
    104   }
    105   else
    106   {
    107     $query .= 'id='.$_GET['cat_id'].';';
    108   }
    109   pwg_query($query);
     93    $query = '
     94UPDATE '.CATEGORIES_TABLE.' SET image_order='.(isset($image_order) ? 'NULL':"'$image_order'").'
     95  WHERE uppercats LIKE "'.$cat_info['uppercats'].',%"';
     96    pwg_query($query);
     97  }
     98
     99  if ($cat_info['visible'] != get_boolean( $_POST['visible'] ) )
     100  {
     101    set_cat_visible(array($_GET['cat_id']), $_POST['visible']);
     102  }
     103  if ($cat_info['status'] != get_boolean( $_POST['status'] ) )
     104  {
     105    set_cat_status(array($_GET['cat_id']), $_POST['status']);
     106  }
     107
     108  if (isset($_POST['parent']) and $cat_info['id_uppercat'] != $_POST['parent'])
     109  {
     110    move_categories( array($_GET['cat_id']), $_POST['parent'] );
     111  }
    110112
    111113  array_push($page['infos'], l10n('editcat_confirm'));
    112114}
    113 else if (isset($_POST['set_random_representant']))
     115elseif (isset($_POST['set_random_representant']))
    114116{
    115117  set_random_representant(array($_GET['cat_id']));
    116118}
    117 else if (isset($_POST['delete_representant']))
     119elseif (isset($_POST['delete_representant']))
    118120{
    119121  $query = '
     
    124126  pwg_query($query);
    125127}
    126 else if (isset($_POST['submitAdd']))
     128elseif (isset($_POST['submitAdd']))
    127129{
    128130  $output_create = create_virtual_category(
     
    160162  }
    161163}
    162 else if (isset($_POST['submitDestinations'])
     164elseif (isset($_POST['submitDestinations'])
    163165         and isset($_POST['destinations'])
    164166         and count($_POST['destinations']) > 0)
  • trunk/admin/template/yoga/admin/cat_modify.tpl

    r2482 r2490  
    7171      <td><strong>{'lock'|@translate}</strong>
    7272      <td>
    73         {html_radios name='visible' values='false,true'|@explode output='No,Yes'|@explode|translate selected=$CAT_VISIBLE}
     73        {html_radios name='visible' values='true,false'|@explode output='No,Yes'|@explode|translate selected=$CAT_VISIBLE}
    7474      </td>
    7575    </tr>
  • trunk/plugins/admin_multi_view/controller.php

    r2340 r2490  
    3131  if ( is_adviser() and $user['id']!=$_GET['view_as'] and $conf['guest_id']!=$_GET['view_as'])
    3232    die('security error');
    33   pwg_set_session_var( 'multiview_as', (int)$_GET['view_as'] );
     33  if ($user['id']===$_GET['view_as'])
     34    pwg_unset_session_var( 'multiview_as' );
     35  else
     36    pwg_set_session_var( 'multiview_as', (int)$_GET['view_as'] );
    3437  // user change resets theme/lang
    3538  pwg_unset_session_var( 'multiview_theme' );
Note: See TracChangeset for help on using the changeset viewer.