PORT PHRAS-1559 and PHRAS-1560 to 4.1

This commit is contained in:
Mike Ng
2017-12-13 10:26:24 +04:00
parent aecc97bc3d
commit e9e9a737c3
5 changed files with 104 additions and 12 deletions

View File

@@ -36,6 +36,31 @@ class MoveCollectionController extends Controller
} else {
// is able to move:
$success = true;
/** @var DisplaySettingService $settings */
$settings = $this->app['settings'];
$userOrderSetting = $settings->getUserSetting($this->app->getAuthenticatedUser(), 'order_collection_by');
// a temporary array to sort the collections
$aName = array();
list($ukey, $uorder) = ["order", SORT_ASC]; // default ORDER_BY_ADMIN
switch ($userOrderSetting) {
case $settings::ORDER_ALPHA_ASC :
list($ukey, $uorder) = ["name", SORT_ASC];
break;
case $settings::ORDER_ALPHA_DESC :
list($ukey, $uorder) = ["name", SORT_DESC];
break;
}
foreach ($collections as $key => $row) {
if($ukey == "order") {
$aName[$key] = $row->get_ord();
}else {
$aName[$key] = $row->get_name();
}
}
// sort the collections
array_multisort($aName, $uorder, SORT_REGULAR, $collections);
$parameters = [
'records' => $records,
'message' => '',