diff options
Diffstat (limited to 'admin/picture_modify.php')
-rw-r--r-- | admin/picture_modify.php | 62 |
1 files changed, 53 insertions, 9 deletions
diff --git a/admin/picture_modify.php b/admin/picture_modify.php index 3eaa0748e..31c89c438 100644 --- a/admin/picture_modify.php +++ b/admin/picture_modify.php @@ -18,8 +18,6 @@ ***************************************************************************/ include_once( './include/isadmin.inc.php' ); -//----------------------------------------- categories structure initialization -$page['plain_structure'] = get_plain_structure(); //--------------------------------------------------------- update informations $errors = array(); // first, we verify whether there is a mistake on the given creation date @@ -106,14 +104,35 @@ if ( isset( $_POST['submit'] ) ) mysql_query( $query ); } } + $associate_or_dissociate = false; // associate with a new category ? - if ( $_POST['associate'] != '-1' ) + if ( $_POST['associate'] != '-1' and $_POST['associate'] != '' ) + { + // does the uppercat id exists in the database ? + if ( !is_numeric( $_POST['associate'] ) ) + { + array_push( $errors, $lang['cat_unknown_id'] ); + } + else + { + $query = 'SELECT id'; + $query.= ' FROM '.PREFIX_TABLE.'categories'; + $query.= ' WHERE id = '.$_POST['associate']; + $query.= ';'; + if ( mysql_num_rows( mysql_query( $query ) ) == 0 ) + array_push( $errors, $lang['cat_unknown_id'] ); + } + } + if ( $_POST['associate'] != '-1' + and $_POST['associate'] != '' + and count( $errors ) == 0 ) { $query = 'INSERT INTO '.PREFIX_TABLE.'image_category'; $query.= ' (category_id,image_id) VALUES '; $query.= '('.$_POST['associate'].','.$_GET['image_id'].')'; $query.= ';'; mysql_query( $query); + $associate_or_dissociate = true; update_category( $_POST['associate'] ); } // dissociate any category ? @@ -132,9 +151,14 @@ if ( isset( $_POST['submit'] ) ) $query.= ' AND category_id = '.$row['category_id']; $query.= ';'; mysql_query( $query ); + $associate_or_dissociate = true; update_category( $row['category_id'] ); } } + if ( $associate_or_dissociate ) + { + synchronize_all_users(); + } } //----------------------------------------------------- template initialization $sub = $vtp->Open( @@ -306,12 +330,32 @@ if ( mysql_num_rows( $result ) > 0 ) $vtp->closeSession( $sub, 'dissociate' ); } // associate to another category ? -$vtp->addSession( $sub, 'associate_cat' ); -$vtp->setVar( $sub, 'associate_cat.value', '-1' ); -$vtp->setVar( $sub, 'associate_cat.content', '' ); -$vtp->closeSession( $sub, 'associate_cat' ); -$structure = create_structure( '', array() ); -display_categories( $structure, ' ' ); +// +// We only show a List Of Values if the number of categories is less than +// $conf['max_LOV_categories'] +$query = 'SELECT COUNT(id) AS nb_total_categories'; +$query.= ' FROM '.PREFIX_TABLE.'categories'; +$query.= ';'; +$row = mysql_fetch_array( mysql_query( $query ) ); +if ( $row['nb_total_categories'] < $conf['max_LOV_categories'] ) +{ + $vtp->addSession( $sub, 'associate_LOV' ); + $vtp->addSession( $sub, 'associate_cat' ); + $vtp->setVar( $sub, 'associate_cat.value', '-1' ); + $vtp->setVar( $sub, 'associate_cat.content', '' ); + $vtp->closeSession( $sub, 'associate_cat' ); + $page['plain_structure'] = get_plain_structure( true ); + $structure = create_structure( '', array() ); + display_categories( $structure, ' ' ); + $vtp->closeSession( $sub, 'associate_LOV' ); +} +// else, we only display a small text field, we suppose the administrator +// knows the id of its category +else +{ + $vtp->addSession( $sub, 'associate_text' ); + $vtp->closeSession( $sub, 'associate_text' ); +} //----------------------------------------------------------- sending html code $vtp->Parse( $handle , 'sub', $sub ); ?>
\ No newline at end of file |