From 0ec91d8b4834d63c65dcbef6ac49ab5a8f68ddd1 Mon Sep 17 00:00:00 2001 From: z0rglub Date: Tue, 1 Jul 2003 09:27:20 +0000 Subject: *** empty log message *** git-svn-id: http://piwigo.org/svn/trunk@21 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/functions_category.inc.php | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'include/functions_category.inc.php') diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php index 21de2ad71..de868db82 100644 --- a/include/functions_category.inc.php +++ b/include/functions_category.inc.php @@ -14,27 +14,25 @@ * the Free Software Foundation; * * * ***************************************************************************/ + function get_subcats_id( $cat_id ) { - $restricted_cat = array(); - $i = 0; + $restricted_cats = array(); - $query = 'select id'; - $query.= ' from '.PREFIX_TABLE.'categories'; - $query.= ' where id_uppercat = '.$cat_id; + $query = 'SELECT id'; + $query.= ' FROM '.PREFIX_TABLE.'categories'; + $query.= ' WHERE id_uppercat = '.$cat_id; $query.= ';'; $result = mysql_query( $query ); while ( $row = mysql_fetch_array( $result ) ) { - $restricted_cat[$i++] = $row['id']; - $sub_restricted_cat = get_subcats_id( $row['id'] ); - for ( $j = 0; $j < sizeof( $sub_restricted_cat ); $j++ ) - { - $restricted_cat[$i++] = $sub_restricted_cat[$j]; + array_push( $restricted_cats, $row['id'] ); + $sub_restricted_cats = get_subcats_id( $row['id'] ); + foreach ( $sub_restricted_cats as $sub_restricted_cat ) { + array_push( $restricted_cats, $sub_restricted_cat ); } } - - return $restricted_cat; + return $restricted_cats; } function check_restrictions( $category_id ) -- cgit v1.2.3