aboutsummaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--admin/admin.php4
-rw-r--r--admin/comments.php19
-rw-r--r--admin/configuration.php2
-rw-r--r--admin/include/functions.php148
-rw-r--r--admin/infos_images.php153
-rw-r--r--admin/picture_modify.php270
-rw-r--r--admin/update.php167
-rw-r--r--admin/waiting.php38
8 files changed, 589 insertions, 212 deletions
diff --git a/admin/admin.php b/admin/admin.php
index 7ea97fdd7..b9b499cf2 100644
--- a/admin/admin.php
+++ b/admin/admin.php
@@ -131,6 +131,10 @@ switch ( $_GET['page'] )
$title = $lang['title_comments'];
$page_valide = true;
break;
+ case 'picture_modify' :
+ $title = $lang['title_picmod'];
+ $page_valide = true;
+ break;
default:
$title = $lang['title_default']; break;
}
diff --git a/admin/comments.php b/admin/comments.php
index 127d495f4..dc9e584ac 100644
--- a/admin/comments.php
+++ b/admin/comments.php
@@ -17,6 +17,7 @@
* *
***************************************************************************/
include_once( './include/isadmin.inc.php' );
+$page['plain_structure'] = get_plain_structure();
//------------------------------------------------------------------- functions
function display_pictures( $mysql_result, $maxtime, $validation_box = false )
{
@@ -28,7 +29,7 @@ function display_pictures( $mysql_result, $maxtime, $validation_box = false )
$vtp->addSession( $sub, 'picture' );
// 2. for each picture, getting informations for displaying thumbnail and
// link to the full size picture
- $query = 'SELECT name,file,cat_id,tn_ext';
+ $query = 'SELECT name,file,storage_category_id as cat_id,tn_ext';
$query.= ' FROM '.PREFIX_TABLE.'images';
$query.= ' WHERE id = '.$row['image_id'];
$query.= ';';
@@ -37,8 +38,9 @@ function display_pictures( $mysql_result, $maxtime, $validation_box = false )
if ( $array_cat_directories[$subrow['cat_id']] == '' )
{
+ $array_cat_directories[$subrow['cat_id']] =
+ get_complete_dir( $subrow['cat_id'] );
$cat_result = get_cat_info( $subrow['cat_id'] );
- $array_cat_directories[$subrow['cat_id']] = $cat_result['dir'];
$array_cat_site_id[$subrow['cat_id']] = $cat_result['site_id'];
$array_cat_names[$subrow['cat_id']] =
get_cat_display_name( $cat_result['name'], ' > ', '' );
@@ -83,10 +85,7 @@ function display_pictures( $mysql_result, $maxtime, $validation_box = false )
{
$vtp->addSession( $sub, 'comment' );
$vtp->setVar( $sub, 'comment.author', $subrow['author'] );
- $displayed_date = $lang['day'][date( "w", $subrow['date'] )];
- $displayed_date.= date( " j ", $subrow['date'] );
- $displayed_date.= $lang['month'][date( "n", $subrow['date'] )];
- $displayed_date.= date( " Y G:i", $subrow['date'] );
+ $displayed_date = format_date( $subrow['date'], 'unix', true );
$vtp->setVar( $sub, 'comment.date', $displayed_date );
$vtp->setVar( $sub, 'comment.content', nl2br( $subrow['content'] ) );
$vtp->addSession( $sub, 'delete' );
@@ -183,11 +182,9 @@ if ( isset( $_GET['last_days'] ) )
$query = 'SELECT DISTINCT(image_id) as image_id';
$query.= ' FROM '.PREFIX_TABLE.'comments';
$query.= ', '.PREFIX_TABLE.'images as images';
- $query.= ', '.PREFIX_TABLE.'categories';
$query.= ' WHERE image_id = images.id';
- $query.= ' AND cat_id = images.cat_id';
$query.= ' AND date > '.$maxtime;
- $query.= ' ORDER BY cat_id ASC,date_available DESC';
+ $query.= ' ORDER BY date_available DESC';
$query.= ';';
$result = mysql_query( $query );
display_pictures( $result, $maxtime );
@@ -221,11 +218,9 @@ if ( isset( $_GET['show_unvalidated'] ) )
$query = 'SELECT DISTINCT(image_id) as image_id';
$query.= ' FROM '.PREFIX_TABLE.'comments as comments';
$query.= ', '.PREFIX_TABLE.'images as images';
- $query.= ', '.PREFIX_TABLE.'categories';
$query.= ' WHERE image_id = images.id';
- $query.= ' AND cat_id = images.cat_id';
$query.= " AND comments.validated = 'false'";
- $query.= ' ORDER BY cat_id ASC,date_available DESC';
+ $query.= ' ORDER BY date_available DESC';
$query.= ';';
$result = mysql_query( $query );
display_pictures( $result, 0, true );
diff --git a/admin/configuration.php b/admin/configuration.php
index de2cc6f26..d2cdda12c 100644
--- a/admin/configuration.php
+++ b/admin/configuration.php
@@ -259,7 +259,7 @@ $sub = $vtp->Open(
'../template/'.$user['template'].'/admin/configuration.vtp' );
$tpl = array( 'conf_confirmation','remote_site','delete',
- 'conf_remote_site_delete_info','submit' );
+ 'conf_remote_site_delete_info','submit','errors_title' );
templatize_array( $tpl, 'lang', $sub );
//-------------------------------------------------------------- errors display
if ( sizeof( $error ) != 0 )
diff --git a/admin/include/functions.php b/admin/include/functions.php
index dfb4aab90..7115f163b 100644
--- a/admin/include/functions.php
+++ b/admin/include/functions.php
@@ -94,6 +94,7 @@ function delete_site( $id )
// The function delete_category deletes the category identified by the $id
// It also deletes (in the database) :
// - all the images of the images (thanks to delete_image, see further)
+// - all the links between images and this category
// - all the restrictions linked to the category
// The function works recursively.
function delete_category( $id )
@@ -101,7 +102,7 @@ function delete_category( $id )
// destruction of all the related images
$query = 'SELECT id';
$query.= ' FROM '.PREFIX_TABLE.'images';
- $query.= ' WHERE cat_id = '.$id;
+ $query.= ' WHERE storage_category_id = '.$id;
$query.= ';';
$result = mysql_query( $query );
while ( $row = mysql_fetch_array( $result ) )
@@ -109,6 +110,12 @@ function delete_category( $id )
delete_image( $row['id'] );
}
+ // destruction of the links between images and this category
+ $query = 'DELETE FROM '.PREFIX_TABLE.'image_category';
+ $query.= ' WHERE category_id = '.$id;
+ $query.= ';';
+ mysql_query( $query );
+
// destruction of the access linked to the category
$query = 'DELETE FROM '.PREFIX_TABLE.'user_access';
$query.= ' WHERE cat_id = '.$id;
@@ -140,6 +147,7 @@ function delete_category( $id )
// The function delete_image deletes the image identified by the $id
// It also deletes (in the database) :
// - all the comments related to the image
+// - all the links between categories and this image
// - all the favorites associated to the image
function delete_image( $id )
{
@@ -150,7 +158,13 @@ function delete_image( $id )
$query.= ' WHERE image_id = '.$id;
$query.= ';';
mysql_query( $query );
-
+
+ // destruction of the links between images and this category
+ $query = 'DELETE FROM '.PREFIX_TABLE.'image_category';
+ $query.= ' WHERE image_id = '.$id;
+ $query.= ';';
+ mysql_query( $query );
+
// destruction of the favorites associated with the picture
$query = 'DELETE FROM '.PREFIX_TABLE.'favorites';
$query.= ' WHERE image_id = '.$id;
@@ -244,15 +258,28 @@ function check_favorites( $user_id )
$restricted_cat = get_all_restrictions( $user_id, $status );
// retrieving all the favorites for this user and comparing their
// categories to the restricted categories
- $query = 'SELECT image_id, cat_id';
- $query.= ' FROM '.PREFIX_TABLE.'favorites, '.PREFIX_TABLE.'images';
+ $query = 'SELECT image_id';
+ $query.= ' FROM '.PREFIX_TABLE.'favorites';
$query.= ' WHERE user_id = '.$user_id;
- $query.= ' AND id = image_id';
$query.= ';';
$result = mysql_query ( $query );
while ( $row = mysql_fetch_array( $result ) )
{
- if ( in_array( $row['cat_id'], $restricted_cat ) )
+ // for each picture, we have to check all the categories it belongs
+ // to. Indeed if a picture belongs to category_1 and category_2 and that
+ // category_2 is not restricted to the user, he can have the picture as
+ // favorite.
+ $query = 'SELECT DISTINCT(category_id) as category_id';
+ $query.= ' FROM '.PREFIX_TABLE.'image_category';
+ $query.= ' WHERE image_id = '.$row['image_id'];
+ $query.= ';';
+ $picture_result = mysql_query( $query );
+ $picture_cat = array();
+ while ( $picture_row = mysql_fetch_array( $picture_result ) )
+ {
+ array_push( $picture_cat, $picture_row['category_id'] );
+ }
+ if ( count( array_diff( $picture_cat, $restricted_cat ) ) > 0 )
{
$query = 'DELETE FROM '.PREFIX_TABLE.'favorites';
$query.= ' WHERE image_id = '.$row['image_id'];
@@ -262,4 +289,113 @@ function check_favorites( $user_id )
}
}
}
+
+// update_category updates calculated informations about a category :
+// date_last and nb_images
+function update_category( $id = 'all' )
+{
+ if ( $id == 'all' )
+ {
+ $query = 'SELECT id';
+ $query.= ' FROM '.PREFIX_TABLE.'categories';
+ $query.= ';';
+ $result = mysql_query( $query );
+ while ( $row = mysql_fetch_array( $result ) )
+ {
+ // recursive call
+ update_category( $row['id'] );
+ }
+ }
+ else if ( is_numeric( $id ) )
+ {
+ // updating the number of pictures
+ $query = 'SELECT COUNT(*) as nb_images';
+ $query.= ' FROM '.PREFIX_TABLE.'image_category';
+ $query.= ' WHERE category_id = '.$id;
+ $query.= ';';
+ $row = mysql_fetch_array( mysql_query( $query ) );
+ $query = 'UPDATE '.PREFIX_TABLE.'categories';
+ $query.= ' SET nb_images = '.$row['nb_images'];
+ $query.= ' WHERE id = '.$id;
+ $query.= ';';
+ mysql_query( $query );
+ // updating the date_last
+ $query = 'SELECT date_available';
+ $query.= ' FROM '.PREFIX_TABLE.'images';
+ $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id';
+ $query.= ' WHERE category_id = '.$id;
+ $query.= ' ORDER BY date_available DESC';
+ $query.= ' LIMIT 0,1';
+ $query.= ';';
+ $row = mysql_fetch_array( mysql_query( $query ) );
+ $query = 'UPDATE '.PREFIX_TABLE.'categories';
+ $query.= " SET date_last = '".$row['date_available']."'";
+ $query.= ' WHERE id = '.$id;
+ $query.= ';';
+ mysql_query( $query );
+ }
+}
+
+function check_date_format( $date )
+{
+ // date arrives at this format : DD/MM/YYYY
+ list($day,$month,$year) = explode( '/', $date );
+ return checkdate ( $month, $day, $year );
+}
+
+function date_convert( $date )
+{
+ // date arrives at this format : DD/MM/YYYY
+ // It must be transformed in YYYY-MM-DD
+ list($day,$month,$year) = explode( '/', $date );
+ return $year.'-'.$month.'-'.$day;
+}
+
+function date_convert_back( $date )
+{
+ // date arrives at this format : YYYY-MM-DD
+ // It must be transformed in DD/MM/YYYY
+ if ( $date != '' )
+ {
+ list($year,$month,$day) = explode( '-', $date );
+ return $day.'/'.$month.'/'.$year;
+ }
+ else
+ {
+ return '';
+ }
+}
+
+// get_keywords returns an array with relevant keywords found in the string
+// given in argument. Keywords must be separated by comma in this string.
+// keywords must :
+// - be longer or equal to 3 characters
+// - not contain ', " or blank characters
+// - unique in the string ("test,test" -> "test")
+function get_keywords( $keywords_string )
+{
+ $keywords = array();
+
+ $candidates = explode( ',', $keywords_string );
+ foreach ( $candidates as $candidate ) {
+ if ( strlen($candidate) >= 3 and !preg_match( '/(\'|"|\s)/', $candidate ) )
+ array_push( $keywords, $candidate );
+ }
+
+ return array_unique( $keywords );
+}
+
+function display_categories( $categories, $indent )
+{
+ global $vtp,$sub;
+
+ foreach ( $categories as $category ) {
+ $vtp->addSession( $sub, 'associate_cat' );
+ $vtp->setVar( $sub, 'associate_cat.value', $category['id'] );
+ $content = $indent.'- '.$category['name'];
+ $vtp->setVar( $sub, 'associate_cat.content', $content );
+ $vtp->closeSession( $sub, 'associate_cat' );
+ display_categories( $category['subcats'], $indent.str_repeat(' ',3) );
+ }
+}
?> \ No newline at end of file
diff --git a/admin/infos_images.php b/admin/infos_images.php
index 9a8b77939..8b3392da0 100644
--- a/admin/infos_images.php
+++ b/admin/infos_images.php
@@ -19,64 +19,15 @@
include_once( './include/isadmin.inc.php' );
include_once( '../template/'.$user['template'].'/htmlfunctions.inc.php' );
-//------------------------------------------------------------------- functions
-function check_date_format( $date )
-{
- // date arrives at this format : DD/MM/YYYY
- list($day,$month,$year) = explode( '/', $date );
- return checkdate ( $month, $day, $year );
-}
-
-function date_convert( $date )
-{
- // date arrives at this format : DD/MM/YYYY
- // It must be transformed in YYYY-MM-DD
- list($day,$month,$year) = explode( '/', $date );
- return $year.'-'.$month.'-'.$day;
-}
-
-function date_convert_back( $date )
-{
- // date arrives at this format : YYYY-MM-DD
- // It must be transformed in DD/MM/YYYY
- if ( $date != '' )
- {
- list($year,$month,$day) = explode( '-', $date );
- return $day.'/'.$month.'/'.$year;
- }
- else
- {
- return '';
- }
-}
-
-// get_keywords returns an array with relevant keywords found in the string
-// given in argument. Keywords must be separated by comma in this string.
-// keywords must :
-// - be longer or equal to 3 characters
-// - not contain ', " or blank characters
-// - unique in the string ("test,test" -> "test")
-function get_keywords( $keywords_string )
-{
- $keywords = array();
-
- $candidates = explode( ',', $keywords_string );
- foreach ( $candidates as $candidate ) {
- if ( strlen($candidate) >= 3 and !preg_match( '/(\'|"|\s)/', $candidate ) )
- array_push( $keywords, $candidate );
- }
-
- return array_unique( $keywords );
-}
//-------------------------------------------------------------- initialization
check_cat_id( $_GET['cat_id'] );
-
if ( isset( $page['cat'] ) )
{
//--------------------------------------------------- update individual options
$query = 'SELECT id,file';
$query.= ' FROM '.PREFIX_TABLE.'images';
- $query.= ' WHERE cat_id = '.$page['cat'];
+ $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id';
+ $query.= ' WHERE category_id = '.$page['cat'];
$query.= ';';
$result = mysql_query( $query );
$i = 1;
@@ -121,53 +72,77 @@ if ( isset( $page['cat'] ) )
$query.= 'NULL';
else
{
- $query.= '"';
+ $query.= "'";
foreach ( $keywords_array as $i => $keyword ) {
if ( $i > 0 ) $query.= ',';
$query.= $keyword;
}
- $query.= '"';
+ $query.= "'";
}
$query.= ' WHERE id = '.$row['id'];
$query.= ';';
mysql_query( $query );
}
+ // add link to another category
+ if ( $_POST['check-'.$row['id']] == 1 )
+ {
+ $query = 'INSERT INTO '.PREFIX_TABLE.'image_category';
+ $query.= ' (image_id,category_id) VALUES';
+ $query.= ' ('.$row['id'].','.$_POST['associate'].')';
+ $query.= ';';
+ mysql_query( $query );
+ }
}
+ update_category( $_POST['associate'] );
//------------------------------------------------------ update general options
if ( $_POST['use_common_author'] == 1 )
{
- $query = 'UPDATE '.PREFIX_TABLE.'images';
- if ( $_POST['author_cat'] == '' )
- {
- $query.= ' SET author = NULL';
- }
- else
+ $query = 'SELECT image_id';
+ $query.= ' FROM '.PREFIX_TABLE.'image_category';
+ $query.= ' WHERE category_id = '.$page['cat'];
+ $result = mysql_query( $query );
+ while ( $row = mysql_fetch_array( $result ) )
{
- $query.= ' SET author = ';
- $query.= "'".htmlentities( $_POST['author_cat'], ENT_QUOTES )."'";
+ $query = 'UPDATE '.PREFIX_TABLE.'images';
+ if ( $_POST['author_cat'] == '' )
+ {
+ $query.= ' SET author = NULL';
+ }
+ else
+ {
+ $query.= ' SET author = ';
+ $query.= "'".htmlentities( $_POST['author_cat'], ENT_QUOTES )."'";
+ }
+ $query.= ' WHERE id = '.$row['image_id'];
+ $query.= ';';
+ mysql_query( $query );
}
- $query.= ' WHERE cat_id = '.$page['cat'];
- $query.= ';';
- mysql_query( $query );
}
if ( $_POST['use_common_date_creation'] == 1 )
{
if ( check_date_format( $_POST['date_creation_cat'] ) )
{
$date = date_convert( $_POST['date_creation_cat'] );
- $query = 'UPDATE '.PREFIX_TABLE.'images';
- if ( $_POST['date_creation_cat'] == '' )
- {
- $query.= ' SET date_creation = NULL';
- }
- else
+ $query = 'SELECT image_id';
+ $query.= ' FROM '.PREFIX_TABLE.'image_category';
+ $query.= ' WHERE category_id = '.$page['cat'];
+ $result = mysql_query( $query );
+ while ( $row = mysql_fetch_array( $result ) )
{
- $query.= " SET date_creation = '".$date."'";
+ $query = 'UPDATE '.PREFIX_TABLE.'images';
+ if ( $_POST['date_creation_cat'] == '' )
+ {
+ $query.= ' SET date_creation = NULL';
+ }
+ else
+ {
+ $query.= " SET date_creation = '".$date."'";
+ }
+ $query.= ' WHERE id = '.$row['image_id'];
+ $query.= ';';
+ mysql_query( $query );
}
- $query.= ' WHERE cat_id = '.$page['cat'];
- $query.= ';';
- mysql_query( $query );
}
else
{
@@ -178,7 +153,8 @@ if ( isset( $page['cat'] ) )
{
$query = 'SELECT id,keywords';
$query.= ' FROM '.PREFIX_TABLE.'images';
- $query.= ' WHERE cat_id = '.$page['cat'];
+ $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id';
+ $query.= ' WHERE category_id = '.$page['cat'];
$query.= ';';
$result = mysql_query( $query );
while ( $row = mysql_fetch_array( $result ) )
@@ -241,11 +217,9 @@ if ( isset( $page['cat'] ) )
floor( $_GET['num'] / $page['nb_image_page'] ) * $page['nb_image_page'];
}
// retrieving category information
+ $page['plain_structure'] = get_plain_structure();
$result = get_cat_info( $page['cat'] );
- $cat['local_dir'] = $result['local_dir'];
- $cat['dir'] = $result['dir'];
$cat['name'] = $result['name'];
- $cat['site_id'] = $result['site_id'];
$cat['nb_images'] = $result['nb_images'];
//----------------------------------------------------- template initialization
$sub = $vtp->Open('../template/'.$user['template'].'/admin/infos_image.vtp');
@@ -254,8 +228,9 @@ if ( isset( $page['cat'] ) )
'infoimage_title','infoimage_comment',
'infoimage_creation_date','keywords',
'infoimage_addtoall','infoimage_removefromall',
- 'infoimage_keyword_separation' );
+ 'infoimage_keyword_separation','infoimage_associate' );
templatize_array( $tpl, 'lang', $sub );
+ $vtp->setGlobalVar( $sub, 'user_template', $user['template'] );
//------------------------------------------------------------------------ form
$url = './admin.php?page=infos_images&cat_id='.$page['cat'];
$url.= '&start='.$page['start'];
@@ -266,9 +241,13 @@ if ( isset( $page['cat'] ) )
$cat_name = get_cat_display_name( $cat['name'], ' - ', 'font-style:italic;');
$vtp->setVar( $sub, 'cat_name', $cat_name );
+ $array_cat_directories = array();
+
$query = 'SELECT id,file,comment,author,tn_ext,name,date_creation,keywords';
+ $query.= ',storage_category_id,category_id';
$query.= ' FROM '.PREFIX_TABLE.'images';
- $query.= ' WHERE cat_id = '.$page['cat'];
+ $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id';
+ $query.= ' WHERE category_id = '.$page['cat'];
$query.= $conf['order_by'];
$query.= ' LIMIT '.$page['start'].','.$page['nb_image_page'];
$query.= ';';
@@ -287,13 +266,15 @@ if ( isset( $page['cat'] ) )
$file = get_filename_wo_extension( $row['file'] );
$vtp->setVar( $sub, 'picture.default_name', $file );
// creating url to thumbnail
- if ( $cat['site_id'] == 1 )
- {
- $thumbnail_url = '../galleries/'.$cat['local_dir'].'/';
+ if ( $array_cat_directories[$row['storage_category_id']] == '' )
+ {
+ $array_cat_directories[$row['storage_category_id']] =
+ get_complete_dir( $row['storage_category_id'] );
}
- else
+ $thumbnail_url = $array_cat_directories[$row['storage_category_id']];
+ if ( preg_match( '/^\.\/galleries/', $thumbnail_url ) )
{
- $thumbnail_url = $cat['dir'];
+ $thumbnail_url = '.'.$thumbnail_url;
}
$thumbnail_url.= 'thumbnail/';
$thumbnail_url.= $conf['prefix_thumbnail'].$file.".".$row['tn_ext'];
@@ -302,6 +283,8 @@ if ( isset( $page['cat'] ) )
$vtp->setVar( $sub, 'picture.url', add_session_id( $url ) );
$vtp->closeSession( $sub, 'picture' );
}
+ $structure = create_structure( '', array() );
+ display_categories( $structure, ' ' );
}
//----------------------------------------------------------- sending html code
$vtp->Parse( $handle , 'sub', $sub );
diff --git a/admin/picture_modify.php b/admin/picture_modify.php
new file mode 100644
index 000000000..804cc8e2c
--- /dev/null
+++ b/admin/picture_modify.php
@@ -0,0 +1,270 @@
+<?php
+/***************************************************************************
+ * picture_modify.php *
+ * ------------------ *
+ * application : PhpWebGallery 1.3 <http://phpwebgallery.net> *
+ * author : Pierrick LE GALL <pierrick@z0rglub.com> *
+ * *
+ * $Id$
+ * *
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; *
+ * *
+ ***************************************************************************/
+
+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
+if ( isset( $_POST['creation_date'] ) and $_POST['creation_date'] != '' )
+{
+ if ( !check_date_format( $_POST['creation_date'] ) )
+ array_push( $errors, $lang['err_date'] );
+}
+if ( isset( $_POST['submit'] ) )
+{
+ $query = 'UPDATE '.PREFIX_TABLE.'images';
+
+ $query.= ' SET name = ';
+ if ( $_POST['name'] == '' )
+ $query.= 'NULL';
+ else
+ $query.= "'".htmlentities( $_POST['name'], ENT_QUOTES )."'";
+
+ $query.= ', author = ';
+ if ( $_POST['author'] == '' )
+ $query.= 'NULL';
+ else
+ $query.= "'".htmlentities($_POST['author'],ENT_QUOTES)."'";
+
+ $query.= ', comment = ';
+ if ( $_POST['comment'] == '' )
+ $query.= 'NULL';
+ else
+ $query.= "'".htmlentities($_POST['comment'],ENT_QUOTES)."'";
+
+ $query.= ', date_creation = ';
+ if ( check_date_format( $_POST['creation_date'] ) )
+ $query.= "'".date_convert( $_POST['creation_date'] )."'";
+ else if ( $_POST['creation_date'] == '' )
+ $query.= 'NULL';
+
+ $query.= ', keywords = ';
+ $keywords_array = get_keywords( $_POST['keywords'] );
+ if ( count( $keywords_array ) == 0 )
+ $query.= 'NULL';
+ else
+ {
+ $query.= "'";
+ foreach ( $keywords_array as $i => $keyword ) {
+ if ( $i > 0 ) $query.= ',';
+ $query.= $keyword;
+ }
+ $query.= "'";
+ }
+
+ $query.= ' WHERE id = '.$_GET['image_id'];
+ $query.= ';';
+ mysql_query( $query );
+ // associate with a new category ?
+ if ( $_POST['associate'] != '-1' )
+ {
+ $query = 'INSERT INTO '.PREFIX_TABLE.'image_category';
+ $query.= ' (category_id,image_id) VALUES ';
+ $query.= '('.$_POST['associate'].','.$_GET['image_id'].')';
+ $query.= ';';
+ mysql_query( $query);
+ update_category( $_POST['associate'] );
+ }
+ // dissociate any category ?
+ // retrieving all the linked categories
+ $query = 'SELECT DISTINCT(category_id) as category_id';
+ $query.= ' FROM '.PREFIX_TABLE.'image_category';
+ $query.= ' WHERE image_id = '.$_GET['image_id'];
+ $query.= ';';
+ $result = mysql_query( $query );
+ while ( $row = mysql_fetch_array( $result ) )
+ {
+ if ( $_POST['dissociate-'.$row['category_id']] == 1 )
+ {
+ $query = 'DELETE FROM '.PREFIX_TABLE.'image_category';
+ $query.= ' WHERE image_id = '.$_GET['image_id'];
+ $query.= ' AND category_id = '.$row['category_id'];
+ $query.= ';';
+ mysql_query( $query );
+ update_category( $row['category_id'] );
+ }
+ }
+}
+//----------------------------------------------------- template initialization
+$sub = $vtp->Open(
+ '../template/'.$user['template'].'/admin/picture_modify.vtp' );
+
+$tpl = array( 'submit','errors_title','picmod_update','picmod_back',
+ 'default','file','size','filesize','registration_date',
+ 'author','creation_date','keywords','comment', 'upload_name',
+ 'dissociate','categories','infoimage_associate',
+ 'cat_image_info' );
+templatize_array( $tpl, 'lang', $sub );
+$vtp->setGlobalVar( $sub, 'user_template', $user['template'] );
+//-------------------------------------------------------------- errors display
+if ( count( $errors ) != 0 )
+{
+ $vtp->addSession( $sub, 'errors' );
+ foreach ( $errors as $error ) {
+ $vtp->addSession( $sub, 'li' );
+ $vtp->setVar( $sub, 'li.content', $error );
+ $vtp->closeSession( $sub, 'li' );
+ }
+ $vtp->closeSession( $sub, 'errors' );
+}
+//-------------------------------------------- displaying informations and form
+$action = './admin.php?'.$_SERVER['QUERY_STRING'];
+$vtp->setVar( $sub, 'form_action', $action );
+// retrieving direct information about picture
+$query = 'SELECT file,date_available,date_creation,tn_ext,name,filesize';
+$query.= ',width,height,author,comment,keywords,storage_category_id';
+$query.= ' FROM '.PREFIX_TABLE.'images';
+$query.= ' WHERE id = '.$_GET['image_id'];
+$query.= ';';
+$row = mysql_fetch_array( mysql_query( $query ) );
+// picture title
+if ( $row['name'] == '' )
+{
+ $title = str_replace( '_',' ',get_filename_wo_extension($row['file']) );
+}
+else
+{
+ $title = $row['name'];
+}
+$vtp->setVar( $sub, 'title', $title );
+$vtp->setVar( $sub, 'f_file', $row['file'] );
+$vtp->setVar( $sub, 'f_size', $row['width'].' * '.$row['height'] );
+$vtp->setVar( $sub, 'f_filesize', $row['filesize'].' KB' );
+$vtp->setVar( $sub, 'f_registration_date',format_date($row['date_available']));
+$default_name = str_replace( '_',' ',get_filename_wo_extension($row['file']) );
+$vtp->setVar( $sub, 'default_name', $default_name );
+// if this form is displayed after an unsucceeded submit, we have to display
+// the values filled by the user (wright or wrong).
+if ( count( $errors ) > 0 )
+{
+ $name = $_POST['name'];
+ $author = $_POST['author'];
+ $creation_date = $_POST['creation_date'];
+ $keywords = $_POST['keywords'];
+ $comment = $_POST['comment'];
+}
+else
+{
+ $name = $row['name'];
+ $author = $row['author'];
+ $creation_date = date_convert_back( $row['date_creation'] );
+ $keywords = $row['keywords'];
+ $comment = $row['comment'];
+}
+$vtp->setVar( $sub, 'f_name', $name );
+$vtp->setVar( $sub, 'f_author', $author );
+$vtp->setVar( $sub, 'f_creation_date', $creation_date );
+$vtp->setVar( $sub, 'f_keywords', $keywords );
+$vtp->setVar( $sub, 'f_comment', $comment );
+// retrieving directory where picture is stored (for displaying the
+// thumbnail)
+$thumbnail_url = get_complete_dir( $row['storage_category_id'] );
+$result = get_cat_info( $row['storage_category_id'] );
+$cat_name = get_cat_display_name( $result['name'], ' &gt; ', '' );
+$vtp->setVar( $sub, 'dir', $cat_name );
+if ( $result['site_id'] == 1 ) $thumbnail_url = '.'.$thumbnail_url;
+$file_wo_ext = get_filename_wo_extension( $row['file'] );
+$thumbnail_url.= '/thumbnail/';
+$thumbnail_url.= $conf['prefix_thumbnail'].$file_wo_ext.'.'.$row['tn_ext'];
+$vtp->setVar( $sub, 'thumbnail_url', $thumbnail_url );
+// storage category is linked by default
+$vtp->addSession( $sub, 'linked_category' );
+$vtp->setVar( $sub, 'linked_category.name', $cat_name );
+$url = '../picture.php?image_id='.$_GET['image_id'];
+$url.= '&amp;cat='.$row['storage_category_id'];
+$vtp->setVar( $sub, 'linked_category.url',add_session_id( $url));
+$url = './admin.php?page=infos_images&amp;cat_id='.$row['storage_category_id'];
+$vtp->setVar( $sub, 'linked_category.infos_images_link',add_session_id( $url));
+if ( $result['status'] == 'private' )
+{
+ $private_string = '<span style="color:red;font-weight:bold;">';
+ $private_string.= $lang['private'].'</span>';
+ $vtp->setVar( $sub, 'linked_category.private', $private_string );
+}
+if ( !$result['visible'] )
+{
+ $invisible_string = '<span style="color:red;">';
+ $invisible_string.= $lang['cat_invisible'].'</span>';
+ $vtp->setVar( $sub, 'linked_category.invisible', $invisible_string );
+}
+$vtp->closeSession( $sub, 'linked_category' );
+// retrieving all the linked categories
+$query = 'SELECT DISTINCT(category_id) as category_id,status,visible';
+$query.= ' FROM '.PREFIX_TABLE.'image_category';
+$query.= ','.PREFIX_TABLE.'categories';
+$query.= ' WHERE image_id = '.$_GET['image_id'];
+$query.= ' AND category_id != '.$row['storage_category_id'];
+$query.= ' AND category_id = id';
+$query.= ';';
+$result = mysql_query( $query );
+while ( $row = mysql_fetch_array( $result ) )
+{
+ $vtp->addSession( $sub, 'linked_category' );
+
+ $vtp->addSession( $sub, 'checkbox' );
+ $vtp->setVar( $sub, 'checkbox.id', $row['category_id'] );
+ $vtp->closeSession( $sub, 'checkbox' );
+
+ $cat_infos = get_cat_info( $row['category_id'] );
+ $cat_name = get_cat_display_name( $cat_infos['name'], ' &gt; ', '' );
+ $vtp->setVar( $sub, 'linked_category.name', $cat_name );
+
+ $url = '../picture.php?image_id='.$_GET['image_id'];
+ $url.= '&amp;cat='.$row['category_id'];
+ $vtp->setVar( $sub, 'linked_category.url',add_session_id( $url));
+
+ $url = './admin.php?page=infos_images&amp;cat_id='.$row['category_id'];
+ $vtp->setVar( $sub, 'linked_category.infos_images_link',
+ add_session_id( $url));
+
+ if ( $row['status'] == 'private' )
+ {
+ $private_string = '<span style="color:red;font-weight:bold;">';
+ $private_string.= $lang['private'].'</span>';
+ $vtp->setVar( $sub, 'linked_category.private', $private_string );
+ }
+
+ if ( !get_boolean( $row['visible'] ) )
+ {
+ $invisible_string = '<span style="color:red;">';
+ $invisible_string.= $lang['cat_invisible'].'</span>';
+ $vtp->setVar( $sub, 'linked_category.invisible', $invisible_string );
+ }
+
+ $vtp->closeSession( $sub, 'linked_category' );
+}
+// if there are linked category other than the storage category, we show
+// propose the dissociate text
+if ( mysql_num_rows( $result ) > 0 )
+{
+ $vtp->addSession( $sub, 'dissociate' );
+ $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;' );
+//----------------------------------------------------------- sending html code
+$vtp->Parse( $handle , 'sub', $sub );
+?> \ No newline at end of file
diff --git a/admin/update.php b/admin/update.php
index 9e6b07e7d..fb2ea3b4a 100644
--- a/admin/update.php
+++ b/admin/update.php
@@ -30,24 +30,24 @@ function insert_local_category( $cat_id )
if ( is_numeric( $cat_id ) )
{
+ $cat_directory.= '/'.get_local_dir( $cat_id );
$result = get_cat_info( $cat_id );
- $cat_directory.= '/'.$result['local_dir'];
// 1. display the category name to update
$src = '../template/'.$user['template'].'/admin/images/puce.gif';
$output = '<img src="'.$src.'" alt="&gt;" />';
$output.= '<span style="font-weight:bold;">'.$result['name'][0].'</span>';
- $output.= ' [ '.$result['last_dir'].' ]';
+ $output.= ' [ '.$result['dir'].' ]';
$output.= '<div class="retrait">';
-
+
// 2. we search pictures of the category only if the update is for all
// or a cat_id is specified
if ( isset( $page['cat'] ) or $_GET['update'] == 'all' )
{
$output.= insert_local_image( $cat_directory, $cat_id );
- update_cat_info( $cat_id );
+ update_category( $cat_id );
}
}
-
+
// 3. we have to remove the categories of the database not present anymore
$query = 'SELECT id';
$query.= ' FROM '.PREFIX_TABLE.'categories';
@@ -65,17 +65,10 @@ function insert_local_category( $cat_id )
while ( $row = mysql_fetch_array( $result ) )
{
// retrieving the directory
- $rep = '../galleries';
- $resultat = get_cat_info( $row['id'] );
- $rep.= '/'.$resultat['local_dir'];
-
+ $rep = '../galleries/'.get_local_dir( $row['id'] );
// is the directory present ?
- if ( !is_dir( $rep ) )
- {
- delete_category( $row['id'] );
- }
+ if ( !is_dir( $rep ) ) delete_category( $row['id'] );
}
-
// 4. retrieving the sub-directories
$sub_rep = array();
$i = 0;
@@ -93,7 +86,6 @@ function insert_local_category( $cat_id )
}
}
}
-
for ( $i = 0; $i < sizeof( $sub_rep ); $i++ )
{
// 5. Is the category already existing ? we create a subcat if not
@@ -119,14 +111,8 @@ function insert_local_category( $cat_id )
$query = 'INSERT INTO '.PREFIX_TABLE.'categories';
$query.= ' (dir,site_id,id_uppercat) VALUES';
$query.= " ('".$sub_rep[$i]."','".$site_id."'";
- if ( !is_numeric( $cat_id ) )
- {
- $query.= ',NULL';
- }
- else
- {
- $query.= ",'".$cat_id."'";
- }
+ if ( !is_numeric( $cat_id ) ) $query.= ',NULL';
+ else $query.= ",'".$cat_id."'";
$query.= ');';
mysql_query( $query );
$category_id = mysql_insert_id();
@@ -158,7 +144,7 @@ function insert_local_image( $rep, $category_id )
// - don't have the associated thumbnail available anymore
$query = 'SELECT id,file,tn_ext';
$query.= ' FROM '.PREFIX_TABLE.'images';
- $query.= ' WHERE cat_id = '.$category_id;
+ $query.= ' WHERE storage_category_id = '.$category_id;
$query.= ';';
$result = mysql_query( $query );
while ( $row = mysql_fetch_array( $result ) )
@@ -199,7 +185,7 @@ function insert_local_image( $rep, $category_id )
// is the picture waiting for validation by an administrator ?
$query = 'SELECT id,validated,infos';
$query.= ' FROM '.PREFIX_TABLE.'waiting';
- $query.= ' WHERE cat_id = '.$category_id;
+ $query.= ' WHERE category_id = '.$category_id;
$query.= " AND file = '".$file."'";
$query.= ';';
$result = mysql_query( $query );
@@ -211,7 +197,7 @@ function insert_local_image( $rep, $category_id )
// is the picture already in the database ?
$query = 'SELECT id';
$query.= ' FROM '.PREFIX_TABLE.'images';
- $query.= ' WHERE cat_id = '.$category_id;
+ $query.= ' WHERE storage_category_id = '.$category_id;
$query.= " AND file = '".$file."'";
$query.= ';';
$result = mysql_query( $query );
@@ -266,7 +252,8 @@ function insert_local_image( $rep, $category_id )
// inserting the pictures found in the directory
foreach ( $pictures as $picture ) {
$query = 'INSERT INTO '.PREFIX_TABLE.'images';
- $query.= ' (file,cat_id,date_available,tn_ext,filesize,width,height';
+ $query.= ' (file,storage_category_id,date_available,tn_ext';
+ $query.= ',filesize,width,height';
$query.= ',name,author,comment,date_creation)';
$query.= ' VALUES ';
$query.= "('".$picture['file']."','".$category_id."'";
@@ -285,7 +272,20 @@ function insert_local_image( $rep, $category_id )
$query.= ');';
mysql_query( $query );
$count_new++;
-
+ // retrieving the id of newly inserted picture
+ $query = 'SELECT id';
+ $query.= ' FROM '.PREFIX_TABLE.'images';
+ $query.= ' WHERE storage_category_id = '.$category_id;
+ $query.= " AND file = '".$picture['file']."'";
+ $query.= ';';
+ list( $image_id ) = mysql_fetch_array( mysql_query( $query ) );
+ // adding the link between this picture and its storage category
+ $query = 'INSERT INTO '.PREFIX_TABLE.'image_category';
+ $query.= ' (image_id,category_id) VALUES ';
+ $query.= ' ('.$image_id.','.$category_id.')';
+ $query.= ';';
+ mysql_query( $query );
+
$output.= $picture['file'];
$output.= ' <span style="font-weight:bold;">';
$output.= $lang['update_research_added'].'</span>';
@@ -294,35 +294,6 @@ function insert_local_image( $rep, $category_id )
}
return $output;
}
-
-// The function "update_cat_info" updates the information about the last
-// online image and the number of images in the category
-function update_cat_info( $category_id )
-{
- $query = 'SELECT date_available';
- $query.= ' FROM '.PREFIX_TABLE.'images';
- $query.= ' WHERE cat_id = '.$category_id;
- $query.= ' ORDER BY date_available DESC';
- $query.= ' LIMIT 0,1';
- $query.= ';';
- $result = mysql_query( $query );
- $row = mysql_fetch_array( $result );
- $date_last = $row['date_available'];
-
- $query = 'SELECT COUNT(*) as nb_images';
- $query.= ' FROM '.PREFIX_TABLE.'images';
- $query.= ' WHERE cat_id = '.$category_id;
- $result = mysql_query( $query );
- $row = mysql_fetch_array( $result );
- $nb_images = $row['nb_images'];
-
- $query = 'UPDATE '.PREFIX_TABLE.'categories';
- $query.= " SET date_last = '".$date_last."'";
- $query.= ', nb_images = '.$nb_images;
- $query.= ' where id = '.$category_id;
- $query.= ';';
- mysql_query( $query );
-}
// remote_images verifies if a file named "listing.xml" is present is the
// admin directory. If it is the case, creation of a remote picture storage
@@ -341,16 +312,16 @@ function remote_images()
$vtp->setVar( $sub, 'remote_update.url', $url );
// 2. is the site already existing ?
- $query = 'select id';
- $query.= ' from '.PREFIX_TABLE.'sites';
- $query.= " where galleries_url = '".$url."'";
+ $query = 'SELECT id';
+ $query.= ' FROM '.PREFIX_TABLE.'sites';
+ $query.= " WHERE galleries_url = '".$url."'";
$query.= ';';
$result = mysql_query( $query );
if ( mysql_num_rows($result ) == 0 )
{
// we have to register this site in the database
- $query = 'insert into '.PREFIX_TABLE.'sites';
- $query.= " (galleries_url) values ('".$url."')";
+ $query = 'INSERT INTO '.PREFIX_TABLE.'sites';
+ $query.= " (galleries_url) VALUES ('".$url."')";
$query.= ';';
mysql_query( $query );
$site_id = mysql_insert_id();
@@ -390,25 +361,25 @@ function insert_remote_category( $xml_dir, $site_id, $id_uppercat, $level )
$output.= '<span style="font-weight:bold;">'.$name.'</span>';
$output.= '<div class="retrait">';
- $query = 'select id';
- $query.= ' from '.PREFIX_TABLE.'categories';
- $query.= ' where site_id = '.$site_id;
- $query.= " and dir = '".$name."'";
+ $query = 'SELECT id';
+ $query.= ' FROM '.PREFIX_TABLE.'categories';
+ $query.= ' WHERE site_id = '.$site_id;
+ $query.= " AND dir = '".$name."'";
if ( $id_uppercat == 'NULL' )
{
- $query.= ' and id_uppercat is NULL';
+ $query.= ' AND id_uppercat IS NULL';
}
else
{
- $query.= ' and id_uppercat = '.$id_uppercat;
+ $query.= ' AND id_uppercat = '.$id_uppercat;
}
$query.= ';';
$result = mysql_query( $query );
if ( mysql_num_rows( $result ) == 0 )
{
// we have to create the category
- $query = 'insert into '.PREFIX_TABLE.'categories';
- $query.= " (dir,site_id,id_uppercat) values ('".$name."',".$site_id;
+ $query = 'INSERT INTO '.PREFIX_TABLE.'categories';
+ $query.= " (dir,site_id,id_uppercat) VALUES ('".$name."',".$site_id;
if ( !is_numeric( $id_uppercat ) )
{
$query.= ',NULL';
@@ -428,23 +399,23 @@ function insert_remote_category( $xml_dir, $site_id, $id_uppercat, $level )
$category_id = $row['id'];
}
$output.= insert_remote_image( $list_dirs[$i], $category_id );
- update_cat_info( $category_id );
+ update_category( $category_id );
$output.= insert_remote_category( $list_dirs[$i], $site_id,
$category_id, $level+1 );
$output.= '</div>';
}
// we have to remove the categories of the database not present in the xml
// file (ie deleted from the picture storage server)
- $query = 'select dir,id';
- $query.= ' from '.PREFIX_TABLE.'categories';
- $query.= ' where site_id = '.$site_id;
+ $query = 'SELECT dir,id';
+ $query.= ' FROM '.PREFIX_TABLE.'categories';
+ $query.= ' WHERE site_id = '.$site_id;
if ( !is_numeric( $id_uppercat ) )
{
- $query.= ' and id_uppercat is NULL';
+ $query.= ' AND id_uppercat IS NULL';
}
else
{
- $query.= ' and id_uppercat = '.$id_uppercat;
+ $query.= ' AND id_uppercat = '.$id_uppercat;
}
$query.= ';';
$result = mysql_query( $query );
@@ -484,18 +455,19 @@ function insert_remote_image( $xml_dir, $category_id )
$pictures[$j] = $file;
// is the picture already existing in the database ?
- $query = 'select id,tn_ext';
- $query.= ' from '.PREFIX_TABLE.'images';
- $query.= ' where cat_id = '.$category_id;
- $query.= " and file = '".$file."'";
+ $query = 'SELECT id,tn_ext';
+ $query.= ' FROM '.PREFIX_TABLE.'images';
+ $query.= ' WHERE storage_category_id = '.$category_id;
+ $query.= " AND file = '".$file."'";
$query.= ';';
$result = mysql_query( $query );
$query = '';
if ( mysql_num_rows( $result ) == 0 )
{
- $query = 'insert into '.PREFIX_TABLE.'images';
- $query.= ' (file,cat_id,date_available,tn_ext,filesize,width,height)';
- $query.= ' values (';
+ $query = 'INSERT INTO '.PREFIX_TABLE.'images';
+ $query.= ' (file,storage_category_id,date_available,tn_ext';
+ $query.= ',filesize,width,height)';
+ $query.= ' VALUES (';
$query.= "'".$file."'";
$query.= ",'".$category_id."'";
$query.= ",'".$date."'";
@@ -505,6 +477,19 @@ function insert_remote_image( $xml_dir, $category_id )
$query.= ",'".$height."'";
$query.= ')';
$query.= ';';
+ // retrieving the id of newly inserted picture
+ $query = 'SELECT id';
+ $query.= ' FROM '.PREFIX_TABLE.'images';
+ $query.= ' WHERE storage_category_id = '.$category_id;
+ $query.= " AND file = '".$file."'";
+ $query.= ';';
+ list( $image_id ) = mysql_fetch_array( mysql_query( $query ) );
+ // adding the link between this picture and its storage category
+ $query = 'INSERT INTO '.PREFIX_TABLE.'image_category';
+ $query.= ' (image_id,category_id) VALUES ';
+ $query.= ' ('.$image_id.','.$category_id.')';
+ $query.= ';';
+ mysql_query( $query );
$output.= $file;
$output.= ' <span style="font-weight:bold;">';
@@ -519,11 +504,11 @@ function insert_remote_image( $xml_dir, $category_id )
$row = mysql_fetch_array( $result );
if ( $row['tn_ext'] != $tn_ext )
{
- $query = 'update '.PREFIX_TABLE.'images';
- $query.= ' set';
+ $query = 'UPDATE '.PREFIX_TABLE.'images';
+ $query.= ' SET';
$query.= " tn_ext = '".$tn_ext."'";
- $query.= ' where cat_id = '.$category_id;
- $query.= " and file = '".$file."'";
+ $query.= ' WHERE storage_category_id = '.$category_id;
+ $query.= " AND file = '".$file."'";
$query.= ';';
}
}
@@ -535,9 +520,9 @@ function insert_remote_image( $xml_dir, $category_id )
}
// we have to remove the pictures of the database not present in the xml file
// (ie deleted from the picture storage server)
- $query = 'select id,file';
- $query.= ' from '.PREFIX_TABLE.'images';
- $query.= ' where cat_id = '.$category_id;
+ $query = 'SELECT id,file';
+ $query.= ' FROM '.PREFIX_TABLE.'images';
+ $query.= ' WHERE storage_category_id = '.$category_id;
$query.= ';';
$result = mysql_query( $query );
while ( $row = mysql_fetch_array( $result ) )
@@ -557,6 +542,8 @@ $tpl = array( 'update_default_title', 'update_only_cat', 'update_all',
'remote_site', 'update_part_research' );
templatize_array( $tpl, 'lang', $sub );
$vtp->setGlobalVar( $sub, 'user_template', $user['template'] );
+//-------------------------------------------------------- categories structure
+$page['plain_structure'] = get_plain_structure();
//-------------------------------------------- introduction : choices of update
// Display choice if "update" var is not specified
check_cat_id( $_GET['update'] );
diff --git a/admin/waiting.php b/admin/waiting.php
index 206705b8f..7b38a387c 100644
--- a/admin/waiting.php
+++ b/admin/waiting.php
@@ -20,7 +20,7 @@ include_once( './include/isadmin.inc.php' );
//--------------------------------------------------------------------- updates
if ( isset( $_POST['submit'] ) )
{
- $query = 'SELECT id,cat_id,file,tn_ext';
+ $query = 'SELECT id,storage_category_id,file,tn_ext';
$query.= ' FROM '.PREFIX_TABLE.'waiting';
$query.= " WHERE validated = 'false'";
$query.= ';';
@@ -39,6 +39,8 @@ if ( isset( $_POST['submit'] ) )
$query.= ' WHERE id = '.$row['id'];
$query.= ';';
mysql_query( $query );
+ // linking logically the picture to its storage category
+ $query = 'INSERT INTO';
}
else
{
@@ -49,14 +51,14 @@ if ( isset( $_POST['submit'] ) )
$query.= ';';
mysql_query( $query );
// deletion of the associated files
- $cat = get_cat_info( $row['cat_id'] );
- unlink( '.'.$cat['dir'].$row['file'] );
+ $dir = get_complete_dir( $row['storage_category_id'] );
+ unlink( '.'.$dir.$row['file'] );
if ( $row['tn_ext'] != '' )
{
$thumbnail = $conf['prefix_thumbnail'];
$thumbnail.= get_filename_wo_extension( $row['file'] );
$thumbnail.= '.'.$row['tn_ext'];
- $url = '.'.$cat['dir'].'thumbnail/'.$thumbnail;
+ $url = '.'.$dir.'thumbnail/'.$thumbnail;
unlink( $url );
}
}
@@ -70,10 +72,11 @@ $tpl = array( 'category','date','author','thumbnail','file','delete',
templatize_array( $tpl, 'lang', $sub );
//---------------------------------------------------------------- form display
$cat_names = array();
-$query = 'SELECT id,cat_id,file,username,mail_address,date,tn_ext';
+$query = 'SELECT id,storage_category_id,file,username,mail_address';
+$query.= ',date,tn_ext';
$query.= ' FROM '.PREFIX_TABLE.'waiting';
$query.= " WHERE validated = 'false'";
-$query.= ' ORDER BY cat_id';
+$query.= ' ORDER BY storage_category_id';
$query.= ';';
$result = mysql_query( $query );
$i = 0;
@@ -85,26 +88,24 @@ while ( $row = mysql_fetch_array( $result ) )
{
$vtp->setVar( $sub, 'picture.class', 'row2' );
}
- if ( !isset( $cat_names[$row['cat_id']] ) )
+ if ( !isset( $cat_names[$row['storage_category_id']] ) )
{
- $cat = get_cat_info( $row['cat_id'] );
- $cat_names[$row['cat_id']] = array();
- $cat_names[$row['cat_id']]['dir'] = '.'.$cat['dir'];
- $cat_names[$row['cat_id']]['display_name'] =
+ $cat = get_cat_info( $row['storage_category_id'] );
+ $cat_names[$row['storage_category_id']] = array();
+ $cat_names[$row['storage_category_id']]['dir'] =
+ '.'.get_complete_dir( $row['storage_category_id'] );
+ $cat_names[$row['storage_category_id']]['display_name'] =
get_cat_display_name( $cat['name'], ' &gt; ', 'font-weight:bold;' );
}
// category name
$vtp->setVar( $sub, 'picture.cat_name',
- $cat_names[$row['cat_id']]['display_name'] );
+ $cat_names[$row['storage_category_id']]['display_name'] );
// date displayed like this (in English ) :
// Sunday 15 June 2003 21:29
- $date = $lang['day'][date( 'w', $row['date'] )]; // Sunday
- $date.= date( ' j ', $row['date'] ); // 15
- $date.= $lang['month'][date( 'n', $row['date'] )]; // June
- $date.= date( ' Y G:i', $row['date'] ); // 2003 21:29
+ $date = format_date( $row['date'], 'unix', true );
$vtp->setVar( $sub, 'picture.date', $date );
// file preview link
- $url = $cat_names[$row['cat_id']]['dir'].$row['file'];
+ $url = $cat_names[$row['storage_category_id']]['dir'].$row['file'];
$vtp->setVar( $sub, 'picture.preview_url', $url );
// file name
$vtp->setVar( $sub, 'picture.file', $row['file'] );
@@ -115,7 +116,8 @@ while ( $row = mysql_fetch_array( $result ) )
$thumbnail = $conf['prefix_thumbnail'];
$thumbnail.= get_filename_wo_extension( $row['file'] );
$thumbnail.= '.'.$row['tn_ext'];
- $url = $cat_names[$row['cat_id']]['dir'].'thumbnail/'.$thumbnail;
+ $url = $cat_names[$row['storage_category_id']]['dir'];
+ $url.= 'thumbnail/'.$thumbnail;
$vtp->setVar( $sub, 'thumbnail.preview_url', $url );
$vtp->setVar( $sub, 'thumbnail.file', $thumbnail );
$vtp->closeSession( $sub, 'thumbnail' );