Commit 85f60fc8 authored by Ghislain Loas's avatar Ghislain Loas

dev #85637 : admin menu maintenance + doc links + filter redmine libraries

parent 5c89b009
Pipeline #6162 passed with stage
in 32 minutes and 26 seconds
......@@ -142,7 +142,7 @@ 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'],
['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],
......@@ -211,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();
}
}
<?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();
}
}
......@@ -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
......@@ -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');
}
}
......
......@@ -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)
......
......@@ -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();
......
<?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
......@@ -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);
}
......
......@@ -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();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment