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/picture_modify.php

    r226 r345  
    1919
    2020include_once( './admin/include/isadmin.inc.php' );
    21 //----------------------------------------- categories structure initialization
    22 $page['plain_structure'] = get_plain_structure();
    2321//--------------------------------------------------------- update informations
    2422$errors = array();
     
    8886    // category, the category is updated in the database (without wondering
    8987    // if this picture was already the representative one)
    90     if ( $_POST['representative-'.$row['category_id']] == 1 )
     88    if ( isset($_POST['representative-'.$row['category_id']]) )
    9189    {
    9290      $query = 'UPDATE '.PREFIX_TABLE.'categories';
     
    9896    // if the user ask this picture to be not any more the representative,
    9997    // we have to set the representative_picture_id of this category to NULL
    100     else if ( $row['representative_picture_id'] == $_GET['image_id'] )
     98    else if ( isset( $row['representative_picture_id'] )
     99              and $row['representative_picture_id'] == $_GET['image_id'] )
    101100    {
    102101      $query = 'UPDATE '.PREFIX_TABLE.'categories';
     
    107106    }
    108107  }
     108  $associate_or_dissociate = false;
    109109  // associate with a new category ?
    110   if ( $_POST['associate'] != '-1' )
     110  if ( $_POST['associate'] != '-1' and $_POST['associate'] != '' )
     111  {
     112    // does the uppercat id exists in the database ?
     113    if ( !is_numeric( $_POST['associate'] ) )
     114    {
     115      array_push( $errors, $lang['cat_unknown_id'] );
     116    }
     117    else
     118    {
     119      $query = 'SELECT id';
     120      $query.= ' FROM '.PREFIX_TABLE.'categories';
     121      $query.= ' WHERE id = '.$_POST['associate'];
     122      $query.= ';';
     123      if ( mysql_num_rows( mysql_query( $query ) ) == 0 )
     124        array_push( $errors, $lang['cat_unknown_id'] );
     125    }
     126  }
     127  if ( $_POST['associate'] != '-1'
     128       and $_POST['associate'] != ''
     129       and count( $errors ) == 0 )
    111130  {
    112131    $query = 'INSERT INTO '.PREFIX_TABLE.'image_category';
     
    115134    $query.= ';';
    116135    mysql_query( $query);
     136    $associate_or_dissociate = true;
    117137    update_category( $_POST['associate'] );
    118138  }
     
    126146  while ( $row = mysql_fetch_array( $result ) )
    127147  {
    128     if ( $_POST['dissociate-'.$row['category_id']] == 1 )
     148    if ( isset($_POST['dissociate-'.$row['category_id']]) )
    129149    {
    130150      $query = 'DELETE FROM '.PREFIX_TABLE.'image_category';
     
    133153      $query.= ';';
    134154      mysql_query( $query );
     155      $associate_or_dissociate = true;
    135156      update_category( $row['category_id'] );
    136157    }
     158  }
     159  if ( $associate_or_dissociate )
     160  {
     161    synchronize_all_users();
    137162  }
    138163}
     
    163188$vtp->setVar( $sub, 'form_action', $action );
    164189// retrieving direct information about picture
    165 $query = 'SELECT file,date_available,date_creation,tn_ext,name,filesize';
    166 $query.= ',width,height,author,comment,keywords,storage_category_id';
     190$infos = array( 'file','date_available','date_creation','tn_ext','name'
     191                ,'filesize','width','height','author','comment','keywords'
     192                ,'storage_category_id' );
     193$query = 'SELECT '. implode( ',', $infos );
    167194$query.= ' FROM '.PREFIX_TABLE.'images';
    168195$query.= ' WHERE id = '.$_GET['image_id'];
    169196$query.= ';';
    170197$row = mysql_fetch_array( mysql_query( $query ) );
     198
     199foreach ( $infos as $info ) {
     200  if ( !isset( $row[$info] ) ) $row[$info] = '';
     201}
     202
    171203// picture title
    172204if ( $row['name'] == '' )
     
    291323  }
    292324
    293   if ( $row['representative_picture_id'] == $_GET['image_id'] )
     325  if ( isset( $row['representative_picture_id'] )
     326       and $row['representative_picture_id'] == $_GET['image_id'] )
    294327  {
    295328    $vtp->setVar( $sub, 'linked_category.representative_checked',
     
    307340}
    308341// associate to another category ?
    309 $vtp->addSession( $sub, 'associate_cat' );
    310 $vtp->setVar( $sub, 'associate_cat.value', '-1' );
    311 $vtp->setVar( $sub, 'associate_cat.content', '' );
    312 $vtp->closeSession( $sub, 'associate_cat' );
    313 $structure = create_structure( '', array() );
    314 display_categories( $structure, ' ' );
     342//
     343// We only show a List Of Values if the number of categories is less than
     344// $conf['max_LOV_categories']
     345$query = 'SELECT COUNT(id) AS nb_total_categories';
     346$query.= ' FROM '.PREFIX_TABLE.'categories';
     347$query.= ';';
     348$row = mysql_fetch_array( mysql_query( $query ) );
     349if ( $row['nb_total_categories'] < $conf['max_LOV_categories'] )
     350{
     351  $vtp->addSession( $sub, 'associate_LOV' );
     352  $vtp->addSession( $sub, 'associate_cat' );
     353  $vtp->setVar( $sub, 'associate_cat.value', '-1' );
     354  $vtp->setVar( $sub, 'associate_cat.content', '' );
     355  $vtp->closeSession( $sub, 'associate_cat' );
     356  $page['plain_structure'] = get_plain_structure( true );
     357  $structure = create_structure( '', array() );
     358  display_categories( $structure, '&nbsp;' );
     359  $vtp->closeSession( $sub, 'associate_LOV' );
     360}
     361// else, we only display a small text field, we suppose the administrator
     362// knows the id of its category
     363else
     364{
     365  $vtp->addSession( $sub, 'associate_text' );
     366  $vtp->closeSession( $sub, 'associate_text' );
     367}
    315368//----------------------------------------------------------- sending html code
    316369$vtp->Parse( $handle , 'sub', $sub );
Note: See TracChangeset for help on using the changeset viewer.