aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--include/category_cats.inc.php8
-rw-r--r--include/category_default.inc.php2
-rw-r--r--include/functions_category.inc.php6
-rw-r--r--include/functions_user.inc.php91
-rw-r--r--include/user.inc.php14
-rw-r--r--index.php51
-rw-r--r--language/en_UK.iso-8859-1/common.lang.php6
-rw-r--r--language/fr_FR.iso-8859-1/common.lang.php6
-rw-r--r--template/yoga/index.tpl12
-rw-r--r--template/yoga/menubar.tpl12
10 files changed, 161 insertions, 47 deletions
diff --git a/include/category_cats.inc.php b/include/category_cats.inc.php
index 36f19ca49..c84bdf6e9 100644
--- a/include/category_cats.inc.php
+++ b/include/category_cats.inc.php
@@ -55,7 +55,7 @@ SELECT
ON id = cat_id and user_id = '.$user['id'].'
WHERE id_uppercat '.
(!isset($page['category']) ? 'is NULL' : '= '.$page['category']);
- if ($page['filter_mode'])
+ if ($page['filter_local_mode'])
{
$query.= '
AND max_date_last > SUBDATE(
@@ -85,7 +85,7 @@ while ($row = mysql_fetch_assoc($result))
SELECT image_id
FROM '.CATEGORIES_TABLE.' AS c INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic
ON ic.category_id = c.id';
- if ($page['filter_mode'])
+ if ($page['filter_local_mode'] or $user['filter_global_mode'])
{
$query.= '
INNER JOIN '.IMAGES_TABLE.' AS i on ic.image_id = i.id ';
@@ -93,7 +93,7 @@ SELECT image_id
$query.= '
WHERE uppercats REGEXP \'(^|,)'.$row['id'].'(,|$)\'
AND c.id NOT IN ('.$user['forbidden_categories'].')';
- if ($page['filter_mode'])
+ if ($page['filter_local_mode'] or $user['filter_global_mode'])
{
$query.= '
AND i.date_available > SUBDATE(
@@ -117,7 +117,7 @@ SELECT representative_picture_id
ON id = cat_id and user_id = '.$user['id'].'
WHERE uppercats REGEXP \'(^|,)'.$row['id'].'(,|$)\'
AND representative_picture_id IS NOT NULL';
- if ($page['filter_mode'])
+ if ($page['filter_local_mode'] or $user['filter_global_mode'])
{
$query.= '
AND max_date_last > SUBDATE(
diff --git a/include/category_default.inc.php b/include/category_default.inc.php
index ae2dc4dce..1fff71956 100644
--- a/include/category_default.inc.php
+++ b/include/category_default.inc.php
@@ -47,7 +47,7 @@ if (count($selection) > 0)
SELECT *
FROM '.IMAGES_TABLE.'
WHERE id IN ('.implode(',', $selection).')';
- if ($page['filter_mode'])
+ if ($page['filter_local_mode'] or $user['filter_global_mode'])
{
$query.= '
AND date_available > SUBDATE(
diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php
index 8113064d6..4ae2b126c 100644
--- a/include/functions_category.inc.php
+++ b/include/functions_category.inc.php
@@ -67,7 +67,7 @@ SELECT ';
$query.= '
FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.'
ON id = cat_id and user_id = '.$user['id'];
- if ($page['filter_mode'])
+ if ($page['filter_local_mode'])
{
$query.= '
where max_date_last > SUBDATE(
@@ -75,8 +75,8 @@ where max_date_last > SUBDATE(
}
else
{
- // Always expand when filter_mode is activated
- if (!$user['expand'])
+ // Always expand when filter_local_mode is activated
+ if (!$user['expand'] and !$user['filter_global_mode'])
{
$query.= '
WHERE (id_uppercat is NULL';
diff --git a/include/functions_user.inc.php b/include/functions_user.inc.php
index 362679f51..d59a97e4d 100644
--- a/include/functions_user.inc.php
+++ b/include/functions_user.inc.php
@@ -143,11 +143,12 @@ function setup_style($style)
return new Template(PHPWG_ROOT_PATH.'template/'.$style);
}
-function build_user( $user_id, $use_cache )
+function build_user( $user_id, $use_cache, $filter_global_mode = false )
{
global $conf;
+
$user['id'] = $user_id;
- $user = array_merge( $user, getuserdata($user_id, $use_cache) );
+ $user = array_merge( $user, getuserdata($user_id, $use_cache, $filter_global_mode) );
if ( $user['id'] == $conf['guest_id'])
{
$user['is_the_guest']=true;
@@ -166,6 +167,7 @@ function build_user( $user_id, $use_cache )
{
$user['is_the_guest']=false;
}
+
// calculation of the number of picture to display per page
$user['nb_image_page'] = $user['nb_image_line'] * $user['nb_line_page'];
@@ -196,7 +198,7 @@ function build_user( $user_id, $use_cache )
* @param boolean use_cache
* @param array
*/
-function getuserdata($user_id, $use_cache)
+function getuserdata($user_id, $use_cache, $filter_global_mode = false )
{
global $conf;
@@ -265,17 +267,21 @@ SELECT ui.*, uc.*
if ($use_cache)
{
+ $userdata['filter_global_mode'] = $filter_global_mode;
+
if (!isset($userdata['need_update'])
or !is_bool($userdata['need_update'])
- or $userdata['need_update'] == true)
+ or $userdata['need_update'] == true
+ or $filter_global_mode // not optimize condition RubTag
+ )
{
$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;
+ $userdata['need_update'] = $userdata['filter_global_mode']; // for draft always update RubTag
$query = '
SELECT COUNT(DISTINCT(image_id)) as total
@@ -492,25 +498,58 @@ function compute_branch_cat_data(&$cats, &$list_cat_id, &$level, &$ref_level)
/**
* update data of user_cache_categories
*
- * @param int user_id
+ * @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);
- $query = '
+ /*$query = '
SELECT id cat_id, date_last max_date_last, nb_images count_images, global_rank
FROM '.CATEGORIES_TABLE;
- if ($user_forbidden_categories != '')
+ if ($userdata['forbidden_categories'] != '')
+ {
+ $query.= '
+ WHERE id NOT IN ('.$userdata['forbidden_categories'].')';
+ }
+ $query.= ';';*/
+
+
+ $query = '
+SELECT c.id cat_id, date_last max_date_last, nb_images count_images, global_rank';
+
+ if (!$userdata['filter_global_mode'])
+ {
+ $query.= '
+ 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
+ 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 '.$userdata['recent_period'].' DAY)';
+ }
+
+ if ($userdata['forbidden_categories'] != '')
+ {
+ $query.= '
+ WHERE C.id NOT IN ('.$userdata['forbidden_categories'].')';
+ }
+
+ if ($userdata['filter_global_mode'])
{
$query.= '
- WHERE id NOT IN ('.$user_forbidden_categories.')';
+ GROUP BY c.id';
}
$query.= ';';
@@ -519,8 +558,13 @@ SELECT id cat_id, date_last max_date_last, nb_images count_images, global_rank
$cats = array();
while ($row = mysql_fetch_assoc($result))
{
- $row['user_id'] = $user_id;
+ $row['user_id'] = $userdata['id'];
$row['count_categories'] = 0;
+ if ($userdata['filter_global_mode'])
+ {
+ $row['count_images'] = $row['filtered_count_images'];
+ $row['max_date_last'] = $row['max_date_available'];
+ }
$cats += array($row['cat_id'] => $row);
}
usort($cats, 'global_rank_compare');
@@ -548,6 +592,27 @@ SELECT id cat_id, date_last max_date_last, nb_images count_images, global_rank
$level = 1;
compute_branch_cat_data($cats, $list_cat_id, $level, $ref_level);
+ if ($userdata['filter_global_mode'])
+ {
+ $forbidden_cats = array();
+ $forbidden_cats = explode(',', $userdata['forbidden_categories']);
+ $cat_tmp = $cats;
+ $cats = array();
+
+ foreach ($cat_tmp as $cat_id => $category)
+ {
+ if (empty($category['max_date_last']))
+ {
+ array_push($forbidden_cats, $category['cat_id']);
+ }
+ else
+ {
+ array_push($cats, $category);
+ }
+ }
+ $userdata['forbidden_categories'] = implode(',', array_unique($forbidden_cats));
+ }
+
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
mass_inserts
(
diff --git a/include/user.inc.php b/include/user.inc.php
index 103052ad2..6f75ac962 100644
--- a/include/user.inc.php
+++ b/include/user.inc.php
@@ -69,8 +69,20 @@ if ($conf['apache_authentication'] and isset($_SERVER['REMOTE_USER']))
$user['id'] = get_userid($_SERVER['REMOTE_USER']);
}
}
+
+if (isset($_GET['filter_global_mode']))
+{
+ $user['filter_global_mode'] = ($_GET['filter_global_mode'] == 'start');
+ pwg_set_session_var('filter_global_mode', $user['filter_global_mode']);
+}
+else
+{
+ $user['filter_global_mode'] = pwg_get_session_var('filter_global_mode', false);
+}
+
$user = build_user( $user['id'],
- ( defined('IN_ADMIN') and IN_ADMIN ) ? false : true // use cache ?
+ ( defined('IN_ADMIN') and IN_ADMIN ) ? false : true, // use cache ?
+ $user['filter_global_mode'] // filter_global_mode ?
);
?> \ No newline at end of file
diff --git a/index.php b/index.php
index e6a184c5f..a7a05b60d 100644
--- a/index.php
+++ b/index.php
@@ -106,31 +106,64 @@ if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0)
$template_title.= ' ['.$page['cat_nb_images'].']';
}
-if (isset($_GET['filter_mode']))
+if (isset($_GET['filter_local_mode']))
{
- $page['filter_mode'] = ($_GET['filter_mode'] == 'start');
- pwg_set_session_var('filter_mode', $page['filter_mode']);
+ $page['filter_local_mode'] = ($_GET['filter_local_mode'] == 'start');
}
else
{
- $page['filter_mode'] = pwg_get_session_var('filter_mode', false);
+ $page['filter_local_mode'] = pwg_get_session_var('filter_local_mode', false);
}
-if ($page['filter_mode'])
+$page['filter_local_mode'] = (($page['filter_local_mode']) and
+ ($page['section'] == 'categories') and
+ (!isset($page['chronology_field'])));
+pwg_set_session_var('filter_local_mode', $page['filter_local_mode']);
+
+if ($page['filter_local_mode'])
+{
+ $template->assign_block_vars(
+ 'stop_filter_local_mode',
+ array(
+ 'URL' => add_url_params(duplicate_index_url(array(), array('start')), array('filter_local_mode' => 'stop'))
+ )
+ );
+}
+else
+{
+ $template->assign_block_vars(
+ 'start_filter_local_mode',
+ array(
+ 'URL' => add_url_params(duplicate_index_url(array(), array('start')), array('filter_local_mode' => 'start'))
+ )
+ );
+}
+
+if (isset($_GET['filter_global_mode']))
+{
+ $user['filter_global_mode'] = ($_GET['filter_global_mode'] == 'start');
+ pwg_set_session_var('filter_global_mode', $user['filter_global_mode']);
+}
+else
+{
+ $user['filter_global_mode'] = pwg_get_session_var('filter_global_mode', false);
+}
+
+if ($user['filter_global_mode'])
{
$template->assign_block_vars(
- 'stop_filter_mode',
+ 'stop_filter_global_mode',
array(
- 'URL' => add_url_params(duplicate_index_url(array(), array('start')), array('filter_mode' => 'stop'))
+ 'URL' => add_url_params(duplicate_index_url(array(), array('start')), array('filter_global_mode' => 'stop'))
)
);
}
else
{
$template->assign_block_vars(
- 'start_filter_mode',
+ 'start_filter_global_mode',
array(
- 'URL' => add_url_params(duplicate_index_url(array(), array('start')), array('filter_mode' => 'start'))
+ 'URL' => add_url_params(duplicate_index_url(array(), array('start')), array('filter_global_mode' => 'start'))
)
);
}
diff --git a/language/en_UK.iso-8859-1/common.lang.php b/language/en_UK.iso-8859-1/common.lang.php
index 3eb29ba29..636d5a21b 100644
--- a/language/en_UK.iso-8859-1/common.lang.php
+++ b/language/en_UK.iso-8859-1/common.lang.php
@@ -490,8 +490,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['start_filter_mode_hint'] = 'displays only recent elements';
-$lang['stop_filter_mode_hint'] = 'return to display all elements';
+$lang['start_filter_local_mode_hint'] = '[local] displays only recent elements';
+$lang['stop_filter_local_mode_hint'] = '[local] return to display all elements';
+$lang['start_filter_global_mode_hint'] = '[global] displays only recent elements';
+$lang['stop_filter_global_mode_hint'] = '[global] return to display all elements';
$lang['mode_created_hint'] = 'displays a calendar by creation date';
$lang['mode_normal_hint'] = 'return to normal view mode';
$lang['mode_posted_hint'] = 'displays a calendar by date posted';
diff --git a/language/fr_FR.iso-8859-1/common.lang.php b/language/fr_FR.iso-8859-1/common.lang.php
index ced90e8ac..9aa1fee9c 100644
--- a/language/fr_FR.iso-8859-1/common.lang.php
+++ b/language/fr_FR.iso-8859-1/common.lang.php
@@ -490,9 +490,11 @@ $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['start_filter_local_mode_hint'] = '[local] afficher que les éléments récents';
+$lang['stop_filter_local_mode_hint'] = '[local] retourner à l\'affichage de tous les éléments';
+$lang['start_filter_global_mode_hint'] = '[global] afficher que les éléments récents';
+$lang['stop_filter_global_mode_hint'] = '[global] retourner à l\'affichage de tous les éléments';
$lang['mode_created_hint'] = 'afficher un calendrier par date de création';
-$lang['start_filter_mode_hint'] = 'afficher que les éléments récents';
-$lang['stop_filter_mode_hint'] = 'retourner à l\'affichage de tous les éléments';
$lang['mode_normal_hint'] = 'retourner à la vue normale';
$lang['mode_posted_hint'] = 'afficher un calendrier par date d\'ajout';
$lang['month'][10] = 'Octobre';
diff --git a/template/yoga/index.tpl b/template/yoga/index.tpl
index cb04162fe..95c6e0051 100644
--- a/template/yoga/index.tpl
+++ b/template/yoga/index.tpl
@@ -27,12 +27,12 @@
<li><a href="{search_rules.URL}" style="border:none;" onclick="popuphelp(this.href); return false;" title="{lang:Search rules}"><img src="{pwg_root}{themeconf:icon_dir}/search_rules.png" class="button" alt="(?)"></a></li>
<!-- END search_rules -->
- <!-- BEGIN start_filter_mode -->
- <li><a href="{start_filter_mode.URL}" title="{lang:start_filter_mode_hint}"><img src="{pwg_root}{themeconf:icon_dir}/start_filter_mode.png" class="button" alt="{lang:start_filter_mode_hint}"></a></li>
- <!-- END start_filter_mode -->
- <!-- BEGIN stop_filter_mode -->
- <li><a href="{stop_filter_mode.URL}" title="{lang:stop_filter_mode_hint}"><img src="{pwg_root}{themeconf:icon_dir}/stop_filter_mode.png" class="button" alt="{lang:stop_filter_mode_hint}"></a></li>
- <!-- END stop_filter_mode -->
+ <!-- BEGIN start_filter_local_mode -->
+ <li><a href="{start_filter_local_mode.URL}" title="{lang:start_filter_local_mode_hint}"><img src="{pwg_root}{themeconf:icon_dir}/start_filter_mode.png" class="button" alt="{lang:start_filter_local_mode_hint}"></a></li>
+ <!-- END start_filter_local_mode -->
+ <!-- BEGIN stop_filter_local_mode -->
+ <li><a href="{stop_filter_local_mode.URL}" title="{lang:stop_filter_local_mode_hint}"><img src="{pwg_root}{themeconf:icon_dir}/stop_filter_mode.png" class="button" alt="{lang:stop_filter_local_mode_hint}"></a></li>
+ <!-- END stop_filter_local_mode -->
<!-- BEGIN mode_normal -->
<li><a href="{mode_normal.URL}" title="{lang:mode_normal_hint}"><img src="{pwg_root}{themeconf:icon_dir}/normal_mode.png" class="button" alt="{lang:mode_normal_hint}"></a></li>
diff --git a/template/yoga/menubar.tpl b/template/yoga/menubar.tpl
index eecf72aac..dd3b72390 100644
--- a/template/yoga/menubar.tpl
+++ b/template/yoga/menubar.tpl
@@ -13,12 +13,12 @@
</dl>
<!-- END links -->
<dl id="mbCategories">
- <!-- BEGIN start_filter_mode -->
- <a href="{start_filter_mode.URL}" title="{lang:start_filter_mode_hint}"><img src="{pwg_root}{themeconf:icon_dir}/start_filter_mode.png" class="buttonmenu" alt="{lang:start_filter_mode_hint}"></a>
- <!-- END start_filter_mode -->
- <!-- BEGIN stop_filter_mode -->
- <a href="{stop_filter_mode.URL}" title="{lang:stop_filter_mode_hint}"><img src="{pwg_root}{themeconf:icon_dir}/stop_filter_mode.png" class="buttonmenu" alt="{lang:stop_filter_mode_hint}"></a>
- <!-- END stop_filter_mode -->
+ <!-- BEGIN start_filter_global_mode -->
+ <a href="{start_filter_global_mode.URL}" title="{lang:start_filter_global_mode_hint}"><img src="{pwg_root}{themeconf:icon_dir}/start_filter_mode.png" class="buttonmenu" alt="{lang:start_filter_global_mode_hint}"></a>
+ <!-- END start_filter_global_mode -->
+ <!-- BEGIN stop_filter_global_mode -->
+ <a href="{stop_filter_global_mode.URL}" title="{lang:stop_filter_global_mode_hint}"><img src="{pwg_root}{themeconf:icon_dir}/stop_filter_mode.png" class="buttonmenu" alt="{lang:stop_filter_global_mode_hint}"></a>
+ <!-- END stop_filter_global_mode -->
<dt><a href="{U_HOME}">{lang:Categories}</a></dt>
<dd>
{MENU_CATEGORIES_CONTENT}