diff options
-rw-r--r-- | admin/cat_list.php | 2 | ||||
-rw-r--r-- | admin/cat_modify.php | 104 | ||||
-rw-r--r-- | admin/cat_options.php | 66 | ||||
-rw-r--r-- | admin/include/functions.php | 102 | ||||
-rw-r--r-- | language/en_UK.iso-8859-1/admin.lang.php | 17 | ||||
-rw-r--r-- | template/default/admin/cat_modify.tpl | 28 |
6 files changed, 201 insertions, 118 deletions
diff --git a/admin/cat_list.php b/admin/cat_list.php index 00bb4a5ac..2914901b5 100644 --- a/admin/cat_list.php +++ b/admin/cat_list.php @@ -132,7 +132,7 @@ while ($row = mysql_fetch_assoc($result)) // +-----------------------------------------------------------------------+ if (isset($_GET['parent_id'])) { - $separator = ' -> '; + $separator = ' <span style="font-size:15px">→</span> '; $base_url = PHPWG_ROOT_PATH.'admin.php?page=cat_list'; $navigation = '<a class="" href="'.add_session_id($base_url).'">'; 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 = '<a class="" href="'.add_session_id(PHPWG_ROOT_PATH.'admin.php?page=cat_list').'">'; -$navigation.= $lang['home'].'</a>->'; -$navigation.= get_cat_display_name($current_category['name'], '->', $url); +$navigation.= $lang['home'].'</a> <span style="font-size:15px">→</span>'; +$navigation.= get_cat_display_name( + $current_category['name'], + ' <span style="font-size:15px">→</span>', + $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 diff --git a/admin/cat_options.php b/admin/cat_options.php index 29e583150..502539d71 100644 --- a/admin/cat_options.php +++ b/admin/cat_options.php @@ -64,26 +64,12 @@ UPDATE '.CATEGORIES_TABLE.' } case 'visible' : { - // locking a category => all its child categories become locked - $subcats = get_subcat_ids($_POST['cat_true']); - $query = ' -UPDATE '.CATEGORIES_TABLE.' - SET visible = \'false\' - WHERE id IN ('.implode(',', $subcats).') -;'; - pwg_query($query); + set_cat_visible($_POST['cat_true'], 'false'); break; } case 'status' : { - // make a category private => all its child categories become private - $subcats = get_subcat_ids($_POST['cat_true']); - $query = ' -UPDATE '.CATEGORIES_TABLE.' - SET status = \'private\' - WHERE id IN ('.implode(',', $subcats).') -;'; - pwg_query($query); + set_cat_status($_POST['cat_true'], 'private'); break; } } @@ -116,52 +102,12 @@ UPDATE '.CATEGORIES_TABLE.' } case 'visible' : { - // unlocking a category => all its parent categories become unlocked - $uppercats = array(); - $query = ' -SELECT uppercats - FROM '.CATEGORIES_TABLE.' - WHERE id IN ('.implode(',', $_POST['cat_false']).') -;'; - $result = pwg_query($query); - while ($row = mysql_fetch_array($result)) - { - $uppercats = array_merge($uppercats, - explode(',', $row['uppercats'])); - } - $uppercats = array_unique($uppercats); - - $query = ' -UPDATE '.CATEGORIES_TABLE.' - SET visible = \'true\' - WHERE id IN ('.implode(',', $uppercats).') -;'; - pwg_query($query); + set_cat_visible($_POST['cat_false'], 'true'); break; } case 'status' : { - // make public a category => all its parent categories become public - $uppercats = array(); - $query = ' -SELECT uppercats - FROM '.CATEGORIES_TABLE.' - WHERE id IN ('.implode(',', $_POST['cat_false']).') -;'; - $result = pwg_query($query); - while ($row = mysql_fetch_array($result)) - { - $uppercats = array_merge($uppercats, - explode(',', $row['uppercats'])); - } - $uppercats = array_unique($uppercats); - - $query = ' -UPDATE '.CATEGORIES_TABLE.' - SET status = \'public\' - WHERE id IN ('.implode(',', $uppercats).') -;'; - pwg_query($query); + set_cat_status($_POST['cat_false'], 'public'); break; } } @@ -273,8 +219,8 @@ SELECT id,name,uppercats,global_rank $template->assign_vars( array( 'L_CAT_TITLE' => $lang['cat_lock_title'], - 'L_CAT_OPTIONS_TRUE' => $lang['lock'], - 'L_CAT_OPTIONS_FALSE' => $lang['unlock'], + 'L_CAT_OPTIONS_TRUE' => $lang['unlocked'], + 'L_CAT_OPTIONS_FALSE' => $lang['locked'], 'L_CAT_OPTIONS_INFO' => $lang['cat_lock_info'], ) ); diff --git a/admin/include/functions.php b/admin/include/functions.php index 5b113d9ce..7a12be755 100644 --- a/admin/include/functions.php +++ b/admin/include/functions.php @@ -990,4 +990,106 @@ SELECT id,uppercats $fields = array('primary' => array('id'), 'update' => array('global_rank')); mass_updates(CATEGORIES_TABLE, $fields, $datas); } + +/** + * change the visible property on a set of categories + * + * @param array categories + * @param string value + * @return void + */ +function set_cat_visible($categories, $value) +{ + if (!in_array($value, array('true', 'false'))) + { + return false; + } + + // unlocking a category => all its parent categories become unlocked + if ($value == 'true') + { + $uppercats = array(); + $query = ' +SELECT uppercats + FROM '.CATEGORIES_TABLE.' + WHERE id IN ('.implode(',', $categories).') +;'; + $result = pwg_query($query); + while ($row = mysql_fetch_array($result)) + { + $uppercats = array_merge($uppercats, + explode(',', $row['uppercats'])); + } + $uppercats = array_unique($uppercats); + + $query = ' +UPDATE '.CATEGORIES_TABLE.' + SET visible = \'true\' + WHERE id IN ('.implode(',', $uppercats).') +;'; + pwg_query($query); + } + // locking a category => all its child categories become locked + if ($value == 'false') + { + $subcats = get_subcat_ids($categories); + $query = ' +UPDATE '.CATEGORIES_TABLE.' + SET visible = \'false\' + WHERE id IN ('.implode(',', $subcats).') +;'; + pwg_query($query); + } +} + +/** + * change the status property on a set of categories : private or public + * + * @param array categories + * @param string value + * @return void + */ +function set_cat_status($categories, $value) +{ + if (!in_array($value, array('public', 'private'))) + { + return false; + } + + // make public a category => all its parent categories become public + if ($value == 'public') + { + $uppercats = array(); + $query = ' +SELECT uppercats + FROM '.CATEGORIES_TABLE.' + WHERE id IN ('.implode(',', $categories).') +;'; + $result = pwg_query($query); + while ($row = mysql_fetch_array($result)) + { + $uppercats = array_merge($uppercats, + explode(',', $row['uppercats'])); + } + $uppercats = array_unique($uppercats); + + $query = ' +UPDATE '.CATEGORIES_TABLE.' + SET status = \'public\' + WHERE id IN ('.implode(',', $uppercats).') +;'; + pwg_query($query); + } + // make a category private => all its child categories become private + if ($value == 'private') + { + $subcats = get_subcat_ids($categories); + $query = ' +UPDATE '.CATEGORIES_TABLE.' + SET status = \'private\' + WHERE id IN ('.implode(',', $subcats).') +;'; + pwg_query($query); + } +} ?> diff --git a/language/en_UK.iso-8859-1/admin.lang.php b/language/en_UK.iso-8859-1/admin.lang.php index 16d249656..8f0e09d41 100644 --- a/language/en_UK.iso-8859-1/admin.lang.php +++ b/language/en_UK.iso-8859-1/admin.lang.php @@ -43,8 +43,12 @@ $lang['authorized'] = 'Authorized'; $lang['forbidden'] = 'Forbidden'; $lang['free'] = 'Free'; $lang['restricted'] = 'Restricted'; +$lang['public'] = 'public'; +$lang['private'] = 'private'; $lang['metadata']='Metadata'; $lang['visitors'] = 'Visitors'; +$lang['locked'] = 'Locked'; +$lang['unlocked'] = 'Unlocked'; $lang['lock'] = 'Lock'; $lang['unlock'] = 'Unlock'; $lang['up'] = 'Move up'; @@ -89,19 +93,26 @@ $lang['cat_image_info'] = 'Images info'; $lang['editcat_status'] = 'Status'; $lang['editcat_confirm'] = 'Category informations updated successfully.'; $lang['editcat_perm'] = 'To set permissions for this category, click'; -$lang['cat_access_info'] = 'Permission management.'; +$lang['editcat_uploadable'] = 'Authorize upload'; +$lang['editcat_uploadable_info'] = 'Authorize users to upload files'; +$lang['editcat_commentable'] = 'Users comments'; +$lang['editcat_commentable_info'] = 'Authorize users to comment elements of this category'; +$lang['cat_access_info'] = 'Permission management. If you make a category private, all its child categories becomes private. If you make a category public, all its parent categories becomes public'; +$lang['editcat_visible_info'] = 'Lock temporary for maintenance. If you lock a category, all its child categories become locked. If you unlock a category, all its parent categories become unlocked.'; $lang['cat_virtual_added'] = 'Virtual category added'; $lang['cat_virtual_deleted'] = 'Virtual category deleted'; $lang['cat_upload_title'] = 'Select uploadable categories'; $lang['cat_upload_info'] = 'Only non virtual and non remote categories are shown.'; $lang['cat_lock_title'] = 'Lock categories'; -$lang['cat_lock_info'] = 'Selected categories will temporary been disabled for maintenance.'; +$lang['cat_lock_info'] = 'Selected categories will temporary been disabled for maintenance. +<br />If you lock a category, all its child categories become locked. +<br />If you unlock a category, all its parent categories become unlocked.'; $lang['cat_comments_title'] = 'Authorize users to add comments on selected categories'; $lang['cat_comments_info'] = 'By inheritance, an element is commentable if it belongs at least to one commentable category.'; $lang['cat_status_title'] = 'Manage authorizations for selected categories'; $lang['cat_status_info'] = 'Selected categories are private : you will need to authorize users and/or groups to access to them. <br />If you make a category private, all its child categories becomes private. -<br />It you make a category public, all its parent categories becomes public'; +<br />If you make a category public, all its parent categories becomes public'; // Titles $lang['admin_panel'] = 'Administration Panel'; diff --git a/template/default/admin/cat_modify.tpl b/template/default/admin/cat_modify.tpl index 4aa8ee032..7dea3c4bd 100644 --- a/template/default/admin/cat_modify.tpl +++ b/template/default/admin/cat_modify.tpl @@ -7,8 +7,8 @@ <table style="width:100%;"> <!-- BEGIN server --> <tr> - <td style="width:50%;">{L_REMOTE_SITE}</td> - <td class="row1">{SITE_URL}</td> + <td style="width:50%;"><strong>{L_REMOTE_SITE}</strong></td> + <td class="row1">{server.SITE_URL}</td> </tr> <!-- END server --> <tr> @@ -32,17 +32,33 @@ <tr> <td><strong>{L_EDIT_STATUS} :</strong><br /><span class="small">{L_EDIT_STATUS_INFO}</span></td> <td class="row1"> - <input type="radio" class="radio" name="status" value="public" {ACCESS_FREE} />{L_ACCESS_FREE} - <input type="radio" class="radio" name="status" value="private" {ACCESS_RESTRICTED} />{L_ACCESS_RESTRICTED} + <input type="radio" class="radio" name="status" value="public" {STATUS_PUBLIC} />{L_STATUS_PUBLIC} + <input type="radio" class="radio" name="status" value="private" {STATUS_PRIVATE} />{L_STATUS_PRIVATE} </td> </tr> - <tr> + <tr> <td><strong>{L_EDIT_LOCK} :</strong><br /><span class="small">{L_EDIT_LOCK_INFO}</span></td> <td class="row1"> <input type="radio" class="radio" name="visible" value="false" {LOCKED} />{L_YES} <input type="radio" class="radio" name="visible" value="true" {UNLOCKED} />{L_NO} </td> </tr> + <tr> + <td><strong>{L_EDIT_COMMENTABLE} :</strong><br /><span class="small">{L_EDIT_COMMENTABLE_INFO}</span></td> + <td class="row1"> + <input type="radio" class="radio" name="commentable" value="false" {COMMENTABLE_TRUE} />{L_YES} + <input type="radio" class="radio" name="commentable" value="true" {COMMENTABLE_FALSE} />{L_NO} + </td> + </tr> + <!-- BEGIN upload --> + <tr> + <td><strong>{L_EDIT_UPLOADABLE} :</strong><br /><span class="small">{L_EDIT_UPLOADABLE_INFO}</span></td> + <td class="row1"> + <input type="radio" class="radio" name="uploadable" value="true" {UPLOADABLE_TRUE} />{L_YES} + <input type="radio" class="radio" name="uploadable" value="false" {UPLOADABLE_FALSE} />{L_NO} + </td> + </tr> + <!-- END upload --> <!-- BEGIN parent --> <tr> <td>{#cat_parent}</td> @@ -69,4 +85,4 @@ </td> </tr> </table> -</form>
\ No newline at end of file +</form> |