Skip to content
Snippets Groups Projects
Commit 7fc79b1c authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Ajout du champs description pour les rôles + Ajout d'un view helper pour l'affichage des rôles

parent a94489a6
Branches main
No related tags found
No related merge requests found
Pipeline #18339 passed
...@@ -4,6 +4,7 @@ use Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain; ...@@ -4,6 +4,7 @@ use Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain;
use Doctrine\ORM\Mapping\Driver\XmlDriver; use Doctrine\ORM\Mapping\Driver\XmlDriver;
use UnicaenUtilisateur\ORM\Event\Listeners\HistoriqueListener; use UnicaenUtilisateur\ORM\Event\Listeners\HistoriqueListener;
use UnicaenUtilisateur\ORM\Event\Listeners\HistoriqueListenerFactory; use UnicaenUtilisateur\ORM\Event\Listeners\HistoriqueListenerFactory;
use UnicaenUtilisateur\View\Helper\RoleViewHelper;
use UnicaenUtilisateur\View\Helper\UserConnection; use UnicaenUtilisateur\View\Helper\UserConnection;
use UnicaenUtilisateur\View\Helper\UserConnectionFactory; use UnicaenUtilisateur\View\Helper\UserConnectionFactory;
use UnicaenUtilisateur\View\Helper\UserCurrent; use UnicaenUtilisateur\View\Helper\UserCurrent;
...@@ -78,6 +79,9 @@ return [ ...@@ -78,6 +79,9 @@ return [
], ],
'view_helpers' => [ 'view_helpers' => [
'invokables' => [
'role' => RoleViewHelper::class,
],
'aliases' => [ 'aliases' => [
'userCurrent' => UserCurrent::class, 'userCurrent' => UserCurrent::class,
'userStatus' => UserStatus::class, 'userStatus' => UserStatus::class,
......
...@@ -7,6 +7,7 @@ CREATE TABLE UNICAEN_UTILISATEUR_ROLE ( ...@@ -7,6 +7,7 @@ CREATE TABLE UNICAEN_UTILISATEUR_ROLE (
ID NUMBER(*, 0) NOT NULL, ID NUMBER(*, 0) NOT NULL,
ROLE_ID VARCHAR2(64) NOT NULL, ROLE_ID VARCHAR2(64) NOT NULL,
LIBELLE VARCHAR2(255) NOT NULL, LIBELLE VARCHAR2(255) NOT NULL,
DESCRIPTION CLOB NOT NULL,
IS_DEFAULT NUMBER(1) DEFAULT 0 NOT NULL, IS_DEFAULT NUMBER(1) DEFAULT 0 NOT NULL,
IS_AUTO NUMBER(1) DEFAULT 0 NOT NULL, IS_AUTO NUMBER(1) DEFAULT 0 NOT NULL,
PARENT_ID NUMBER(*, 0), PARENT_ID NUMBER(*, 0),
......
...@@ -5,6 +5,7 @@ CREATE TABLE UNICAEN_UTILISATEUR_ROLE ( ...@@ -5,6 +5,7 @@ CREATE TABLE UNICAEN_UTILISATEUR_ROLE (
ID SERIAL PRIMARY KEY, ID SERIAL PRIMARY KEY,
ROLE_ID VARCHAR(64) NOT NULL, ROLE_ID VARCHAR(64) NOT NULL,
LIBELLE VARCHAR(255) NOT NULL, LIBELLE VARCHAR(255) NOT NULL,
DESCRIPTION TEXT NOT NULL,
IS_DEFAULT BOOLEAN DEFAULT false NOT NULL, IS_DEFAULT BOOLEAN DEFAULT false NOT NULL,
IS_AUTO BOOLEAN DEFAULT false NOT NULL, IS_AUTO BOOLEAN DEFAULT false NOT NULL,
PARENT_ID INTEGER, PARENT_ID INTEGER,
......
...@@ -2,6 +2,14 @@ Module Unicaen Utilisateur ...@@ -2,6 +2,14 @@ Module Unicaen Utilisateur
======================= =======================
------------------------ ------------------------
Changelogs
==========
**5.0.7**
* Ajout du champs description pour les rôles
* Ajout d'un view helper pour l'affichage des rôles ```echo $this->role($role)```
* Début de nettoyage des classes vers la syntaxe PHP8
Description Description
======================= =======================
......
...@@ -8,325 +8,152 @@ use UnicaenPrivilege\Entity\Db\PrivilegeInterface; ...@@ -8,325 +8,152 @@ use UnicaenPrivilege\Entity\Db\PrivilegeInterface;
abstract class AbstractRole implements RoleInterface abstract class AbstractRole implements RoleInterface
{ {
/** protected ?int $id = null;
* @var int protected ?string $roleId = null;
*/ protected ?string $libelle = null;
protected $id; protected ?string $description = null;
protected bool $default = false;
/** protected bool $auto = false;
* @var string protected ?RoleInterface $parent = null;
*/ protected ?string $ldapFilter = null;
protected $roleId; protected bool $accessibleExterieur = true;
/** protected Collection $users;
* @var string protected Collection $privileges;
*/
protected $libelle;
/**
* @var boolean
*/
protected $default = false;
/**
* @var boolean
*/
protected $auto = false;
/**
* @var RoleInterface
*/
protected $parent;
/**
* @var string
*/
protected $ldapFilter;
/**
* @var boolean
*/
protected $accessibleExterieur = true;
/**
* @var ArrayCollection
*/
protected $users;
/**
* @var ArrayCollection
*/
protected $privileges;
/**
* AbstractRole constructor.
*/
public function __construct() public function __construct()
{ {
$this->users = new ArrayCollection(); $this->users = new ArrayCollection();
$this->privileges = new ArrayCollection();
} }
/**
* @return string
*/
public function __toString()
{
return $this->getLibelle();
}
/**
* Get id.
*
* @return int|null
*/
public function getId() : ?int public function getId() : ?int
{ {
return $this->id; return $this->id;
} }
/** public function setId(?int $id) : void
* Set id.
*
* @param int $id
* @return RoleInterface
*/
public function setId($id)
{ {
$this->id = (int)$id; $this->id = (int)$id;
return $this;
} }
/** public function getRoleId() : ?string
* Get roleId.
*
* @return string
*/
public function getRoleId()
{ {
return $this->roleId; return $this->roleId;
} }
/** public function setRoleId(?string $roleId) : void
* Set roleId.
*
* @param string $roleId
* @return RoleInterface
*/
public function setRoleId($roleId)
{ {
$this->roleId = (string)$roleId; $this->roleId = (string)$roleId;
return $this;
} }
/** public function getLibelle() : ?string
* Get libelle.
*
* @return string
*/
public function getLibelle()
{ {
return $this->libelle; return $this->libelle;
} }
/** public function setLibelle(?string $libelle) : void
* Set libelle.
*
* @param string|null $libelle
* @return RoleInterface
*/
public function setLibelle($libelle)
{ {
$this->libelle = $libelle; $this->libelle = $libelle;
return $this;
} }
/** public function getDescription(): ?string
* Is this role the default one ? {
* return $this->description;
* @return boolean }
*/
public function isDefault() public function setDescription(?string $description): void
{
$this->description = $description;
}
public function isDefault() : bool
{ {
return $this->default; return $this->default;
} }
/** public function setDefault(bool $default) : void
* Set this role as the default one.
*
* @param boolean $default
* @return RoleInterface
*/
public function setDefault($default)
{ {
$this->default = (boolean) $default; $this->default = (boolean) $default;
return $this;
} }
/** public function isAuto() : bool
* Is auto ?
*
* @return boolean
*/
public function isAuto()
{ {
return $this->auto; return $this->auto;
} }
/** public function setAuto(bool $auto) : void
* Set auto.
*
* @param boolean $auto
* @return RoleInterface
*/
public function setAuto($auto)
{ {
$this->auto = $auto; $this->auto = $auto;
return $this;
} }
/** public function isAccessibleExterieur() : bool
* Is accessible from the outside ?
*
* @return boolean
*/
public function isAccessibleExterieur()
{ {
return $this->accessibleExterieur; return $this->accessibleExterieur;
} }
/** public function setAccessibleExterieur(bool $accessibleExterieur) : void
* Set accessible from the outside.
*
* @param boolean $accessibleExterieur
* @return RoleInterface
*/
public function setAccessibleExterieur($accessibleExterieur)
{ {
$this->accessibleExterieur = $accessibleExterieur; $this->accessibleExterieur = $accessibleExterieur;
return $this;
} }
/** public function getParent() : ?RoleInterface
* Get the parent role
*
* @return RoleInterface
*/
public function getParent()
{ {
return $this->parent; return $this->parent;
} }
/** public function setParent(?RoleInterface $parent = null) : void
* Set the parent role.
*
* @param RoleInterface|null $parent
* @return RoleInterface
*/
public function setParent(?RoleInterface $parent = null)
{ {
$this->parent = $parent; $this->parent = $parent;
return $this;
} }
/** public function getLdapFilter() : ?string
* Get ldapFilter.
*
* @return string
*/
public function getLdapFilter()
{ {
return $this->ldapFilter; return $this->ldapFilter;
} }
/** public function setLdapFilter(?string $ldapFilter) : void
* Set ldapFilter.
*
* @param string $ldapFilter
* @return RoleInterface
*/
public function setLdapFilter($ldapFilter)
{ {
$this->ldapFilter = $ldapFilter; $this->ldapFilter = $ldapFilter;
return $this;
} }
/** public function getUsers() : Collection
* Get users.
*
* @return Collection
*/
public function getUsers()
{ {
return $this->users; return $this->users;
} }
/** public function addUser(UserInterface $user) : void
* Add user.
*
* @param UserInterface $user
* @return RoleInterface
*/
public function addUser(UserInterface $user)
{ {
$this->users->add($user); $this->users->add($user);
return $this;
} }
/** public function removeUser(UserInterface $user) : void
* Remove user.
*
* @param UserInterface $user
* @return RoleInterface
*/
public function removeUser(UserInterface $user)
{ {
$this->users->removeElement($user); $this->users->removeElement($user);
return $this;
} }
/** public function getPrivileges() : Collection
* Get privileges.
*
* @return Collection
*/
public function getPrivileges()
{ {
return $this->privileges; return $this->privileges;
} }
/** public function addPrivilege(PrivilegeInterface $privilege) : void
* Add privilege.
*
* @param PrivilegeInterface $privilege
* @return RoleInterface
*/
public function addPrivilege(PrivilegeInterface $privilege)
{ {
$this->privileges->add($privilege); $this->privileges->add($privilege);
return $this;
} }
/** public function removePrivilege(PrivilegeInterface $privilege) : void
* Remove privilege.
*
* @param PrivilegeInterface $privilege
* @return RoleInterface
*/
public function removePrivilege(PrivilegeInterface $privilege)
{ {
$this->privileges->removeElement($privilege); $this->privileges->removeElement($privilege);
}
/** Fonctions magiques ********************************************************************************************/
return $this; public function __toString() : string
{
return $this->getLibelle();
} }
} }
\ No newline at end of file
...@@ -19,9 +19,9 @@ ...@@ -19,9 +19,9 @@
<generator strategy="IDENTITY"/> <generator strategy="IDENTITY"/>
</id> </id>
<!-- <field name="id" type="integer" column="ID" nullable="false"/>-->
<field name="roleId" type="string" column="ROLE_ID" length="64" nullable="false"/> <field name="roleId" type="string" column="ROLE_ID" length="64" nullable="false"/>
<field name="libelle" type="string" column="LIBELLE" length="64" nullable="false"/> <field name="libelle" type="string" column="LIBELLE" length="64" nullable="false"/>
<field name="description" type="string" column="DESCRIPTION" length="9999" nullable="false"/>
<field name="default" type="boolean" column="IS_DEFAULT" nullable="false"/> <field name="default" type="boolean" column="IS_DEFAULT" nullable="false"/>
<field name="auto" type="boolean" column="IS_AUTO" nullable="false"/> <field name="auto" type="boolean" column="IS_AUTO" nullable="false"/>
<field name="ldapFilter" type="string" column="LDAP_FILTER" length="255" nullable="true"/> <field name="ldapFilter" type="string" column="LDAP_FILTER" length="255" nullable="true"/>
......
...@@ -8,174 +8,34 @@ use UnicaenPrivilege\Entity\Db\PrivilegeInterface; ...@@ -8,174 +8,34 @@ use UnicaenPrivilege\Entity\Db\PrivilegeInterface;
interface RoleInterface extends HierarchicalRoleInterface interface RoleInterface extends HierarchicalRoleInterface
{ {
/** public function __toString() : string;
* @return string
*/ public function getId() : ?int;
public function __toString(); public function setId(?int $id) : void;
public function getRoleId() : ?string;
public function setRoleId(?string $roleId) : void;
public function getLibelle() : ?string;
public function setLibelle(?string $libelle) : void;
public function getDescription() : ?string;
public function setDescription(?string $description) : void;
public function isDefault() : bool;
public function setDefault(bool $default) : void;
public function isAuto() : bool;
public function setAuto(bool $auto) : void;
public function isAccessibleExterieur() : bool;
public function setAccessibleExterieur(bool $accessibleExterieur) : void;
public function getParent() : ?RoleInterface;
public function setParent(?RoleInterface $parent = null) : void;
public function getLdapFilter() : ?string;
public function setLdapFilter(?string $ldapFilter) : void;
public function getUsers() : Collection;
public function addUser(UserInterface $user) : void;
public function removeUser(UserInterface $user) : void;
/**
* Get id.
*
* @return int
*/
public function getId();
/**
* Set id.
*
* @param int $id
* @return self
*/
public function setId($id);
/**
* Get roleId.
*
* @return string
*/
public function getRoleId();
/**
* Set roleId.
*
* @param string $roleId
* @return RoleInterface
*/
public function setRoleId($roleId);
/**
* Get libelle.
*
* @return string
*/
public function getLibelle();
/**
* Set libelle.
*
* @param string|null $libelle
* @return RoleInterface
*/
public function setLibelle($libelle);
/**
* Is this role the default one ?
*
* @return boolean
*/
public function isDefault();
/**
* Set this role as the default one.
*
* @param boolean $default
* @return RoleInterface
*/
public function setDefault($default);
/**
* Is auto ?
*
* @return boolean
*/
public function isAuto();
/**
* Set auto.
*
* @param boolean $auto
* @return RoleInterface
*/
public function setAuto($auto);
/**
* Get parent.
*
* @return RoleInterface|null
*/
public function getParent();
/**
* Set parent.
*
* @param RoleInterface|null $parent
* @return RoleInterface
*/
public function setParent(RoleInterface $parent = null);
/**
* Get ldapFilter.
*
* @return string
*/
public function getLdapFilter();
/**
* Set ldapFilter.
*
* @param string $ldapFilter
* @return RoleInterface
*/
public function setLdapFilter($ldapFilter);
/**
* Check accessibleExterieur.
*
* @return boolean
*/
public function isAccessibleExterieur();
/**
* Set accessibleExterieur.
*
* @param boolean $accessibleExterieur
* @return RoleInterface
*/
public function setAccessibleExterieur($accessibleExterieur);
/**
* Get users.
*
* @return Collection
*/
public function getUsers();
/**
* Add user.
*
* @param UserInterface $user
* @return RoleInterface
*/
public function addUser(UserInterface $user);
/**
* Remove user.
*
* @param UserInterface $user
* @return RoleInterface
*/
public function removeUser(UserInterface $user);
/**
* Get privileges.
*
* @return Collection
*/
public function getPrivileges(); public function getPrivileges();
public function addPrivilege(PrivilegeInterface $privilege) : void;
/** public function removePrivilege(PrivilegeInterface $privilege) : void;
* Add privilege.
*
* @param PrivilegeInterface $privilege
* @return RoleInterface
*/
public function addPrivilege(PrivilegeInterface $privilege);
/**
* Remove privilege.
*
* @param PrivilegeInterface $privilege
* @return RoleInterface
*/
public function removePrivilege(PrivilegeInterface $privilege);
} }
\ No newline at end of file
...@@ -6,6 +6,7 @@ use Application\Entity\Db\UtilisateurRole; ...@@ -6,6 +6,7 @@ use Application\Entity\Db\UtilisateurRole;
use DoctrineModule\Form\Element\ObjectSelect; use DoctrineModule\Form\Element\ObjectSelect;
use DoctrineModule\Validator\NoObjectExists; use DoctrineModule\Validator\NoObjectExists;
use DoctrineModule\Validator\UniqueObject; use DoctrineModule\Validator\UniqueObject;
use Laminas\Form\Element\Textarea;
use UnicaenApp\Service\EntityManagerAwareTrait; use UnicaenApp\Service\EntityManagerAwareTrait;
use UnicaenUtilisateur\Entity\Db\UserInterface; use UnicaenUtilisateur\Entity\Db\UserInterface;
use UnicaenUtilisateur\Form\Strategy\RoleParentStrategy; use UnicaenUtilisateur\Form\Strategy\RoleParentStrategy;
...@@ -43,6 +44,18 @@ class RoleForm extends Form ...@@ -43,6 +44,18 @@ class RoleForm extends Form
'id' => 'libelle', 'id' => 'libelle',
], ],
]); ]);
$this->add([
'type' => Textarea::class,
'name' => 'description',
'options' => [
'label' => "Description :",
'label_attributes' => [
],
],
'attributes' => [
'id' => 'description',
],
]);
$this->add([ $this->add([
'type' => Text::class, 'type' => Text::class,
...@@ -177,7 +190,9 @@ class RoleForm extends Form ...@@ -177,7 +190,9 @@ class RoleForm extends Form
], ],
], ],
], ],
'description' => [
'required' => true,
],
'roleId' => [ 'roleId' => [
'required' => true, 'required' => true,
'validators' => [ 'validators' => [
......
<?php
namespace UnicaenUtilisateur\View\Helper;
use Laminas\View\Helper\AbstractHelper;
use Laminas\View\Helper\Partial;
use Laminas\View\Renderer\PhpRenderer;
use Laminas\View\Resolver\TemplatePathStack;
use Prestation\Entity\Db\Type;
use UnicaenUtilisateur\Entity\Db\RoleInterface;
class RoleViewHelper extends AbstractHelper
{
/**
* @param RoleInterface|null $role
* @param array $options
* @return string|Partial
*
* options :: tooltip
*/
public function __invoke(RoleInterface $role, array $options = [])
{
/** @var PhpRenderer $view */
$view = $this->getView();
$view->resolver()->attach(new TemplatePathStack(['script_paths' => [__DIR__ . "/partial"]]));
return $view->partial('role', ['role' => $role, 'options' => $options]);
}
}
\ No newline at end of file
<?php
use UnicaenUtilisateur\Entity\Db\RoleInterface;
/**
* @see \UnicaenUtilisateur\View\Helper\RoleViewHelper
* @var RoleInterface $role
* @var array $options
*/
?>
<span title="<?php echo $role->getDescription(); ?>">
<?php echo $role->getLibelle(); ?>
</span>
<?php echo $role->isDefault()
? '<i title="par défaut" class="fas fa-check-circle text-muted"></i>' : ''; ?>
...@@ -73,9 +73,7 @@ $this->headTitle("Rôles"); ...@@ -73,9 +73,7 @@ $this->headTitle("Rôles");
?> ?>
<tr> <tr>
<td> <td>
<?php echo $role->getLibelle(); ?> <?php echo $this->role($role); ?>
<?php echo $role->isDefault()
? '<i title="par défaut" class="fas fa-check-circle text-muted"></i>' : ''; ?>
</td> </td>
<td> <td>
<?php echo ($parent = $role->getParent()) ? $parent->getLibelle() : ''; ?> <?php echo ($parent = $role->getParent()) ? $parent->getLibelle() : ''; ?>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment