Add a new force_sort_criteria option, to globally override the SortCriteria value sent by the client.

This commit is contained in:
Justin Maggard
2014-01-07 11:30:15 -08:00
parent a75bdadce1
commit 3f4877cf2f
8 changed files with 36 additions and 8 deletions

View File

@ -490,7 +490,9 @@ parse_sort_criteria(char *sortCriteria, int *error)
struct string_s str;
*error = 0;
if( !sortCriteria )
if( force_sort_criteria )
sortCriteria = strdup(force_sort_criteria);
else if( !sortCriteria )
return NULL;
if( (item = strtok_r(sortCriteria, ",", &saveptr)) )
@ -563,12 +565,17 @@ parse_sort_criteria(char *sortCriteria, int *error)
if( i <= 0 )
{
free(order);
if( force_sort_criteria )
free(sortCriteria);
return NULL;
}
/* Add a "tiebreaker" sort order */
if( !title_sorted )
strcatf(&str, ", TITLE ASC");
if( force_sort_criteria )
free(sortCriteria);
return order;
}
@ -1211,6 +1218,8 @@ BrowseContentDirectory(struct upnphttp * h, const char * action)
#endif
ret = asprintf(&orderBy, "order by o.CLASS, d.DISC, d.TRACK, d.TITLE");
}
else
orderBy = parse_sort_criteria(SortCriteria, &ret);
if( ret == -1 )
{
orderBy = NULL;