From 571efe1ad95bb5f05a71b790d6af6774b5f2ff0d Mon Sep 17 00:00:00 2001 From: afornerot Date: Sat, 2 Nov 2024 20:16:52 +0100 Subject: [PATCH] svg --- .env | 6 +++--- src/Controller/HomeController.php | 24 ++++++++++++++++++++++-- src/Controller/SecurityController.php | 4 ++-- src/Controller/UserController.php | 4 ++-- templates/Home/home.html.twig | 17 ++++++++++++++++- 5 files changed, 45 insertions(+), 10 deletions(-) diff --git a/.env b/.env index 71f92b4..9e0819d 100644 --- a/.env +++ b/.env @@ -20,9 +20,9 @@ APP_CRON=1 # NINEGATE NINEGATE_ACTIVATE=0 -NINEGATE_URL= -NINEGATE_SECRET= -NINEGATE_MASTERIDENTITY= +NINEGATE_URL=http://192.168.0.22 +NINEGATE_SECRET=changeme +NINEGATE_MASTERIDENTITY=SQL # CAS CAS_HOST= diff --git a/src/Controller/HomeController.php b/src/Controller/HomeController.php index 8687d32..c6df18f 100755 --- a/src/Controller/HomeController.php +++ b/src/Controller/HomeController.php @@ -11,8 +11,27 @@ class HomeController extends AbstractController { public function home() { - $em = $this->getDoctrine()->getManager(); + $items=null; + if($this->getParameter("appNinegateactivate")) { + // Entete + $headers = ['Accept' => 'application/json', 'key' => $this->getParameter("appNinegatesecret"), 'only'=>'items']; + $query = []; + $url=$this->getParameter("appNinegateurl"); + // Paramétrage unirest + \Unirest\Request::verifyPeer(false); + \Unirest\Request::verifyHost(false); + \Unirest\Request::timeout(5); + try { + $response = \Unirest\Request::get($url.'/rest/user/'.($this->getUser()?$this->getUser()->getUsername():"nononononouser"),$headers); + $items=$response->body->items; + } + catch (\Exception $e) { + } + } + dump($items); + + $em = $this->getDoctrine()->getManager(); $users = $em->getRepository("App:User")->findBy([],["pseudo"=>"ASC"]); $illustrations = $em->getRepository("App:Illustration")->findBy([],["submittime"=>"DESC"]); $links = $em->getRepository("App:Link")->findBy(["user"=>null]); @@ -25,7 +44,8 @@ class HomeController extends AbstractController "users" => $users, "illustrations" => $illustrations, "links" => $links, - "webzines" => $webzines + "webzines" => $webzines, + "items" => $items, ]); } diff --git a/src/Controller/SecurityController.php b/src/Controller/SecurityController.php index d748d37..d6a56a3 100755 --- a/src/Controller/SecurityController.php +++ b/src/Controller/SecurityController.php @@ -168,7 +168,7 @@ class SecurityController extends AbstractController private function updateNinegate($user) { if($this->getParameter("appNinegateactivate") && $this->getParameter("appNinegatemasteridentity")=="SQL") { // Entete - $headers = ['Accept' => 'application/json', 'key' => $this->getParameter("appNinegatesecret")]; + $headers = ['Accept' => 'application/json', 'key' => $this->getParameter("appNinegatesecret"), 'only' => 'user']; $query = []; $url=$this->getParameter("appNinegateurl"); // Paramétrage unirest @@ -177,7 +177,7 @@ class SecurityController extends AbstractController \Unirest\Request::verifyHost(false); \Unirest\Request::timeout(5); try { - $response = \Unirest\Request::get($url.'/rest/user/'.$user->getUsername(),$headers,["only"=>"user"]); + $response = \Unirest\Request::get($url.'/rest/user/'.$user->getUsername(),$headers); $em = $this->getDoctrine()->getManager(); diff --git a/src/Controller/UserController.php b/src/Controller/UserController.php index 362298b..d45c98e 100755 --- a/src/Controller/UserController.php +++ b/src/Controller/UserController.php @@ -259,14 +259,14 @@ class UserController extends AbstractController private function updateNinegate($user) { if($this->getParameter("appNinegateactivate") && $this->getParameter("appNinegatemasteridentity")=="SQL") { // Entete - $headers = ['Accept' => 'application/json', 'key' => $this->getParameter("appNinegatesecret")]; + $headers = ['Accept' => 'application/json', 'key' => $this->getParameter("appNinegatesecret"), 'only' => 'user']; $query = []; $url=$this->getParameter("appNinegateurl"); \Unirest\Request::verifyPeer(false); \Unirest\Request::verifyHost(false); \Unirest\Request::timeout(5); try { - $response = \Unirest\Request::get($url.'/rest/user/'.$user->getUsername(),$headers,["only"=>"user"]); + $response = \Unirest\Request::get($url.'/rest/user/'.$user->getUsername(),$headers); $em = $this->getDoctrine()->getManager(); if(property_exists($response->body->user,'lastname')) $user->setLastname($response->body->user->lastname); diff --git a/templates/Home/home.html.twig b/templates/Home/home.html.twig index b8d12e4..bef1bdd 100644 --- a/templates/Home/home.html.twig +++ b/templates/Home/home.html.twig @@ -180,6 +180,21 @@ Liens
{% endif %} + + {% if not items is empty %} +
+ {% for item in items %} + {% if item.title|lower != "ninefolio" %} + +
+ + {{ item.title }} +
+
+ {% endif %} + {% endfor %} +
+ {% endif %} @@ -312,7 +327,7 @@ {% endif %} {% set source=source~"?"~illustration.updatetime|date('ymdHis') %} -
+
{% endfor %}