aboutsummaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2004-12-18 22:05:30 +0000
committerplegall <plg@piwigo.org>2004-12-18 22:05:30 +0000
commitf0e9cd804af6512529982e66f73a27fa7658c46c (patch)
treed7a2be782e859b9b4e9bdc06069122cc38c95729 /admin
parent775e9ee74cf910f858f08b24d4b4820ea42bac85 (diff)
- bug fixed : in admin/cat_list, next_rank cant' be calculted and query to
count sub-categories per sub-categories became false if no sub-categories - virtual association come back in admin/infos_images (not only in admin/picture_modify) - check_favorites function in admin section becomes check_user_favorites in public section : favorites are checked when user tries to display his favorites. Function was optimized. - in function update_category, wrap of long queries due to many categories to update at the same time - typo fixed in description of paginate_pages_around configuration parameter - bug fixed in new navigation bar : no separation pipe was displayed between next and last when the page displayed was the last - sessions.expiration changed of type from int to datetime (a lot easier to read) - sessions.ip removed : IP address is no longer used to verify session - $lang['cat_options'] was missing in en_UK.iso-8859-1 - typo fixed in language/en_UK.iso-8859-1/admin.lang.php on editcat_lock_info language item git-svn-id: http://piwigo.org/svn/trunk@647 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'admin')
-rw-r--r--admin/cat_list.php32
-rw-r--r--admin/include/functions.php55
-rw-r--r--admin/infos_images.php42
3 files changed, 41 insertions, 88 deletions
diff --git a/admin/cat_list.php b/admin/cat_list.php
index d92575fe8..2f7834730 100644
--- a/admin/cat_list.php
+++ b/admin/cat_list.php
@@ -327,9 +327,18 @@ if (isset($_GET['parent_id']))
$form_action.= '&amp;parent_id='.$_GET['parent_id'];
}
+if (count($categories) > 0)
+{
+ $next_rank = max(array_keys($categories)) + 1;
+}
+else
+{
+ $next_rank = 1;
+}
+
$template->assign_vars(array(
'CATEGORIES_NAV'=>$navigation,
- 'NEXT_RANK'=>max(array_keys($categories))+1,
+ 'NEXT_RANK'=>$next_rank,
'F_ACTION'=>$form_action,
'L_ADD_VIRTUAL'=>$lang['cat_add'],
@@ -367,21 +376,26 @@ if (count($infos) != 0)
// | Categories display |
// +-----------------------------------------------------------------------+
$ranks = array();
-foreach ($categories as $category)
+
+if (count($categories) > 0)
{
- $ranks[$category['id']] = $category['rank'];
-}
+ foreach ($categories as $category)
+ {
+ $ranks[$category['id']] = $category['rank'];
+ }
-$query = '
+ $query = '
SELECT id_uppercat, COUNT(*) AS nb_subcats
FROM '. CATEGORIES_TABLE.'
WHERE id_uppercat IN ('.implode(',', array_keys($ranks)).')
GROUP BY id_uppercat
;';
-$result = pwg_query($query);
-while ($row = mysql_fetch_array($result))
-{
- $categories[$ranks[$row['id_uppercat']]]['nb_subcats'] = $row['nb_subcats'];
+ $result = pwg_query($query);
+ while ($row = mysql_fetch_array($result))
+ {
+ $categories[$ranks[$row['id_uppercat']]]['nb_subcats']
+ = $row['nb_subcats'];
+ }
}
foreach ($categories as $category)
diff --git a/admin/include/functions.php b/admin/include/functions.php
index 1191f1f6f..1e8926aee 100644
--- a/admin/include/functions.php
+++ b/admin/include/functions.php
@@ -391,55 +391,6 @@ function delete_group( $group_id )
pwg_query( $query );
}
-// The check_favorites function deletes all the favorites of a user if he is
-// not allowed to see them (the category or an upper category is restricted
-// or invisible)
-function check_favorites( $user_id )
-{
- $query = 'SELECT status,forbidden_categories';
- $query.= ' FROM '.USERS_TABLE;
- $query.= ' WHERE id = '.$user_id;
- $query.= ';';
- $row = mysql_fetch_array( pwg_query( $query ) );
- $status = $row['status'];
- // retrieving all the restricted categories for this user
- if ( isset( $row['forbidden_categories'] ) )
- $restricted_cat = explode( ',', $row['forbidden_categories'] );
- else
- $restricted_cat = array();
- // retrieving all the favorites for this user and comparing their
- // categories to the restricted categories
- $query = 'SELECT image_id FROM '.FAVORITES_TABLE;
- $query.= ' WHERE user_id = '.$user_id;
- $query.= ';';
- $result = pwg_query ( $query );
- while ( $row = mysql_fetch_array( $result ) )
- {
- // 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 = pwg_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 '.FAVORITES_TABLE;
- $query.= ' WHERE image_id = '.$row['image_id'];
- $query.= ' AND user_id = '.$user_id;
- $query.= ';';
- pwg_query( $query );
- }
- }
-}
-
/**
* updates calculated informations about a set of categories : date_last and
* nb_images. It also verifies that the representative picture is really
@@ -479,7 +430,7 @@ SELECT id
else
{
$query.= '
- WHERE id IN ('.implode(',', $ids).')';
+ WHERE id IN ('.wordwrap(implode(', ', $ids), 80, "\n").')';
}
}
$query.= '
@@ -502,7 +453,7 @@ SELECT category_id,
COUNT(image_id) AS nb_images,
MAX(date_available) AS date_last
FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id
- WHERE category_id IN ('.implode(',', $cat_ids).')
+ WHERE category_id IN ('.wordwrap(implode(', ', $cat_ids), 80, "\n").')
GROUP BY category_id
;';
$result = pwg_query($query);
@@ -542,7 +493,7 @@ SELECT id
FROM '.CATEGORIES_TABLE.' LEFT JOIN '.IMAGE_CATEGORY_TABLE.'
ON id = category_id AND representative_picture_id = image_id
WHERE representative_picture_id IS NOT NULL
- AND id IN ('.implode(',', $cat_ids).')
+ AND id IN ('.wordwrap(implode(', ', $cat_ids), 80, "\n").')
AND category_id IS NULL
;';
$result = pwg_query($query);
diff --git a/admin/infos_images.php b/admin/infos_images.php
index ef02c91b7..9a7ab5590 100644
--- a/admin/infos_images.php
+++ b/admin/infos_images.php
@@ -60,8 +60,6 @@ if (isset($page['cat']))
}
}
- $associate = false;
-
$query = 'SELECT id,file FROM '.IMAGES_TABLE;
$query.= ' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id';
$query.= ' WHERE category_id = '.$page['cat'];
@@ -111,18 +109,21 @@ if (isset($page['cat']))
pwg_query($query);
}
// add link to another category
- if (isset($_POST['check-'.$row['id']]) and count($errors) == 0)
+ if (isset($_POST['check-'.$row['id']])
+ and isset($_POST['associate'])
+ and $_POST['associate'] != '')
{
$query = 'INSERT INTO '.IMAGE_CATEGORY_TABLE;
$query.= ' (image_id,category_id) VALUES';
$query.= ' ('.$row['id'].','.$_POST['associate'].')';
$query.= ';';
pwg_query($query);
- $associate = true;
}
}
- if (isset($_POST['associate'])) update_category($_POST['associate']);
- if ($associate) synchronize_all_users();
+ if (isset($_POST['associate']) and $_POST['associate'] != '')
+ {
+ update_category(array($_POST['associate']));
+ }
// +-----------------------------------------------------------------------+
// | update general options |
// +-----------------------------------------------------------------------+
@@ -336,27 +337,14 @@ SELECT *
}
// Virtualy associate a picture to a category
- //
- // 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 '.CATEGORIES_TABLE.';';
- $row = mysql_fetch_array(pwg_query($query));
- if ($row['nb_total_categories'] < $conf['max_LOV_categories'])
- {
- /*$vtp->addSession($sub, 'associate_LOV');
- $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');
- }
+ $query = '
+SELECT id,name,uppercats,global_rank
+ FROM '.CATEGORIES_TABLE.'
+;';
+ display_select_cat_wrapper($query,
+ array(),
+ 'associate_option',
+ true);
}
//----------------------------------------------------------- sending html code
$template->assign_var_from_handle('ADMIN_CONTENT', 'infos_images');