aboutsummaryrefslogtreecommitdiffstats
path: root/category.php
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2005-03-25 22:10:55 +0000
committerplegall <plg@piwigo.org>2005-03-25 22:10:55 +0000
commitef080278bf4d0e073daa5f6a6f6d3b8ae4c29d9c (patch)
tree243d94d5b810325c43ea9e6998b7929319bc1e3e /category.php
parent333d44c398e31dd7f24efbcf50d53c1ce2a754ba (diff)
- new feature : caddie. The purpose is batch management, especially
concerning elements to categories associations. This is the very first release, needs many improvements. - new function : array_from_query. Firstly used by "caddie" feature, it may be useful in many cases. git-svn-id: http://piwigo.org/svn/trunk@755 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'category.php')
-rw-r--r--category.php36
1 files changed, 35 insertions, 1 deletions
diff --git a/category.php b/category.php
index 09decc08a..7de82f31c 100644
--- a/category.php
+++ b/category.php
@@ -75,6 +75,39 @@ if ( isset( $_GET['num'] )
initialize_category();
+// caddie filling :-)
+if (isset($_GET['caddie']))
+{
+ include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
+ // You can't add in caddie elements that are already in !
+
+ $query = '
+SELECT DISTINCT(id)
+ FROM '.IMAGES_TABLE.' AS i
+ INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
+ '.$page['where'].'
+;';
+ $ids = array_from_query($query, 'id');
+
+ $query = '
+SELECT element_id
+ FROM '.CADDIE_TABLE.'
+ WHERE user_id = '.$user['id'].'
+;';
+ $in_caddie = array_from_query($query, 'element_id');
+
+ $caddiables = array_diff($ids, $in_caddie);
+
+ $datas = array();
+
+ foreach ($caddiables as $caddiable)
+ {
+ array_push($datas, array('element_id' => $caddiable,
+ 'user_id' => $user['id']));
+ }
+ mass_inserts(CADDIE_TABLE, array('element_id','user_id'), $datas);
+}
+
// creation of the array containing the cat ids to expand in the menu
// $page['tab_expand'] contains an array with the category ids
// $page['expand'] contains the string to display in URL with comma
@@ -157,7 +190,8 @@ $template->assign_vars(array(
'U_REGISTER' => add_session_id( PHPWG_ROOT_PATH.'register.php' ),
'U_LOGOUT' => PHPWG_ROOT_PATH.'category.php?act=logout',
'U_ADMIN'=>add_session_id( PHPWG_ROOT_PATH.'admin.php' ),
- 'U_PROFILE'=>add_session_id(PHPWG_ROOT_PATH.'profile.php?'.str_replace( '&', '&amp;', $_SERVER['QUERY_STRING'] ))
+ 'U_PROFILE'=>add_session_id(PHPWG_ROOT_PATH.'profile.php?'.str_replace( '&', '&amp;', $_SERVER['QUERY_STRING'] )),
+ 'U_CADDIE'=>add_session_id(PHPWG_ROOT_PATH.'category.php'.get_query_string_diff(array('caddie')).'&amp;caddie=1')
)
);
//---------------------------------------------------------- special categories