From 33a9a7b1bb9539b0ef5551af631986213e0c77ab Mon Sep 17 00:00:00 2001
From: Patrick Barroca <pbarroca@afi-sa.fr>
Date: Fri, 30 Aug 2019 16:33:06 +0200
Subject: [PATCH] dev #94469 : add authorities search and browse

---
 .../opac/controllers/AuthoritySearchController.php       | 9 +--------
 application/modules/opac/controllers/ErrorController.php | 3 +--
 library/Class/CriteresRecherche/Authority.php            | 3 ++-
 3 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/application/modules/opac/controllers/AuthoritySearchController.php b/application/modules/opac/controllers/AuthoritySearchController.php
index c8393c1afda..166e9c2c829 100644
--- a/application/modules/opac/controllers/AuthoritySearchController.php
+++ b/application/modules/opac/controllers/AuthoritySearchController.php
@@ -22,14 +22,10 @@
 
 class AuthoritySearchController extends ZendAfi_Controller_Action {
   public function indexAction() {
-    $tree_roots = $this->_getParam('tree_roots', '');
     $criteres = (new Class_CriteresRecherche_Authority)->setParams($this->_request->getParams());
 
     if ($this->_request->isPost()) {
       $redirect_params = $criteres->getUrlCriteres();
-      if ($tree_roots)
-        $redirect_params['tree_roots'] = $tree_roots;
-
       return $this->_redirect($this->view->url($redirect_params, null, true),
                               ['prependBase' => false]);
     }
@@ -37,11 +33,8 @@ class AuthoritySearchController extends ZendAfi_Controller_Action {
     $prefs = $this->_getActionPreferences();
 
     $this->view->titre = $prefs['titre'];
-    $this->view->tree_roots = $tree_roots;
+    $this->view->tree_roots = $criteres->getParam('tree_roots');
     $action_params = $criteres->getUrlWithoutExpression();
-    if ($tree_roots)
-      $action_params['tree_roots'] = $tree_roots;
-
     $this->view->form = (new ZendAfi_Form_AuthoritySearch())
       ->setAction($this->view->url($action_params, null, true));
 
diff --git a/application/modules/opac/controllers/ErrorController.php b/application/modules/opac/controllers/ErrorController.php
index 714d41d0b3e..0deba4e4495 100644
--- a/application/modules/opac/controllers/ErrorController.php
+++ b/application/modules/opac/controllers/ErrorController.php
@@ -35,8 +35,7 @@ class ErrorController extends ZendAfi_Controller_Action {
 
     if (($this->_request->getServer('HTTP_HOST') == 'localhost')
         || $this->_isInspecting()
-        || ((null != ($user = Class_Users::getLoader()->getIdentity()))
-            && $user->isAdmin())) {
+        || Class_Users::isCurrentUserAdmin()) {
       $this->view->errors = $errors;
       return;
     }
diff --git a/library/Class/CriteresRecherche/Authority.php b/library/Class/CriteresRecherche/Authority.php
index 80d6be4e30d..c24cef1e66a 100644
--- a/library/Class/CriteresRecherche/Authority.php
+++ b/library/Class/CriteresRecherche/Authority.php
@@ -24,13 +24,14 @@ class Class_CriteresRecherche_Authority extends Class_CriteresRecherche_Abstract
   public function getValidParameters() {
     $parameters = parent::getValidParameters();
     $parameters[] = 'expressionRecherche';
+    $parameters[] = 'tree_roots';
     return $parameters;
   }
 
 
   public function acceptVisitor($visitor) {
     $visitor->visitNoExtension(true);
-    $visitor->visitExpression($this->getParam('expressionRecherche'), false, $this->getTri());
+    $visitor->visitExpression($this->getParam('expressionRecherche'), false, $this->getTri(), false);
     $visitor->visitRecordType(Class_Notice::TYPE_AUTHORITY);
     foreach($this->getFacettes() as $facette)
       $visitor->visitFacette($facette);
-- 
GitLab