2003-05-09 14:42:42 +02:00
|
|
|
<?php
|
2004-02-12 00:20:38 +01:00
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | cat_modify.php |
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | application : PhpWebGallery <http://phpwebgallery.net> |
|
|
|
|
// | branch : BSF (Best So Far) |
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | 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
|
|
|
|
2003-11-03 21:59:40 +01:00
|
|
|
include_once( './admin/include/isadmin.inc.php' );
|
2003-05-18 23:42:32 +02:00
|
|
|
//----------------------------------------------------- template initialization
|
2003-11-02 12:18:25 +01:00
|
|
|
$sub = $vtp->Open( './template/'.$user['template'].'/admin/cat_modify.vtp' );
|
2003-05-18 23:42:32 +02:00
|
|
|
$tpl = array( 'remote_site','editcat_confirm','editcat_back','editcat_title1',
|
2003-07-01 11:27:20 +02:00
|
|
|
'editcat_name','editcat_comment','editcat_status',
|
2003-07-25 23:33:41 +02:00
|
|
|
'editcat_visible','editcat_visible_info', 'submit',
|
2003-09-07 12:14:33 +02:00
|
|
|
'editcat_uploadable','cat_virtual','cat_parent' );
|
2003-05-18 23:42:32 +02:00
|
|
|
templatize_array( $tpl, 'lang', $sub );
|
2003-07-01 11:27:20 +02:00
|
|
|
//---------------------------------------------------------------- verification
|
|
|
|
if ( !is_numeric( $_GET['cat'] ) )
|
|
|
|
{
|
|
|
|
$_GET['cat'] = '-1';
|
|
|
|
}
|
2003-05-18 23:42:32 +02:00
|
|
|
//--------------------------------------------------------- form criteria check
|
|
|
|
if ( isset( $_POST['submit'] ) )
|
|
|
|
{
|
2003-07-01 11:27:20 +02:00
|
|
|
// if new status is different from previous one, deletion of all related
|
|
|
|
// links for access rights
|
|
|
|
$query = 'SELECT status';
|
|
|
|
$query.= ' FROM '.PREFIX_TABLE.'categories';
|
|
|
|
$query.= ' WHERE id = '.$_GET['cat'];
|
|
|
|
$query.= ';';
|
|
|
|
$row = mysql_fetch_array( mysql_query( $query ) );
|
|
|
|
|
2003-05-18 23:42:32 +02:00
|
|
|
$query = 'UPDATE '.PREFIX_TABLE.'categories';
|
2003-07-25 23:33:41 +02:00
|
|
|
|
|
|
|
$query.= ' SET name = ';
|
2003-05-18 23:42:32 +02:00
|
|
|
if ( $_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 = ';
|
2003-05-18 23:42:32 +02:00
|
|
|
if ( $_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-05-18 23:42:32 +02:00
|
|
|
$query.= ", status = '".$_POST['status']."'";
|
2003-07-01 11:27:20 +02:00
|
|
|
$query.= ", visible = '".$_POST['visible']."'";
|
2003-09-07 12:14:33 +02:00
|
|
|
|
|
|
|
if ( isset( $_POST['uploadable'] ) )
|
|
|
|
$query.= ", uploadable = '".$_POST['uploadable']."'";
|
|
|
|
|
|
|
|
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
|
|
|
}
|
2003-07-25 23:33:41 +02:00
|
|
|
$query.= ' WHERE id = '.$_GET['cat'];
|
2003-05-18 23:42:32 +02:00
|
|
|
$query.= ';';
|
|
|
|
mysql_query( $query );
|
|
|
|
|
2004-02-02 01:55:18 +01:00
|
|
|
if ( $_POST['status'] != $row['status'] )
|
|
|
|
{
|
|
|
|
// deletion of all access for groups concerning this category
|
|
|
|
$query = 'DELETE';
|
|
|
|
$query.= ' FROM '.PREFIX_TABLE.'group_access';
|
|
|
|
$query.= ' WHERE cat_id = '.$_GET['cat'];
|
|
|
|
mysql_query( $query );
|
|
|
|
// deletion of all access for users concerning this category
|
|
|
|
$query = 'DELETE';
|
|
|
|
$query.= ' FROM '.PREFIX_TABLE.'user_access';
|
|
|
|
$query.= ' WHERE cat_id = '.$_GET['cat'];
|
|
|
|
mysql_query( $query );
|
|
|
|
// resynchronize all users
|
|
|
|
synchronize_all_users();
|
|
|
|
}
|
|
|
|
|
2003-10-05 12:41:33 +02:00
|
|
|
// checking users favorites
|
2003-05-18 23:42:32 +02:00
|
|
|
$query = 'SELECT id';
|
2004-02-19 01:31:09 +01:00
|
|
|
$query.= ' FROM '.USERS_TABLE;
|
2003-05-18 23:42:32 +02:00
|
|
|
$query.= ';';
|
|
|
|
$result = mysql_query( $query );
|
2003-10-05 12:41:33 +02:00
|
|
|
while ( $row = mysql_fetch_array( $result ) )
|
2003-05-18 23:42:32 +02:00
|
|
|
{
|
|
|
|
check_favorites( $row['id'] );
|
|
|
|
}
|
2003-10-05 12:41:33 +02:00
|
|
|
|
2003-05-18 23:42:32 +02:00
|
|
|
$vtp->addSession( $sub, 'confirmation' );
|
2003-07-01 11:27:20 +02:00
|
|
|
$url = add_session_id( './admin.php?page=cat_list' );
|
2003-05-18 23:42:32 +02:00
|
|
|
$vtp->setVar( $sub, 'confirmation.back_url', $url );
|
|
|
|
$vtp->closeSession( $sub, 'confirmation' );
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------ form
|
2003-07-01 11:27:20 +02:00
|
|
|
$form_action = './admin.php?page=cat_modify&cat='.$_GET['cat'];
|
2003-05-18 23:42:32 +02:00
|
|
|
$vtp->setVar( $sub, 'form_action', add_session_id( $form_action ) );
|
|
|
|
|
2003-07-25 23:33:41 +02:00
|
|
|
$query = 'SELECT a.id,name,dir,status,comment,uploadable';
|
2003-07-01 11:27:20 +02:00
|
|
|
$query.= ',id_uppercat,site_id,galleries_url,visible';
|
2003-05-18 23:42:32 +02:00
|
|
|
$query.= ' FROM '.PREFIX_TABLE.'categories as a, '.PREFIX_TABLE.'sites as b';
|
|
|
|
$query.= ' WHERE a.id = '.$_GET['cat'];
|
|
|
|
$query.= ' AND a.site_id = b.id';
|
|
|
|
$query.= ';';
|
|
|
|
$row = mysql_fetch_array( mysql_query( $query ) );
|
2004-02-02 01:55:18 +01:00
|
|
|
|
|
|
|
if ( !isset( $row['dir'] ) ) $row['dir'] = '';
|
|
|
|
if ( !isset( $row['id_uppercat'] ) ) $row['id_uppercat'] = '';
|
|
|
|
|
2003-05-18 23:42:32 +02:00
|
|
|
$result = get_cat_info( $row['id'] );
|
2003-07-01 11:27:20 +02:00
|
|
|
// cat name
|
2004-03-26 18:08:09 +01:00
|
|
|
$cat_name = get_cat_display_name( $result['name'], ' - ' );
|
2003-05-18 23:42:32 +02:00
|
|
|
$vtp->setVar( $sub, 'cat:name', $cat_name );
|
2003-07-01 11:27:20 +02:00
|
|
|
// cat dir
|
2003-09-07 12:14:33 +02:00
|
|
|
if ( $row['dir'] != '' )
|
|
|
|
{
|
|
|
|
$vtp->addSession( $sub, 'storage' );
|
|
|
|
$vtp->setVar( $sub, 'storage.dir', $row['dir'] );
|
|
|
|
$vtp->closeSession( $sub, 'storage' );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$vtp->addSession( $sub, 'virtual' );
|
|
|
|
$vtp->closeSession( $sub, 'virtual' );
|
|
|
|
}
|
2003-07-01 11:27:20 +02:00
|
|
|
// remote site ?
|
2003-05-18 23:42:32 +02:00
|
|
|
if ( $row['site_id'] != 1 )
|
|
|
|
{
|
|
|
|
$vtp->addSession( $sub, 'server' );
|
|
|
|
$vtp->setVar( $sub, 'server.url', $row['galleries_url'] );
|
|
|
|
$vtp->closeSession( $sub, 'server' );
|
|
|
|
}
|
|
|
|
$vtp->setVar( $sub, 'name', $row['name'] );
|
2004-02-02 01:55:18 +01:00
|
|
|
if ( !isset( $row['comment'] ) ) $row['comment'] = '';
|
2003-05-18 23:42:32 +02:00
|
|
|
$vtp->setVar( $sub, 'comment', $row['comment'] );
|
2003-07-01 11:27:20 +02:00
|
|
|
// status : public, private...
|
2003-05-18 23:42:32 +02:00
|
|
|
$options = get_enums( PREFIX_TABLE.'categories', 'status' );
|
|
|
|
foreach ( $options as $option ) {
|
|
|
|
$vtp->addSession( $sub, 'status_option' );
|
2003-07-01 11:27:20 +02:00
|
|
|
$vtp->setVar( $sub, 'status_option.option', $lang[$option] );
|
|
|
|
$vtp->setVar( $sub, 'status_option.value', $option );
|
2003-05-18 23:42:32 +02:00
|
|
|
if ( $option == $row['status'] )
|
|
|
|
{
|
2003-05-27 22:56:13 +02:00
|
|
|
$vtp->setVar( $sub, 'status_option.checked', ' checked="checked"' );
|
2003-05-18 23:42:32 +02:00
|
|
|
}
|
|
|
|
$vtp->closeSession( $sub, 'status_option' );
|
|
|
|
}
|
2003-07-01 11:27:20 +02:00
|
|
|
// visible : true or false
|
|
|
|
$vtp->addSession( $sub, 'visible_option' );
|
|
|
|
$vtp->setVar( $sub, 'visible_option.value', 'true' );
|
|
|
|
$vtp->setVar( $sub, 'visible_option.option', $lang['yes'] );
|
|
|
|
$checked = '';
|
|
|
|
if ( $row['visible'] == 'true' )
|
|
|
|
{
|
|
|
|
$checked = ' checked="checked"';
|
|
|
|
}
|
|
|
|
$vtp->setVar( $sub, 'visible_option.checked', $checked );
|
|
|
|
$vtp->closeSession( $sub, 'visible_option' );
|
|
|
|
$vtp->addSession( $sub, 'visible_option' );
|
|
|
|
$vtp->setVar( $sub, 'visible_option.value', 'false' );
|
|
|
|
$vtp->setVar( $sub, 'visible_option.option', $lang['no'] );
|
|
|
|
$checked = '';
|
|
|
|
if ( $row['visible'] == 'false' )
|
|
|
|
{
|
|
|
|
$checked = ' checked="checked"';
|
|
|
|
}
|
|
|
|
$vtp->setVar( $sub, 'visible_option.checked', $checked );
|
|
|
|
$vtp->closeSession( $sub, 'visible_option' );
|
2003-07-25 23:33:41 +02:00
|
|
|
// uploadable : true or false
|
2003-09-07 12:14:33 +02:00
|
|
|
// a category can be uploadable if :
|
|
|
|
// 1. upload is authorized
|
|
|
|
// 2. category is not virtual
|
|
|
|
// 3. category is on the main site
|
|
|
|
if ( $conf['upload_available'] and $row['dir'] != '' and $row['site_id'] == 1 )
|
2003-07-25 23:33:41 +02:00
|
|
|
{
|
|
|
|
$vtp->addSession( $sub, 'uploadable' );
|
|
|
|
$vtp->addSession( $sub, 'uploadable_option' );
|
|
|
|
$vtp->setVar( $sub, 'uploadable_option.value', 'true' );
|
|
|
|
$vtp->setVar( $sub, 'uploadable_option.option', $lang['yes'] );
|
|
|
|
$checked = '';
|
|
|
|
if ( $row['uploadable'] == 'true' )
|
|
|
|
{
|
|
|
|
$checked = ' checked="checked"';
|
|
|
|
}
|
|
|
|
$vtp->setVar( $sub, 'uploadable_option.checked', $checked );
|
|
|
|
$vtp->closeSession( $sub, 'uploadable_option' );
|
|
|
|
$vtp->addSession( $sub, 'uploadable_option' );
|
|
|
|
$vtp->setVar( $sub, 'uploadable_option.value', 'false' );
|
|
|
|
$vtp->setVar( $sub, 'uploadable_option.option', $lang['no'] );
|
|
|
|
$checked = '';
|
|
|
|
if ( $row['uploadable'] == 'false' )
|
|
|
|
{
|
|
|
|
$checked = ' checked="checked"';
|
|
|
|
}
|
|
|
|
$vtp->setVar( $sub, 'uploadable_option.checked', $checked );
|
|
|
|
$vtp->closeSession( $sub, 'uploadable_option' );
|
|
|
|
$vtp->closeSession( $sub, 'uploadable' );
|
|
|
|
}
|
2003-09-07 12:14:33 +02:00
|
|
|
// can the parent category be changed ? (is the category virtual ?)
|
|
|
|
if ( $row['dir'] == '' )
|
|
|
|
{
|
|
|
|
$vtp->addSession( $sub, 'parent' );
|
2004-02-02 01:55:18 +01:00
|
|
|
// We only show a List Of Values if the number of categories is less than
|
|
|
|
// $conf['max_LOV_categories']
|
|
|
|
$query = 'SELECT COUNT(id) AS nb_total_categories';
|
|
|
|
$query.= ' FROM '.PREFIX_TABLE.'categories';
|
|
|
|
$query.= ';';
|
|
|
|
$countrow = mysql_fetch_array( mysql_query( $query ) );
|
|
|
|
if ( $countrow['nb_total_categories'] < $conf['max_LOV_categories'] )
|
|
|
|
{
|
|
|
|
$vtp->addSession( $sub, 'associate_LOV' );
|
|
|
|
$vtp->addSession( $sub, 'associate_cat' );
|
|
|
|
$vtp->setVar( $sub, 'associate_cat.value', '-1' );
|
|
|
|
$vtp->setVar( $sub, 'associate_cat.content', '' );
|
|
|
|
$vtp->closeSession( $sub, 'associate_cat' );
|
|
|
|
$page['plain_structure'] = get_plain_structure( true );
|
|
|
|
$structure = create_structure( '', array() );
|
|
|
|
display_categories( $structure, ' ', $row['id_uppercat'],$row['id'] );
|
|
|
|
$vtp->closeSession( $sub, 'associate_LOV' );
|
|
|
|
}
|
|
|
|
// else, we only display a small text field, we suppose the administrator
|
|
|
|
// knows the id of its category
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$vtp->addSession( $sub, 'associate_text' );
|
|
|
|
$vtp->setVar( $sub, 'associate_text.value', $row['id_uppercat'] );
|
|
|
|
$vtp->closeSession( $sub, 'associate_text' );
|
|
|
|
}
|
2003-09-07 12:14:33 +02:00
|
|
|
$vtp->closeSession( $sub, 'parent' );
|
|
|
|
}
|
2003-05-18 23:42:32 +02:00
|
|
|
//----------------------------------------------------------- sending html code
|
|
|
|
$vtp->Parse( $handle , 'sub', $sub );
|
2004-02-12 00:20:38 +01:00
|
|
|
?>
|