aboutsummaryrefslogtreecommitdiffstats
path: root/admin/cat_modify.php
diff options
context:
space:
mode:
authorz0rglub <z0rglub@piwigo.org>2004-01-30 22:47:18 +0000
committerz0rglub <z0rglub@piwigo.org>2004-01-30 22:47:18 +0000
commit27c7e9d5a2c0252e417fbcc471ea86d416c572f9 (patch)
tree48fc790b12cffbf12c55de1fe0c0d5e03c64ffae /admin/cat_modify.php
parent6ea2c1b7d9faa4ed2075ee767eb74d74a9d53f7e (diff)
- Php warnings correction
- many categories management : display a simple text field for uppercat id instead of a selection box git-svn-id: http://piwigo.org/svn/branches/release-1_3@331 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'admin/cat_modify.php')
-rw-r--r--admin/cat_modify.php44
1 files changed, 35 insertions, 9 deletions
diff --git a/admin/cat_modify.php b/admin/cat_modify.php
index 2eb9d5fdf..679d9a6a9 100644
--- a/admin/cat_modify.php
+++ b/admin/cat_modify.php
@@ -64,8 +64,10 @@ if ( isset( $_POST['submit'] ) )
if ( isset( $_POST['associate'] ) )
{
$query.= ', id_uppercat = ';
- if ( $_POST['associate'] == -1 ) $query.= 'NULL';
- else $query.= $_POST['associate'];
+ if ( $_POST['associate'] == -1 or $_POST['associate'] == '' )
+ $query.= 'NULL';
+ else
+ $query.= $_POST['associate'];
}
$query.= ' WHERE id = '.$_GET['cat'];
$query.= ';';
@@ -113,12 +115,16 @@ $query.= ' WHERE a.id = '.$_GET['cat'];
$query.= ' AND a.site_id = b.id';
$query.= ';';
$row = mysql_fetch_array( mysql_query( $query ) );
+
+if ( !isset( $row['dir'] ) ) $row['dir'] = '';
+if ( !isset( $row['id_uppercat'] ) ) $row['id_uppercat'] = '';
+
$result = get_cat_info( $row['id'] );
// cat name
$cat_name = get_cat_display_name( $result['name'], ' - ', '' );
$vtp->setVar( $sub, 'cat:name', $cat_name );
// cat dir
-if ( isset( $row['dir'] ) and $row['dir'] != '' )
+if ( $row['dir'] != '' )
{
$vtp->addSession( $sub, 'storage' );
$vtp->setVar( $sub, 'storage.dir', $row['dir'] );
@@ -206,12 +212,32 @@ if ( $conf['upload_available'] and $row['dir'] != '' and $row['site_id'] == 1 )
if ( $row['dir'] == '' )
{
$vtp->addSession( $sub, 'parent' );
- $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, '&nbsp;', $row['id_uppercat'], $row['id'] );
+ // 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.= ';';
+ $countrow = mysql_fetch_array( mysql_query( $query ) );
+ if ( $countrow['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, '&nbsp;', $row['id_uppercat'],$row['id'] );
+ $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->setVar( $sub, 'associate_text.value', $row['id_uppercat'] );
+ $vtp->closeSession( $sub, 'associate_text' );
+ }
$vtp->closeSession( $sub, 'parent' );
}
//----------------------------------------------------------- sending html code