fixes #403 configuration of new album position

This commit is contained in:
jeremydurand
2016-06-13 17:37:55 +02:00
parent 4d75cf35b5
commit ba940dd503
2 changed files with 21 additions and 1 deletions
+18 -1
View File
@@ -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,
);
+3
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 : ' / ', ' » ', ' → ', ' - ',
// ' >'