aboutsummaryrefslogtreecommitdiffstats
path: root/admin/cat_modify.php
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--admin/cat_modify.php (renamed from admin/edit_cat.php)71
1 files changed, 62 insertions, 9 deletions
diff --git a/admin/edit_cat.php b/admin/cat_modify.php
index bcd78b751..3e171139f 100644
--- a/admin/edit_cat.php
+++ b/admin/cat_modify.php
@@ -1,6 +1,6 @@
<?php
/***************************************************************************
- * edit_cat.php *
+ * cat_modify.php *
* ------------------- *
* application : PhpWebGallery 1.3 *
* author : Pierrick LE GALL <pierrick@z0rglub.com> *
@@ -17,14 +17,41 @@
include_once( './include/isadmin.inc.php' );
//----------------------------------------------------- template initialization
-$sub = $vtp->Open( '../template/'.$user['template'].'/admin/edit_cat.vtp' );
+$sub = $vtp->Open( '../template/'.$user['template'].'/admin/cat_modify.vtp' );
$tpl = array( 'remote_site','editcat_confirm','editcat_back','editcat_title1',
- 'editcat_name', 'editcat_comment', 'editcat_status',
- 'editcat_status_info', 'submit' );
+ 'editcat_name','editcat_comment','editcat_status',
+ 'editcat_visible','editcat_status_info', 'submit' );
templatize_array( $tpl, 'lang', $sub );
+//---------------------------------------------------------------- verification
+if ( !is_numeric( $_GET['cat'] ) )
+{
+ $_GET['cat'] = '-1';
+}
//--------------------------------------------------------- form criteria check
if ( isset( $_POST['submit'] ) )
{
+ // 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 ) );
+
+ 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 );
+ }
+
$query = 'UPDATE '.PREFIX_TABLE.'categories';
if ( $_POST['name'] == '' )
{
@@ -43,6 +70,7 @@ if ( isset( $_POST['submit'] ) )
$query.= ", comment = '".htmlentities( $_POST['comment'], ENT_QUOTES )."'";
}
$query.= ", status = '".$_POST['status']."'";
+ $query.= ", visible = '".$_POST['visible']."'";
$query.= " WHERE id = '".$_GET['cat']."'";
$query.= ';';
mysql_query( $query );
@@ -57,26 +85,28 @@ if ( isset( $_POST['submit'] ) )
check_favorites( $row['id'] );
}
$vtp->addSession( $sub, 'confirmation' );
- $url = add_session_id( './admin.php?page=cat' );
+ $url = add_session_id( './admin.php?page=cat_list' );
$vtp->setVar( $sub, 'confirmation.back_url', $url );
$vtp->closeSession( $sub, 'confirmation' );
}
//------------------------------------------------------------------------ form
-$form_action = './admin.php?page=edit_cat&amp;cat='.$_GET['cat'];
+$form_action = './admin.php?page=cat_modify&amp;cat='.$_GET['cat'];
$vtp->setVar( $sub, 'form_action', add_session_id( $form_action ) );
$query = 'SELECT a.id,name,dir,status,comment';
-$query.= ',id_uppercat,site_id,galleries_url';
+$query.= ',id_uppercat,site_id,galleries_url,visible';
$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 ) );
$result = get_cat_info( $row['id'] );
-
+// cat name
$cat_name = get_cat_display_name( $result['name'], ' - ', '' );
$vtp->setVar( $sub, 'cat:name', $cat_name );
+// cat dir
$vtp->setVar( $sub, 'cat:dir', $row['dir'] );
+// remote site ?
if ( $row['site_id'] != 1 )
{
$vtp->addSession( $sub, 'server' );
@@ -85,16 +115,39 @@ if ( $row['site_id'] != 1 )
}
$vtp->setVar( $sub, 'name', $row['name'] );
$vtp->setVar( $sub, 'comment', $row['comment'] );
+// status : public, private...
$options = get_enums( PREFIX_TABLE.'categories', 'status' );
foreach ( $options as $option ) {
$vtp->addSession( $sub, 'status_option' );
- $vtp->setVar( $sub, 'status_option.option', $option );
+ $vtp->setVar( $sub, 'status_option.option', $lang[$option] );
+ $vtp->setVar( $sub, 'status_option.value', $option );
if ( $option == $row['status'] )
{
$vtp->setVar( $sub, 'status_option.checked', ' checked="checked"' );
}
$vtp->closeSession( $sub, 'status_option' );
}
+// 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' );
//----------------------------------------------------------- sending html code
$vtp->Parse( $handle , 'sub', $sub );
?> \ No newline at end of file