From a383f3148cb7c9a23dadbdcd12ede4e1de274af5 Mon Sep 17 00:00:00 2001 From: plegall Date: Sat, 4 Dec 2004 12:10:17 +0000 Subject: - change "->" in a beautiful arrow :-) for categories level in admin - single category management screen updated : commentable and uploadable properties added, full directory displayed, status and visibility properties update uses inheritance, user favorite elements check moved to somewhere else : would be too long to calculate here for too many users - new admin functions set_cat_visible and set_cat_status : visibility and status updates can be done in cat_options and cat_modify - language : differentiate "locked" (state) and "lock" (action) git-svn-id: http://piwigo.org/svn/trunk@632 68402e56-0260-453c-a942-63ccdbb3a9ee --- admin/cat_modify.php | 104 +++++++++++++++++++++++++++------------------------ 1 file changed, 56 insertions(+), 48 deletions(-) (limited to 'admin/cat_modify.php') diff --git a/admin/cat_modify.php b/admin/cat_modify.php index 98ea0b287..00f52abd4 100644 --- a/admin/cat_modify.php +++ b/admin/cat_modify.php @@ -25,12 +25,11 @@ // | USA. | // +-----------------------------------------------------------------------+ -if( !defined("PHPWG_ROOT_PATH") ) +if (!defined('PHPWG_ROOT_PATH')) { - die ("Hacking attempt!"); + die('Hacking attempt!'); } -include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php' ); - +include_once(PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php'); //---------------------------------------------------------------- verification if ( !isset( $_GET['cat_id'] ) || !is_numeric( $_GET['cat_id'] ) ) { @@ -42,8 +41,6 @@ $template->set_filenames( array('categories'=>'admin/cat_modify.tpl') ); //--------------------------------------------------------- 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 '.CATEGORIES_TABLE; $query.= ' WHERE id = '.$_GET['cat_id']; @@ -63,8 +60,6 @@ if ( isset( $_POST['submit'] ) ) else $query.= "'".htmlentities( $_POST['comment'], ENT_QUOTES )."'"; - $query.= ", status = '".$_POST['status']."'"; - $query.= ", visible = '".$_POST['visible']."'"; if ( isset( $_POST['uploadable'] ) ) $query.= ", uploadable = '".$_POST['uploadable']."'"; @@ -80,40 +75,20 @@ if ( isset( $_POST['submit'] ) ) $query.= ';'; pwg_query( $query ); - if ( $_POST['status'] != $row['status'] ) - { - // deletion of all access for groups concerning this category - $query = 'DELETE'; - $query.= ' FROM '.GROUP_ACCESS_TABLE; - $query.= ' WHERE cat_id = '.$_GET['cat_id']; - pwg_query( $query ); - // deletion of all access for users concerning this category - $query = 'DELETE'; - $query.= ' FROM '.USER_ACCESS_TABLE; - $query.= ' WHERE cat_id = '.$_GET['cat_id']; - pwg_query( $query ); - } + set_cat_visible(array($_GET['cat_id']), $_POST['visible']); + set_cat_status(array($_GET['cat_id']), $_POST['status']); - // checking users favorites - $query = 'SELECT id'; - $query.= ' FROM '.USERS_TABLE; - $query.= ';'; - $result = pwg_query( $query ); - while ( $row = mysql_fetch_array( $result ) ) - { - check_favorites( $row['id'] ); - } $template->assign_block_vars('confirmation' ,array()); } -$query = 'SELECT a.*, b.*'; -$query.= ' FROM '.CATEGORIES_TABLE.' as a, '.SITES_TABLE.' as b'; -$query.= ' WHERE a.id = '.$_GET['cat_id']; -$query.= ' AND a.site_id = b.id'; -$query.= ';'; +$query = ' +SELECT * + FROM '.CATEGORIES_TABLE.' + WHERE id = '.$_GET['cat_id'].' +;'; $category = mysql_fetch_array( pwg_query( $query ) ); // nullable fields -foreach (array('comment','dir') as $nullable) +foreach (array('comment','dir','site_id') as $nullable) { if (!isset($category[$nullable])) { @@ -125,34 +100,60 @@ foreach (array('comment','dir') as $nullable) $current_category = get_cat_info($_GET['cat_id']); $url = PHPWG_ROOT_PATH.'admin.php?page=cat_list&parent_id='; $navigation = ''; -$navigation.= $lang['home'].'->'; -$navigation.= get_cat_display_name($current_category['name'], '->', $url); +$navigation.= $lang['home'].' '; +$navigation.= get_cat_display_name( + $current_category['name'], + ' ', + $url); $form_action = PHPWG_ROOT_PATH.'admin.php?page=cat_modify&cat_id='.$_GET['cat_id']; -$access = ($category['status']=='public')?'ACCESS_FREE':'ACCESS_RESTRICTED'; +$status = ($category['status']=='public')?'STATUS_PUBLIC':'STATUS_PRIVATE'; $lock = ($category['visible']=='true')?'UNLOCKED':'LOCKED'; +if ($category['commentable'] == 'true') +{ + $commentable = 'COMMENTABLE_TRUE'; +} +else +{ + $commentable = 'COMMENTABLE_FALSE'; +} +if ($category['uploadable'] == 'true') +{ + $uploadable = 'UPLOADABLE_TRUE'; +} +else +{ + $uploadable = 'UPLOADABLE_FALSE'; +} + //----------------------------------------------------- template initialization $template->assign_vars(array( 'CATEGORIES_NAV'=>$navigation, 'CAT_NAME'=>$category['name'], 'CAT_COMMENT'=>$category['comment'], - 'CATEGORY_DIR'=>$category['dir'], - 'SITE_URL'=>$category['galleries_url'], + 'CATEGORY_DIR'=>preg_replace('/\/$/', '', get_complete_dir($category['id'])), - $access=>'checked="checked"', + $status=>'checked="checked"', $lock=>'checked="checked"', + $commentable=>'checked="checked"', + $uploadable=>'checked="checked"', 'L_EDIT_CONFIRM'=>$lang['editcat_confirm'], 'L_EDIT_NAME'=>$lang['description'], 'L_STORAGE'=>$lang['storage'], + 'L_REMOTE_SITE'=>$lang['remote_site'], 'L_EDIT_COMMENT'=>$lang['comment'], 'L_EDIT_STATUS'=>$lang['conf_access'], 'L_EDIT_STATUS_INFO'=>$lang['cat_access_info'], - 'L_ACCESS_FREE'=>$lang['free'], - 'L_ACCESS_RESTRICTED'=>$lang['restricted'], + 'L_STATUS_PUBLIC'=>$lang['public'], + 'L_STATUS_PRIVATE'=>$lang['private'], 'L_EDIT_LOCK'=>$lang['lock'], - 'L_EDIT_LOCK_INFO'=>$lang['cat_lock_info'], + 'L_EDIT_LOCK_INFO'=>$lang['editcat_visible_info'], + 'L_EDIT_UPLOADABLE'=>$lang['editcat_uploadable'], + 'L_EDIT_UPLOADABLE_INFO'=>$lang['editcat_uploadable_info'], + 'L_EDIT_COMMENTABLE'=>$lang['editcat_commentable'], + 'L_EDIT_COMMENTABLE_INFO'=>$lang['editcat_commentable_info'], 'L_YES'=>$lang['yes'], 'L_NO'=>$lang['no'], 'L_SUBMIT'=>$lang['submit'], @@ -160,14 +161,21 @@ $template->assign_vars(array( 'F_ACTION'=>add_session_id($form_action) )); -if ( !empty($category['dir'])) +if (!empty($category['dir'])) { $template->assign_block_vars('storage' ,array()); + $template->assign_block_vars('upload' ,array()); } -if ( $category['site_id'] != 1 ) +if (is_numeric($category['site_id']) and $category['site_id'] != 1) { - $template->assign_block_vars('storage' ,array()); + $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)); } //----------------------------------------------------------- sending html code -- cgit v1.2.3