public function getNotifications(Request $request)
    {
        if (!$request->isXmlHttpRequest()) {
            $this->app->abort(400);
        }

        $ret = [
            'status'  => 'unknown',
            'message' => '',
            'notifications' => false,
            'changed' => []
        ];

        $authenticator = $this->getAuthenticator();
        if ($authenticator->isAuthenticated()) {
            $usr_id = $authenticator->getUser()->getId();
            if ($usr_id != $request->request->get('usr')) { // I logged with another user
                $ret['status'] = 'disconnected';

                return $this->app->json($ret);
            }
        } else {
            $ret['status'] = 'disconnected';

            return $this->app->json($ret);
        }

        try {
            $this->getApplicationBox()->get_connection();
        } catch (\Exception $e) {
            return $this->app->json($ret);
        }

        if (1 > $moduleId = (int) $request->request->get('module')) {
            $ret['message'] = 'Missing or Invalid `module` parameter';

            return $this->app->json($ret);
        }

        $ret['status'] = 'ok';

        $ret['notifications'] = $this->render('prod/notifications.html.twig', [
            'notifications' => $this->getEventsManager()->get_notifications()
        ]);

        $baskets = $this->getBasketRepository()->findUnreadActiveByUser($authenticator->getUser());

        foreach ($baskets as $basket) {
            $ret['changed'][] = $basket->getId();
        }

        if (in_array($this->getSession()->get('phraseanet.message'), ['1', null])) {
            if ($this->app['phraseanet.configuration']['main']['maintenance']) {
                $ret['message'] .= $this->app->trans('The application is going down for maintenance, please logout.');
            }

            if ($this->getConf()->get(['registry', 'maintenance', 'enabled'], false)) {
                $ret['message'] .= strip_tags($this->getConf()->get(['registry', 'maintenance', 'message']));
            }
        }

        return $this->app->json($ret);
    }