]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Add modify default object sorting in object overview endpoint
authorMarcin Haba <marcin.haba@bacula.pl>
Thu, 6 Jul 2023 14:49:12 +0000 (16:49 +0200)
committerMarcin Haba <marcin.haba@bacula.pl>
Thu, 6 Jul 2023 14:49:12 +0000 (16:49 +0200)
gui/baculum/protected/API/Modules/ObjectManager.php

index 9b7b884ffbd885e7d672f2d4fa9a33d15a60d367..81236f19db0a7c403eef5244f06e4235b2601530 100644 (file)
@@ -204,7 +204,7 @@ LEFT JOIN Client USING (ClientId) '
                        $file_order .= sprintf(',%s %s', $sort_col, $sort_order);
                }
                $order = sprintf(
-                       'ORDER BY %s %s ',
+                       ' %s %s ',
                        $sort_col,
                        $sort_order
                );
@@ -429,14 +429,14 @@ LEFT JOIN Client USING (ClientId) '
                                if ($object_count[$i]['objecttype'] == 'files') {
                                        $sql = 'SELECT * 
                                                FROM ' . $objects_tname4 . '
-                                               ' . ((stripos($sort_col, 'object') === false) ? $order : '') . $limit . $offset;
+                                               ' . ((stripos($sort_col, 'object') === false) ? 'ORDER BY ' . $order : '') . $limit . $offset;
                                        $statement = Database::runQuery($sql);
                                        $items = $statement->fetchAll(PDO::FETCH_ASSOC);
                                } else {
                                        $sql = 'SELECT * 
                                                FROM ' . $objects_tname1 . '
                                                WHERE ObjectType = \'' . $object_count[$i]['objecttype'] . '\'
-                                               ' . $order . $limit . $offset;
+                                               ORDER BY ObjectType, ObjectSource, ObjectCategory, ' . $order . $limit . $offset;
                                        $statement = Database::runQuery($sql);
                                        $items = $statement->fetchAll(PDO::FETCH_ASSOC);
                                }
@@ -466,7 +466,7 @@ LEFT JOIN Client USING (ClientId) '
                        }
                } catch(\PDOException $e) {
                        // rollback the transaction
-                       //$pdo->rollBack();
+                       $pdo->rollBack();
 
                        // show the error message
                        $msg = 'SQL transation commit error: ' . $e->getMessage();