aboutsummaryrefslogtreecommitdiffstats
path: root/admin/cat_modify.php
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2005-08-13 23:09:54 +0000
committerplegall <plg@piwigo.org>2005-08-13 23:09:54 +0000
commit1549745402270b86d2116b8f2a498fddf28ea2e8 (patch)
tree5a6b29e9ef9d7a98d58725685f4170d0a892a793 /admin/cat_modify.php
parent273884a65274e2688df1b2d3dc37103a46117772 (diff)
- new : maintenance screen in administration. There you can update
categories informations (number of images, date of the last added element), update images informations (path, average rate), purge obsolete sessions, purge history. - new : ability to have random representative for categories. This configuration parameter is set to false by default. - new : ability to set an element as representative of a category without belonging to the category. Thus, administrator can choose representative even for empty categories. - improvement : semantically superior design for category edition screen by regrouping fields in fieldsets. The improved screen contains action buttons as in category list screen. - new : ability to move a virtual category (ie change its parent category). - bug fixed : the sync_users function checks all user children tables (access, cache, group association). git-svn-id: http://piwigo.org/svn/trunk@809 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'admin/cat_modify.php')
-rw-r--r--admin/cat_modify.php155
1 files changed, 138 insertions, 17 deletions
diff --git a/admin/cat_modify.php b/admin/cat_modify.php
index 44c07ad85..700b6fe5f 100644
--- a/admin/cat_modify.php
+++ b/admin/cat_modify.php
@@ -41,12 +41,6 @@ $template->set_filenames( array('categories'=>'admin/cat_modify.tpl') );
//--------------------------------------------------------- form criteria check
if ( isset( $_POST['submit'] ) )
{
- $query = 'SELECT status';
- $query.= ' FROM '.CATEGORIES_TABLE;
- $query.= ' WHERE id = '.$_GET['cat_id'];
- $query.= ';';
- $row = mysql_fetch_array( pwg_query( $query ) );
-
$query = 'UPDATE '.CATEGORIES_TABLE;
$query.= ' SET name = ';
if ( empty($_POST['name']))
@@ -81,12 +75,26 @@ if ( isset( $_POST['submit'] ) )
set_cat_visible(array($_GET['cat_id']), $_POST['visible']);
set_cat_status(array($_GET['cat_id']), $_POST['status']);
- array_push($infos, $lang['editcat_confirm']);
+ if (isset($_POST['parent']))
+ {
+ move_category($_GET['cat_id'], $_POST['parent']);
+ }
+
+ array_push($page['infos'], $lang['editcat_confirm']);
}
else if (isset($_POST['set_random_representant']))
{
set_random_representant(array($_GET['cat_id']));
}
+else if (isset($_POST['delete_representant']))
+{
+ $query = '
+UPDATE '.CATEGORIES_TABLE.'
+ SET representative_picture_id = NULL
+ WHERE id = '.$_GET['cat_id'].'
+;';
+ pwg_query($query);
+}
$query = '
SELECT *
@@ -95,7 +103,7 @@ SELECT *
;';
$category = mysql_fetch_array( pwg_query( $query ) );
// nullable fields
-foreach (array('comment','dir','site_id') as $nullable)
+foreach (array('comment','dir','site_id', 'id_uppercat') as $nullable)
{
if (!isset($category[$nullable]))
{
@@ -103,6 +111,8 @@ foreach (array('comment','dir','site_id') as $nullable)
}
}
+$category['is_virtual'] = empty($category['dir']) ? true : false;
+
// Navigation path
$url = PHPWG_ROOT_PATH.'admin.php?page=cat_list&amp;parent_id=';
$navigation = '<a class="" href="'.add_session_id(PHPWG_ROOT_PATH.'admin.php?page=cat_list').'">';
@@ -134,6 +144,16 @@ else
}
//----------------------------------------------------- template initialization
+
+$base_url = PHPWG_ROOT_PATH.'admin.php?page=';
+$cat_list_url = $base_url.'cat_list';
+
+$self_url = $cat_list_url;
+if (!empty($category['id_uppercat']))
+{
+ $self_url.= '&amp;parent_id='.$category['id_uppercat'];
+}
+
$template->assign_vars(array(
'CATEGORIES_NAV'=>$navigation,
'CAT_NAME'=>$category['name'],
@@ -163,27 +183,89 @@ $template->assign_vars(array(
'L_NO'=>$lang['no'],
'L_SUBMIT'=>$lang['submit'],
'L_SET_RANDOM_REPRESENTANT'=>$lang['cat_representant'],
+
+ 'U_JUMPTO'=>
+ add_session_id(PHPWG_ROOT_PATH.'category.php?cat='.$category['id']),
+ 'U_CHILDREN'=>
+ add_session_id($cat_list_url.'&amp;parent_id='.$category['id']),
'F_ACTION'=>add_session_id($form_action)
));
+
+if ('private' == $category['status'])
+{
+ $template->assign_block_vars(
+ 'permissions',
+ array(
+ 'URL'=>add_session_id($base_url.'cat_perm&amp;cat='.$category['id'])
+ )
+ );
+}
+
+// manage category elements link
if ($category['nb_images'] > 0)
{
- $query = '
+ $template->assign_block_vars(
+ 'elements',
+ array(
+ 'URL'=>add_session_id($base_url.'element_set&amp;cat='.$category['id'])
+ )
+ );
+}
+
+// representant management
+if ($category['nb_images'] > 0
+ or !empty($category['representative_picture_id']))
+{
+ $template->assign_block_vars('representant', array());
+
+ // picture to display : the identified representant or the generic random
+ // representant ?
+ if (!empty($category['representative_picture_id']))
+ {
+ $query = '
SELECT tn_ext,path
FROM '.IMAGES_TABLE.'
WHERE id = '.$category['representative_picture_id'].'
;';
- $row = mysql_fetch_array(pwg_query($query));
- $src = get_thumbnail_src($row['path'], @$row['tn_ext']);
- $url = PHPWG_ROOT_PATH.'admin.php?page=picture_modify';
- $url.= '&amp;image_id='.$category['representative_picture_id'];
- $template->assign_block_vars('representant',
- array('SRC' => $src,
- 'URL' => $url));
+ $row = mysql_fetch_array(pwg_query($query));
+ $src = get_thumbnail_src($row['path'], @$row['tn_ext']);
+ $url = PHPWG_ROOT_PATH.'admin.php?page=picture_modify';
+ $url.= '&amp;image_id='.$category['representative_picture_id'];
+
+ $template->assign_block_vars(
+ 'representant.picture',
+ array(
+ 'SRC' => $src,
+ 'URL' => $url
+ )
+ );
+ }
+ else // $category['nb_images'] > 0
+ {
+ $template->assign_block_vars('representant.random', array());
+ }
+
+ // can the admin choose to set a new random representant ?
+ if ($category['nb_images'] > 0)
+ {
+ $template->assign_block_vars('representant.set_random', array());
+ }
+
+ // can the admin delete the current representant ?
+ if (
+ ($category['nb_images'] > 0
+ and $conf['allow_random_representative'])
+ or
+ ($category['nb_images'] == 0
+ and !empty($category['representative_picture_id'])))
+ {
+ $template->assign_block_vars('representant.delete_representant', array());
+ }
}
-if (!empty($category['dir']))
+if (!$category['is_virtual']) //!empty($category['dir']))
{
$template->assign_block_vars(
'storage',
@@ -192,6 +274,45 @@ if (!empty($category['dir']))
get_complete_dir($category['id']))));
$template->assign_block_vars('upload' ,array());
}
+else
+{
+ $template->assign_block_vars(
+ 'delete',
+ array(
+ 'URL'=>add_session_id($self_url.'&amp;delete='.$category['id'])
+ )
+ );
+
+ $template->assign_block_vars('move', array());
+
+ // the category can be moved in any category but in itself, in any
+ // sub-category
+ $unmovables = get_subcat_ids(array($category['id']));
+
+ $blockname = 'move.parent_option';
+
+ $template->assign_block_vars(
+ $blockname,
+ array(
+ 'SELECTED'
+ => empty($category['id_uppercat']) ? 'selected="selected"' : '',
+ 'VALUE'=> 0,
+ 'OPTION' => '------------'
+ )
+ );
+
+ $query = '
+SELECT id,name,uppercats,global_rank
+ FROM '.CATEGORIES_TABLE.'
+ WHERE id NOT IN ('.implode(',', $unmovables).')
+;';
+
+ display_select_cat_wrapper(
+ $query,
+ empty($category['id_uppercat']) ? array() : array($category['id_uppercat']),
+ $blockname
+ );
+}
if (is_numeric($category['site_id']) and $category['site_id'] != 1)
{