aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/category_cats.inc.php7
-rw-r--r--include/functions_category.inc.php7
-rw-r--r--include/functions_html.inc.php63
-rw-r--r--include/functions_user.inc.php46
4 files changed, 57 insertions, 66 deletions
diff --git a/include/category_cats.inc.php b/include/category_cats.inc.php
index d50347a44..eaa01b80b 100644
--- a/include/category_cats.inc.php
+++ b/include/category_cats.inc.php
@@ -37,7 +37,7 @@ if ($page['section']=='recent_cats')
$query = '
SELECT
id,name, representative_picture_id, comment, nb_images, uppercats,
- max_date_last, is_child_date_last, count_images, count_categories
+ date_last, max_date_last, count_images, count_categories
FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.'
ON id = cat_id and user_id = '.$user['id'].'
WHERE date_last > SUBDATE(
@@ -50,7 +50,7 @@ else
$query = '
SELECT
id,name, representative_picture_id, comment, nb_images,
- max_date_last, is_child_date_last, count_images, count_categories
+ date_last, max_date_last, count_images, count_categories
FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.'
ON id = cat_id and user_id = '.$user['id'].'
WHERE id_uppercat '.
@@ -65,7 +65,8 @@ $image_ids = array();
while ($row = mysql_fetch_assoc($result))
{
- $row['is_child_date_last'] = get_boolean($row['is_child_date_last']);
+ $row['is_child_date_last'] = isset($row['date_last'])
+ and $row['max_date_last']>$row['date_last'];
if (isset($row['representative_picture_id'])
and is_numeric($row['representative_picture_id']))
diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php
index e8a066923..706d9c401 100644
--- a/include/functions_category.inc.php
+++ b/include/functions_category.inc.php
@@ -61,7 +61,7 @@ SELECT ';
name, id, nb_images, global_rank,';
// From USER_CACHE_CATEGORIES_TABLE
$query.= '
- max_date_last, is_child_date_last, count_images, count_categories';
+ date_last, max_date_last, count_images, count_categories';
// $user['forbidden_categories'] including with USER_CACHE_CATEGORIES_TABLE
$query.= '
@@ -82,9 +82,8 @@ SELECT ';
$result = pwg_query($query);
$cats = array();
- while ($row = mysql_fetch_array($result))
+ while ($row = mysql_fetch_assoc($result))
{
- $row['is_child_date_last'] = get_boolean($row['is_child_date_last']);
array_push($cats, $row);
}
usort($cats, 'global_rank_compare');
@@ -391,4 +390,4 @@ function get_display_images_count($cat_nb_images, $cat_count_images, $cat_count_
return $display_text;
}
-?> \ No newline at end of file
+?>
diff --git a/include/functions_html.inc.php b/include/functions_html.inc.php
index 6c69b0fb0..ef0ee026c 100644
--- a/include/functions_html.inc.php
+++ b/include/functions_html.inc.php
@@ -26,55 +26,63 @@
function get_icon($date, $is_child_date = false)
{
- global $page, $user, $conf, $lang;
+ global $page, $user, $lang;
if (empty($date))
{
- $date = 'NULL';
+ return '';
}
- if (isset($page['get_icon_cache'][$is_child_date][$date]))
+ if (isset($page['get_icon_cache'][$date]))
{
- return $page['get_icon_cache'][$is_child_date][$date];
+ if (! $page['get_icon_cache'][$date] )
+ return '';
+ return $page['get_icon_cache']['_icons_'][$is_child_date];
}
if (!preg_match('/^(\d{4})-(\d{2})-(\d{2})/', $date, $matches))
- {
- // date can be empty, no icon to display
- $page['get_icon_cache'][$is_child_date][$date] = '';
- return $page['get_icon_cache'][$is_child_date][$date];
+ {// date can be empty, no icon to display
+ $page['get_icon_cache'][$date] = false;
+ return '';
}
list($devnull, $year, $month, $day) = $matches;
$unixtime = mktime( 0, 0, 0, $month, $day, $year );
-
if ($unixtime === false // PHP 5.1.0 and above
or $unixtime === -1) // PHP prior to 5.1.0
{
- $page['get_icon_cache'][$is_child_date][$date] = '';
- return $page['get_icon_cache'][$is_child_date][$date];
+ $page['get_icon_cache'][$date] = false;
+ return '';
}
$diff = time() - $unixtime;
$day_in_seconds = 24*60*60;
- $output = '';
- $title = $lang['recent_image'].' ';
+ $page['get_icon_cache'][$date] = false;
if ( $diff < $user['recent_period'] * $day_in_seconds )
{
- $icon_url = get_themeconf('icon_dir').'/'.($is_child_date ? 'recent_by_child.png' : 'recent.png');
- $title .= $user['recent_period'];
- $title .= '&nbsp;'.$lang['days'];
- $size = getimagesize( PHPWG_ROOT_PATH.$icon_url );
- $icon_url = get_root_url().$icon_url;
- $output = '<img title="'.$title.'" src="'.$icon_url.'" class="icon" style="border:0;';
- $output.= 'height:'.$size[1].'px;width:'.$size[0].'px" alt="(!)" />';
+ if ( !isset($page['get_icon_cache']['_icons_'] ) )
+ {
+ $icons = array(false => 'recent', true => 'recent_by_child' );
+ $title = $lang['recent_image'].'&nbsp;'.$user['recent_period']
+ .'&nbsp;'.$lang['days'];
+ foreach ($icons as $key => $icon)
+ {
+ $icon_url = get_themeconf('icon_dir').'/'.$icon.'.png';
+ $size = getimagesize( PHPWG_ROOT_PATH.$icon_url );
+ $icon_url = get_root_url().$icon_url;
+ $output = '<img title="'.$title.'" src="'.$icon_url.'" class="icon" style="border:0;';
+ $output.= 'height:'.$size[1].'px;width:'.$size[0].'px" alt="(!)" />';
+ $page['get_icon_cache']['_icons_'][$key] = $output;
+ }
+ }
+ $page['get_icon_cache'][$date] = true;
}
-
- $page['get_icon_cache'][$is_child_date][$date] = $output;
-
- return $page['get_icon_cache'][$is_child_date][$date];
+ if (! $page['get_icon_cache'][$date] )
+ return '';
+ return $page['get_icon_cache']['_icons_'][$is_child_date];
}
+
function create_navigation_bar(
$url, $nb_element, $start, $nb_element_page, $clean_url = false
)
@@ -392,7 +400,7 @@ SELECT id,name
*
* HTML code generated uses logical list tags ul and each category is an
* item li. The paramter given is the category informations as an array,
- * used keys are : id, name, nb_images, max_date_last, is_child_date_last,
+ * used keys are : id, name, nb_images, max_date_last, date_last
* count_images, count_categories
*
* @param array categories
@@ -473,8 +481,9 @@ function get_html_menu_category($categories)
: $category['count_images']).']';
$menu.= '</span>';
}
-
- $menu.= get_icon($category['max_date_last'], $category['is_child_date_last']);
+ $child_date_last = isset($category['date_last'])
+ and $category['max_date_last']>$category['date_last'] ;
+ $menu.= get_icon($category['max_date_last'], $child_date_last);
}
$menu.= str_repeat("\n</li></ul>",($level));
diff --git a/include/functions_user.inc.php b/include/functions_user.inc.php
index 206ccf4a6..362679f51 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_categorie($userdata['id'], $userdata['forbidden_categories']);
+ update_user_cache_categories($userdata['id'], $userdata['forbidden_categories']);
// Set need update are done
$userdata['need_update'] = false;
@@ -449,9 +449,6 @@ SELECT id
/**
* compute data of categories branches
- *
- * was internal function of update_user_cache_categorie
- * move to global because function be redeclare when it's internal
*/
function compute_branch_cat_data(&$cats, &$list_cat_id, &$level, &$ref_level)
{
@@ -472,7 +469,6 @@ function compute_branch_cat_data(&$cats, &$list_cat_id, &$level, &$ref_level)
if ((empty($cats[$cat_id]['max_date_last'])) or ($cats[$cat_id]['max_date_last'] < $date))
{
$cats[$cat_id]['max_date_last'] = $date;
- $cats[$cat_id]['is_child_date_last'] = true;
}
else
{
@@ -494,37 +490,37 @@ function compute_branch_cat_data(&$cats, &$list_cat_id, &$level, &$ref_level)
}
/**
- * update data of user_cache_categorie
+ * update data of user_cache_categories
*
* @param int user_id
* @return null
*/
-function update_user_cache_categorie($user_id, $user_forbidden_categories)
+function update_user_cache_categories($user_id, $user_forbidden_categories)
{
// delete user cache
$query = '
- delete from '.USER_CACHE_CATEGORIES_TABLE.'
- where user_id = '.$user_id.'
+DELETE FROM '.USER_CACHE_CATEGORIES_TABLE.'
+ WHERE user_id = '.$user_id.'
;';
pwg_query($query);
$query = '
- select
- id cat_id, date_last,
- nb_images, global_rank
- from '.CATEGORIES_TABLE;
+SELECT id cat_id, date_last max_date_last, nb_images count_images, global_rank
+ FROM '.CATEGORIES_TABLE;
if ($user_forbidden_categories != '')
{
$query.= '
- where id not in ('.$user_forbidden_categories.')';
+ WHERE id NOT IN ('.$user_forbidden_categories.')';
}
$query.= ';';
$result = pwg_query($query);
$cats = array();
- while ($row = mysql_fetch_array($result))
+ while ($row = mysql_fetch_assoc($result))
{
+ $row['user_id'] = $user_id;
+ $row['count_categories'] = 0;
$cats += array($row['cat_id'] => $row);
}
usort($cats, 'global_rank_compare');
@@ -535,13 +531,6 @@ function update_user_cache_categorie($user_id, $user_forbidden_categories)
foreach ($cats as $id => $category)
{
- // Update field
- $cats[$id]['user_id'] = $user_id;
- $cats[$id]['is_child_date_last'] = false;
- $cats[$id]['max_date_last'] = $cats[$id]['date_last'];
- $cats[$id]['count_images'] = $cats[$id]['nb_images'];
- $cats[$id]['count_categories'] = 0;
-
// Compute
$level = substr_count($category['global_rank'], '.') + 1;
if ($level > $ref_level)
@@ -559,21 +548,14 @@ function update_user_cache_categorie($user_id, $user_forbidden_categories)
$level = 1;
compute_branch_cat_data($cats, $list_cat_id, $level, $ref_level);
- foreach ($cats as $id => $category)
- {
- // Convert field
- $cats[$id]['is_child_date_last'] = boolean_to_string($cats[$id]['is_child_date_last']);
- }
-
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
mass_inserts
(
USER_CACHE_CATEGORIES_TABLE,
array
(
- 'user_id', 'cat_id',
- 'is_child_date_last', 'max_date_last',
- 'count_images', 'count_categories'
+ 'user_id', 'cat_id',
+ 'max_date_last', 'count_images', 'count_categories'
),
$cats
);
@@ -800,7 +782,7 @@ function log_user($user_id, $remember_me)
{
global $conf, $user;
- if ($remember_me)
+ if ($remember_me and $conf['authorize_remembering'])
{
$key = calculate_auto_login_key($user_id);
if ($key!==false)