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

init

parents
Branches
Tags 1.0.3
No related merge requests found
Pipeline #16892 passed
Showing
with 885 additions and 0 deletions
image: registre.unicaen.fr:5000/unicaen-dev-php7.3-apache
stages:
- publish
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- vendor/
update-satis:
stage: publish
script:
- curl https://gest.unicaen.fr/packagist/update
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/indicateur.iml" filepath="$PROJECT_DIR$/.idea/indicateur.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PhpProjectSharedConfiguration" php_language_level="7.1">
<option name="suggestChangeDefaultLanguageLevel" value="false" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="SqlDialectMappings">
<file url="file://$PROJECT_DIR$/documentation/02_privileges.sql" dialect="GenericSQL" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
<?php
/**
* Laminas Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/LaminasSkeletonApplication for the canonical source repository
* @copyright Copyright (c) 2005-2012 Laminas Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace Indicateur;
use Laminas\Config\Factory as ConfigFactory;
use Laminas\Console\Adapter\AdapterInterface as Console;
use Laminas\Mvc\ModuleRouteListener;
use Laminas\Mvc\MvcEvent;
use Laminas\Stdlib\ArrayUtils;
use Laminas\Stdlib\Glob;
class Module
{
public function onBootstrap(MvcEvent $e)
{
$e->getApplication()->getServiceManager()->get('translator');
$eventManager = $e->getApplication()->getEventManager();
$moduleRouteListener = new ModuleRouteListener();
$moduleRouteListener->attach($eventManager);
}
public function getConfig()
{
$configInit = [
__DIR__ . '/config/module.config.php'
];
$configFiles = ArrayUtils::merge(
$configInit,
Glob::glob(__DIR__ . '/config/merged/{,*.}{config}.php', Glob::GLOB_BRACE)
);
return ConfigFactory::fromFiles($configFiles);
}
public function getAutoloaderConfig()
{
return array(
'Laminas\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
),
),
);
}
public function getConsoleUsage(Console $console)
{
return [
'indicateur-refresh' => "Rafraichir la liste des indicateurs",
'indicateur-notifier' => "Notifier les personnes abonnées à des indicateurs avec les données du dernier rafraichissement",
];
}
}
{
"name": "unicaen/indicateur",
"description": "Module de gestion d'indicateur",
"repositories": [
{
"type": "composer",
"url": "https://gest.unicaen.fr/packagist"
}
],
"require": {
"unicaen/app": "^4|^5",
"unicaen/utilisateur": "^4|^5",
"unicaen/privilege": "^4|^5",
"unicaen/mail": "^4|^5"
},
"autoload": {
"psr-0": [],
"classmap": [
"./Module.php"
]
}
}
<?php
namespace Application;
use Indicateur\Controller\AbonnementController;
use Indicateur\Controller\AbonnementControllerFactory;
use Indicateur\Provider\Privilege\AbonnementPrivileges;
use Indicateur\Service\Abonnement\AbonnementService;
use Indicateur\Service\Abonnement\AbonnementServiceFactory;
use UnicaenPrivilege\Guard\PrivilegeController;
use Laminas\Mvc\Console\Router\Simple;
use Laminas\Router\Http\Literal;
use Laminas\Router\Http\Segment;
return [
'bjyauthorize' => [
'guards' => [
PrivilegeController::class => [
[
'controller' => AbonnementController::class,
'action' => [
'souscrire',
'resilier',
'notifier'
],
'privileges' => [
AbonnementPrivileges::EDITER,
],
],
[
'controller' => AbonnementController::class,
'action' => [
'notifier-console'
],
'roles' => [],
],
],
],
],
'router' => [
'routes' => [
'abonnement' => [
'type' => Literal::class,
'options' => [
'route' => '/abonnement',
'defaults' => [
'controller' => AbonnementController::class,
],
],
'may_terminate' => false,
'child_routes' => [
'souscrire' => [
'type' => Segment::class,
'options' => [
'route' => '/souscrire/:indicateur',
'defaults' => [
'controller' => AbonnementController::class,
'action' => 'souscrire'
],
],
'may_terminate' => true,
],
'resilier' => [
'type' => Segment::class,
'options' => [
'route' => '/resilier/:indicateur',
'defaults' => [
'controller' => AbonnementController::class,
'action' => 'resilier'
],
],
'may_terminate' => true,
],
'notifier' => [
'type' => Literal::class,
'options' => [
'route' => '/notifier',
'defaults' => [
'controller' => AbonnementController::class,
'action' => 'notifier'
],
],
'may_terminate' => true,
],
],
],
],
],
'console' => [
'router' => [
'routes' => [
'indicateur-notifier' => [
'type' => Simple::class,
'options' => [
'route' => 'indicateur-notifier',
'defaults' => [
'controller' => AbonnementController::class,
'action' => 'notifier-console'
],
],
],
],
],
],
'service_manager' => [
'factories' => [
AbonnementService::class => AbonnementServiceFactory::class,
],
],
'controllers' => [
'factories' => [
AbonnementController::class => AbonnementControllerFactory::class,
],
],
'form_elements' => [
'factories' => [],
],
'hydrators' => [
'factories' => [],
]
];
\ No newline at end of file
<?php
namespace Application;
use Indicateur\Controller\IndexController;
use Indicateur\Controller\IndexControllerFactory;
use Indicateur\Provider\Privilege\IndicateurPrivileges;
use UnicaenPrivilege\Guard\PrivilegeController;
use Laminas\Router\Http\Literal;
return [
'bjyauthorize' => [
'guards' => [
PrivilegeController::class => [
[
'controller' => IndexController::class,
'action' => [
'index',
'abonnement'
],
'privileges' => [
IndicateurPrivileges::AFFICHER,
],
],
],
],
],
'navigation' => [
'default' => [
'home' => [
'pages' => [
'gestion' => [
'pages' => [
'emc2' => [
'label' => 'Mon EMC2',
'route' => 'mes-indicateurs',
'resource' => PrivilegeController::getResourceId(IndexController::class, 'index'),
'order' => 10001,
'dropdown-header' => true,
],
'indeicateur' => [
'label' => 'Mes indicateurs',
'route' => 'mes-indicateurs',
'resource' => PrivilegeController::getResourceId(IndexController::class, 'index'),
'order' => 10001,
'icon' => 'fas fa-angle-right',
],
],
],
],
],
],
],
'router' => [
'routes' => [
'mes-indicateurs' => [
'type' => Literal::class,
'options' => [
'route' => '/mes-indicateurs',
'defaults' => [
'controller' => IndexController::class,
'action' => 'index',
],
],
'may_terminate' => true,
'child_routes' => [
'abonnement' => [
'type' => Literal::class,
'options' => [
'route' => '/abonnement',
'defaults' => [
'controller' => IndexController::class,
'action' => 'abonnement',
],
],
],
],
],
],
],
'service_manager' => [
'factories' => [
],
],
'controllers' => [
'factories' => [
IndexController::class => IndexControllerFactory::class,
],
],
'form_elements' => [
'factories' => [
],
],
'hydrators' => [
'factories' => [
],
]
];
\ No newline at end of file
<?php
namespace Application;
use Indicateur\Controller\IndicateurController;
use Indicateur\Controller\IndicateurControllerFactory;
use Indicateur\Form\Indicateur\IndicateurForm;
use Indicateur\Form\Indicateur\IndicateurFormFactory;
use Indicateur\Form\Indicateur\IndicateurHydrator;
use Indicateur\Form\Indicateur\IndicateurHydratorFactory;
use Indicateur\Provider\Privilege\IndicateurPrivileges;
use Indicateur\Service\Indicateur\IndicateurService;
use Indicateur\Service\Indicateur\IndicateurServiceFactory;
use UnicaenPrivilege\Guard\PrivilegeController;
use Laminas\Mvc\Console\Router\Simple;
use Laminas\Router\Http\Literal;
use Laminas\Router\Http\Segment;
return [
'bjyauthorize' => [
'guards' => [
PrivilegeController::class => [
[
'controller' => IndicateurController::class,
'action' => [
'index',
'afficher',
'rafraichir',
'creer',
'modifier',
'detruire',
'exporter',
],
'privileges' => [
IndicateurPrivileges::AFFICHER,
],
],
[
'controller' => IndicateurController::class,
'action' => [
'rafraichir-console',
],
'roles' => [],
],
],
],
],
'router' => [
'routes' => [
'indicateurs' => [
'type' => Literal::class,
'options' => [
'route' => '/indicateurs',
'defaults' => [
'controller' => IndicateurController::class,
'action' => 'index',
],
],
'may_terminate' => true,
],
'indicateur' => [
'type' => Literal::class,
'options' => [
'route' => '/indicateur',
],
'may_terminate' => false,
'child_routes' => [
'afficher' => [
'type' => Segment::class,
'options' => [
'route' => '/afficher/:indicateur',
'defaults' => [
'controller' => IndicateurController::class,
'action' => 'afficher',
],
],
'may_terminate' => true,
],
'rafraichir' => [
'type' => Segment::class,
'options' => [
'route' => '/rafraichir/:indicateur',
'defaults' => [
'controller' => IndicateurController::class,
'action' => 'rafraichir',
],
],
'may_terminate' => true,
],
'creer' => [
'type' => Literal::class,
'options' => [
'route' => '/creer',
'defaults' => [
'controller' => IndicateurController::class,
'action' => 'creer',
],
],
'may_terminate' => true,
],
'modifier' => [
'type' => Segment::class,
'options' => [
'route' => '/modifier/:indicateur',
'defaults' => [
'controller' => IndicateurController::class,
'action' => 'modifier',
],
],
'may_terminate' => true,
],
'detruire' => [
'type' => Segment::class,
'options' => [
'route' => '/detruire/:indicateur',
'defaults' => [
'controller' => IndicateurController::class,
'action' => 'detruire',
],
],
'may_terminate' => true,
],
'exporter' => [
'type' => Segment::class,
'options' => [
'route' => '/exporter/:indicateur',
'defaults' => [
'controller' => IndicateurController::class,
'action' => 'exporter',
],
],
'may_terminate' => true,
],
],
],
],
],
'console' => [
'router' => [
'routes' => [
'indicateur-refresh' => [
'type' => Simple::class,
'options' => [
'route' => 'indicateur-refresh',
'defaults' => [
'controller' => IndicateurController::class,
'action' => 'rafraichir-console'
],
],
],
],
],
],
'service_manager' => [
'factories' => [
IndicateurService::class => IndicateurServiceFactory::class,
],
],
'controllers' => [
'factories' => [
IndicateurController::class => IndicateurControllerFactory::class,
],
],
'form_elements' => [
'factories' => [
IndicateurForm::class => IndicateurFormFactory::class,
],
],
'hydrators' => [
'factories' => [
IndicateurHydrator::class => IndicateurHydratorFactory::class,
],
]
];
\ No newline at end of file
<?php
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain;
use Doctrine\ORM\Mapping\Driver\XmlDriver;
use Indicateur\Provider\Privilege\IndicateurPrivileges;
use UnicaenPrivilege\Guard\PrivilegeController;
return array(
'bjyauthorize' => [
'guards' => [
PrivilegeController::class => [],
],
],
'doctrine' => [
'driver' => [
'orm_default' => [
'class' => MappingDriverChain::class,
'drivers' => [
'Indicateur\Entity\Db' => 'orm_default_xml_driver',
],
],
'orm_default_xml_driver' => [
'class' => XmlDriver::class,
'cache' => 'apc',
'paths' => [
__DIR__ . '/../src/Indicateur/Entity/Db/Mapping',
],
],
],
'cache' => [
'apc' => [
'namespace' => 'PREECOG__' . __NAMESPACE__,
],
],
],
'navigation' => [
'default' => [
'home' => [
'pages' => [
'administration' => [
'pages' => [
'indicateurs' => [
'label' => 'Indicateurs',
'route' => 'indicateurs',
'resource' => IndicateurPrivileges::getResourceId(IndicateurPrivileges::AFFICHER),
'order' => 4000,
'icon' => 'fas fa-angle-right',
],
],
],
],
],
],
],
'router' => [
'routes' => [
],
],
'form_elements' => [
'factories' => [
],
],
'hydrators' => [
'invokables' => [
],
],
'controllers' => [
'factories' => [
],
],
'view_helpers' => [
'invokables' => [
],
],
'view_manager' => [
'template_path_stack' => [
__DIR__ . '/../view',
],
],
);
create table unicaen_indicateur
(
id serial constraint indicateur_pk primary key,
titre varchar(256) not null,
description varchar(2048),
requete varchar(4096) not null,
dernier_rafraichissement timestamp,
view_id varchar(256),
entity varchar(256)
);
create table unicaen_indicateur_abonnement
(
id serial constraint abonnement_pk primary key,
user_id integer constraint indicateur_abonnement_user_id_fk references unicaen_utilisateur_user on delete cascade,
indicateur_id integer constraint indicateur_abonnement_indicateur_definition_id_fk references unicaen_indicateur on delete cascade,
frequence varchar(256),
dernier_envoi timestamp
);
create unique index abonnement_id_uindex on unicaen_indicateur_abonnement (id);
create unique index indicateur_id_uindex on unicaen_indicateur (id);
INSERT INTO unicaen_privilege_categorie (code, libelle, ordre, namespace)
VALUES ('indicateur', 'Gestions des indicateurs', 800, 'Indicateur\Provider\Privilege');
INSERT INTO unicaen_privilege_privilege(CATEGORIE_ID, CODE, LIBELLE, ORDRE)
WITH d(code, lib, ordre) AS (
SELECT 'afficher-indicateur', 'Afficher un indicateur', 1 UNION
SELECT 'editer-indicateur', 'Éditer un indicateur', 2 UNION
SELECT 'detruire-indicateur', 'Effacer un indicateur', 3 UNION
SELECT 'afficher-abonnement', 'Afficher un abonnement', 4 UNION
SELECT 'editer-abonnement', 'Éditer un abonnement', 5 UNION
SELECT 'detruire-abonnement', 'Effacer un abonnement', 6
)
SELECT cp.id, d.code, d.lib, d.ordre
FROM d
JOIN unicaen_privilege_categorie cp ON cp.CODE = 'indicateur';
Module Unicaen Indiciateur
=======================
------------------------
Description
-----------
Le module **unicaen/indicateur** est en charge
Description du fonctionnement
============================
Tables pour les données du modules
==================================
Dépendances extérieurs
======================
<?php
namespace Indicateur\Controller;
use DateInterval;
use DateTime;
use Indicateur\Entity\Db\Abonnement;
use Indicateur\Service\Abonnement\AbonnementServiceAwareTrait;
use Indicateur\Service\Indicateur\IndicateurServiceAwareTrait;
use UnicaenUtilisateur\Service\User\UserServiceAwareTrait;
use Laminas\Mvc\Controller\AbstractActionController;
use Laminas\View\Model\ViewModel;
class AbonnementController extends AbstractActionController {
use AbonnementServiceAwareTrait;
use IndicateurServiceAwareTrait;
use UserServiceAwareTrait;
public function indexAction()
{
$abonnements = [];
return new ViewModel([
'abonnements' => $abonnements,
]);
}
public function souscrireAction()
{
$indicateur = $this->getIndicateurService()->getRequestedIndicateur($this);
$user = $this->getUserService()->getConnectedUser();
$abonnement = new Abonnement();
$abonnement->setIndicateur($indicateur);
$abonnement->setUser($user);
$abonnement->setFrequence('P1D');
$this->getAbonnementService()->create($abonnement);
return $this->redirect()->toRoute('indicateurs', [], [], true);
}
public function resilierAction()
{
$indicateur = $this->getIndicateurService()->getRequestedIndicateur($this);
$user = $this->getUserService()->getConnectedUser();
$retour = $this->params()->fromQuery('retour');
$abonnements = $this->getAbonnementService()->getAbonnementsByUserAndIndicateur($user, $indicateur);
foreach ($abonnements as $abonnement) $this->getAbonnementService()->delete($abonnement);
if ($retour) return $this->redirect()->toUrl($retour);
return $this->redirect()->toRoute('indicateurs', [], [], true);
}
public function notifierAction()
{
$this->getAbonnementService()->notifyAbonnements();
return $this->redirect()->toRoute('indicateurs', [], [], true);
}
public function notifierConsoleAction()
{
$this->getAbonnementService()->notifyAbonnements();
exit();
}
}
\ No newline at end of file
<?php
namespace Indicateur\Controller;
use Indicateur\Service\Abonnement\AbonnementService;
use Indicateur\Service\Indicateur\IndicateurService;
use Interop\Container\ContainerInterface;
use UnicaenUtilisateur\Service\User\UserService;;
class AbonnementControllerFactory {
public function __invoke(ContainerInterface $container)
{
/**
* @var AbonnementService $abonnementService
* @var IndicateurService $indicateurService
* @var UserService $userService
*/
$abonnementService = $container->get(AbonnementService::class);
$indicateurService = $container->get(IndicateurService::class);
$userService = $container->get(UserService::class);
/** @var AbonnementController $controller */
$controller = new AbonnementController();
$controller->setAbonnementService($abonnementService);
$controller->setIndicateurService($indicateurService);
$controller->setUserService($userService);
return $controller;
}
}
\ No newline at end of file
<?php
namespace Indicateur\Controller;
use Indicateur\Entity\Db\Abonnement;
use Indicateur\Service\Abonnement\AbonnementServiceAwareTrait;
use Indicateur\Service\Indicateur\IndicateurServiceAwareTrait;
use UnicaenUtilisateur\Service\User\UserServiceAwareTrait;
use Laminas\Mvc\Controller\AbstractActionController;
use Laminas\View\Model\ViewModel;
class IndexController extends AbstractActionController {
use AbonnementServiceAwareTrait;
use IndicateurServiceAwareTrait;
use UserServiceAwareTrait;
public function indexAction() : ViewModel
{
$user = $this->getUserService()->getConnectedUser();
$abonnements = $this->getAbonnementService()->getAbonnementsByUser($user);
$result = [];
foreach ($abonnements as $abonnement) {
$indicateur = $abonnement->getIndicateur();
$data = $this->getIndicateurService()->getIndicateurData($indicateur);
$result[$indicateur->getId()] = count($data[1]);
}
return new ViewModel([
'abonnements' => $abonnements,
'result' => $result,
]);
}
public function abonnementAction()
{
$user = $this->getUserService()->getConnectedUser();
$indicateurs = $this->getIndicateurService()->getIndicateurs();
$request = $this->getRequest();
if ($request->isPost()) {
$data = $request->getPost();
$id = $data['indicateur'];
$indicateur = $this->getIndicateurService()->getIndicateur($id);
if (!$this->getAbonnementService()->isAbonner($user, $indicateur)) {
$abonnement = new Abonnement();
$abonnement->setUser($user);
$abonnement->setIndicateur($indicateur);
// $abonnement->setFrequence('P1W');
$this->getAbonnementService()->create( $abonnement );
}
exit();
}
return new ViewModel([
'title' => "S'abonner à un indicateur",
'indicateurs' => $indicateurs,
]);
}
}
\ No newline at end of file
<?php
namespace Indicateur\Controller;
use Indicateur\Service\Abonnement\AbonnementService;
use Indicateur\Service\Indicateur\IndicateurService;
use Interop\Container\ContainerInterface;
use UnicaenUtilisateur\Service\User\UserService;
class IndexControllerFactory {
public function __invoke(ContainerInterface $container) : IndexController
{
/**
* @var AbonnementService $abonnementService
* @var IndicateurService $indicateurService
* @var UserService $userService
*/
$abonnementService = $container->get(AbonnementService::class);
$indicateurService = $container->get(IndicateurService::class);
$userService = $container->get(UserService::class);
$controller = new IndexController();
$controller->setAbonnementService($abonnementService);
$controller->setIndicateurService($indicateurService);
$controller->setUserService($userService);
return $controller;
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment