diff --git a/config/acl.yaml b/config/acl.yaml index 1ecbfcdb..83cdedad 100644 --- a/config/acl.yaml +++ b/config/acl.yaml @@ -23,6 +23,8 @@ access_keys: label: User Profile - id: user.logs label: User Logs + - id: user.change.history + label: User Change History - id: role label: Role Access acls: diff --git a/config/routes/user.yaml b/config/routes/user.yaml index 171d4f93..4b0bb93f 100644 --- a/config/routes/user.yaml +++ b/config/routes/user.yaml @@ -49,5 +49,15 @@ user_view_logs_form: user_view_logs: path: /user/{id}/logs - controller: App\Controller\UserController::getLogs + controller: App\Controller\UserController::getAuditLogs + methods: [POST] + +user_view_change_history_form: + path: /users/{id}/change-history + controller: App\Controller\UserController::viewChangeHistoryForm + methods: [GET] + +user_view_change_history: + path: /user/{id}/change-history + controller: App\Controller\UserController::getChangeHistory methods: [POST] diff --git a/src/Controller/UserController.php b/src/Controller/UserController.php index 8bd441aa..39422e9a 100644 --- a/src/Controller/UserController.php +++ b/src/Controller/UserController.php @@ -497,10 +497,10 @@ class UserController extends Controller $params['id'] = $id; // response - return $this->render('user/log.html.twig', $params); + return $this->render('user/audit.log.html.twig', $params); } - public function getLogs(Client $client, $id) + public function getAuditLogs(Client $client, $id) { // fetch database $log_db = $this->getParameter('log_db'); @@ -513,10 +513,40 @@ class UserController extends Controller // get the points from the resultset, which is an array $points = $result->getPoints(); - // TODO: might need to format time data + return $this->json([ + 'data' => $points, + ]); + } + + /** + * @Menu(selected="user_list") + */ + public function viewChangeHistoryForm($id) + { + $this->denyAccessUnlessGranted('user.change.history', null, 'No access.'); + + $params['id'] = $id; + + // response + return $this->render('user/change.history.log.html.twig', $params); + } + + public function getChangeHistory(Client $client, $id) + { + // fetch database + $log_db = $this->getParameter('log_db'); + $database = $client->selectDB($log_db); + + // query will return a resultset object + $query_string = 'SELECT * FROM entity_log WHERE entity_id = \'' . $id . '\''; + $result = $database->query($query_string); + + // get the points from the resultset, which is an array + $points = $result->getPoints(); return $this->json([ 'data' => $points, ]); } + } diff --git a/templates/user/log.html.twig b/templates/user/audit.log.html.twig similarity index 100% rename from templates/user/log.html.twig rename to templates/user/audit.log.html.twig diff --git a/templates/user/change.history.log.html.twig b/templates/user/change.history.log.html.twig new file mode 100644 index 00000000..cf7ed1dc --- /dev/null +++ b/templates/user/change.history.log.html.twig @@ -0,0 +1,79 @@ +{% extends 'base.html.twig' %} + +{% block body %} + +