Loading config/merged/role.config.php +4 −0 Original line number Diff line number Diff line Loading @@ -129,6 +129,10 @@ return [ 'service_manager' => [ 'factories' => [ 'UnicaenUtilisateur\Provider\Role\Config' => 'UnicaenUtilisateur\Provider\Role\ConfigServiceFactory', 'UnicaenUtilisateur\Provider\Role\Config' => 'UnicaenUtilisateur\Provider\Role\ConfigServiceFactory', 'UnicaenUtilisateur\Provider\Role\DbRole' => 'UnicaenUtilisateur\Provider\Role\DbRoleServiceFactory', 'UnicaenUtilisateur\Provider\Role\Username' => 'UnicaenUtilisateur\Provider\Role\UsernameServiceFactory', RoleService::class => RoleServiceFactory::class, ], ], Loading config/merged/utilisateur.config.php +11 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ return [ 'action' => [ 'index', 'rechercher', 'rechercher-utilisateur', 'listing', 'export' ], Loading Loading @@ -151,6 +152,16 @@ return [ ], ], ], 'rechercher-utilisateur' => [ 'type' => Literal::class, 'options' => [ 'route' => '/rechercher-utilisateur', 'defaults' => [ 'controller' => UtilisateurController::class, 'action' => 'rechercher-utilisateur', ], ], ], 'add-role' => [ 'type' => Segment::class, 'options' => [ Loading config/module.config.php +22 −3 Original line number Diff line number Diff line Loading @@ -19,8 +19,6 @@ use UnicaenUtilisateur\View\Helper\UserProfileSelectRadioItem; use UnicaenUtilisateur\View\Helper\UserProfileSelectRadioItemFactory; use UnicaenUtilisateur\View\Helper\UserStatus; use UnicaenUtilisateur\View\Helper\UserStatusFactory; use UnicaenUtilisateur\View\Helper\UserUsurpationHelper; use UnicaenUtilisateur\View\Helper\UserUsurpationHelperFactory; return [ 'doctrine' => [ Loading @@ -46,12 +44,34 @@ return [ ], ], 'bjyauthorize' => [ /* role providers simply provide a list of roles that should be inserted * into the Zend\Acl instance. the module comes with two providers, one * to specify roles in a config file and one to load roles using a * Zend\Db adapter. */ 'role_providers' => [ /** * 2 rôles doivent systématiquement exister dans les ACL : * - le rôle par défaut 'guest', c'est le rôle de tout utilisateur non authentifié. * - le rôle 'user', c'est le rôle de tout utilisateur authentifié. */ 'UnicaenUtilisateur\Provider\Role\Config' => [ 'guest' => ['name' => "Non authentifié(e)", 'selectable' => false, 'children' => [ 'user' => ['name' => "Authentifié(e)", 'selectable' => false], ]], ], ], ], 'service_manager' => [ 'invokables' => [ 'UserRoleSelectedEventListener' => UserRoleSelectedEventListener::class, ], 'factories' => [ // 'UserAuthenticatedEventListener' => UserAuthenticatedEventListenerFactory::class, HistoriqueListener::class => HistoriqueListenerFactory::class, ], ], Loading Loading @@ -79,7 +99,6 @@ return [ UserInfo::class => UserInfoFactory::class, UserProfileSelect::class => UserProfileSelectFactory::class, UserProfileSelectRadioItem::class => UserProfileSelectRadioItemFactory::class, UserUsurpationHelper::class => UserUsurpationHelperFactory::class, ], ], ]; src/UnicaenUtilisateur/Acl/NamedRole.php 0 → 100644 +127 −0 Original line number Diff line number Diff line <?php namespace UnicaenUtilisateur\Acl; use Zend\Permissions\Acl\Role\RoleInterface; /** * Rôle avec nom explicite (humainement intelligible). * * @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr> */ class NamedRole extends \BjyAuthorize\Acl\Role { /** * @var string */ protected $roleName; /** * @var string */ protected $roleDescription; /** * @var bool */ protected $selectable = true; /** * Constructeur. * * @param string|null $id * @param RoleInterface|string|null $parent * @param string $name * @param string $description * @param bool $selectable */ public function __construct($id = null, $parent = null, $name = null, $description = null, $selectable = true) { parent::__construct($id, $parent); $this ->setRoleName($name ?: $id) ->setRoleDescription($description ?: null) ->setSelectable($selectable); } /** * Retourne la représentation littérale de ce rôle. * * @return string */ public function __toString() { return $this->getRoleName() ?: $this->getRoleId(); } /** * Retourne le nom du rôle. * * @return string */ public function getRoleName() { return $this->roleName; } /** * Spécifie le nom du rôle. * * @param string $roleName * @return self */ public function setRoleName($roleName) { $this->roleName = (string) $roleName; return $this; } /** * Retourne la description du rôle. * * @return string */ public function getRoleDescription() { return $this->roleDescription; } /** * Spécifie la description du rôle. * * @param string $roleDescription * @return self */ public function setRoleDescription($roleDescription) { $this->roleDescription = (string) $roleDescription; return $this; } /** * Teste si ce rôle est sélectionnable par l'utilisateur. * Cela concerne les applications qui permettent à l'utilisateur de choisir son profil courant * parmi les différents rôles qu'il possède. * * @return bool */ public function getSelectable() { return $this->selectable; } /** * Spécifie si ce rôle est sélectionnable par l'utilisateur. * Cela concerne les applications qui permettent à l'utilisateur de choisir son profil courant * parmi les différents rôles qu'il possède. * * @param bool $selectable * @return \UnicaenAuth\Acl\NamedRole */ public function setSelectable($selectable = true) { $this->selectable = $selectable; return $this; } } No newline at end of file src/UnicaenUtilisateur/Controller/UtilisateurController.php +18 −2 Original line number Diff line number Diff line Loading @@ -63,7 +63,7 @@ class UtilisateurController extends AbstractActionController { default : if (isset($this->recherche[$source])) { $people = $this->recherche[$source]->findById($id); $utilisateur = $this->getUserService()->importFromRechercheIndividuResultatInterface($people, 'ldap'); $utilisateur = $this->getUserService()->importFromRechercheIndividuResultatInterface($people, $source); $params = []; if (!$this->userService->exist($utilisateur->getUsername())) { Loading Loading @@ -228,7 +228,8 @@ class UtilisateurController extends AbstractActionController { return $vm; } public function rechercherAction() { public function rechercherAction() : JsonModel { $term = $this->params()->fromQuery('term'); $serviceName = $this->params()->fromRoute('service-name'); Loading @@ -254,6 +255,21 @@ class UtilisateurController extends AbstractActionController { return new JsonModel($result); } public function rechercherUtilisateurAction() : JsonModel { $term = $this->params()->fromQuery('term'); $res = $this->getUserService()->findByTerm($term); foreach ($res as $user) { $result[] = array( 'id' => $user->getId(), 'label' => $user->getDisplayName(), 'extra' => "<span class='badge' id='app' >" . (($user->getEmail())?:"Aucun mail") . "</span>", ); } return new JsonModel($result); } public function listingAction() { $users = $this->getUserService()->getUtilisateurs(); Loading Loading
config/merged/role.config.php +4 −0 Original line number Diff line number Diff line Loading @@ -129,6 +129,10 @@ return [ 'service_manager' => [ 'factories' => [ 'UnicaenUtilisateur\Provider\Role\Config' => 'UnicaenUtilisateur\Provider\Role\ConfigServiceFactory', 'UnicaenUtilisateur\Provider\Role\Config' => 'UnicaenUtilisateur\Provider\Role\ConfigServiceFactory', 'UnicaenUtilisateur\Provider\Role\DbRole' => 'UnicaenUtilisateur\Provider\Role\DbRoleServiceFactory', 'UnicaenUtilisateur\Provider\Role\Username' => 'UnicaenUtilisateur\Provider\Role\UsernameServiceFactory', RoleService::class => RoleServiceFactory::class, ], ], Loading
config/merged/utilisateur.config.php +11 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ return [ 'action' => [ 'index', 'rechercher', 'rechercher-utilisateur', 'listing', 'export' ], Loading Loading @@ -151,6 +152,16 @@ return [ ], ], ], 'rechercher-utilisateur' => [ 'type' => Literal::class, 'options' => [ 'route' => '/rechercher-utilisateur', 'defaults' => [ 'controller' => UtilisateurController::class, 'action' => 'rechercher-utilisateur', ], ], ], 'add-role' => [ 'type' => Segment::class, 'options' => [ Loading
config/module.config.php +22 −3 Original line number Diff line number Diff line Loading @@ -19,8 +19,6 @@ use UnicaenUtilisateur\View\Helper\UserProfileSelectRadioItem; use UnicaenUtilisateur\View\Helper\UserProfileSelectRadioItemFactory; use UnicaenUtilisateur\View\Helper\UserStatus; use UnicaenUtilisateur\View\Helper\UserStatusFactory; use UnicaenUtilisateur\View\Helper\UserUsurpationHelper; use UnicaenUtilisateur\View\Helper\UserUsurpationHelperFactory; return [ 'doctrine' => [ Loading @@ -46,12 +44,34 @@ return [ ], ], 'bjyauthorize' => [ /* role providers simply provide a list of roles that should be inserted * into the Zend\Acl instance. the module comes with two providers, one * to specify roles in a config file and one to load roles using a * Zend\Db adapter. */ 'role_providers' => [ /** * 2 rôles doivent systématiquement exister dans les ACL : * - le rôle par défaut 'guest', c'est le rôle de tout utilisateur non authentifié. * - le rôle 'user', c'est le rôle de tout utilisateur authentifié. */ 'UnicaenUtilisateur\Provider\Role\Config' => [ 'guest' => ['name' => "Non authentifié(e)", 'selectable' => false, 'children' => [ 'user' => ['name' => "Authentifié(e)", 'selectable' => false], ]], ], ], ], 'service_manager' => [ 'invokables' => [ 'UserRoleSelectedEventListener' => UserRoleSelectedEventListener::class, ], 'factories' => [ // 'UserAuthenticatedEventListener' => UserAuthenticatedEventListenerFactory::class, HistoriqueListener::class => HistoriqueListenerFactory::class, ], ], Loading Loading @@ -79,7 +99,6 @@ return [ UserInfo::class => UserInfoFactory::class, UserProfileSelect::class => UserProfileSelectFactory::class, UserProfileSelectRadioItem::class => UserProfileSelectRadioItemFactory::class, UserUsurpationHelper::class => UserUsurpationHelperFactory::class, ], ], ];
src/UnicaenUtilisateur/Acl/NamedRole.php 0 → 100644 +127 −0 Original line number Diff line number Diff line <?php namespace UnicaenUtilisateur\Acl; use Zend\Permissions\Acl\Role\RoleInterface; /** * Rôle avec nom explicite (humainement intelligible). * * @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr> */ class NamedRole extends \BjyAuthorize\Acl\Role { /** * @var string */ protected $roleName; /** * @var string */ protected $roleDescription; /** * @var bool */ protected $selectable = true; /** * Constructeur. * * @param string|null $id * @param RoleInterface|string|null $parent * @param string $name * @param string $description * @param bool $selectable */ public function __construct($id = null, $parent = null, $name = null, $description = null, $selectable = true) { parent::__construct($id, $parent); $this ->setRoleName($name ?: $id) ->setRoleDescription($description ?: null) ->setSelectable($selectable); } /** * Retourne la représentation littérale de ce rôle. * * @return string */ public function __toString() { return $this->getRoleName() ?: $this->getRoleId(); } /** * Retourne le nom du rôle. * * @return string */ public function getRoleName() { return $this->roleName; } /** * Spécifie le nom du rôle. * * @param string $roleName * @return self */ public function setRoleName($roleName) { $this->roleName = (string) $roleName; return $this; } /** * Retourne la description du rôle. * * @return string */ public function getRoleDescription() { return $this->roleDescription; } /** * Spécifie la description du rôle. * * @param string $roleDescription * @return self */ public function setRoleDescription($roleDescription) { $this->roleDescription = (string) $roleDescription; return $this; } /** * Teste si ce rôle est sélectionnable par l'utilisateur. * Cela concerne les applications qui permettent à l'utilisateur de choisir son profil courant * parmi les différents rôles qu'il possède. * * @return bool */ public function getSelectable() { return $this->selectable; } /** * Spécifie si ce rôle est sélectionnable par l'utilisateur. * Cela concerne les applications qui permettent à l'utilisateur de choisir son profil courant * parmi les différents rôles qu'il possède. * * @param bool $selectable * @return \UnicaenAuth\Acl\NamedRole */ public function setSelectable($selectable = true) { $this->selectable = $selectable; return $this; } } No newline at end of file
src/UnicaenUtilisateur/Controller/UtilisateurController.php +18 −2 Original line number Diff line number Diff line Loading @@ -63,7 +63,7 @@ class UtilisateurController extends AbstractActionController { default : if (isset($this->recherche[$source])) { $people = $this->recherche[$source]->findById($id); $utilisateur = $this->getUserService()->importFromRechercheIndividuResultatInterface($people, 'ldap'); $utilisateur = $this->getUserService()->importFromRechercheIndividuResultatInterface($people, $source); $params = []; if (!$this->userService->exist($utilisateur->getUsername())) { Loading Loading @@ -228,7 +228,8 @@ class UtilisateurController extends AbstractActionController { return $vm; } public function rechercherAction() { public function rechercherAction() : JsonModel { $term = $this->params()->fromQuery('term'); $serviceName = $this->params()->fromRoute('service-name'); Loading @@ -254,6 +255,21 @@ class UtilisateurController extends AbstractActionController { return new JsonModel($result); } public function rechercherUtilisateurAction() : JsonModel { $term = $this->params()->fromQuery('term'); $res = $this->getUserService()->findByTerm($term); foreach ($res as $user) { $result[] = array( 'id' => $user->getId(), 'label' => $user->getDisplayName(), 'extra' => "<span class='badge' id='app' >" . (($user->getEmail())?:"Aucun mail") . "</span>", ); } return new JsonModel($result); } public function listingAction() { $users = $this->getUserService()->getUtilisateurs(); Loading