Commit 8d1d077d authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Aide de vue UserInfo : n'a besoin que du mapper d'accès aux structures LDAP.

parent 075bdac1
......@@ -137,7 +137,7 @@ class Module implements ConfigProviderInterface, ViewHelperProviderInterface, Se
},
'userInfo' => function (HelperPluginManager $sm) {
$helper = new View\Helper\UserInfo($sm->getServiceLocator()->get('zfcuser_auth_service'));
$helper->setServiceStructure($sm->getServiceLocator()->get('ldap_structure_service'));
$helper->setMapperStructure($sm->getServiceLocator()->get('ldap_structure_mapper'));
return $helper;
},
),
......
......@@ -2,7 +2,7 @@
namespace UnicaenAuth\View\Helper;
use UnicaenApp\Entity\Ldap\People;
use UnicaenApp\Service\Ldap\Structure as ServiceStructure;
use UnicaenApp\Mapper\Ldap\Structure as MapperStructure;
use Zend\View\Helper\HtmlList;
/**
......@@ -15,9 +15,9 @@ use Zend\View\Helper\HtmlList;
class UserInfo extends UserAbstract
{
/**
* @var ServiceStructure
* @var MapperStructure
*/
protected $serviceStructure;
protected $mapperStructure;
/**
* @var bool
......@@ -28,7 +28,7 @@ class UserInfo extends UserAbstract
* Point d'entrée.
*
* @param boolean $affectationPrincipale Indique s'il ne faut prendre en compte que l'affectation principale
* @return UserInfo
* @return self
*/
public function __invoke($affectationPrincipale = false)
{
......@@ -48,18 +48,18 @@ class UserInfo extends UserAbstract
}
$out = '';
$templateAff= '<strong>' . $this->getView()->translate("Affectations administratives") . ' :</strong> %s';
$templateAffRech= '<strong>' . $this->getView()->translate("Affectations recherche") . ' :</strong> %s';
$templateFonctStruct= '<strong>' . $this->getView()->translate("Responsabilités") . ' :</strong> %s';
$templateAff = '<strong>' . $this->getView()->translate("Affectations administratives") . ' :</strong> %s';
$templateAffRech = '<strong>' . $this->getView()->translate("Affectations recherche") . ' :</strong> %s';
$templateFonctStruct = '<strong>' . $this->getView()->translate("Responsabilités") . ' :</strong> %s';
$helperHtmlList = new HtmlList();
if ($authIdentity instanceof People) {
// affectations admin
$affectations = $authIdentity->getAffectationsAdmin($this->getServiceStructure()->getMapper(), $this->getAffectationPrincipale());
$affectations = $authIdentity->getAffectationsAdmin($this->getMapperStructure(), $this->getAffectationPrincipale());
if ($affectations) {
// $affectations = (array)$this->getServiceStructure()->getMapper()->findChemin(array_keys($affectations));
// $affectations = (array)$this->getMapperStructure()->getMapper()->findChemin(array_keys($affectations));
if (empty($affectations))
$affectations[] = $this->getView()->translate("Aucune affectation trouvée.");
ksort($affectations);
......@@ -70,7 +70,7 @@ class UserInfo extends UserAbstract
// affectations recherche
$affectations = $authIdentity->getAffectationsRecherche();
if ($affectations) {
$affectations = (array)$this->getServiceStructure()->getMapper()->findAllPathByCodeStructure(array_keys($affectations));
$affectations = (array)$this->getMapperStructure()->findAllPathByCodeStructure(array_keys($affectations));
ksort($affectations);
$affectations = $helperHtmlList($affectations, $ordered = false, $attribs = false, $escape = false);
$out .= sprintf($templateAffRech, $affectations);
......@@ -101,7 +101,7 @@ class UserInfo extends UserAbstract
// // affectations admin
// $affectations = $authIdentity->getLdapIdentityData()->getAffectationsAdmin($this->getAffectationPrincipale());
// if ($affectations) {
// $affectations = (array)$this->getServiceStructure()->findChemin(array_keys($affectations));
// $affectations = (array)$this->getMapperStructure()->findChemin(array_keys($affectations));
// if (empty($affectations))
// $affectations[] = "Aucune affectation trouvée.";
// ksort($affectations);
......@@ -112,7 +112,7 @@ class UserInfo extends UserAbstract
// // affectations recherche
// $affectations = $authIdentity->getLdapIdentityData()->getAffectationsRecherche();
// if ($affectations) {
// $affectations = (array)$this->getServiceStructure()->findChemin(array_keys($affectations));
// $affectations = (array)$this->getMapperStructure()->findChemin(array_keys($affectations));
// ksort($affectations);
// $affectations = $helperHtmlList($affectations, $ordered = false, $attribs = false, $escape = false);
// $out .= sprintf($templateAffRech, $affectations);
......@@ -174,7 +174,7 @@ class UserInfo extends UserAbstract
* Active ou non l'affichage de l'affectation principale seulement.
*
* @param bool $affectationPrincipale
* @return UserInfo
* @return self
*/
public function setAffectationPrincipale($affectationPrincipale = true)
{
......@@ -183,24 +183,24 @@ class UserInfo extends UserAbstract
}
/**
* Spécifie le service d'accès aux structures de l'annuaire LDAP.
* Spécifie le mapper d'accès aux structures de l'annuaire LDAP.
*
* @param ServiceStructure $serviceStructure
* @return UserInfo
* @param MapperStructure $mapperStructure
* @return self
*/
public function setServiceStructure(ServiceStructure $serviceStructure)
public function setMapperStructure(MapperStructure $mapperStructure)
{
$this->serviceStructure = $serviceStructure;
$this->mapperStructure = $mapperStructure;
return $this;
}
/**
* Retourne le service d'accès aux structures de l'annuaire LDAP.
* Retourne le mapper d'accès aux structures de l'annuaire LDAP.
*
* @return ServiceStructure
* @return MapperStructure
*/
public function getServiceStructure()
public function getMapperStructure()
{
return $this->serviceStructure;
return $this->mapperStructure;
}
}
}
\ No newline at end of file
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