Ignore:
Timestamp:
Feb 2, 2004, 1:55:18 AM (20 years ago)
Author:
gweltas
Message:

Merge of the 1.3.1 release
Creation of an unique include file (common.php)
Creation of an unique define file (include/constants.php)
Modification of the installation procedure

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/cat_modify.php

    r226 r345  
    4141  $query.= ';';
    4242  $row = mysql_fetch_array( mysql_query( $query ) );
     43 
     44  $query = 'UPDATE '.PREFIX_TABLE.'categories';
     45
     46  $query.= ' SET name = ';
     47  if ( $_POST['name'] == '' )
     48    $query.= 'NULL';
     49  else
     50    $query.= "'".htmlentities( $_POST['name'], ENT_QUOTES)."'";
     51
     52  $query.= ', comment = ';
     53  if ( $_POST['comment'] == '' )
     54    $query.= 'NULL';
     55  else
     56    $query.= "'".htmlentities( $_POST['comment'], ENT_QUOTES )."'";
     57
     58  $query.= ", status = '".$_POST['status']."'";
     59  $query.= ", visible = '".$_POST['visible']."'";
     60
     61  if ( isset( $_POST['uploadable'] ) )
     62    $query.= ", uploadable = '".$_POST['uploadable']."'";
     63
     64  if ( isset( $_POST['associate'] ) )
     65  {
     66    $query.= ', id_uppercat = ';
     67    if ( $_POST['associate'] == -1 or $_POST['associate'] == '' )
     68      $query.= 'NULL';
     69    else
     70      $query.= $_POST['associate'];
     71  }
     72  $query.= ' WHERE id = '.$_GET['cat'];
     73  $query.= ';';
     74  mysql_query( $query );
    4375
    4476  if ( $_POST['status'] != $row['status'] )
     
    5486    $query.= ' WHERE cat_id = '.$_GET['cat'];
    5587    mysql_query( $query );
    56   }
    57  
    58   $query = 'UPDATE '.PREFIX_TABLE.'categories';
    59 
    60   $query.= ' SET name = ';
    61   if ( $_POST['name'] == '' )
    62     $query.= 'NULL';
    63   else
    64     $query.= "'".htmlentities( $_POST['name'], ENT_QUOTES)."'";
    65 
    66   $query.= ', comment = ';
    67   if ( $_POST['comment'] == '' )
    68     $query.= 'NULL';
    69   else
    70     $query.= "'".htmlentities( $_POST['comment'], ENT_QUOTES )."'";
    71 
    72   $query.= ", status = '".$_POST['status']."'";
    73   $query.= ", visible = '".$_POST['visible']."'";
    74 
    75   if ( isset( $_POST['uploadable'] ) )
    76     $query.= ", uploadable = '".$_POST['uploadable']."'";
    77 
    78   if ( isset( $_POST['associate'] ) )
    79   {
    80     $query.= ', id_uppercat = ';
    81     if ( $_POST['associate'] == -1 ) $query.= 'NULL';
    82     else                             $query.= $_POST['associate'];
    83   }
    84   $query.= ' WHERE id = '.$_GET['cat'];
    85   $query.= ';';
    86   mysql_query( $query );
     88    // resynchronize all users
     89    synchronize_all_users();
     90  }
    8791
    8892  // checking users favorites
     
    112116$query.= ';';
    113117$row = mysql_fetch_array( mysql_query( $query ) );
     118
     119if ( !isset( $row['dir'] ) ) $row['dir'] = '';
     120if ( !isset( $row['id_uppercat'] ) ) $row['id_uppercat'] = '';
     121
    114122$result = get_cat_info( $row['id'] );
    115123// cat name
     
    136144}
    137145$vtp->setVar( $sub, 'name',    $row['name'] );
     146if ( !isset( $row['comment'] ) ) $row['comment'] = '';
    138147$vtp->setVar( $sub, 'comment', $row['comment'] );
    139148// status : public, private...
     
    204213{
    205214  $vtp->addSession( $sub, 'parent' );
    206   $vtp->addSession( $sub, 'associate_cat' );
    207   $vtp->setVar( $sub, 'associate_cat.value', '-1' );
    208   $vtp->setVar( $sub, 'associate_cat.content', '' );
    209   $vtp->closeSession( $sub, 'associate_cat' );
    210   $structure = create_structure( '', array() );
    211   display_categories( $structure, ' ', $row['id_uppercat'], $row['id'] );
     215  // We only show a List Of Values if the number of categories is less than
     216  // $conf['max_LOV_categories']
     217  $query = 'SELECT COUNT(id) AS nb_total_categories';
     218  $query.= ' FROM '.PREFIX_TABLE.'categories';
     219  $query.= ';';
     220  $countrow = mysql_fetch_array( mysql_query( $query ) );
     221  if ( $countrow['nb_total_categories'] < $conf['max_LOV_categories'] )
     222  {
     223    $vtp->addSession( $sub, 'associate_LOV' );
     224    $vtp->addSession( $sub, 'associate_cat' );
     225    $vtp->setVar( $sub, 'associate_cat.value', '-1' );
     226    $vtp->setVar( $sub, 'associate_cat.content', '' );
     227    $vtp->closeSession( $sub, 'associate_cat' );
     228    $page['plain_structure'] = get_plain_structure( true );
     229    $structure = create_structure( '', array() );
     230    display_categories( $structure, '&nbsp;', $row['id_uppercat'],$row['id'] );
     231    $vtp->closeSession( $sub, 'associate_LOV' );
     232  }
     233  // else, we only display a small text field, we suppose the administrator
     234  // knows the id of its category
     235  else
     236  {
     237    $vtp->addSession( $sub, 'associate_text' );
     238    $vtp->setVar( $sub, 'associate_text.value', $row['id_uppercat'] );
     239    $vtp->closeSession( $sub, 'associate_text' );
     240  }
    212241  $vtp->closeSession( $sub, 'parent' );
    213242}
Note: See TracChangeset for help on using the changeset viewer.