From ba940dd503f6d1a4e51bf5cb307ce22368cc4867 Mon Sep 17 00:00:00 2001 From: jeremydurand Date: Mon, 13 Jun 2016 17:37:55 +0200 Subject: [PATCH] fixes #403 configuration of new album position --- admin/include/functions.php | 19 ++++++++++++++++++- include/config_default.inc.php | 3 +++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/admin/include/functions.php b/admin/include/functions.php index 9a827d1d6..5ec01ec4d 100644 --- a/admin/include/functions.php +++ b/admin/include/functions.php @@ -1364,9 +1364,26 @@ function create_virtual_category($category_name, $parent_id=null, $options=array return array('error' => l10n('The name of an album must not be empty')); } + $rank = 0; + if ('last' == $conf['newcat_default_position']) + { + //what is the current higher rank for this parent? + $query = ' +SELECT MAX(rank) AS max_rank + FROM '. CATEGORIES_TABLE .' + WHERE id_uppercat '.(empty($parent_id) ? 'IS NULL' : '= '.$parent_id).' +;'; + $row = pwg_db_fetch_assoc(pwg_query($query)); + + if (is_numeric($row['max_rank'])) + { + $rank = $row['max_rank'] + 1; + } + } + $insert = array( 'name' => $category_name, - 'rank' => 0, + 'rank' => $rank, 'global_rank' => 0, ); diff --git a/include/config_default.inc.php b/include/config_default.inc.php index f66dab486..cf9a810b5 100644 --- a/include/config_default.inc.php +++ b/include/config_default.inc.php @@ -110,6 +110,9 @@ $conf['newcat_default_visible'] = true; // automatically create private. $conf['newcat_default_status'] = 'public'; +// newcat_default_position : at creation, should the album appear at the first or last position ? +$conf['newcat_default_position'] = 'first'; + // level_separator : character string used for separating a category level // to the sub level. Suggestions : ' / ', ' » ', ' → ', ' - ', // ' >'