MDL-74779 mod_bigbluebuttonbn: Fix recording sort

AMOS BEGIN
 MOV [config_recordings_sortorder,mod_bigbluebuttonbn],[config_recordings_asc_sort,mod_bigbluebuttonbn]
 MOV [config_recordings_sortorder_description,mod_bigbluebuttonbn],[config_recordings_asc_sort_description,mod_bigbluebuttonbn]
AMOS END
This commit is contained in:
Shamiso.Jaravaza 2022-12-05 08:30:09 -07:00
parent 6b24f59302
commit f954848667
4 changed files with 13 additions and 14 deletions

View File

@ -288,17 +288,14 @@ class recording_proxy extends proxy_base {
public static function sort_recordings(array $recordings): array {
global $CFG;
$resultless = !empty($CFG->bigbluebuttonbn_recordings_sortorder) ? -1 : 1;
$resultmore = !empty($CFG->bigbluebuttonbn_recordings_sortorder) ? 1 : -1;
uasort($recordings, function($a, $b) use ($resultless, $resultmore) {
uasort($recordings, function($a, $b) {
if ($a['startTime'] < $b['startTime']) {
return $resultless;
return -1;
}
if ($a['startTime'] == $b['startTime']) {
return 0;
}
return $resultmore;
return 1;
});
return $recordings;

View File

@ -689,16 +689,18 @@ class recording extends persistent {
* @return recording[]
*/
protected static function fetch_records(array $selects, array $params): array {
global $DB;
global $DB, $CFG;
$withindays = time() - (self::RECORDING_TIME_LIMIT_DAYS * DAYSECS);
// Sort for recordings when fetching from the database.
$recordingsort = $CFG->bigbluebuttonbn_recordings_asc_sort ? 'timecreated ASC' : 'timecreated DESC';
// Fetch the local data. Arbitrary sort by id, so we get the same result on different db engines.
$recordings = $DB->get_records_select(
static::TABLE,
implode(" AND ", $selects),
$params,
self::DEFAULT_RECORDING_SORT
$recordingsort
);
// Grab the recording IDs.

View File

@ -486,13 +486,13 @@ class settings {
$showrecordingsettings
);
$item = new admin_setting_configcheckbox(
'bigbluebuttonbn_recordings_sortorder',
get_string('config_recordings_sortorder', 'bigbluebuttonbn'),
get_string('config_recordings_sortorder_description', 'bigbluebuttonbn'),
'bigbluebuttonbn_recordings_asc_sort',
get_string('config_recordings_asc_sort', 'bigbluebuttonbn'),
get_string('config_recordings_asc_sort_description', 'bigbluebuttonbn'),
0
);
$this->add_conditional_element(
'recordings_sortorder',
'recordings_asc_sort',
$item,
$showrecordingsettings
);

View File

@ -181,8 +181,8 @@ $string['config_recordings_preview_default'] = 'Preview is enabled by default';
$string['config_recordings_preview_default_description'] = 'If enabled the table includes a preview of the presentation.';
$string['config_recordings_preview_editable'] = 'Preview feature can be edited';
$string['config_recordings_preview_editable_description'] = 'Preview feature can be edited when the instance is added or updated.';
$string['config_recordings_sortorder'] = 'Order the recordings in ascending order.';
$string['config_recordings_sortorder_description'] = 'By default recordings are displayed in descending order. When checked they will be sorted in ascending order.';
$string['config_recordings_asc_sort'] = 'Order the recordings in ascending order.';
$string['config_recordings_asc_sort_description'] = 'By default recordings are displayed in descending order. When checked they will be sorted in ascending order.';
$string['config_importrecordings'] = 'Import recordings';
$string['config_importrecordings_description'] = 'These settings are feature specific.';