aboutsummaryrefslogtreecommitdiffstats
path: root/include/functions_category.inc.php
diff options
context:
space:
mode:
authorz0rglub <z0rglub@piwigo.org>2004-11-01 15:01:28 +0000
committerz0rglub <z0rglub@piwigo.org>2004-11-01 15:01:28 +0000
commitb1db5e55ae77c1ce386b25f8083a8bdd88607a96 (patch)
tree1d49d20a6cd52a82b1373c4e7784e931fd563eb0 /include/functions_category.inc.php
parentfa9a5cd07bc9931d1dffb9c54ab93ce3736ac506 (diff)
- synchronization interface redesigned : a form lets user choose option of
dirs/files/metadata sync on all categories or a defined one (including subcategories) - database sync is only available through update.php git-svn-id: http://piwigo.org/svn/trunk@589 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include/functions_category.inc.php')
-rw-r--r--include/functions_category.inc.php82
1 files changed, 62 insertions, 20 deletions
diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php
index f924d5c83..9253a24d8 100644
--- a/include/functions_category.inc.php
+++ b/include/functions_category.inc.php
@@ -115,49 +115,59 @@ function get_user_plain_structure()
{
global $page,$user;
- $infos = array( 'name','id','date_last','nb_images','dir','id_uppercat',
+ $infos = array('name','id','date_last','nb_images','dir','id_uppercat',
'rank','site_id','uppercats');
- $query = 'SELECT '.implode( ',', $infos );
- $query.= ' FROM '.CATEGORIES_TABLE;
- $query.= ' WHERE 1 = 1'; // stupid but permit using AND after it !
- if ( !$user['expand'] )
+ $query = '
+SELECT '.implode(',', $infos).'
+ FROM '.CATEGORIES_TABLE.'
+ WHERE 1 = 1'; // stupid but permit using AND after it !
+ if (!$user['expand'])
{
- $query.= ' AND (id_uppercat is NULL';
- if ( isset ($page['tab_expand']) && count( $page['tab_expand'] ) > 0 )
+ $query.= '
+ AND (id_uppercat is NULL';
+ if (isset ($page['tab_expand']) and count($page['tab_expand']) > 0)
{
$query.= ' OR id_uppercat IN ('.implode(',',$page['tab_expand']).')';
}
$query.= ')';
}
- if ( $user['forbidden_categories'] != '' )
+ if ($user['forbidden_categories'] != '')
{
- $query.= ' AND id NOT IN ';
- $query.= '('.$user['forbidden_categories'].')';
+ $query.= '
+ AND id NOT IN ('.$user['forbidden_categories'].')';
}
- $query.= ' ORDER BY id_uppercat ASC, rank ASC';
- $query.= ';';
+ $query.= '
+ ORDER BY id_uppercat ASC, rank ASC
+;';
$plain_structure = array();
- $result = pwg_query( $query );
- while ( $row = mysql_fetch_array( $result ) )
+ $result = pwg_query($query);
+ while ($row = mysql_fetch_array($result))
{
$category = array();
- foreach ( $infos as $info ) {
- if ( $info == 'uc.date_last')
+ foreach ($infos as $info)
+ {
+ if ($info == 'uc.date_last')
{
- if ( empty( $row['date_last'] ) )
+ if (empty($row['date_last']))
{
$category['date_last'] = 0;
}
else
{
- list($year,$month,$day) = explode( '-', $row['date_last'] );
+ list($year,$month,$day) = explode('-', $row['date_last']);
$category['date_last'] = mktime(0,0,0,$month,$day,$year);
}
}
- else if ( isset( $row[$info] ) ) $category[$info] = $row[$info];
- else $category[$info] = '';
+ else if (isset($row[$info]))
+ {
+ $category[$info] = $row[$info];
+ }
+ else
+ {
+ $category[$info] = '';
+ }
}
$plain_structure[$row['id']] = $category;
}
@@ -897,4 +907,36 @@ function get_first_non_empty_cat_id( $id_uppercat )
}
return false;
}
+
+function display_select_categories($categories,
+ $indent,
+ $selecteds,
+ $blockname)
+{
+ global $template,$user;
+
+ foreach ($categories as $category)
+ {
+ if (!in_array($category['id'], $user['restrictions']))
+ {
+ $selected = '';
+ if (in_array($category['id'], $selecteds))
+ {
+ $selected = ' selected="selected"';
+ }
+
+ $template->assign_block_vars(
+ $blockname,
+ array('SELECTED'=>$selected,
+ 'VALUE'=>$category['id'],
+ 'OPTION'=>$indent.'- '.$category['name']
+ ));
+
+ display_select_categories($category['subcats'],
+ $indent.str_repeat('&nbsp;',3),
+ $selecteds,
+ $blockname);
+ }
+ }
+}
?>