From d61c2fc94d1f0e459df235e618b47754159a88aa Mon Sep 17 00:00:00 2001 From: afornerot Date: Mon, 5 Jul 2021 14:07:18 +0200 Subject: [PATCH] passage en cas proxy pour imapunread --- dicos/91_ninegate.xml | 1 - .../Controller/SecurityController.php | 27 +++++++++++++- .../CASBundle/Resources/config/routing.yml | 4 +++ .../PortalBundle/Command/InitDataCommand.php | 2 +- tmpl/ninegate-template.yml | 12 +++++++ tmpl/ninegate-unread.php | 35 ------------------- 6 files changed, 43 insertions(+), 38 deletions(-) delete mode 100644 tmpl/ninegate-unread.php diff --git a/dicos/91_ninegate.xml b/dicos/91_ninegate.xml index 41bb8e51..e13c01f2 100644 --- a/dicos/91_ninegate.xml +++ b/dicos/91_ninegate.xml @@ -13,7 +13,6 @@ - diff --git a/src/ninegate-1.0/src/Cadoles/CASBundle/Controller/SecurityController.php b/src/ninegate-1.0/src/Cadoles/CASBundle/Controller/SecurityController.php index 778949cf..609ffbef 100644 --- a/src/ninegate-1.0/src/Cadoles/CASBundle/Controller/SecurityController.php +++ b/src/ninegate-1.0/src/Cadoles/CASBundle/Controller/SecurityController.php @@ -30,7 +30,7 @@ class SecurityController extends Controller // Init Client CAS \phpCAS::setDebug("/var/log/phpcas/phpCAS-ninegate.log"); - @\phpCAS::client(CAS_VERSION_2_0, $this->getParameter('cas_host'), $this->getParameter('cas_port'), is_null($this->getParameter('cas_path')) ? '' : $this->getParameter('cas_path'), false); + @\phpCAS::proxy(CAS_VERSION_2_0, $this->getParameter('cas_host'), $this->getParameter('cas_port'), is_null($this->getParameter('cas_path')) ? '' : $this->getParameter('cas_path'), false); \phpCAS::setNoCasServerValidation(); @@ -295,4 +295,29 @@ class SecurityController extends Controller } } + + function imapunreadAction() { + if($this->getParameter("active_imapunread")) { + $ip=$this->getParameter("imapundread_ip"); + + // Init Client CAS + \phpCAS::setDebug("/var/log/phpcas/phpCAS-ninegate.log"); + @\phpCAS::proxy(CAS_VERSION_2_0, $this->getParameter('cas_host'), $this->getParameter('cas_port'), is_null($this->getParameter('cas_path')) ? '' : $this->getParameter('cas_path'), false); + \phpCAS::setNoCasServerValidation(); + \phpCAS::forceAuthentication(); + + + $pt= \phpCAS::retrievePT('imap://'.$ip,$t,$f); + $a = \phpCAS::serviceMail("{".$ip.":993/imap/ssl/novalidate-cert}","imap://".$ip,0, $errc,$err,$pt); + $unseen = imap_status($a, "{".$ip.":993/imap/ssl/novalidate-cert}INBOX", SA_UNSEEN); + + $count=$unseen->unseen; + $response = new Response(json_encode($count)); + } + else + $response = new Response(json_encode("")); + + $response->headers->set('Content-Type', 'application/json'); + return $response; + } } diff --git a/src/ninegate-1.0/src/Cadoles/CASBundle/Resources/config/routing.yml b/src/ninegate-1.0/src/Cadoles/CASBundle/Resources/config/routing.yml index f97aa770..eeb99047 100644 --- a/src/ninegate-1.0/src/Cadoles/CASBundle/Resources/config/routing.yml +++ b/src/ninegate-1.0/src/Cadoles/CASBundle/Resources/config/routing.yml @@ -10,3 +10,7 @@ cas_sp.test: path: /test defaults: { _controller: CadolesCASBundle:Security:test } +cas_sp.imapunread: + path: /imapunread + defaults: { _controller: CadolesCASBundle:Security:imapunread } + diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Command/InitDataCommand.php b/src/ninegate-1.0/src/Cadoles/PortalBundle/Command/InitDataCommand.php index 44e87fa4..efe78e63 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Command/InitDataCommand.php +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Command/InitDataCommand.php @@ -973,7 +973,7 @@ class InitDataCommand extends ContainerAwareCommand $entityItem->addGroup($groupall); } $entityItem->setUrl($widroundcube_url); - $entityItem->setBadgeurl("/ninegate/imap-unread.php"); + $entityItem->setBadgeurl("/ninegate/cas/imapunread"); $em->persist($entityItem); } diff --git a/tmpl/ninegate-template.yml b/tmpl/ninegate-template.yml index 91e69cc7..b9f7fc9d 100644 --- a/tmpl/ninegate-template.yml +++ b/tmpl/ninegate-template.yml @@ -585,6 +585,18 @@ parameters: noreply: %%ninegate_noreply %end if +%if %%is_defined('adresse_imap') or %%is_defined('adresse_ip_mail') + active_imapunread: true + %if %%is_defined('adresse_imap') + imapundread_ip: %%adresse_imap + %else + imapundread_ip: %%adresse_ip_mail + %end if +%else + active_imapunread: false + imapunread_ip: +%end if + # Doctrine Configuration doctrine: dbal: diff --git a/tmpl/ninegate-unread.php b/tmpl/ninegate-unread.php deleted file mode 100644 index 16ebf844..00000000 --- a/tmpl/ninegate-unread.php +++ /dev/null @@ -1,35 +0,0 @@ -unseen; - echo $count; - %end if -?>