2003-05-09 14:42:42 +02:00
|
|
|
<?php
|
2004-02-12 00:20:38 +01:00
|
|
|
// +-----------------------------------------------------------------------+
|
2004-11-06 22:12:59 +01:00
|
|
|
// | PhpWebGallery - a PHP based picture gallery |
|
|
|
|
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
|
2005-01-08 00:10:51 +01:00
|
|
|
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
|
2004-02-12 00:20:38 +01:00
|
|
|
// +-----------------------------------------------------------------------+
|
2004-11-06 22:12:59 +01:00
|
|
|
// | branch : BSF (Best So Far)
|
2004-02-12 00:20:38 +01:00
|
|
|
// | file : $RCSfile$
|
|
|
|
// | last update : $Date$
|
|
|
|
// | last modifier : $Author$
|
|
|
|
// | revision : $Revision$
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | This program is free software; you can redistribute it and/or modify |
|
|
|
|
// | it under the terms of the GNU General Public License as published by |
|
|
|
|
// | the Free Software Foundation |
|
|
|
|
// | |
|
|
|
|
// | This program is distributed in the hope that it will be useful, but |
|
|
|
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
|
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
|
|
|
// | General Public License for more details. |
|
|
|
|
// | |
|
|
|
|
// | You should have received a copy of the GNU General Public License |
|
|
|
|
// | along with this program; if not, write to the Free Software |
|
|
|
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
|
|
|
// | USA. |
|
|
|
|
// +-----------------------------------------------------------------------+
|
2003-05-18 23:42:32 +02:00
|
|
|
|
2004-12-04 13:10:17 +01:00
|
|
|
if (!defined('PHPWG_ROOT_PATH'))
|
2004-03-31 19:26:31 +02:00
|
|
|
{
|
2004-12-04 13:10:17 +01:00
|
|
|
die('Hacking attempt!');
|
2004-03-31 19:26:31 +02:00
|
|
|
}
|
2004-12-04 13:10:17 +01:00
|
|
|
include_once(PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php');
|
2003-07-01 11:27:20 +02:00
|
|
|
//---------------------------------------------------------------- verification
|
2004-03-31 19:26:31 +02:00
|
|
|
if ( !isset( $_GET['cat_id'] ) || !is_numeric( $_GET['cat_id'] ) )
|
2003-07-01 11:27:20 +02:00
|
|
|
{
|
2004-03-31 19:26:31 +02:00
|
|
|
$_GET['cat_id'] = '-1';
|
2003-07-01 11:27:20 +02:00
|
|
|
}
|
2004-03-31 19:26:31 +02:00
|
|
|
|
|
|
|
$template->set_filenames( array('categories'=>'admin/cat_modify.tpl') );
|
|
|
|
|
2003-05-18 23:42:32 +02:00
|
|
|
//--------------------------------------------------------- form criteria check
|
2005-08-18 19:59:00 +02:00
|
|
|
if (isset($_POST['submit']))
|
2003-05-18 23:42:32 +02:00
|
|
|
{
|
2005-08-18 19:59:00 +02:00
|
|
|
$data =
|
|
|
|
array(
|
|
|
|
'id' => $_GET['cat_id'],
|
|
|
|
'name' => @$_POST['name'],
|
|
|
|
'commentable' => $_POST['commentable'],
|
|
|
|
'uploadable' =>
|
|
|
|
isset($_POST['uploadable']) ? $_POST['uploadable'] : 'false',
|
|
|
|
'comment' =>
|
|
|
|
$conf['allow_html_descriptions'] ?
|
|
|
|
@$_POST['comment'] : strip_tags(@$_POST['comment'])
|
|
|
|
);
|
2003-05-18 23:42:32 +02:00
|
|
|
|
2005-08-18 19:59:00 +02:00
|
|
|
mass_updates(
|
|
|
|
CATEGORIES_TABLE,
|
|
|
|
array(
|
|
|
|
'primary' => array('id'),
|
|
|
|
'update' => array_diff(array_keys($data), array('id'))
|
|
|
|
),
|
|
|
|
array($data)
|
|
|
|
);
|
|
|
|
|
2004-12-04 13:10:17 +01:00
|
|
|
set_cat_visible(array($_GET['cat_id']), $_POST['visible']);
|
|
|
|
set_cat_status(array($_GET['cat_id']), $_POST['status']);
|
2004-02-02 01:55:18 +01:00
|
|
|
|
2005-08-14 01:09:54 +02:00
|
|
|
if (isset($_POST['parent']))
|
|
|
|
{
|
|
|
|
move_category($_GET['cat_id'], $_POST['parent']);
|
|
|
|
}
|
|
|
|
|
|
|
|
array_push($page['infos'], $lang['editcat_confirm']);
|
2003-05-18 23:42:32 +02:00
|
|
|
}
|
2004-12-04 18:42:07 +01:00
|
|
|
else if (isset($_POST['set_random_representant']))
|
|
|
|
{
|
|
|
|
set_random_representant(array($_GET['cat_id']));
|
|
|
|
}
|
2005-08-14 01:09:54 +02:00
|
|
|
else if (isset($_POST['delete_representant']))
|
|
|
|
{
|
|
|
|
$query = '
|
|
|
|
UPDATE '.CATEGORIES_TABLE.'
|
|
|
|
SET representative_picture_id = NULL
|
|
|
|
WHERE id = '.$_GET['cat_id'].'
|
|
|
|
;';
|
|
|
|
pwg_query($query);
|
|
|
|
}
|
2004-03-31 19:26:31 +02:00
|
|
|
|
2004-12-04 13:10:17 +01:00
|
|
|
$query = '
|
|
|
|
SELECT *
|
|
|
|
FROM '.CATEGORIES_TABLE.'
|
|
|
|
WHERE id = '.$_GET['cat_id'].'
|
|
|
|
;';
|
2004-10-30 17:42:29 +02:00
|
|
|
$category = mysql_fetch_array( pwg_query( $query ) );
|
2004-09-20 23:10:17 +02:00
|
|
|
// nullable fields
|
2005-08-14 01:09:54 +02:00
|
|
|
foreach (array('comment','dir','site_id', 'id_uppercat') as $nullable)
|
2004-09-20 23:10:17 +02:00
|
|
|
{
|
|
|
|
if (!isset($category[$nullable]))
|
|
|
|
{
|
|
|
|
$category[$nullable] = '';
|
|
|
|
}
|
|
|
|
}
|
2004-02-02 01:55:18 +01:00
|
|
|
|
2005-08-14 01:09:54 +02:00
|
|
|
$category['is_virtual'] = empty($category['dir']) ? true : false;
|
|
|
|
|
2004-03-31 19:26:31 +02:00
|
|
|
// Navigation path
|
|
|
|
$url = PHPWG_ROOT_PATH.'admin.php?page=cat_list&parent_id=';
|
|
|
|
$navigation = '<a class="" href="'.add_session_id(PHPWG_ROOT_PATH.'admin.php?page=cat_list').'">';
|
2004-12-12 22:06:39 +01:00
|
|
|
$navigation.= $lang['home'].'</a>'.$conf['level_separator'];
|
- on picture.php, related categories under the element are displayed in
global_rank order
- when adding a new virtual category, initializes its global_rank
- bug fixed : in admin/cat_list, false next rank
- in admin/cat_modify, complete directory is calculated only if category is
not virtual
- admin/picture_modify rewritten : graphically nearer to admin/cat_modify,
virtual associations are back
- update_category partially rewritten : take an array of categories in
parameter, becomes optionnaly recursive, use the set_random_representant
function, set a random representant for categories with elements and no
representant
- bug fixed : on a search results screen, elements belonging to more than 1
category were shown more than once
- bug fixed : in admin/cat_modify, changing a value in a textefield and
hitting enter was setting a new random representant
git-svn-id: http://piwigo.org/svn/trunk@635 68402e56-0260-453c-a942-63ccdbb3a9ee
2004-12-05 22:28:40 +01:00
|
|
|
|
|
|
|
$navigation.= get_cat_display_name_cache(
|
|
|
|
$category['uppercats'],
|
2004-12-04 13:10:17 +01:00
|
|
|
$url);
|
2004-02-02 01:55:18 +01:00
|
|
|
|
2004-03-31 19:26:31 +02:00
|
|
|
$form_action = PHPWG_ROOT_PATH.'admin.php?page=cat_modify&cat_id='.$_GET['cat_id'];
|
2004-12-04 13:10:17 +01:00
|
|
|
$status = ($category['status']=='public')?'STATUS_PUBLIC':'STATUS_PRIVATE';
|
2004-03-31 19:26:31 +02:00
|
|
|
$lock = ($category['visible']=='true')?'UNLOCKED':'LOCKED';
|
|
|
|
|
2004-12-04 13:10:17 +01:00
|
|
|
if ($category['commentable'] == 'true')
|
|
|
|
{
|
|
|
|
$commentable = 'COMMENTABLE_TRUE';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$commentable = 'COMMENTABLE_FALSE';
|
|
|
|
}
|
|
|
|
if ($category['uploadable'] == 'true')
|
|
|
|
{
|
|
|
|
$uploadable = 'UPLOADABLE_TRUE';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$uploadable = 'UPLOADABLE_FALSE';
|
|
|
|
}
|
|
|
|
|
2004-03-31 19:26:31 +02:00
|
|
|
//----------------------------------------------------- template initialization
|
2005-08-14 01:09:54 +02:00
|
|
|
|
|
|
|
$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.= '&parent_id='.$category['id_uppercat'];
|
|
|
|
}
|
|
|
|
|
2004-03-31 19:26:31 +02:00
|
|
|
$template->assign_vars(array(
|
|
|
|
'CATEGORIES_NAV'=>$navigation,
|
|
|
|
'CAT_NAME'=>$category['name'],
|
|
|
|
'CAT_COMMENT'=>$category['comment'],
|
|
|
|
|
2004-12-04 13:10:17 +01:00
|
|
|
$status=>'checked="checked"',
|
2004-03-31 19:26:31 +02:00
|
|
|
$lock=>'checked="checked"',
|
2004-12-04 13:10:17 +01:00
|
|
|
$commentable=>'checked="checked"',
|
|
|
|
$uploadable=>'checked="checked"',
|
2004-03-31 19:26:31 +02:00
|
|
|
|
2004-12-20 15:52:30 +01:00
|
|
|
'L_EDIT_NAME'=>$lang['name'],
|
2004-03-31 19:26:31 +02:00
|
|
|
'L_STORAGE'=>$lang['storage'],
|
2004-12-04 13:10:17 +01:00
|
|
|
'L_REMOTE_SITE'=>$lang['remote_site'],
|
2004-12-20 15:52:30 +01:00
|
|
|
'L_EDIT_COMMENT'=>$lang['description'],
|
2004-12-16 15:49:47 +01:00
|
|
|
'L_EDIT_CAT_OPTIONS'=>$lang['cat_options'],
|
2004-09-20 23:10:17 +02:00
|
|
|
'L_EDIT_STATUS'=>$lang['conf_access'],
|
2004-03-31 19:26:31 +02:00
|
|
|
'L_EDIT_STATUS_INFO'=>$lang['cat_access_info'],
|
2004-12-04 13:10:17 +01:00
|
|
|
'L_STATUS_PUBLIC'=>$lang['public'],
|
|
|
|
'L_STATUS_PRIVATE'=>$lang['private'],
|
2004-11-25 17:44:41 +01:00
|
|
|
'L_EDIT_LOCK'=>$lang['lock'],
|
2004-12-16 15:49:47 +01:00
|
|
|
'L_EDIT_LOCK_INFO'=>$lang['editcat_lock_info'],
|
2004-12-04 13:10:17 +01:00
|
|
|
'L_EDIT_UPLOADABLE'=>$lang['editcat_uploadable'],
|
|
|
|
'L_EDIT_UPLOADABLE_INFO'=>$lang['editcat_uploadable_info'],
|
2004-12-16 15:49:47 +01:00
|
|
|
'L_EDIT_COMMENTABLE'=>$lang['comments'],
|
2004-12-04 13:10:17 +01:00
|
|
|
'L_EDIT_COMMENTABLE_INFO'=>$lang['editcat_commentable_info'],
|
2004-03-31 19:26:31 +02:00
|
|
|
'L_YES'=>$lang['yes'],
|
|
|
|
'L_NO'=>$lang['no'],
|
|
|
|
'L_SUBMIT'=>$lang['submit'],
|
2004-12-16 15:49:47 +01:00
|
|
|
'L_SET_RANDOM_REPRESENTANT'=>$lang['cat_representant'],
|
2005-08-14 01:09:54 +02:00
|
|
|
|
|
|
|
'U_JUMPTO'=>
|
|
|
|
add_session_id(PHPWG_ROOT_PATH.'category.php?cat='.$category['id']),
|
|
|
|
'U_CHILDREN'=>
|
|
|
|
add_session_id($cat_list_url.'&parent_id='.$category['id']),
|
2004-03-31 19:26:31 +02:00
|
|
|
|
|
|
|
'F_ACTION'=>add_session_id($form_action)
|
|
|
|
));
|
2004-12-04 18:42:07 +01:00
|
|
|
|
2005-08-14 01:09:54 +02:00
|
|
|
|
|
|
|
if ('private' == $category['status'])
|
|
|
|
{
|
|
|
|
$template->assign_block_vars(
|
|
|
|
'permissions',
|
|
|
|
array(
|
|
|
|
'URL'=>add_session_id($base_url.'cat_perm&cat='.$category['id'])
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// manage category elements link
|
2004-12-04 18:42:07 +01:00
|
|
|
if ($category['nb_images'] > 0)
|
|
|
|
{
|
2005-08-14 01:09:54 +02:00
|
|
|
$template->assign_block_vars(
|
|
|
|
'elements',
|
|
|
|
array(
|
|
|
|
'URL'=>add_session_id($base_url.'element_set&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 = '
|
2004-12-04 18:42:07 +01:00
|
|
|
SELECT tn_ext,path
|
|
|
|
FROM '.IMAGES_TABLE.'
|
|
|
|
WHERE id = '.$category['representative_picture_id'].'
|
|
|
|
;';
|
2005-08-14 01:09:54 +02:00
|
|
|
$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.= '&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());
|
|
|
|
}
|
2004-12-04 18:42:07 +01:00
|
|
|
}
|
|
|
|
|
2005-08-14 01:09:54 +02:00
|
|
|
if (!$category['is_virtual']) //!empty($category['dir']))
|
2003-07-01 11:27:20 +02:00
|
|
|
{
|
- on picture.php, related categories under the element are displayed in
global_rank order
- when adding a new virtual category, initializes its global_rank
- bug fixed : in admin/cat_list, false next rank
- in admin/cat_modify, complete directory is calculated only if category is
not virtual
- admin/picture_modify rewritten : graphically nearer to admin/cat_modify,
virtual associations are back
- update_category partially rewritten : take an array of categories in
parameter, becomes optionnaly recursive, use the set_random_representant
function, set a random representant for categories with elements and no
representant
- bug fixed : on a search results screen, elements belonging to more than 1
category were shown more than once
- bug fixed : in admin/cat_modify, changing a value in a textefield and
hitting enter was setting a new random representant
git-svn-id: http://piwigo.org/svn/trunk@635 68402e56-0260-453c-a942-63ccdbb3a9ee
2004-12-05 22:28:40 +01:00
|
|
|
$template->assign_block_vars(
|
|
|
|
'storage',
|
|
|
|
array('CATEGORY_DIR'=>preg_replace('/\/$/',
|
|
|
|
'',
|
|
|
|
get_complete_dir($category['id']))));
|
2004-12-04 13:10:17 +01:00
|
|
|
$template->assign_block_vars('upload' ,array());
|
2003-07-01 11:27:20 +02:00
|
|
|
}
|
2005-08-14 01:09:54 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
$template->assign_block_vars(
|
|
|
|
'delete',
|
|
|
|
array(
|
|
|
|
'URL'=>add_session_id($self_url.'&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
|
|
|
|
);
|
|
|
|
}
|
2004-03-31 19:26:31 +02:00
|
|
|
|
2004-12-04 13:10:17 +01:00
|
|
|
if (is_numeric($category['site_id']) and $category['site_id'] != 1)
|
2003-07-25 23:33:41 +02:00
|
|
|
{
|
2004-12-04 13:10:17 +01:00
|
|
|
$query = '
|
|
|
|
SELECT galleries_url
|
|
|
|
FROM '.SITES_TABLE.'
|
|
|
|
WHERE id = '.$category['site_id'].'
|
|
|
|
;';
|
|
|
|
list($galleries_url) = mysql_fetch_array(pwg_query($query));
|
|
|
|
$template->assign_block_vars('server', array('SITE_URL' => $galleries_url));
|
2003-07-25 23:33:41 +02:00
|
|
|
}
|
2004-03-31 19:26:31 +02:00
|
|
|
|
2003-05-18 23:42:32 +02:00
|
|
|
//----------------------------------------------------------- sending html code
|
2004-03-31 19:26:31 +02:00
|
|
|
$template->assign_var_from_handle('ADMIN_CONTENT', 'categories');
|
2004-02-12 00:20:38 +01:00
|
|
|
?>
|