Commit 611775c6 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Trop de modif!

parent 3a42de22
......@@ -187,7 +187,12 @@ class Module implements ConfigProviderInterface, ViewHelperProviderInterface, Se
// ->setDbStorage($sm->get('UnicaenAuth\Authentication\Storage\Db'));
// return $storage;
// },
'ZfcUser\Authentication\Adapter\AdapterChain' => 'UnicaenAuth\Authentication\Adapter\AdapterChainServiceFactory',
// 'ZfcUser\Authentication\Adapter\AdapterChain' => 'UnicaenAuth\Authentication\Adapter\AdapterChainServiceFactory',
'UnicaenAuth\Provider\Identity\LdapPeople' => function($sm) {
$authService = $sm->get('zfcuser_auth_service');
$provider = new \UnicaenAuth\Provider\Identity\LdapPeople($authService);
return $provider;
},
),
);
}
......
......@@ -54,8 +54,8 @@ $zfcuserSettings = array(
'auth_adapters' => array(
// 100 => 'UnicaenAuth\Authentication\Service\StrategyService',
300 => 'UnicaenAuth\Authentication\Adapter\Ldap', // notifié en 1er
200 => 'UnicaenAuth\Authentication\Adapter\Db', // 2e (si échec d'authentification Ldap)
100 => 'UnicaenAuth\Authentication\Adapter\Cas', // 3e (si échec d'authentification Db)
200 => 'UnicaenAuth\Authentication\Adapter\Db', // ensuite (si échec d'authentification Ldap)
100 => 'UnicaenAuth\Authentication\Adapter\Cas', // ensuite (si échec d'authentification Db)
),
);
......
<?php
namespace UnicaenAuth\Provider\Identity;
use BjyAuthorize\Exception\InvalidRoleException;
use BjyAuthorize\Provider\Identity\ProviderInterface;
use Zend\Authentication\AuthenticationService;
use Zend\Permissions\Acl\Role\RoleInterface;
use Zend\ServiceManager\ServiceLocatorAwareInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
/**
* Description of LdapGroupProviderInterface
*
* @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>
*/
class LdapPeople implements ProviderInterface, ServiceLocatorAwareInterface
{
/**
* @var ServiceLocatorAwareInterface
*/
protected $serviceLocator;
/**
* @var AuthenticationService
*/
protected $authService;
/**
* @var string|RoleInterface
*/
protected $defaultRole = 'guest';
/**
* @param AuthenticationService $authService
*/
public function __construct(AuthenticationService $authService)
{
$this->authService = $authService;
}
/**
* Retrieve roles for the current identity
*
* @return string[]|RoleInterface[]
*/
public function getIdentityRoles()
{
$roles = array();
$identity = $this->authService->getIdentity();
if ($identity instanceof \UnicaenApp\Entity\Ldap\People) {
/* @var $identity \UnicaenApp\Entity\Ldap\People */
$authorizeService = $this->getServiceLocator()->get('BjyAuthorize\Service\Authorize');
/* @var $authorizeService \BjyAuthorize\Service\Authorize */
foreach ($identity->getMemberOf() as $group) {
if ($authorizeService->getAcl()->hasRole($group)) {
$roles[] = $group;
}
}
}
if (!$roles) {
$roles = array($this->getDefaultRole());
}
// var_dump($roles);
return $roles;
}
/**
* Get the rule that's used if you're not authenticated
*
* @return string|RoleInterface
*/
public function getDefaultRole()
{
return $this->defaultRole;
}
/**
* Set the rule that's used if you're not authenticated
*
* @param $defaultRole
*
* @throws \BjyAuthorize\Exception\InvalidRoleException
*/
public function setDefaultRole($defaultRole)
{
if ( ! ($defaultRole instanceof RoleInterface || is_string($defaultRole))) {
throw InvalidRoleException::invalidRoleInstance($defaultRole);
}
$this->defaultRole = $defaultRole;
}
/**
* Set service locator
*
* @param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator
*/
public function setServiceLocator(ServiceLocatorInterface $serviceLocator)
{
$this->serviceLocator = $serviceLocator;
return $this;
}
/**
* Get service locator
*
* @return \Zend\ServiceManager\ServiceLocatorInterface
*/
public function getServiceLocator()
{
return $this->serviceLocator;
}
}
......@@ -55,7 +55,7 @@ EOS;
$out .= <<<EOS
<script type="text/javascript">
$(function() {
$("#$id").popover({ html: true });
$("#$id").popover({ html: true, container: 'body' });
});
</script>
EOS;
......
......@@ -22,18 +22,17 @@ class UserInfo extends UserAbstract
/**
* @var bool
*/
protected $affectationFineSiDispo = false;
protected $affectationPrincipale = false;
/**
* Point d'entrée.
*
* @param boolean $affectationFineSiDispo Indique s'il faut prendre en compte l'affectation
* plus fine (ucbnSousStructure) si elle existe, à la place de l'affectation standard (niveau 2)
* @param boolean $affectationPrincipale Indique s'il ne faut prendre en compte que l'affectation principale
* @return UserInfo
*/
public function __invoke($affectationFineSiDispo = false)
public function __invoke($affectationPrincipale = false)
{
$this->setAffectationFineSiDispo($affectationFineSiDispo);
$this->setAffectationPrincipale($affectationPrincipale);
return $this;
}
......@@ -58,9 +57,9 @@ class UserInfo extends UserAbstract
if ($authIdentity instanceof People) {
// affectations admin
$affectations = $authIdentity->getAffectationsAdmin($this->getAffectationFineSiDispo());
$affectations = $authIdentity->getAffectationsAdmin($this->getServiceStructure()->getMapper(), $this->getAffectationPrincipale());
if ($affectations) {
$affectations = (array)$this->getServiceStructure()->getMapper()->findChemin(array_keys($affectations));
// $affectations = (array)$this->getServiceStructure()->getMapper()->findChemin(array_keys($affectations));
if (empty($affectations))
$affectations[] = $this->getView()->translate("Aucune affectation trouvée.");
ksort($affectations);
......@@ -100,7 +99,7 @@ class UserInfo extends UserAbstract
// && $authIdentity->getLdapIdentityData() instanceof Unicaen_Model_LdapPeople) {
//
// // affectations admin
// $affectations = $authIdentity->getLdapIdentityData()->getAffectationsAdmin($this->getAffectationFineSiDispo());
// $affectations = $authIdentity->getLdapIdentityData()->getAffectationsAdmin($this->getAffectationPrincipale());
// if ($affectations) {
// $affectations = (array)$this->getServiceStructure()->findChemin(array_keys($affectations));
// if (empty($affectations))
......@@ -163,23 +162,23 @@ class UserInfo extends UserAbstract
}
/**
* Indique si l'affichage de l'affectation fine éventuelle est activé ou non.
* Indique si l'affichage de l'affectation princiaple seulement est activé ou non.
* @return bool
*/
public function getAffectationFineSiDispo()
public function getAffectationPrincipale()
{
return $this->affectationFineSiDispo;
return $this->affectationPrincipale;
}
/**
* Active ou non l'affichage de l'affectation fine éventuelle.
* Active ou non l'affichage de l'affectation principale seulement.
*
* @param bool $affectationFineSiDispo
* @param bool $affectationPrincipale
* @return UserInfo
*/
public function setAffectationFineSiDispo($affectationFineSiDispo = true)
public function setAffectationPrincipale($affectationPrincipale = true)
{
$this->affectationFineSiDispo = $affectationFineSiDispo;
$this->affectationPrincipale = $affectationPrincipale;
return $this;
}
......
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