aboutsummaryrefslogtreecommitdiffstats
path: root/admin/cat_modify.php
diff options
context:
space:
mode:
authorgweltas <gweltas@piwigo.org>2004-02-02 00:55:18 +0000
committergweltas <gweltas@piwigo.org>2004-02-02 00:55:18 +0000
commitbef4b3e3aa8e3d54cbf8b4962b9b5d4a89b55429 (patch)
tree647b2cf07ee8451a9314e1e8aebd11d9396cb32b /admin/cat_modify.php
parenteea989f019f21fbd7ae4aa8e2f4a1503992c23bf (diff)
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 git-svn-id: http://piwigo.org/svn/trunk@345 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--admin/cat_modify.php73
1 files changed, 51 insertions, 22 deletions
diff --git a/admin/cat_modify.php b/admin/cat_modify.php
index ad0911a0c..50741feea 100644
--- a/admin/cat_modify.php
+++ b/admin/cat_modify.php
@@ -40,20 +40,6 @@ if ( isset( $_POST['submit'] ) )
$query.= ' WHERE id = '.$_GET['cat'];
$query.= ';';
$row = mysql_fetch_array( mysql_query( $query ) );
-
- if ( $_POST['status'] != $row['status'] )
- {
- // deletion of all access for groups concerning this category
- $query = 'DELETE';
- $query.= ' FROM '.PREFIX_TABLE.'group_access';
- $query.= ' WHERE cat_id = '.$_GET['cat'];
- mysql_query( $query );
- // deletion of all access for users concerning this category
- $query = 'DELETE';
- $query.= ' FROM '.PREFIX_TABLE.'user_access';
- $query.= ' WHERE cat_id = '.$_GET['cat'];
- mysql_query( $query );
- }
$query = 'UPDATE '.PREFIX_TABLE.'categories';
@@ -78,13 +64,31 @@ 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.= ';';
mysql_query( $query );
+ if ( $_POST['status'] != $row['status'] )
+ {
+ // deletion of all access for groups concerning this category
+ $query = 'DELETE';
+ $query.= ' FROM '.PREFIX_TABLE.'group_access';
+ $query.= ' WHERE cat_id = '.$_GET['cat'];
+ mysql_query( $query );
+ // deletion of all access for users concerning this category
+ $query = 'DELETE';
+ $query.= ' FROM '.PREFIX_TABLE.'user_access';
+ $query.= ' WHERE cat_id = '.$_GET['cat'];
+ mysql_query( $query );
+ // resynchronize all users
+ synchronize_all_users();
+ }
+
// checking users favorites
$query = 'SELECT id';
$query.= ' FROM '.PREFIX_TABLE.'users';
@@ -111,6 +115,10 @@ $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'], ' - ', '' );
@@ -135,6 +143,7 @@ if ( $row['site_id'] != 1 )
$vtp->closeSession( $sub, 'server' );
}
$vtp->setVar( $sub, 'name', $row['name'] );
+if ( !isset( $row['comment'] ) ) $row['comment'] = '';
$vtp->setVar( $sub, 'comment', $row['comment'] );
// status : public, private...
$options = get_enums( PREFIX_TABLE.'categories', 'status' );
@@ -203,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