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 |
|
|
|
|
// | Copyright (C) 2003-2004 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
|
|
|
|
if ( isset( $_POST['submit'] ) )
|
|
|
|
{
|
2003-07-01 11:27:20 +02:00
|
|
|
$query = 'SELECT status';
|
2004-03-31 19:26:31 +02:00
|
|
|
$query.= ' FROM '.CATEGORIES_TABLE;
|
|
|
|
$query.= ' WHERE id = '.$_GET['cat_id'];
|
2003-07-01 11:27:20 +02:00
|
|
|
$query.= ';';
|
2004-10-30 17:42:29 +02:00
|
|
|
$row = mysql_fetch_array( pwg_query( $query ) );
|
2003-07-01 11:27:20 +02:00
|
|
|
|
2004-03-31 19:26:31 +02:00
|
|
|
$query = 'UPDATE '.CATEGORIES_TABLE;
|
2003-07-25 23:33:41 +02:00
|
|
|
$query.= ' SET name = ';
|
2004-03-31 19:26:31 +02:00
|
|
|
if ( empty($_POST['name']))
|
2003-07-25 23:33:41 +02:00
|
|
|
$query.= 'NULL';
|
2003-05-18 23:42:32 +02:00
|
|
|
else
|
2003-07-25 23:33:41 +02:00
|
|
|
$query.= "'".htmlentities( $_POST['name'], ENT_QUOTES)."'";
|
|
|
|
|
|
|
|
$query.= ', comment = ';
|
2004-03-31 19:26:31 +02:00
|
|
|
if ( empty($_POST['comment']))
|
2003-07-25 23:33:41 +02:00
|
|
|
$query.= 'NULL';
|
2003-05-18 23:42:32 +02:00
|
|
|
else
|
2003-07-25 23:33:41 +02:00
|
|
|
$query.= "'".htmlentities( $_POST['comment'], ENT_QUOTES )."'";
|
|
|
|
|
2003-09-07 12:14:33 +02:00
|
|
|
if ( isset( $_POST['uploadable'] ) )
|
|
|
|
$query.= ", uploadable = '".$_POST['uploadable']."'";
|
|
|
|
|
2004-12-30 09:36:48 +01:00
|
|
|
if ( isset( $_POST['commentable'] ) )
|
|
|
|
$query.= ", commentable = '".$_POST['commentable']."'";
|
|
|
|
|
2003-09-07 12:14:33 +02:00
|
|
|
if ( isset( $_POST['associate'] ) )
|
|
|
|
{
|
|
|
|
$query.= ', id_uppercat = ';
|
2004-02-02 01:55:18 +01:00
|
|
|
if ( $_POST['associate'] == -1 or $_POST['associate'] == '' )
|
|
|
|
$query.= 'NULL';
|
|
|
|
else
|
|
|
|
$query.= $_POST['associate'];
|
2003-09-07 12:14:33 +02:00
|
|
|
}
|
2004-03-31 19:26:31 +02:00
|
|
|
$query.= ' WHERE id = '.$_GET['cat_id'];
|
2003-05-18 23:42:32 +02:00
|
|
|
$query.= ';';
|
2004-10-30 17:42:29 +02:00
|
|
|
pwg_query( $query );
|
2003-05-18 23:42:32 +02:00
|
|
|
|
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
|
|
|
|
2004-03-31 19:26:31 +02:00
|
|
|
$template->assign_block_vars('confirmation' ,array());
|
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']));
|
|
|
|
}
|
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
|
2004-12-04 13:10:17 +01:00
|
|
|
foreach (array('comment','dir','site_id') as $nullable)
|
2004-09-20 23:10:17 +02:00
|
|
|
{
|
|
|
|
if (!isset($category[$nullable]))
|
|
|
|
{
|
|
|
|
$category[$nullable] = '';
|
|
|
|
}
|
|
|
|
}
|
2004-02-02 01:55:18 +01:00
|
|
|
|
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
|
|
|
|
$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
|
|
|
|
|
|
|
'L_EDIT_CONFIRM'=>$lang['editcat_confirm'],
|
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'],
|
2004-03-31 19:26:31 +02:00
|
|
|
|
|
|
|
'F_ACTION'=>add_session_id($form_action)
|
|
|
|
));
|
2004-12-04 18:42:07 +01:00
|
|
|
|
|
|
|
if ($category['nb_images'] > 0)
|
|
|
|
{
|
|
|
|
$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.= '&image_id='.$category['representative_picture_id'];
|
|
|
|
$template->assign_block_vars('representant',
|
|
|
|
array('SRC' => $src,
|
|
|
|
'URL' => $url));
|
|
|
|
}
|
|
|
|
|
2004-12-04 13:10:17 +01:00
|
|
|
if (!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
|
|
|
}
|
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
|
|
|
?>
|