diff --git a/VERSIONS_WIP/85637 b/VERSIONS_WIP/85637 new file mode 100644 index 0000000000000000000000000000000000000000..d63c0dd11416b403bcf907d26ad26189e60c5bd1 --- /dev/null +++ b/VERSIONS_WIP/85637 @@ -0,0 +1,2 @@ + - ticket #85637 : Administration : maintenance des entrées de menu gauche et ajout de liens vers la documentation. + \ No newline at end of file diff --git a/library/Class/AdminVar.php b/library/Class/AdminVar.php index e97e42be25625cb159d49690aeca99b5b3d87940..dbf8c045df28a9fb3b7e14476fc01f9ce3ddc1ee 100644 --- a/library/Class/AdminVar.php +++ b/library/Class/AdminVar.php @@ -118,14 +118,14 @@ class Class_AdminVarLoader extends Storm_Model_Loader { if (null !== $this->all_vars) return $this->all_vars; - return $this->all_vars= + return $this->all_vars = [ 'avis' => $this->_getCommentVars(), 'modo' => $this->_getModerationVars(), 'stat' => $this->_getStatVars(), 'global' => $this->_getGlobalVars(), 'cosmogramme' => $this->_getCosmogrammeVars(), - 'catalogue' => $this->_getOAIVars(), + 'catalogue' => $this->_getCatalogVars(), 'newsletter' => $this->_getNewsletterVars(), 'cms' => $this->_getCmsVars(), 'album' => $this->_getAlbumVars(), @@ -155,7 +155,10 @@ class Class_AdminVarLoader extends Storm_Model_Loader { 'ALBUM_MEDIA_NO_AUTOINDEX_TITLE' => Class_AdminVar_Meta::newOnOff($this->_('Bibliothèque numérique: ne pas créer de zone 464 pour les médias dont le titre n\'est pas saisi')), 'BIBNUM' => Class_AdminVar_Meta::newOnOff($this->_('Activer ou désactiver la bibliothèque numérique')), - 'SITO_IN_ALBUMS' => Class_AdminVar_Meta::newOnOff($this->_('Gérer la sitothèque dans la bibliothèque numérique, nécessite l\'activation de la bibliothèque numérique'))->bePrivate(), + 'IMPORT_EAD' => Class_AdminVar_Meta::newOnOff($this->_('Activation de l\'import EAD')), + 'OAI_REPOSITORY' => Class_AdminVar_Meta::newOnOff($this->_('Activation de l\'import de dépôts OAI')), + 'OPDS' => Class_AdminVar_Meta::newOnOff($this->_('Activation de l\'import de catalogues OPDS')), + 'SITO_IN_ALBUMS' => Class_AdminVar_Meta::newOnOff($this->_('Gérer la sitothèque dans la bibliothèque numérique, nécessite l\'activation de la bibliothèque numérique')), 'NUMILOG_URL' => Class_AdminVar_Meta::newDefault($this->_('Paramétrage <a href="http://forge.afi-sa.fr/projects/opac3/wiki/Ressources_externes_enrichissements#Numilog">Numilog</a>'))->bePrivate(), 'NUMILOG_OAI_URL' => Class_AdminVar_Meta::newDefault($this->_('Paramétrage <a href="http://forge.afi-sa.fr/projects/opac3/wiki/Ressources_externes_enrichissements#Numilog">Numilog</a>'))->bePrivate(), @@ -283,7 +286,7 @@ class Class_AdminVarLoader extends Storm_Model_Loader { 'WORKFLOW_TEXT_MAIL_ARTICLE_PENDING' => Class_AdminVar_Meta::newDefault($this->_('Contenu de l\'email de notification d\'article en attente de validation. Termes substitués: TITRE_ARTICLE, URL_ARTICLE, AUTHOR_ARTICLE, SAVED_BY_ARTICLE, STATUS_ARTICLE, NEXT_STATUS_ARTICLE')), 'WORKFLOW_TEXT_MAIL_ARTICLE_REFUSED' => Class_AdminVar_Meta::newDefault($this->_('Contenu de l\'email de notification de refus d\'un article à valider. Termes substitués: TITRE_ARTICLE, URL_ARTICLE, AUTHOR_ARTICLE, SAVED_BY_ARTICLE')), 'WORKFLOW_TEXT_MAIL_ARTICLE_VALIDATED' => Class_AdminVar_Meta::newDefault($this->_('Contenu de l\'email de notification de validation d\'un article. Termes substitués: TITRE_ARTICLE, URL_ARTICLE, AUTHOR_ARTICLE, SAVED_BY_ARTICLE')), - + 'CUSTOM_GENRE_ICON' => Class_AdminVar_Meta::newOnOff($this->_('Activation de l\'interface de personnalisation des icones des genres')), ]; } @@ -368,7 +371,11 @@ class Class_AdminVarLoader extends Storm_Model_Loader { 'BUSINESS_EMAIL' => Class_AdminVar_Meta::newDefault($this->_('Email utilisé pour les demandes d\'accompagnement de mise en place ou d\'utilisation des fonctionnalités du logiciel'), ['value' => 'cial-bib@afi-sa.fr'])->bePrivate(), 'CODIFICATION_BROWSER' => Class_AdminVar_Meta::newOnOff($this->_('Activer l\'outil de parcours des codifications')), 'TEMPLATING' => Class_AdminVar_Meta::newOnOff('Active l\'accès au magasin de thèmes', - ['value' => 0])->bePrivate() + ['value' => 0])->bePrivate(), + 'GENERATION_SITE' => Class_AdminVar_Meta::newOnOff($this->_('Activation de la génération de site.')), + 'CUSTOM_FIELDS_REPORT' => Class_AdminVar_Meta::newOnOff($this->_('Activation des rapports statistiques sur les champs personnalisés')), + 'WEBSERVICE_TEST' => Class_AdminVar_Meta::newOnOff($this->_('Activation des tests de webservices')), + 'IMPORT_AVIS_OPAC2' => Class_AdminVar_Meta::newOnOff($this->_('Activation de l\'import des avis de l\'opac2')), ]; } @@ -407,8 +414,9 @@ class Class_AdminVarLoader extends Storm_Model_Loader { } - protected function _getOAIVars() { + protected function _getCatalogVars() { return [ + 'IMPORT_THESAURUS' => Class_AdminVar_Meta::newOnOff($this->_('Activation de l\'import de thesaurus')), 'OAI_SERVER' => Class_AdminVar_Meta::newOnOff($this->_('Activation du serveur OAI: permet le moissonnage des domaines par d\'autres logiciels via OAI')), 'OAI_REPOSITORY_NAME' => Class_AdminVar_Meta::newDefault($this->_('Contenu de la balise "repositoryName" dans la réponse au verb Identify, si vide sera [NOM DU SERVEUR] Oai repository')), 'OAI_ADMIN_EMAIL' => Class_AdminVar_Meta::newDefault($this->_('Contenu de la balise "adminEmail" dans la réponse au verb Identify, si vide sera tiré de la variable cosmogramme "mail_admin"')),]; @@ -877,6 +885,51 @@ class Class_AdminVarLoader extends Storm_Model_Loader { } + public static function isImportThesaurusEnabled() { + return Class_AdminVar::isModuleEnabled('IMPORT_THESAURUS'); + } + + + public static function isImportEadEnabled() { + return Class_AdminVar::isModuleEnabled('IMPORT_EAD'); + } + + + public static function isOaiRepositoryEnabled() { + return Class_AdminVar::isModuleEnabled('OAI_REPOSITORY'); + } + + + public static function isOpdsEnabled() { + return Class_AdminVar::isModuleEnabled('OPDS'); + } + + + public static function isCustomGenreIconEnabled() { + return Class_AdminVar::isModuleEnabled('CUSTOM_GENRE_ICON'); + } + + + public static function isGenerationSiteEnabled() { + return Class_AdminVar::isModuleEnabled('GENERATION_SITE'); + } + + + public static function isCustomFieldsReportEnabled() { + return Class_AdminVar::isModuleEnabled('CUSTOM_FIELDS_REPORT'); + } + + + public static function isWebserviceTestEnabled() { + return Class_AdminVar::isModuleEnabled('WEBSERVICE_TEST'); + } + + + public static function isImportAvisOpac2Enabled() { + return Class_AdminVar::isModuleEnabled('IMPORT_AVIS_OPAC2'); + } + + public function getBabelthequeId() { $mathes = []; if (preg_match('/bw_([^\.]+)\.js/', (string)Class_AdminVar::get('BABELTHEQUE_JS'), $matches)) diff --git a/library/Class/Bib.php b/library/Class/Bib.php index 32a8e4217b26b18f090736e1b97f3304cf220cff..aa742310a53b563645884241bffe264dd0ef10e9 100644 --- a/library/Class/Bib.php +++ b/library/Class/Bib.php @@ -56,6 +56,13 @@ class BibLoader extends Storm_Model_Loader { } + public function findAllRedmineEnabled() { + return (new Storm_Model_Collection(Class_Bib::findAllBy(['order' => 'libelle']))) + ->select('isRedmineEnabled') + ->getArrayCopy(); + } + + public function getUserFriendlyBibs() { $all_bibs = Class_Bib::getLoader()->findAllBy(['order' => 'libelle']); $bibs_as_array = []; @@ -732,6 +739,11 @@ class Class_Bib extends Storm_Model_Abstract { } + public function isRedmineEnabled() { + return (bool)$this->getRedmineLoginOrKey(); + } + + public function isReceivedFile() { if (!$this->_isFileInRequest('photo')) return true; diff --git a/library/Class/Users.php b/library/Class/Users.php index cd1d6d383e7f85f5c553d323b6243b012d5da983..5c917a7adea4143d91341b66749c80a8b0589684 100644 --- a/library/Class/Users.php +++ b/library/Class/Users.php @@ -1815,8 +1815,8 @@ class Class_Users extends Storm_Model_Abstract { public function getRedmineLibraries() { - if($this->getRoleLevel() >= ZendAfi_Acl_AdminControllerRoles::MODO_PORTAIL) - return Class_Bib::findAllBy(['order' => 'libelle']); + if ($this->getRoleLevel() >= ZendAfi_Acl_AdminControllerRoles::MODO_PORTAIL) + return Class_Bib::findAllRedmineEnabled(); return [$this->getRedmineLibrary()]; } diff --git a/library/ZendAfi/Acl/AdminControllerGroup.php b/library/ZendAfi/Acl/AdminControllerGroup.php index 9693cfd026d3cd79eba28aa1ba6e2cf38f2f6eab..9624585c79d0b693c0c8353f3bf1436fe7fc06b7 100644 --- a/library/ZendAfi/Acl/AdminControllerGroup.php +++ b/library/ZendAfi/Acl/AdminControllerGroup.php @@ -50,8 +50,8 @@ class ZendAfi_Acl_AdminControllerGroup { public function __construct() { $this->_activated = ['activity' => Class_AdminVar::isActivityEnabled(), 'album' => Class_AdminVar::isBibNumEnabled(), - 'oai' => Class_AdminVar::isBibNumEnabled(), - 'ead' => Class_AdminVar::isBibNumEnabled(), + 'oai' => Class_AdminVar::isBibNumEnabled() && Class_AdminVar::isOaiRepositoryEnabled(), + 'opds' => Class_AdminVar::isBibNumEnabled() && Class_AdminVar::isOpdsEnabled(), 'harvest/arte-vod-browse' => Class_AdminVar::isArteVODEnabled(), 'harvest/vodeclic-browse' => Class_AdminVar::isVodeclicEnabled(), 'harvest/orphea-browse' => Class_AdminVar::isOrpheaEnabled(), @@ -61,11 +61,18 @@ class ZendAfi_Acl_AdminControllerGroup { 'harvest/soundcloud' => Class_AdminVar::isSoundCloudEnabled(), 'sito/create' => Class_AdminVar::isSitoInAlbums(), 'album/dilicom' => Class_AdminVar::isDilicomPNBEnabled(), + 'album/import_ead' => Class_AdminVar::isImportEadEnabled(), 'premier-chapitre' => Class_AdminVar::isPremierChapitreEnabled(), 'i18n' => Class_AdminVar::isTranslationEnabled(), 'stat/matomo' => (new Class_AdminVar_Matomo())->isEnabled(), 'multimedia' => Class_AdminVar::isMultimediaEnabled(), 'search-form' => Class_AdminVar::isCustomSearchFormEnabled(), + 'systeme/importthesaurus' => Class_AdminVar::isImportThesaurusEnabled(), + 'systeme/generationsite' => Class_AdminVar::isGenerationSiteEnabled(), + 'systeme/webservices' => Class_AdminVar::isWebserviceTestEnabled(), + 'systeme/importavisopac2' => Class_AdminVar::isImportAvisOpac2Enabled(), + 'profil/genres' => Class_AdminVar::isCustomGenreIconEnabled(), + 'custom-fields-report' => Class_AdminVar::isCustomFieldsReportEnabled(), ]; $this->_activated = array_merge($this->_activated, diff --git a/library/ZendAfi/Acl/AdminControllerRoles.php b/library/ZendAfi/Acl/AdminControllerRoles.php index 8e0cdfef71d309751b6a888aadf957e57ebe3d9c..8b54e8a589d93d7f09a852ced4cfb6ad72cad632 100644 --- a/library/ZendAfi/Acl/AdminControllerRoles.php +++ b/library/ZendAfi/Acl/AdminControllerRoles.php @@ -90,6 +90,9 @@ class ZendAfi_Acl_AdminControllerRoles extends Zend_Acl { $this->add(new Zend_Acl_Resource('print')); $this->add(new Zend_Acl_Resource('external-agendas')); $this->add(new Zend_Acl_Resource('systeme')); + $this->add(new Zend_Acl_Resource('systeme/webservices')); + $this->add(new Zend_Acl_Resource('systeme/phpinfo')); + $this->add(new Zend_Acl_Resource('custom-fields-report')); $this->add(new Zend_Acl_Resource('batch')); $this->add(new Zend_Acl_Resource('file-manager')); $this->add(new Zend_Acl_Resource('url-manager')); @@ -191,6 +194,9 @@ class ZendAfi_Acl_AdminControllerRoles extends Zend_Acl { $this->deny('modo_portail','systeme'); $this->deny('modo_portail','batch'); $this->deny('modo_portail','search-form'); + $this->deny('modo_portail','custom-fields-report'); + $this->deny('modo_portail','systeme/webservices'); + $this->deny('modo_portail','systeme/phpinfo'); foreach($codifications as $controller) $this->deny('modo_portail', $controller); diff --git a/library/ZendAfi/View/Helper/Admin/ContentNav.php b/library/ZendAfi/View/Helper/Admin/ContentNav.php index 043d6a8a25a80d0f25a461b6c33832729d9a09e3..ea1d6c10e3c6788606ade9e57f42bb3ecc51552b 100644 --- a/library/ZendAfi/View/Helper/Admin/ContentNav.php +++ b/library/ZendAfi/View/Helper/Admin/ContentNav.php @@ -32,8 +32,9 @@ class ZendAfi_View_Helper_Admin_ContentNav extends ZendAfi_View_Helper_BaseHelpe $this->menuMiseEnPage(), $this->menuStats(), $this->menuPortail(), + $this->menuCatalogue(), $this->menuSysteme(), - $this->menuCatalogue()]; + ]; return $this->_tag('div', implode($content), @@ -67,6 +68,7 @@ class ZendAfi_View_Helper_Admin_ContentNav extends ZendAfi_View_Helper_BaseHelpe ['newsletters', $this->_("Lettres d'information"), '/admin/newsletter'], ['trainings', $this->_('Activités'), '/admin/activity'], ['places', $this->_('Lieux'), '/admin/lieu'], + ['filebrowser', $this->_('Explorateur de fichiers'), '/admin/file-manager'], ]); } @@ -140,24 +142,24 @@ class ZendAfi_View_Helper_Admin_ContentNav extends ZendAfi_View_Helper_BaseHelpe ['links', $this->_('Contrôle des URL'), '/admin/url-manager'], ['variables', $this->_('Variables'), '/admin/index/adminvar', [], $is_admin], - ['webservice_tests', $this->_('Test des web-services'), '/admin/systeme/webservices', - [], $is_super_admin], + ['webservice_tests', $this->_('Test des web-services'), '/admin/systeme/webservices', [], $is_super_admin], ['sendmail_tests', $this->_('Test envoi mails'), '/admin/systeme/mailtest', [], $is_super_admin], ['php', $this->_('Informations système'), '/admin/systeme/phpinfo', [], $is_super_admin], ['image_cache', $this->_('Cache des images'), '/admin/systeme/cacheimages', [], $is_admin], ['migrate_comments', $this->_('Import avis opac2'), '/admin/systeme/importavisopac2', - [], $is_super_admin], + [], + function ($user) use ($is_super_admin) { + return $is_super_admin($user) && Class_AdminVar::isImportAvisOpac2Enabled(); + }], - ['portal_init', $this->_('Génération du site'), '/admin/systeme/generationsite', - [], function($user) { return defined('DEVELOPMENT') && $user->isAdmin();}], + ['portal_init', $this->_('Génération du site'), '/admin/systeme/generationsite'], - ['filebrowser', $this->_('Explorateur de fichiers'), '/admin/file-manager'], ['search_form', $this->_('Formulaires de recherche'), '/admin/search-form'], ['customfields', $this->_('Champs personnalisés'), '/admin/custom-fields/index', [], $is_admin], - ['customreports', $this->_('Rapports statistiques'), '/admin/custom-fields-report', [], $is_admin] + ['customreports', $this->_('Rapports statistiques'), '/admin/custom-fields-report'] ]); } @@ -168,12 +170,8 @@ class ZendAfi_View_Helper_Admin_ContentNav extends ZendAfi_View_Helper_BaseHelpe [["doctypes", $this->_("Types de documents"), "/admin/type-docs", [], function($user) { return $user->isAdmin(); }], - ["thesaurus_init", $this->_("Import Thesaurus"), "/admin/systeme/importthesaurus", - [], function($user) { return defined('DEVELOPMENT') && $user->isAdmin();}], - - ["thesaurus_edit", - $this->_("Parcourir les codifications"), "/admin/codification-browser", - []] + ["thesaurus_init", $this->_("Import Thesaurus"), "/admin/systeme/importthesaurus"], + ["thesaurus_edit", $this->_("Parcourir les codifications"), "/admin/codification-browser"] ]); } @@ -213,91 +211,3 @@ class ZendAfi_View_Helper_Admin_MenuGaucheAdminBloc { ['class' => 'menuGaucheAdmin']); } } - - - -class ZendAfi_View_Helper_Admin_MenuGaucheAdminItem { - protected static $_acl; - - protected - $_icon, - $_title, - $_url, - $_attribs, - $_skin; - - - public static function newWith($params) { - return new static($params[0], - $params[1], - $params[2], - isset($params[3]) ? $params[3] : [], - isset($params[4]) ? $params[4] : null); - } - - - public function __construct($icon, $title, $url, $attribs=[], $filter=null) { - $this->_icon = $icon; - $this->_title = $title; - $this->_url = $url; - $this->_attribs = $attribs; - $this->_filter = $filter; - $this->_skin = Class_Admin_Skin::current(); - } - - - public function renderFor($user, $view) { - if (!$this->_isAllowed($user)) - return ''; - - $url = $this->_url; - if('http' != substr($url, 0, 4)) - $url = BASE_URL . $url; - - $extra_infos = isset($this->_attribs['extra_infos']) - ? $view->tag('span', $this->_attribs['extra_infos'], ['class' => 'menu_info']) - : ''; - - $attributes = (array_key_exists('REQUEST_URI', $_SERVER) - && false !== strpos($_SERVER['REQUEST_URI'], $url)) - ? ['class' => 'selected'] - : []; - - $anchor_params = ['href' => $url]; - if (isset($this->_attribs['target'])) - $anchor_params['target'] = $this->_attribs['target']; - - $ico = $this->_skin->renderMenuIconOn($this->_icon, $view, ['alt' => $this->_title]); - - return $view->tag('li', - $view->tag('a', $ico . $this->_title, $anchor_params) . $extra_infos, - $attributes); - } - - - protected function _isAllowed($user) { - if (($filter = $this->_filter) && !$filter($user)) - return false; - - if ('/admin/' != substr($this->_url, 0, 7)) - return true; - - $url = substr($this->_url, 7); - $parts = explode('/', $url); - - return $this->getAcl()->isAllowed($user, $parts[0], isset($parts[1]) ? $parts[1] : ''); - } - - - /** @category testing */ - public static function setAcl($acl) { - static::$_acl = $acl; - } - - - protected function getAcl() { - return static::$_acl - ? static::$_acl - : static::$_acl = new ZendAfi_Acl_AdminControllerGroup(); - } -} diff --git a/library/ZendAfi/View/Helper/Admin/HelpLink.php b/library/ZendAfi/View/Helper/Admin/HelpLink.php index 516eacce6de047f335787ede99ab8a7273b5c870..db10d5fc8a719ec4534f15cab0760cfee01d4292 100644 --- a/library/ZendAfi/View/Helper/Admin/HelpLink.php +++ b/library/ZendAfi/View/Helper/Admin/HelpLink.php @@ -76,7 +76,8 @@ class ZendAfi_View_Helper_Admin_HelpLinkBokehWiki { 'library' => 'Afficher_les_horaires_d\'ouverture'], 'ouvertures' => ['index' => 'Ouvertures_des_bibliothèques'], 'bibnum' => ['index' => 'Connecteurs'], - 'album' => ['index' => 'Collections'], + 'album' => ['index' => 'Collections', + 'add-website' => 'Sitothèque_ressource_numérique'], 'catalogue' => ['index' => 'Domaines'], 'cms' => ['index' => 'Articles_-_Créer,_rédiger_et_ordonner'], 'custom-fields' => ['index' => 'Gestion_des_champs_personnalisés'], @@ -107,7 +108,15 @@ class ZendAfi_View_Helper_Admin_HelpLinkBokehWiki { 'stat' => ['matomo' => 'Matomo'], 'print' => ['index' => 'Imprimer_un_résultat_de_recherche,_une_notice_ou_des_articles'], 'file-manager' => ['index' => 'Explorateur_de_fichiers'], - 'url-manager' => ['index' => 'Gestion_des_URL'] + 'url-manager' => ['index' => 'Gestion_des_URL'], + 'search-form' => ['index' => 'Personnalisation_de_la_recherche_avancée'], + 'sito' => ['index' => 'Indexation_des_sitothèques'], + 'external-agendas' => ['index' => 'Agendas_Externes'], + 'lieu' => ['index' => 'Modifier_un_Lieu'], + 'users' => ['index' => 'Gestion_des_utilisateurs'], + 'codification-browser' => ['index' => 'Explorateur_de_codifications'], + 'batch' => ['index' => 'Batchs,_tâches_planifiées'], + 'feature' => ['index' => 'Nouvelles_fonctionnalités'], ]; diff --git a/library/ZendAfi/View/Helper/Admin/MenuGaucheAdminItem.php b/library/ZendAfi/View/Helper/Admin/MenuGaucheAdminItem.php new file mode 100644 index 0000000000000000000000000000000000000000..76020eb755c4dd20bb6ec842c4db781ee600db8c --- /dev/null +++ b/library/ZendAfi/View/Helper/Admin/MenuGaucheAdminItem.php @@ -0,0 +1,107 @@ +<?php +/** + * Copyright (c) 2012-2019, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class ZendAfi_View_Helper_Admin_MenuGaucheAdminItem { + protected static $_acl; + + protected + $_icon, + $_title, + $_url, + $_attribs, + $_skin; + + + public static function newWith($params) { + return new static($params[0], + $params[1], + $params[2], + isset($params[3]) ? $params[3] : [], + isset($params[4]) ? $params[4] : null); + } + + + public function __construct($icon, $title, $url, $attribs=[], $filter=null) { + $this->_icon = $icon; + $this->_title = $title; + $this->_url = $url; + $this->_attribs = $attribs; + $this->_filter = $filter; + $this->_skin = Class_Admin_Skin::current(); + } + + + public function renderFor($user, $view) { + if (!$this->_isAllowed($user)) + return ''; + + $url = $this->_url; + if('http' != substr($url, 0, 4)) + $url = BASE_URL . $url; + + $extra_infos = isset($this->_attribs['extra_infos']) + ? $view->tag('span', $this->_attribs['extra_infos'], ['class' => 'menu_info']) + : ''; + + $attributes = (array_key_exists('REQUEST_URI', $_SERVER) + && false !== strpos($_SERVER['REQUEST_URI'], $url)) + ? ['class' => 'selected'] + : []; + + $anchor_params = ['href' => $url]; + if (isset($this->_attribs['target'])) + $anchor_params['target'] = $this->_attribs['target']; + + $ico = $this->_skin->renderMenuIconOn($this->_icon, $view, ['alt' => $this->_title]); + + return $view->tag('li', + $view->tag('a', $ico . $this->_title, $anchor_params) . $extra_infos, + $attributes); + } + + + protected function _isAllowed($user) { + if (($filter = $this->_filter) && !$filter($user)) + return false; + + if ('/admin/' != substr($this->_url, 0, 7)) + return true; + + $url = substr($this->_url, 7); + $parts = explode('/', $url); + + return $this->getAcl()->isAllowed($user, $parts[0], isset($parts[1]) ? $parts[1] : ''); + } + + + /** @category testing */ + public static function setAcl($acl) { + static::$_acl = $acl; + } + + + protected function getAcl() { + return static::$_acl + ? static::$_acl + : static::$_acl = new ZendAfi_Acl_AdminControllerGroup(); + } +} diff --git a/tests/application/modules/admin/controllers/AdminAbstractControllerTestCase.php b/tests/application/modules/admin/controllers/AdminAbstractControllerTestCase.php index f30bfe8617bfc4b218b409ad68b3b7c803672296..64ef5ff067d3e0d9b1d54f1d9549c91d37b9c62c 100644 --- a/tests/application/modules/admin/controllers/AdminAbstractControllerTestCase.php +++ b/tests/application/modules/admin/controllers/AdminAbstractControllerTestCase.php @@ -31,5 +31,10 @@ abstract class Admin_AbstractControllerTestCase extends AbstractControllerTestCa $account->LOGIN = "sysadmin"; $account->PSEUDO = "admin"; } + + + public function tearDown() { + ZendAfi_View_Helper_Admin_MenuGaucheAdminItem::setAcl(null); + parent::tearDown(); + } } -?> \ No newline at end of file diff --git a/tests/application/modules/admin/controllers/AdminIndexControllerTest.php b/tests/application/modules/admin/controllers/AdminIndexControllerTest.php index b39c7077e15b650b8350b3c504ac07d2db85fcb9..23a09001d62c1aee5155d067e86873f255bd1454 100644 --- a/tests/application/modules/admin/controllers/AdminIndexControllerTest.php +++ b/tests/application/modules/admin/controllers/AdminIndexControllerTest.php @@ -81,12 +81,6 @@ class AdminIndexControllerIndexActionTest extends AdminIndexControllerTestCase { public function menuGaucheShouldContainsCustomFields() { $this->assertXPathContentContains('//li//a','Champs personnalisés'); } - - - /** @test */ - public function menuGaucheShouldContainsCustomFieldReport() { - $this->assertXPathContentContains('//li//a','Rapports statistiques'); - } } diff --git a/tests/application/modules/admin/controllers/AlbumControllerTest.php b/tests/application/modules/admin/controllers/AlbumControllerTest.php index 64821a20b22be6dcece4adb20178b04e35f8a1a1..c31ce32943db5f891790aa1e3f426f44b125e6bd 100644 --- a/tests/application/modules/admin/controllers/AlbumControllerTest.php +++ b/tests/application/modules/admin/controllers/AlbumControllerTest.php @@ -42,9 +42,9 @@ abstract class Admin_AlbumControllerTestCase extends Admin_AbstractControllerTes $fre = $langue_loader->newInstanceWithId('fre')->setLibelle('français'); $dak = $langue_loader->newInstanceWithId('dak')->setLibelle('dakota'); - Storm_Test_ObjectWrapper::onLoaderOfModel('Class_CodifLangue') - ->whenCalled('findAllBy') - ->answers(array($cus, $fre, $dak)); + $this->onLoaderOfModel('Class_CodifLangue') + ->whenCalled('findAllBy') + ->answers([$cus, $fre, $dak]); $favoris = $this->fixture('Class_AlbumCategorie', ['id' => 2]) ->setParentId(0) @@ -2646,6 +2646,9 @@ class Admin_AlbumControllerPreviewAlbumBibleSouvignyPostTest extends Admin_Album class Admin_AlbumControllerImportEADTest extends Admin_AlbumControllerTestCase { public function setUp() { parent::setUp(); + + Class_AdminVar::set('IMPORT_EAD', 1); + $this->dispatch('/admin/album/import_ead'); } diff --git a/tests/application/modules/admin/controllers/CustomFieldsReportControllerTest.php b/tests/application/modules/admin/controllers/CustomFieldsReportControllerTest.php index 5f0503bb5cdd721bc8ab80e8dd512f37c543a8ba..7f3e70280cfdb12904e909f26d9547672dc82837 100644 --- a/tests/application/modules/admin/controllers/CustomFieldsReportControllerTest.php +++ b/tests/application/modules/admin/controllers/CustomFieldsReportControllerTest.php @@ -25,6 +25,7 @@ class CustomFieldsReportControllerAddTest extends AbstractControllerTestCase { public function setUp() { parent::setUp(); + Class_AdminVar::set('CUSTOM_FIELDS_REPORT', 1); $this->dispatch('/admin/custom-fields-report/add', true); } @@ -67,6 +68,8 @@ class CustomFieldsReportControllerEditTest extends AbstractControllerTestCase { public function setUp() { parent::setUp(); + Class_AdminVar::set('CUSTOM_FIELDS_REPORT', 1); + $this->fixture('Class_Report', [ 'id' => 2, 'label' => 'Report', @@ -90,6 +93,9 @@ class CustomFieldsReportControllerGenerateTest extends AbstractControllerTestCas public function setUp() { parent::setUp(); + + Class_AdminVar::set('CUSTOM_FIELDS_REPORT', 1); + $this->fixture('Class_Report', [ 'id' => 42, 'label' => '', @@ -108,5 +114,4 @@ class CustomFieldsReportControllerGenerateTest extends AbstractControllerTestCas public function customFieldsJsShouldBePresent() { $this->assertXPath('//script[contains(@src, "custom-fields/custom_fields.js")]'); } -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/tests/application/modules/admin/controllers/OaiControllerTest.php b/tests/application/modules/admin/controllers/OaiControllerTest.php index bce98625543a380761d7f0b967338f8639bbfac0..817488322b86ef884991501c5aad07852ca4e115 100644 --- a/tests/application/modules/admin/controllers/OaiControllerTest.php +++ b/tests/application/modules/admin/controllers/OaiControllerTest.php @@ -48,6 +48,9 @@ abstract class Admin_OaiControllerTestCase extends Admin_AbstractControllerTestC class Admin_OaiControllerIndexActionTest extends Admin_OaiControllerTestCase { public function setUp() { parent::setUp(); + + Class_AdminVar::set('OAI_REPOSITORY', 1); + $this->dispatch('/admin/oai'); } @@ -91,6 +94,7 @@ class Admin_OaiControllerIndexActionTest extends Admin_OaiControllerTestCase { class Admin_OaiControllerAddActionTest extends Admin_OaiControllerTestCase { public function setUp() { parent::setUp(); + Class_AdminVar::set('OAI_REPOSITORY', 1); $this->dispatch('/admin/oai/add'); } @@ -107,6 +111,7 @@ class Admin_OaiControllerAddActionTest extends Admin_OaiControllerTestCase { class Admin_OaiControllerEditActionTest extends Admin_OaiControllerTestCase { public function setUp() { parent::setUp(); + Class_AdminVar::set('OAI_REPOSITORY', 1); $this->dispatch('/admin/oai/edit/id/4'); } @@ -123,6 +128,7 @@ class Admin_OaiControllerEditActionTest extends Admin_OaiControllerTestCase { class Admin_OaiControllerBrowseGallicaActionTest extends Admin_OaiControllerTestCase { public function setUp() { parent::setUp(); + Class_AdminVar::set('OAI_REPOSITORY', 1); $web_client = Storm_Test_ObjectWrapper::mock(); Class_WebService_OAI::setDefaultHttpClient($web_client); @@ -155,6 +161,9 @@ class Admin_OaiControllerImportIsaacAsimovFoundationTest extends Admin_OaiContro public function setUp() { parent::setUp(); + + Class_AdminVar::set('OAI_REPOSITORY', 1); + $foundation = Class_NoticeOAI::getLoader() ->newInstanceWithId(23) ->setData(serialize(array('titre' => 'Prelude to foundation', @@ -227,6 +236,7 @@ class Admin_OaiControllerImportIsaacAsimovFoundationTest extends Admin_OaiContro class Admin_OaiControllerSearchAsimovActionTest extends Admin_OaiControllerTestCase { /** @test */ public function pageShouldRedirectToOaiIndexWithExpressionRecherche() { + Class_AdminVar::set('OAI_REPOSITORY', 1); $this->dispatch('/admin/oai/search?expression=asimov', true); $this->assertRedirectTo('/admin/oai/index/expression/asimov'); } @@ -238,6 +248,7 @@ class Admin_OaiControllerSearchAsimovActionTest extends Admin_OaiControllerTestC abstract class Admin_OaiControllerSearchActionTestCase extends Admin_OaiControllerTestCase { public function setUp() { parent::setUp(); + Class_AdminVar::set('OAI_REPOSITORY', 1); $this->mock_sql = Storm_Test_ObjectWrapper::on(Zend_Registry::get('sql')); Zend_Registry::set('sql', $this->mock_sql); } @@ -307,8 +318,4 @@ class Admin_OaiControllerIndexSearchInsignifantWordActionTest extends Admin_OaiC public function pageShouldContainsPasAssezDeMotsSignifications() { $this->assertXPathContentContains('//div[@class="error"]', "Il n'y aucun mot assez significatif pour la recherche"); } -} - - - -?> \ No newline at end of file +} \ No newline at end of file diff --git a/tests/application/modules/admin/controllers/OpdsControllerTest.php b/tests/application/modules/admin/controllers/OpdsControllerTest.php index 1beb9a10de8ed051b57b2883e9ebaf99f53cccd5..a9f8579094ffc4f9f19599e33079374f5ffd1f46 100644 --- a/tests/application/modules/admin/controllers/OpdsControllerTest.php +++ b/tests/application/modules/admin/controllers/OpdsControllerTest.php @@ -24,6 +24,9 @@ abstract class Admin_OpdsControllerTestCase extends Admin_AbstractControllerTest public function setUp() { parent::setUp(); + + Class_AdminVar::set('OPDS', 1); + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_OpdsCatalog') ->whenCalled('findAllBy') ->with(array('order' => 'libelle')) @@ -59,6 +62,7 @@ class Admin_OpdsControllerWithReferentActionTest extends Admin_AbstractControlle public function setUp() { parent::setUp(); + Class_AdminVar::set('OPDS', 1); Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Users') ->whenCalled('getIdentity') ->answers($user_referent=Class_Users::getLoader()->newInstanceWithId(2) @@ -945,5 +949,4 @@ class Admin_OpdsControllerBrowseFeedbooksTestCase extends Admin_OpdsControllerTe $album = Class_Album::getLoader()->getFirstAttributeForLastCallOn('save'); $this->assertEquals('In his extraordinary debut novel of psychological suspense, Thomas OCallaghan proves himself a worthy successor to Thomas Harris as he introduces one of the most compelling and terrifying serial killers since Hannibal Lecter in a book where every...', $album->getDescription()); } -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/tests/application/modules/admin/controllers/ProfilControllerTest.php b/tests/application/modules/admin/controllers/ProfilControllerTest.php index d4c6642b22b56fbacc43a8fe9844531c90751e23..6b201a6be244c71fb5cf96010c5c08e59586167d 100644 --- a/tests/application/modules/admin/controllers/ProfilControllerTest.php +++ b/tests/application/modules/admin/controllers/ProfilControllerTest.php @@ -1357,17 +1357,19 @@ class Admin_ProfilControllerNonExistingProfileTest extends Admin_AbstractControl class Admin_ProfilControllerGenresActionTest extends Admin_AbstractControllerTestCase { public function setUp() { parent::setUp(); + Class_AdminVar::set('CUSTOM_GENRE_ICON', 1); + $this->dispatch('/admin/profil/genres'); } /** @test */ - function actionShouldBeGenres() { + public function actionShouldBeGenres() { $this->assertAction('genres'); } - } + class Admin_ProfilControllerEditMenuHorizontalTest extends Admin_AbstractControllerTestCase { public function setUp() { parent::setUp(); diff --git a/tests/application/modules/admin/controllers/ReferentPortailControllerTest.php b/tests/application/modules/admin/controllers/ReferentPortailControllerTest.php index 8df217220e728e80c0ca0f0aa9518aa79d270c76..c91cb8c5cdc770063b7aea7454528f8223122be8 100644 --- a/tests/application/modules/admin/controllers/ReferentPortailControllerTest.php +++ b/tests/application/modules/admin/controllers/ReferentPortailControllerTest.php @@ -1,4 +1,4 @@ -<?php +b<?php /** * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. * @@ -16,12 +16,13 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ require_once 'AbstractControllerTestCase.php'; -abstract class ReferentPortailController_AbstractControllerTestCase extends AbstractControllerTestCase { - use Trait_UserGroupFixtures; +abstract class ReferentPortailControllerTestCase extends AbstractControllerTestCase { + use Trait_UserGroupFixtures; + protected function _initProfilHook($profil) { $profil->setLibelle('AFI'); } @@ -36,10 +37,10 @@ abstract class ReferentPortailController_AbstractControllerTestCase extends Abst public function setUp() { parent::setUp(); $user_referent=Class_Users::getLoader()->newInstanceWithId(777) - ->setLogin('referent') - ->setRoleLevel(ZendAfi_Acl_AdminControllerRoles::MODO_PORTAIL) - ->setPseudo('referent'); - + ->setLogin('referent') + ->setRoleLevel(ZendAfi_Acl_AdminControllerRoles::MODO_PORTAIL) + ->setPseudo('referent'); + $this->addUserToRightsReferent($user_referent); } @@ -47,39 +48,42 @@ abstract class ReferentPortailController_AbstractControllerTestCase extends Abst -class ReferentPortailControllerIndexActionTest extends ReferentPortailController_AbstractControllerTestCase { +class ReferentPortailControllerIndexActionTest extends ReferentPortailControllerTestCase { public function setUp() { parent::setUp(); - Class_AdminVar::getLoader()->newInstanceWithId('BIBNUM') - ->setValeur(1); + + Class_AdminVar::set('BIBNUM', 1); + Class_AdminVar::set('OPDS', 1); + $this->dispatch('/admin/index', true); } + /** @test */ function menuGaucheShouldContainsSitotheque() { $this->assertXPathContentContains('//li//a','Sitothèque',$this->_response->getBody()); } - /** @test */ + /** @test */ function menuGaucheShouldContainsDomaines() { $this->assertXPathContentContains('//li//a','Domaines',$this->_response->getBody()); } - /** @test */ + /** @test */ function menuGaucheShouldContainsModeration() { $this->assertXPathContentContains('//li//a','Modération',$this->_response->getBody()); } - /** @test */ + /** @test */ function menuGaucheShouldContainsDemandeDinscription() { $this->assertXPathContentContains('//li//a','Demandes d\'inscription',$this->_response->getBody()); } - /** @test */ + /** @test */ function menuGaucheShouldContainsCollections() { $this->assertXPathContentContains('//li//a','Collections',$this->_response->getBody()); } @@ -99,8 +103,4 @@ class ReferentPortailControllerIndexActionTest extends ReferentPortailController function menuGaucheShouldContainsUtilisateurs() { $this->assertXPathContentContains('//li//a','Utilisateurs',$this->_response->getBody()); } - - -} - -?> \ No newline at end of file +} \ No newline at end of file diff --git a/tests/application/modules/admin/controllers/SystemeControllerOpac2ImportTest.php b/tests/application/modules/admin/controllers/SystemeControllerOpac2ImportTest.php index ec4c1e924c4bb32f12886ad98192a5f7ef5fe6bf..43403ee7fe2104ef79558d8ed176654c0694b640 100644 --- a/tests/application/modules/admin/controllers/SystemeControllerOpac2ImportTest.php +++ b/tests/application/modules/admin/controllers/SystemeControllerOpac2ImportTest.php @@ -27,6 +27,8 @@ abstract class SystemeControllerOpac2ImportTestCase parent::setUp(); Storm_Model_Loader::defaultToVolatile(); + Class_AdminVar::set('IMPORT_AVIS_OPAC2', 1); + $this->fixture('Class_AdminVar', ['id' => 'AVIS_MAX_SAISIE', 'valeur' => '1000000']); diff --git a/tests/application/modules/admin/controllers/SystemeControllerWebServicesTest.php b/tests/application/modules/admin/controllers/SystemeControllerWebServicesTest.php index 1be3c1c221f959b5ac199a15d18bad4248a63c2f..0834aa3952b5512b591f6e38bb9521869a40787d 100644 --- a/tests/application/modules/admin/controllers/SystemeControllerWebServicesTest.php +++ b/tests/application/modules/admin/controllers/SystemeControllerWebServicesTest.php @@ -21,6 +21,9 @@ class SystemeControllerWebServicesIndexActionTest extends Admin_AbstractControllerTestCase { public function setUp() { parent::setUp(); + + Class_AdminVar::set('WEBSERVICE_TEST', 1); + $this->dispatch('admin/systeme/webservices'); } @@ -48,6 +51,7 @@ class SystemeControllerWebServicesActionTest extends Admin_AbstractControllerTes * @test */ public function webServiceFnacGetResumeShouldWork() { + Class_AdminVar::set('WEBSERVICE_TEST', 1); $this->dispatch('/admin/systeme/webservices/id_service/Fnac/id_fonction/1'); $this->assertXPathContentContains('//pre[@class="resultat"]', 'Un campus prestigieux figé sous la neige', @@ -62,11 +66,10 @@ class SystemeControllerWebServicesActionTest extends Admin_AbstractControllerTes * @test */ public function webServicePremiereGetResumeShouldWork() { + Class_AdminVar::set('WEBSERVICE_TEST', 1); $this->dispatch('/admin/systeme/webservices/id_service/Premiere/id_fonction/1', true); $this->assertXPathContentContains('//pre[@class="resultat"]', 'Jake Sully est un ancien marine', $this->_response->getBody()); } -} - -?> \ No newline at end of file +} \ No newline at end of file diff --git a/tests/library/ZendAfi/View/Helper/Admin/MenuGaucheAdminTest.php b/tests/library/ZendAfi/View/Helper/Admin/MenuGaucheAdminTest.php index b81b0e4aff3b49b100e7589b2dd060824957a7c4..64c32e9924bbfe346f4bc2191d0c820a1425a602 100644 --- a/tests/library/ZendAfi/View/Helper/Admin/MenuGaucheAdminTest.php +++ b/tests/library/ZendAfi/View/Helper/Admin/MenuGaucheAdminTest.php @@ -35,6 +35,8 @@ abstract class ZendAfi_View_Helper_Admin_MenuGaucheAdminTestCase extends ViewHel $this->helper->setView($this->view); ZendAfi_View_Helper_Admin_MenuGaucheAdminItem::setAcl(null); + Class_AdminVar::set('OPDS', 1); + Class_AdminVar::set('BIBNUM', 1); $this->html = $this->helper->Admin_ContentNav(); } @@ -60,7 +62,6 @@ class ZendAfi_View_Helper_Admin_MenuGaucheAdminVariableAsAdminTest public function _prepareFixtures() { parent::_prepareFixtures(); - $this->login(ZendAfi_Acl_AdminControllerRoles::ADMIN_PORTAIL); RessourcesNumeriquesFixtures::activateOrphea(); RessourcesNumeriquesFixtures::deactivateDilicom(); @@ -354,10 +355,20 @@ class ZendAfi_View_Helper_Admin_MenuGaucheAdminRightsTest extends ViewHelperTest $this->helper = new ZendAfi_View_Helper_Admin_ContentNav(); $this->helper->setView($this->view); ZendAfi_View_Helper_Admin_MenuGaucheAdminItem::setAcl(null); + Class_AdminVar::set('ACTIVITY', 1); Class_AdminVar::set('BIBNUM', 1); Class_AdminVar::set('SITO_IN_ALBUMS', 1); Class_AdminVar::set('CODIFICATION_BROWSER', 1); + Class_AdminVar::set('OAI_REPOSITORY', 1); + Class_AdminVar::set('CUSTOM_GENRE_ICON', 1); + Class_AdminVar::set('WEBSERVICE_TEST', 1); + Class_AdminVar::set('IMPORT_AVIS_OPAC2', 1); + Class_AdminVar::set('GENERATION_SITE', 1); + Class_AdminVar::set('CUSTOM_FIELDS_REPORT', 1); + Class_AdminVar::set('IMPORT_THESAURUS', 1); + Class_AdminVar::set('IMPORT_EAD', 1); + } diff --git a/tests/scenarios/AdvancedSearch/AdminConfigurationTest.php b/tests/scenarios/AdvancedSearch/AdminConfigurationTest.php index ae828b91d92eca5e8f82443b34d8dc4512028071..252cc063c5de409862d6ecbdfc52a8b6db5179fc 100644 --- a/tests/scenarios/AdvancedSearch/AdminConfigurationTest.php +++ b/tests/scenarios/AdvancedSearch/AdminConfigurationTest.php @@ -20,7 +20,7 @@ */ -class AdvancedSearch_AdminConfigurationUnactiveTest extends Admin_AbstractControllerTestCase { +class AdvancedSearch_AdminConfigurationUnactiveTest extends Admin_AbstractControllerTestCase { protected $_storm_default_to_volatile = true; public function setUp() { @@ -29,12 +29,6 @@ class AdvancedSearch_AdminConfigurationUnactiveTest extends Admin_AbstractCont } - public function tearDown() { - ZendAfi_View_Helper_Admin_MenuGaucheAdminItem::setAcl(null); - parent::tearDown(); - } - - /** @test */ public function menuAdvancedFormShouldBeDisplayed() { $this->dispatch('/admin'); @@ -64,12 +58,6 @@ abstract class AdvancedSearch_ActiveTestCase extends Admin_AbstractControllerTes 'visible' => true ]); } - - - public function tearDown() { - ZendAfi_View_Helper_Admin_MenuGaucheAdminItem::setAcl(null); - parent::tearDown(); - } }