aboutsummaryrefslogtreecommitdiffstats
path: root/admin/picture_modify.php
diff options
context:
space:
mode:
authorz0rglub <z0rglub@piwigo.org>2004-01-03 21:36:59 +0000
committerz0rglub <z0rglub@piwigo.org>2004-01-03 21:36:59 +0000
commitfa92671b15dec1e072f2c6407e86c2370125070b (patch)
treea55cdd81a11e9c1f83f3b577fad9b4bc4ba5767e /admin/picture_modify.php
parent02f153125b79bdb5c4dea8ecf0d64f5a1bddc148 (diff)
for virtual category to picture association, if the number of categories is
more than $conf['max_LOV_categories'], we only show a text box asking parent category id git-svn-id: http://piwigo.org/svn/branches/release-1_3@258 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'admin/picture_modify.php')
-rw-r--r--admin/picture_modify.php62
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, '&nbsp;' );
+//
+// 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, '&nbsp;' );
+ $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