Merge branch 'jeremydurand-bug/403-configuration-new-album-position'

This commit is contained in:
plegall 2016-12-05 15:36:50 +01:00
commit 102e0f0608
2 changed files with 21 additions and 1 deletions

View file

@ -1365,9 +1365,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,
);

View file

@ -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 : ' / ', ' » ', ' → ', ' - ',
// ' >'