diff options
Diffstat (limited to '')
-rw-r--r-- | admin.php | 14 | ||||
-rw-r--r-- | admin/cat_options.php | 270 | ||||
-rw-r--r-- | admin/include/functions.php | 21 | ||||
-rw-r--r-- | admin/include/functions_metadata.php | 2 | ||||
-rw-r--r-- | admin/update.php | 55 |
5 files changed, 175 insertions, 187 deletions
@@ -166,6 +166,7 @@ if ( mysql_num_rows( $result ) > 0 ) $link_start = PHPWG_ROOT_PATH.'admin.php?page='; $conf_link = $link_start.'configuration&section='; +$opt_link = $link_start.'cat_options&section='; //----------------------------------------------------- template initialization include(PHPWG_ROOT_PATH.'include/page_header.php'); $template->set_filenames( array('admin'=>'admin.tpl') ); @@ -189,7 +190,6 @@ $template->assign_vars(array( 'L_SITES'=>$lang['remote_sites'], 'L_CATEGORIES'=>$lang['categories'], 'L_MANAGE'=>$lang['manage'], - 'L_UPLOAD'=>$lang['upload'], 'L_IMAGES'=>$lang['pictures'], 'L_WAITING'=>$lang['waiting'].$nb_waiting, 'L_COMMENTS'=>$lang['comments'].$nb_comments, @@ -199,8 +199,11 @@ $template->assign_vars(array( 'L_GROUPS'=>$lang['groups'], 'L_AUTH'=>$lang['permissions'], 'L_UPDATE'=>$lang['update'], - 'L_CAT_OPTIONS'=>$lang['cat_options_menu'], - + 'L_UPLOAD'=>$lang['cat_options_upload_menu'], + 'L_COMMENTS'=>$lang['cat_options_comments_menu'], + 'L_VISIBLE'=>$lang['cat_options_visible_menu'], + 'L_STATUS'=>$lang['cat_options_status_menu'], + 'U_CONFIG_GENERAL'=>add_session_id($conf_link.'general' ), 'U_CONFIG_COMMENTS'=>add_session_id($conf_link.'comments' ), 'U_CONFIG_DISPLAY'=>add_session_id($conf_link.'default' ), @@ -212,7 +215,10 @@ $template->assign_vars(array( 'U_USERS'=>add_session_id($link_start.'user_search' ), 'U_GROUPS'=>add_session_id($link_start.'group_list' ), 'U_CATEGORIES'=>add_session_id($link_start.'cat_list' ), - 'U_UPLOAD'=>add_session_id($link_start.'admin_upload' ), + 'U_UPLOAD'=>add_session_id($opt_link.'upload'), + 'U_COMMENTS'=>add_session_id($opt_link.'comments'), + 'U_VISIBLE'=>add_session_id($opt_link.'visible'), + 'U_STATUS'=>add_session_id($opt_link.'status'), 'U_WAITING'=>add_session_id($link_start.'waiting' ), 'U_COMMENTS'=>add_session_id($link_start.'comments' ), 'U_CAT_UPDATE'=>add_session_id($link_start.'update'), diff --git a/admin/cat_options.php b/admin/cat_options.php index cb518f7db..b62422961 100644 --- a/admin/cat_options.php +++ b/admin/cat_options.php @@ -36,7 +36,7 @@ include_once(PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php'); // print '<pre>'; // print_r($_POST); // print '</pre>'; -if (isset($_POST['submit']) and count($_POST['cat']) > 0) +if (isset($_POST['falsify']) and count($_POST['cat_true']) > 0) { switch ($_GET['section']) { @@ -44,8 +44,8 @@ if (isset($_POST['submit']) and count($_POST['cat']) > 0) { $query = ' UPDATE '.CATEGORIES_TABLE.' - SET uploadable = \''.$_POST['option'].'\' - WHERE id IN ('.implode(',', $_POST['cat']).') + SET uploadable = \'false\' + WHERE id IN ('.implode(',', $_POST['cat_true']).') ;'; pwg_query($query); break; @@ -54,8 +54,8 @@ UPDATE '.CATEGORIES_TABLE.' { $query = ' UPDATE '.CATEGORIES_TABLE.' - SET commentable = \''.$_POST['option'].'\' - WHERE id IN ('.implode(',', $_POST['cat']).') + SET commentable = \'false\' + WHERE id IN ('.implode(',', $_POST['cat_true']).') ;'; pwg_query($query); break; @@ -63,79 +63,101 @@ UPDATE '.CATEGORIES_TABLE.' case 'visible' : { // locking a category => all its child categories become locked - if ($_POST['option'] == 'false') - { - $subcats = get_subcat_ids($_POST['cat']); - $query = ' + $subcats = get_subcat_ids($_POST['cat_true']); + $query = ' UPDATE '.CATEGORIES_TABLE.' SET visible = \'false\' WHERE id IN ('.implode(',', $subcats).') ;'; - pwg_query($query); - } + pwg_query($query); + 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); + break; + } + } +} +else if (isset($_POST['trueify']) and count($_POST['cat_false']) > 0) +{ + switch ($_GET['section']) + { + case 'upload' : + { + $query = ' +UPDATE '.CATEGORIES_TABLE.' + SET uploadable = \'true\' + WHERE id IN ('.implode(',', $_POST['cat_false']).') +;'; + pwg_query($query); + break; + } + case 'comments' : + { + $query = ' +UPDATE '.CATEGORIES_TABLE.' + SET commentable = \'true\' + WHERE id IN ('.implode(',', $_POST['cat_false']).') +;'; + pwg_query($query); + break; + } + case 'visible' : + { // unlocking a category => all its parent categories become unlocked - if ($_POST['option'] == 'true') - { - $uppercats = array(); - $query = ' + $uppercats = array(); + $query = ' SELECT uppercats FROM '.CATEGORIES_TABLE.' - WHERE id IN ('.implode(',', $_POST['cat']).') + 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 = ' + $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); - } + pwg_query($query); break; } case 'status' : { - // make a category private => all its child categories become private - if ($_POST['option'] == 'false') - { - $subcats = get_subcat_ids($_POST['cat']); - $query = ' -UPDATE '.CATEGORIES_TABLE.' - SET status = \'private\' - WHERE id IN ('.implode(',', $subcats).') -;'; - pwg_query($query); - } // make public a category => all its parent categories become public - if ($_POST['option'] == 'true') - { - $uppercats = array(); - $query = ' + $uppercats = array(); + $query = ' SELECT uppercats FROM '.CATEGORIES_TABLE.' - WHERE id IN ('.implode(',', $_POST['cat']).') + 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 = ' + $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); - } + pwg_query($query); break; } } @@ -159,22 +181,6 @@ $template->assign_vars( array( 'L_SUBMIT'=>$lang['submit'], 'L_RESET'=>$lang['reset'], - 'L_CAT_OPTIONS_MENU_UPLOAD'=>$lang['cat_options_menu_upload'], - 'L_CAT_OPTIONS_MENU_VISIBLE'=>$lang['cat_options_menu_visible'], - 'L_CAT_OPTIONS_MENU_COMMENTS'=>$lang['cat_options_menu_comments'], - 'L_CAT_OPTIONS_MENU_STATUS'=>$lang['cat_options_menu_status'], - 'L_CAT_OPTIONS_UPLOAD_INFO'=>$lang['cat_options_upload_info'], - 'L_CAT_OPTIONS_UPLOAD_TRUE'=>$lang['cat_options_upload_true'], - 'L_CAT_OPTIONS_UPLOAD_FALSE'=>$lang['cat_options_upload_false'], - 'L_CAT_OPTIONS_COMMENTS_INFO'=>$lang['cat_options_comments_info'], - 'L_CAT_OPTIONS_COMMENTS_TRUE'=>$lang['cat_options_comments_true'], - 'L_CAT_OPTIONS_COMMENTS_FALSE'=>$lang['cat_options_comments_false'], - 'L_CAT_OPTIONS_VISIBLE_INFO'=>$lang['cat_options_visible_info'], - 'L_CAT_OPTIONS_VISIBLE_TRUE'=>$lang['cat_options_visible_true'], - 'L_CAT_OPTIONS_VISIBLE_FALSE'=>$lang['cat_options_visible_false'], - 'L_CAT_OPTIONS_STATUS_INFO'=>$lang['cat_options_status_info'], - 'L_CAT_OPTIONS_STATUS_TRUE'=>$lang['cat_options_status_true'], - 'L_CAT_OPTIONS_STATUS_FALSE'=>$lang['cat_options_status_false'], 'U_UPLOAD'=>add_session_id($base_url.'upload'), 'U_VISIBLE'=>add_session_id($base_url.'visible'), @@ -205,127 +211,103 @@ switch ($page['section']) { case 'upload' : { - $query = ' -SELECT id + $query_true = ' +SELECT id,name,uppercats,global_rank FROM '.CATEGORIES_TABLE.' WHERE uploadable = \'true\' AND dir IS NOT NULL AND site_id = 1 ;'; - $result = pwg_query($query); - while ($row = mysql_fetch_array($result)) - { - array_push($cats_true, $row['id']); - } - $query = ' -SELECT id + $query_false = ' +SELECT id,name,uppercats,global_rank FROM '.CATEGORIES_TABLE.' WHERE uploadable = \'false\' AND dir IS NOT NULL AND site_id = 1 ;'; - $result = pwg_query($query); - while ($row = mysql_fetch_array($result)) - { - array_push($cats_false, $row['id']); - } - + $template->assign_vars( + array( + 'L_TITLE' => $lang['cat_options_upload_title'], + 'L_CAT_OPTIONS_TRUE' => $lang['cat_options_upload_true'], + 'L_CAT_OPTIONS_FALSE' => $lang['cat_options_upload_false'], + 'L_CAT_OPTIONS_INFO' => $lang['cat_options_upload_info'], + ) + ); $template->assign_block_vars('upload', array()); - break; } case 'comments' : { - $query = ' -SELECT id + $query_true = ' +SELECT id,name,uppercats,global_rank FROM '.CATEGORIES_TABLE.' WHERE commentable = \'true\' ;'; - $result = pwg_query($query); - while ($row = mysql_fetch_array($result)) - { - array_push($cats_true, $row['id']); - } - $query = ' -SELECT id + $query_false = ' +SELECT id,name,uppercats,global_rank FROM '.CATEGORIES_TABLE.' WHERE commentable = \'false\' ;'; - $result = pwg_query($query); - while ($row = mysql_fetch_array($result)) - { - array_push($cats_false, $row['id']); - } - + $template->assign_vars( + array( + 'L_TITLE' => $lang['cat_options_comments_title'], + 'L_CAT_OPTIONS_TRUE' => $lang['cat_options_comments_true'], + 'L_CAT_OPTIONS_FALSE' => $lang['cat_options_comments_false'], + 'L_CAT_OPTIONS_INFO' => $lang['cat_options_comments_info'], + ) + ); $template->assign_block_vars('comments', array()); - break; } case 'visible' : { - $query = ' -SELECT id + $query_true = ' +SELECT id,name,uppercats,global_rank FROM '.CATEGORIES_TABLE.' WHERE visible = \'true\' ;'; - $result = pwg_query($query); - while ($row = mysql_fetch_array($result)) - { - array_push($cats_true, $row['id']); - } - $query = ' -SELECT id + $query_false = ' +SELECT id,name,uppercats,global_rank FROM '.CATEGORIES_TABLE.' WHERE visible = \'false\' ;'; - $result = pwg_query($query); - while ($row = mysql_fetch_array($result)) - { - array_push($cats_false, $row['id']); - } - + $template->assign_vars( + array( + 'L_TITLE' => $lang['cat_options_visible_title'], + 'L_CAT_OPTIONS_TRUE' => $lang['cat_options_visible_true'], + 'L_CAT_OPTIONS_FALSE' => $lang['cat_options_visible_false'], + 'L_CAT_OPTIONS_INFO' => $lang['cat_options_visible_info'], + ) + ); $template->assign_block_vars('visible', array()); - break; } case 'status' : { - $query = ' -SELECT id + $query_true = ' +SELECT id,name,uppercats,global_rank FROM '.CATEGORIES_TABLE.' WHERE status = \'public\' ;'; - $result = pwg_query($query); - while ($row = mysql_fetch_array($result)) - { - array_push($cats_true, $row['id']); - } - $query = ' -SELECT id + $query_false = ' +SELECT id,name,uppercats,global_rank FROM '.CATEGORIES_TABLE.' WHERE status = \'private\' ;'; - $result = pwg_query($query); - while ($row = mysql_fetch_array($result)) - { - array_push($cats_false, $row['id']); - } - + $template->assign_vars( + array( + 'L_TITLE' => $lang['cat_options_status_title'], + 'L_CAT_OPTIONS_TRUE' => $lang['cat_options_status_true'], + 'L_CAT_OPTIONS_FALSE' => $lang['cat_options_status_false'], + 'L_CAT_OPTIONS_INFO' => $lang['cat_options_status_info'], + ) + ); $template->assign_block_vars('status', array()); - break; } } -$CSS_classes = array('optionTrue'=>$cats_true, - 'optionFalse'=>$cats_false); - -$user['expand'] = true; -$structure = create_user_structure(''); -display_select_categories($structure, - ' ', - array(), - 'category_option', - $CSS_classes); +display_select_cat_wrapper($query_true,array(),'category_option_true'); +display_select_cat_wrapper($query_false,array(),'category_option_false'); // +-----------------------------------------------------------------------+ // | sending html code | // +-----------------------------------------------------------------------+ diff --git a/admin/include/functions.php b/admin/include/functions.php index 2b28f6784..c78df307e 100644 --- a/admin/include/functions.php +++ b/admin/include/functions.php @@ -580,27 +580,6 @@ function get_keywords( $keywords_string ) return array_unique( $keywords ); } -function display_categories( $categories, $indent, - $selected = -1, $forbidden = -1 ) -{ - global $vtp,$sub; - - foreach ( $categories as $category ) { - if ( $category['id'] != $forbidden ) - { - $vtp->addSession( $sub, 'associate_cat' ); - $vtp->setVar( $sub, 'associate_cat.value', $category['id'] ); - $content = $indent.'- '.$category['name']; - $vtp->setVar( $sub, 'associate_cat.content', $content ); - if ( $category['id'] == $selected ) - $vtp->setVar( $sub, 'associate_cat.selected', ' selected="selected"' ); - $vtp->closeSession( $sub, 'associate_cat' ); - display_categories( $category['subcats'], $indent.str_repeat(' ',3), - $selected, $forbidden ); - } - } -} - /** * returns an array with the ids of the restricted categories for the user * diff --git a/admin/include/functions_metadata.php b/admin/include/functions_metadata.php index 3872718fa..0e11d4d10 100644 --- a/admin/include/functions_metadata.php +++ b/admin/include/functions_metadata.php @@ -40,7 +40,7 @@ function get_sync_iptc_data($file) { if (in_array($pwg_key, $datefields)) { - if ( preg_match('/(\d{4})(\d{2})(\d{2})/', $value, $matches)) + if (preg_match('/(\d{4})(\d{2})(\d{2})/', $value, $matches)) { $iptc[$pwg_key] = $matches[1].'-'.$matches[2].'-'.$matches[3]; } diff --git a/admin/update.php b/admin/update.php index 10813349e..ac364e465 100644 --- a/admin/update.php +++ b/admin/update.php @@ -37,12 +37,13 @@ define('CURRENT_DATE', date('Y-m-d')); // +-----------------------------------------------------------------------+ /** - * order categories (update categories.rank database field) + * order categories (update categories.rank and global_rank database fields) * * the purpose of this function is to give a rank for all categories * (insides its sub-category), even the newer that have none at te * beginning. For this, ordering function selects all categories ordered by - * rank ASC then name ASC for each uppercat. + * rank ASC then name ASC for each uppercat. It also updates the global rank + * which is able to order any two categorie in the whole tree * * @returns void */ @@ -71,6 +72,35 @@ UPDATE '.CATEGORIES_TABLE.' ;'; pwg_query($query); } + // global rank update + $query = ' +UPDATE '.CATEGORIES_TABLE.' + SET global_rank = rank + WHERE id_uppercat IS NULL +;'; + pwg_query($query); + + $query = ' +SELECT DISTINCT(id_uppercat) + FROM '.CATEGORIES_TABLE.' + WHERE id_uppercat IS NOT NULL +;'; + $result = pwg_query($query); + while ($row = mysql_fetch_array($result)) + { + $query = ' +SELECT global_rank + FROM '.CATEGORIES_TABLE.' + WHERE id = '.$row['id_uppercat'].' +;'; + list($uppercat_global_rank) = mysql_fetch_array(pwg_query($query)); + $query = ' +UPDATE '.CATEGORIES_TABLE.' + SET global_rank = CONCAT(\''.$uppercat_global_rank.'\', \'.\', rank) + WHERE id_uppercat = '.$row['id_uppercat'].' +;'; + pwg_query($query); + } } function insert_local_category($id_uppercat) @@ -571,23 +601,14 @@ if (!isset($_POST['submit'])) $template->assign_block_vars('introduction', array()); $query = ' -SELECT id +SELECT id,name,uppercats,global_rank FROM '.CATEGORIES_TABLE.' - WHERE site_id != 1 + WHERE site_id = 1 ;'; - $result = pwg_query($query); - while ($row = mysql_fetch_array($result)) - { - array_push($user['restrictions'], $row['id']); - } - $user['forbidden_categories'] = implode(',', $user['restrictions']); - $user['expand'] = true; - $structure = create_user_structure(''); - display_select_categories($structure, - ' ', - array(), - 'introduction.category_option', - array()); + display_select_cat_wrapper($query, + array(), + 'introduction.category_option', + false); } // +-----------------------------------------------------------------------+ // | synchronize files | |