From 6f1f244f07282371b5c66abbb83d2a76827cb6f5 Mon Sep 17 00:00:00 2001 From: Greg Besson Date: Mon, 24 Jun 2019 08:01:42 +0200 Subject: [PATCH] userLog --- src/Form/LoginFilter.php | 12 +++++++----- src/Service/User.php | 28 ++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/Form/LoginFilter.php b/src/Form/LoginFilter.php index da86d35..ef5d227 100644 --- a/src/Form/LoginFilter.php +++ b/src/Form/LoginFilter.php @@ -9,11 +9,13 @@ class LoginFilter extends \ZfcUser\Form\LoginFilter { public function __construct(AuthenticationOptionsInterface $options) { - $this->add(array( - 'name' => 'remember_me', - 'required' => false, - 'allowEmpty' => true, - )); + $this->add( + array( + 'name' => 'remember_me', + 'required' => false, + 'allowEmpty' => true, + ) + ); parent::__construct($options); } diff --git a/src/Service/User.php b/src/Service/User.php index 9867959..fe695ea 100644 --- a/src/Service/User.php +++ b/src/Service/User.php @@ -1014,6 +1014,34 @@ public function getCSV($array) return ob_get_clean(); // ... then return it as a string! } + + public function getUserActions() + { + $config = $this->serviceManager->get('config'); + $logFrontendUser = ($config['playgrounduser']['log_frontend_user']) ? $config['playgrounduser']['log_frontend_user'] : false; + $routes = []; + + // echo '$controllerClass : ' . $controllerClass . '
'; + // echo '$moduleName : ' .$moduleName. '
'; + // echo '$routeName : '.$routeName. '
'; + // echo '$areaName : '.$areaName. '
'; + // echo '$controllerName : ' .$controllerName. '
'; + // echo '$actionName : ' . $actionName. '
'; + if ($logFrontendUser) { + $em = $this->getServiceManager()->get('doctrine.entitymanager.orm_default'); + $emConfig = $em->getConfiguration(); + $emConfig->addCustomStringFunction('SUBSTRING_INDEX', '\DoctrineExtensions\Query\Mysql\SubstringIndex'); + $query = $em->createQuery( + "select DISTINCT CONCAT(SUBSTRING_INDEX(ul.controllerClass, '\\', -1), '/', ul.actionName) as path from PlaygroundUser\Entity\UserLog ul + WHERE SUBSTRING_INDEX(ul.uri, '.', -1) NOT IN ('jpg','svg','gif','png','css','js') + AND ul.areaName = 'frontend'" + ); + $routes = $query->getResult(); + } + + return $routes; + } + public function findAll() { return $this->getUserMapper()->findAll();