aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2007-02-26 23:52:22 +0000
committerrvelices <rv-github@modusoptimus.com>2007-02-26 23:52:22 +0000
commitbfb4b15d2f75835033d9bbb865edd77dcb282bb6 (patch)
tree80f55833ccce52ffe2f5f4ae320bd90234682cfd
parenteac687a6e67aec80481830e3899eaf19776a513d (diff)
- bug 654: sql error on user comment (since my commit 1849)
- languages: english corrections + keep lang files sorted by key - admin multi view correction: language was not always properly changed - refactor function get_computed_categories (with rub's blessing) git-svn-id: http://piwigo.org/svn/trunk@1860 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--include/filter.inc.php3
-rw-r--r--include/functions_user.inc.php84
-rw-r--r--include/picture_comment.inc.php4
-rw-r--r--language/en_UK.iso-8859-1/common.lang.php13
-rw-r--r--language/fr_FR.iso-8859-1/common.lang.php14
-rw-r--r--plugins/admin_multi_view/is_admin.inc.php2
-rw-r--r--template/yoga/index.tpl2
7 files changed, 52 insertions, 70 deletions
diff --git a/include/filter.inc.php b/include/filter.inc.php
index fb0474bbd..f373ca1cd 100644
--- a/include/filter.inc.php
+++ b/include/filter.inc.php
@@ -3,7 +3,6 @@
// | PhpWebGallery - a PHP based picture gallery |
// | Copyright (C) 2006-2007 PhpWebGallery Team - http://phpwebgallery.net |
// +-----------------------------------------------------------------------+
-// | branch : BSF (Best So Far)
// | file : $Id$
// | last update : $Date$
// | last modifier : $Author$
@@ -75,7 +74,7 @@ if ($filter['enabled'])
{
// Need to compute dats
$filter['check_key'] = get_filter_check_key();
- $filter['categories'] = get_computed_categories($user['id'], $user['forbidden_categories'], true, $filter['recent_period']);
+ $filter['categories'] = get_computed_categories($user, (int)$filter['recent_period']);
$filter['visible_categories'] = implode(',', array_keys($filter['categories']));
if (empty($filter['visible_categories']))
diff --git a/include/functions_user.inc.php b/include/functions_user.inc.php
index 8be4f03cb..72754ca33 100644
--- a/include/functions_user.inc.php
+++ b/include/functions_user.inc.php
@@ -272,7 +272,7 @@ SELECT ui.*, uc.*
$userdata['forbidden_categories'] =
calculate_permissions($userdata['id'], $userdata['status']);
- update_user_cache_categories($userdata['id'], $userdata['forbidden_categories']);
+ update_user_cache_categories($userdata);
// Set need update are done
$userdata['need_update'] = false;
@@ -533,116 +533,104 @@ function compute_categories_data(&$cats)
/**
* get computed array of categories
*
- * @param int user_id
- * @param list user_forbidden_categories
- * @param bool filter_enabled
- * @param int recent_period
+ * @param array userdata
+ * @param int filter_days number of recent days to filter on or null
* @return array
*/
-function get_computed_categories($user_id, $user_forbidden_categories, $filter_enabled, $recent_period = 0)
+function get_computed_categories($userdata, $filter_days=null)
{
- $query = '
-SELECT
- c.id cat_id,
- date_last max_date_last,
- nb_images count_images,
- global_rank';
+ $group_by = '';
- if (!$filter_enabled)
+ $query = 'SELECT c.id cat_id, global_rank';
+ if ( !isset($filter_days) )
{
- $query.= '
-FROM '.CATEGORIES_TABLE.' as c';
+ $query .= ',
+ date_last cat_date_last,
+ nb_images cat_nb_images
+ FROM '.CATEGORIES_TABLE.' as c';
}
else
{
// Count by date_available to avoid count null
- $query.= ',
- count(date_available) filtered_count_images,
- max(date_available) max_date_available
-FROM '.CATEGORIES_TABLE.' as c
+ $query .= ',
+ MAX(date_available) cat_date_last,
+ COUNT(date_available) cat_nb_images
+ FROM '.CATEGORIES_TABLE.' as c
LEFT JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON ic.category_id = c.id
LEFT JOIN '.IMAGES_TABLE.' AS i
- ON ic.image_id = i.id AND
- i.date_available > SUBDATE(CURRENT_DATE,INTERVAL '.$recent_period.' DAY)';
+ ON ic.image_id = i.id AND
+ i.date_available > SUBDATE(CURRENT_DATE,INTERVAL '.$filter_days.' DAY)';
+ $group_by = 'c.id';
}
- if ($user_forbidden_categories != '')
+ if ( !empty($userdata['forbidden_categories']) )
{
$query.= '
-WHERE
- c.id NOT IN ('.$user_forbidden_categories.')';
+ WHERE c.id NOT IN ('.$userdata['forbidden_categories'].')';
}
- if ($filter_enabled)
+ if ( !empty($group_by) )
{
$query.= '
-GROUP BY
- c.id';
+ GROUP BY '.$group_by;
}
- $query.= ';';
$result = pwg_query($query);
$cats = array();
while ($row = mysql_fetch_assoc($result))
{
- $row['user_id'] = $user_id;
+ $row['user_id'] = $userdata['id'];
$row['count_categories'] = 0;
- if ($filter_enabled)
- {
- $row['nb_images'] = $row['filtered_count_images'];
- $row['count_images'] = $row['filtered_count_images'];
- $row['max_date_last'] = $row['max_date_available'];
- }
+ $row['count_images'] = $row['cat_nb_images'];
+ $row['max_date_last'] = $row['cat_date_last'];
+
$cats += array($row['cat_id'] => $row);
}
usort($cats, 'global_rank_compare');
compute_categories_data($cats);
- if ($filter_enabled)
+ if ( isset($filter_days) )
{
$cat_tmp = $cats;
$cats = array();
-
+
foreach ($cat_tmp as $category)
{
if (!empty($category['max_date_last']))
{
// Re-init counters
$category['count_categories'] = 0;
- $category['nb_images'] = $category['filtered_count_images'];
- $category['count_images'] = $category['filtered_count_images'];
+ $category['count_images'] = $category['cat_nb_images'];
+ // next line for update_cats_with_filtered_data
+ $category['nb_images'] = $category['cat_nb_images'];
// Keep category
$cats[$category['cat_id']] = $category;
-
}
}
// Compute a second time
compute_categories_data($cats);
}
-
return $cats;
}
/**
* update data of user_cache_categories
*
- * @param int user_id
- * @param list user_forbidden_categories
- * @param bool filter_enabled
+ * @param array userdata
* @return null
*/
-function update_user_cache_categories($user_id, $user_forbidden_categories)
+function update_user_cache_categories($userdata)
{
// delete user cache
$query = '
DELETE FROM '.USER_CACHE_CATEGORIES_TABLE.'
- WHERE user_id = '.$user_id.'
+ WHERE user_id = '.$userdata['id'].'
;';
pwg_query($query);
- $cats = get_computed_categories($user_id, $user_forbidden_categories, false);
+ $cats = get_computed_categories($userdata, null);
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
mass_inserts
@@ -1184,4 +1172,4 @@ function get_sql_condition_FandF(
return $sql;
}
-?>
+?> \ No newline at end of file
diff --git a/include/picture_comment.inc.php b/include/picture_comment.inc.php
index 424fd3fd3..c84f2a629 100644
--- a/include/picture_comment.inc.php
+++ b/include/picture_comment.inc.php
@@ -56,9 +56,7 @@ if ( $page['show_comments'] and isset( $_POST['content'] ) )
include_once(PHPWG_ROOT_PATH.'include/functions_comment.inc.php');
- $comment_action = insert_user_comment(
- $comm, @$_POST['key'], $page['image_id'], $infos
- );
+ $comment_action = insert_user_comment($comm, @$_POST['key'], $infos );
switch ($comment_action)
{
diff --git a/language/en_UK.iso-8859-1/common.lang.php b/language/en_UK.iso-8859-1/common.lang.php
index 4b70ce8ca..dafd1c82d 100644
--- a/language/en_UK.iso-8859-1/common.lang.php
+++ b/language/en_UK.iso-8859-1/common.lang.php
@@ -489,12 +489,10 @@ $lang['maxheight'] = 'Maximum height of the pictures';
$lang['maxheight_error'] = 'Maximum height must be a number superior to 50';
$lang['maxwidth'] = 'Maximum width of the pictures';
$lang['maxwidth_error'] = 'Maximum width must be a number superior to 50';
-$lang['flat_hint'] = 'flat display elements of categories and sub-categories';
-$lang['start_filter_hint'] = 'displays only recent elements';
-$lang['stop_filter_hint'] = 'return to display all elements';
$lang['mode_created_hint'] = 'displays a calendar by creation date';
+$lang['mode_flat_hint'] = 'displays all elements in all sub-categories';
$lang['mode_normal_hint'] = 'return to normal view mode';
-$lang['mode_posted_hint'] = 'displays a calendar by date posted';
+$lang['mode_posted_hint'] = 'displays a calendar by posted date';
$lang['month'][10] = 'October';
$lang['month'][11] = 'November';
$lang['month'][12] = 'December';
@@ -520,6 +518,8 @@ $lang['next_page'] = 'Next';
$lang['no'] = 'No';
$lang['no_category'] = 'Home';
$lang['no_rate'] = 'no rate';
+$lang['note_filter_day'] = 'Only displays elements posted within the last %s day.';
+$lang['note_filter_days'] = 'Only displays elements posted within the last %s days.';
$lang['password updated'] = 'password updated';
$lang['periods_error'] = 'Recent period must be a positive integer value';
$lang['picture'] = 'picture';
@@ -579,6 +579,8 @@ $lang['slideshow'] = 'slideshow';
$lang['slideshow_stop'] = 'stop the slideshow';
$lang['special_categories'] = 'Specials';
$lang['sql_queries_in'] = 'SQL queries in';
+$lang['start_filter_hint'] = 'displays only recently posted elements';
+$lang['stop_filter_hint'] = 'return to the display of all elements';
$lang['submit'] = 'Submit';
$lang['the beginning'] = 'the beginning';
$lang['theme'] = 'Interface theme';
@@ -611,8 +613,5 @@ $lang['upload_username'] = 'Username';
$lang['useful when password forgotten'] = 'useful when password forgotten';
$lang['w_month'] = 'Month';
$lang['yes'] = 'Yes';
-$lang['note_filter_day'] = 'The whole of the elements are filtered in order to diplay the recent elements of less %s day.';
-$lang['note_filter_days'] = 'The whole of the elements are filtered in order to diplay the recent elements of less %s days.';
$lang['page_end'] = 'Page bottom';
-
?>
diff --git a/language/fr_FR.iso-8859-1/common.lang.php b/language/fr_FR.iso-8859-1/common.lang.php
index 42478be28..31ac85d99 100644
--- a/language/fr_FR.iso-8859-1/common.lang.php
+++ b/language/fr_FR.iso-8859-1/common.lang.php
@@ -489,10 +489,8 @@ $lang['maxheight'] = 'Hauteur maximum des images';
$lang['maxheight_error'] = 'La hauteur maximum des images doit être supérieure à 50';
$lang['maxwidth'] = 'Largeur maximum des images';
$lang['maxwidth_error'] = 'La largeur des images doit être supérieure à 50';
-$lang['flat_hint'] = 'affiche à plat les éléments des catégories et des sous-catégories';
-$lang['start_filter_hint'] = 'afficher que les éléments récents';
-$lang['stop_filter_hint'] = 'retourner à l\'affichage de tous les éléments';
$lang['mode_created_hint'] = 'afficher un calendrier par date de création';
+$lang['mode_flat_hint'] = 'afficher à plat les éléments des catégories et des sous-catégories';
$lang['mode_normal_hint'] = 'retourner à la vue normale';
$lang['mode_posted_hint'] = 'afficher un calendrier par date d\'ajout';
$lang['month'][10] = 'Octobre';
@@ -520,6 +518,8 @@ $lang['next_page'] = 'Suivant';
$lang['no'] = 'Non';
$lang['no_category'] = 'Accueil';
$lang['no_rate'] = 'pas de note';
+$lang['note_filter_day'] = 'L\'ensemble des éléments est filtré pour n\'afficher que les éléments récents de moins de %d jour.';
+$lang['note_filter_days'] = 'L\'ensemble des éléments est filtré pour n\'afficher que les éléments récents de moins de %d jours.';
$lang['password updated'] = 'mot de passe mis à jour';
$lang['periods_error'] = 'La période de nouveauté doit être un entier positif';
$lang['picture'] = 'image';
@@ -557,13 +557,12 @@ $lang['search_ascending'] = 'Croissant';
$lang['search_author'] = 'Rechercher un auteur';
$lang['search_categories'] = 'Rechercher dans les catégories';
$lang['search_date'] = 'Recherche par date';
-$lang['search_date_creation'] = 'Création';
$lang['search_date_from'] = 'Date';
$lang['search_date_to'] = 'Date de fin';
$lang['search_date_type'] = 'Type de date';
$lang['search_descending'] = 'Décroissant';
$lang['search_keywords'] = 'Recherche de mot';
-$lang['sear ch_mode_and'] = 'Rechercher tous les mots';
+$lang['search_mode_and'] = 'Rechercher tous les mots';
$lang['search_mode_or'] = 'Rechercher un des mots';
$lang['search_one_clause_at_least'] = 'Requête vide. Aucun critère fourni.';
$lang['search_options'] = 'Options de recherche';
@@ -580,6 +579,8 @@ $lang['slideshow'] = 'diaporama';
$lang['slideshow_stop'] = 'arrêter le diaporama';
$lang['special_categories'] = 'Spéciales';
$lang['sql_queries_in'] = 'requêtes SQL en';
+$lang['start_filter_hint'] = 'afficher que les éléments récents';
+$lang['stop_filter_hint'] = 'retourner à l\'affichage de tous les éléments';
$lang['submit'] = 'Valider';
$lang['the beginning'] = 'le début';
$lang['theme'] = 'Thème de l\'interface';
@@ -612,8 +613,5 @@ $lang['upload_username'] = 'Nom d\'utilisateur';
$lang['useful when password forgotten'] = 'utile en cas d\'oubli de mot de passe';
$lang['w_month'] = 'Mois';
$lang['yes'] = 'Oui';
-$lang['note_filter_day'] = 'L\'ensemble des éléments est filtré pour n\'afficher que les éléments récents de moins de %d jour.';
-$lang['note_filter_days'] = 'L\'ensemble des éléments est filtré pour n\'afficher que les éléments récents de moins de %d jours.';
$lang['page_end'] = 'Bas de page';
-
?>
diff --git a/plugins/admin_multi_view/is_admin.inc.php b/plugins/admin_multi_view/is_admin.inc.php
index 7dbedf8f3..78f68eef1 100644
--- a/plugins/admin_multi_view/is_admin.inc.php
+++ b/plugins/admin_multi_view/is_admin.inc.php
@@ -13,7 +13,7 @@ if (! defined('MULTIVIEW_CONTROLLER') )
list($user['template'], $user['theme']) = explode('/', $theme);
}
$lang = pwg_get_session_var( 'multiview_lang', '' );
- if ( !empty($theme) )
+ if ( !empty($lang) )
{
$user['language'] = $lang;
}
diff --git a/template/yoga/index.tpl b/template/yoga/index.tpl
index 0e0a1d1af..c47b82f30 100644
--- a/template/yoga/index.tpl
+++ b/template/yoga/index.tpl
@@ -32,7 +32,7 @@
<!-- END mode_normal -->
<!-- BEGIN flat -->
- <li><a href="{flat.URL}" title="{lang:flat_hint}" rel="nofollow"><img src="{pwg_root}{themeconf:icon_dir}/flat.png" class="button" alt="{lang:flat_hint}"></a></li>
+ <li><a href="{flat.URL}" title="{lang:mode_flat_hint}" rel="nofollow"><img src="{pwg_root}{themeconf:icon_dir}/flat.png" class="button" alt="{lang:flat_hint}"></a></li>
<!-- END flat -->
<!-- BEGIN mode_posted -->