Compare commits
42 Commits
master
...
WORK_merge
@ -1,61 +0,0 @@
|
|||||||
kind: pipeline
|
|
||||||
type: docker
|
|
||||||
name: HeartWave
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
event:
|
|
||||||
- push
|
|
||||||
|
|
||||||
steps:
|
|
||||||
|
|
||||||
# Test ✔️
|
|
||||||
- name: test
|
|
||||||
image: composer:2.6
|
|
||||||
commands:
|
|
||||||
- cd Sources
|
|
||||||
# Installe les dépendances PHP si nécessaire
|
|
||||||
- composer install --no-interaction
|
|
||||||
- ./vendor/bin/phpunit tests
|
|
||||||
|
|
||||||
# Sonar static code analisis deployment
|
|
||||||
# TODO : use an image that already have unzip
|
|
||||||
- name: code-analysis
|
|
||||||
image: php:8.1-cli
|
|
||||||
environment:
|
|
||||||
SONAR_TOKEN:
|
|
||||||
from_secret: SONAR_TOKEN
|
|
||||||
commands:
|
|
||||||
- apt-get update && apt-get install -y curl unzip
|
|
||||||
- export SONAR_SCANNER_VERSION=4.7.0.2747
|
|
||||||
- export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
|
|
||||||
- curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip
|
|
||||||
- unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
|
|
||||||
- export PATH=$SONAR_SCANNER_HOME/bin:$PATH
|
|
||||||
- export SONAR_SCANNER_OPTS="-server"
|
|
||||||
- cd Sources
|
|
||||||
- sonar-scanner -D sonar.projectKey=HeartTrack -D sonar.host.url=https://codefirst.iut.uca.fr/sonar
|
|
||||||
depends_on: [ test ]
|
|
||||||
|
|
||||||
# build image and push on the registry ✔️
|
|
||||||
- name: docker-build-and-push
|
|
||||||
image: plugins/docker
|
|
||||||
settings:
|
|
||||||
dockerfile: Sources/config/Dockerfile
|
|
||||||
context: Sources
|
|
||||||
registry: hub.codefirst.iut.uca.fr
|
|
||||||
repo: hub.codefirst.iut.uca.fr/david.d_almeida/web
|
|
||||||
username:
|
|
||||||
from_secret: SECRET_REGISTRY_USERNAME
|
|
||||||
password:
|
|
||||||
from_secret: SECRET_REGISTRY_PASSWORD
|
|
||||||
|
|
||||||
- name: notify
|
|
||||||
image: ruby:2.1
|
|
||||||
when:
|
|
||||||
status: [ success ]
|
|
||||||
ref:
|
|
||||||
include:
|
|
||||||
- refs/tags/*-demo
|
|
||||||
commands:
|
|
||||||
- sh ./notifymail.sh
|
|
||||||
depends_on: [ docker-build-and-push ]
|
|
@ -0,0 +1,121 @@
|
|||||||
|
[retour au README.md](../../../README.md)
|
||||||
|
[Retour aux Documents](../../README_DOCUMENTS.md)
|
||||||
|
[Retour au diagramme de classes](../README_DIAGRAMMES.md)
|
||||||
|
|
||||||
|
# BDD
|
||||||
|
|
||||||
|
```plantuml
|
||||||
|
@startuml
|
||||||
|
skinparam classAttributeIconSize 0
|
||||||
|
package MLD{
|
||||||
|
entity "Athlète" as athlete {
|
||||||
|
{static} idAthlete
|
||||||
|
nom
|
||||||
|
prénom
|
||||||
|
email
|
||||||
|
sexe
|
||||||
|
taille
|
||||||
|
poids
|
||||||
|
motDePasse
|
||||||
|
dateNaissance
|
||||||
|
}
|
||||||
|
|
||||||
|
entity "Amitié" as friendship{
|
||||||
|
{static}# idAthlete1
|
||||||
|
{static}# idAthlete2
|
||||||
|
début
|
||||||
|
}
|
||||||
|
|
||||||
|
entity "Notification" as notif {
|
||||||
|
{static} idNotif
|
||||||
|
message
|
||||||
|
date
|
||||||
|
statut
|
||||||
|
urgence
|
||||||
|
#athleteId
|
||||||
|
}
|
||||||
|
|
||||||
|
entity "Coach" as coach {
|
||||||
|
{static} idCoach
|
||||||
|
// attributs spécifiques au coach
|
||||||
|
#athleteId
|
||||||
|
}
|
||||||
|
|
||||||
|
entity "Statistique" as stats {
|
||||||
|
{static} idStatistique
|
||||||
|
poids
|
||||||
|
fcMoyenne
|
||||||
|
fcMax
|
||||||
|
caloriesBrûléesMoy
|
||||||
|
date
|
||||||
|
#athleteId
|
||||||
|
}
|
||||||
|
|
||||||
|
entity "Entraînement" as training {
|
||||||
|
{static} idEntrainement
|
||||||
|
date
|
||||||
|
description
|
||||||
|
// Exercices
|
||||||
|
latitude
|
||||||
|
longitude
|
||||||
|
feedback
|
||||||
|
#coachId
|
||||||
|
}
|
||||||
|
|
||||||
|
entity "Participe" as takepart {
|
||||||
|
{static} #athleteId
|
||||||
|
{static} #entrainementId
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
entity "SourceDonnée" as source {
|
||||||
|
{static} idSource
|
||||||
|
type
|
||||||
|
modèle
|
||||||
|
précision
|
||||||
|
#athleteId
|
||||||
|
}
|
||||||
|
|
||||||
|
entity "Activité" as activity {
|
||||||
|
{static} idActivité
|
||||||
|
type
|
||||||
|
date
|
||||||
|
heureDeDébut
|
||||||
|
heureDeFin
|
||||||
|
effortRessent
|
||||||
|
variabilité
|
||||||
|
variance
|
||||||
|
ecartType
|
||||||
|
moyenne
|
||||||
|
maximum
|
||||||
|
minimum
|
||||||
|
temperatureMoyenne
|
||||||
|
#athleteId
|
||||||
|
#sourceId
|
||||||
|
}
|
||||||
|
entity "FréquenceCardiaque" as fc {
|
||||||
|
{static} idFc
|
||||||
|
altitude
|
||||||
|
temps : time
|
||||||
|
température
|
||||||
|
bpm
|
||||||
|
longitude
|
||||||
|
latitude
|
||||||
|
#activitéId
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
activity --> athlete
|
||||||
|
activity --> source
|
||||||
|
activity <-- fc
|
||||||
|
coach --> athlete
|
||||||
|
athlete <-- source
|
||||||
|
stats --> athlete
|
||||||
|
takepart --> athlete
|
||||||
|
takepart --> training
|
||||||
|
friendship --> athlete
|
||||||
|
notif --> athlete
|
||||||
|
coach <-- training
|
||||||
|
athlete <-- friendship
|
||||||
|
@enduml
|
||||||
|
```
|
After Width: | Height: | Size: 48 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 2.0 MiB |
After Width: | Height: | Size: 136 KiB |
After Width: | Height: | Size: 98 KiB |
Before Width: | Height: | Size: 586 B After Width: | Height: | Size: 692 B |
@ -0,0 +1,34 @@
|
|||||||
|
/*!
|
||||||
|
* Start Bootstrap - New Age v6.0.7 (https://startbootstrap.com/theme/new-age)
|
||||||
|
* Copyright 2013-2023 Start Bootstrap
|
||||||
|
* Licensed under MIT (https://github.com/StartBootstrap/startbootstrap-new-age/blob/master/LICENSE)
|
||||||
|
*/
|
||||||
|
//
|
||||||
|
// Scripts
|
||||||
|
//
|
||||||
|
|
||||||
|
window.addEventListener('DOMContentLoaded', event => {
|
||||||
|
|
||||||
|
// Activate Bootstrap scrollspy on the main nav element
|
||||||
|
const mainNav = document.body.querySelector('#mainNav');
|
||||||
|
if (mainNav) {
|
||||||
|
new bootstrap.ScrollSpy(document.body, {
|
||||||
|
target: '#mainNav',
|
||||||
|
offset: 74,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// Collapse responsive navbar when toggler is visible
|
||||||
|
const navbarToggler = document.body.querySelector('.navbar-toggler');
|
||||||
|
const responsiveNavItems = [].slice.call(
|
||||||
|
document.querySelectorAll('#navbarResponsive .nav-link')
|
||||||
|
);
|
||||||
|
responsiveNavItems.map(function (responsiveNavItem) {
|
||||||
|
responsiveNavItem.addEventListener('click', () => {
|
||||||
|
if (window.getComputedStyle(navbarToggler).display !== 'none') {
|
||||||
|
navbarToggler.click();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
@ -0,0 +1,34 @@
|
|||||||
|
/*!
|
||||||
|
* Start Bootstrap - New Age v6.0.7 (https://startbootstrap.com/theme/new-age)
|
||||||
|
* Copyright 2013-2023 Start Bootstrap
|
||||||
|
* Licensed under MIT (https://github.com/StartBootstrap/startbootstrap-new-age/blob/master/LICENSE)
|
||||||
|
*/
|
||||||
|
//
|
||||||
|
// Scripts
|
||||||
|
//
|
||||||
|
|
||||||
|
window.addEventListener('DOMContentLoaded', event => {
|
||||||
|
|
||||||
|
// Activate Bootstrap scrollspy on the main nav element
|
||||||
|
const mainNav = document.body.querySelector('#mainNav');
|
||||||
|
if (mainNav) {
|
||||||
|
new bootstrap.ScrollSpy(document.body, {
|
||||||
|
target: '#mainNav',
|
||||||
|
offset: 74,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// Collapse responsive navbar when toggler is visible
|
||||||
|
const navbarToggler = document.body.querySelector('.navbar-toggler');
|
||||||
|
const responsiveNavItems = [].slice.call(
|
||||||
|
document.querySelectorAll('#navbarResponsive .nav-link')
|
||||||
|
);
|
||||||
|
responsiveNavItems.map(function (responsiveNavItem) {
|
||||||
|
responsiveNavItem.addEventListener('click', () => {
|
||||||
|
if (window.getComputedStyle(navbarToggler).display !== 'none') {
|
||||||
|
navbarToggler.click();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
@ -1,563 +1,422 @@
|
|||||||
<?php
|
<?php
|
||||||
|
//
|
||||||
namespace App\Controller;
|
//namespace App\Controller;
|
||||||
|
//
|
||||||
use App\Container;
|
//use App\Container;
|
||||||
use App\Router\Request\IRequest;
|
//use App\Router\Request\IRequest;
|
||||||
use App\Router\Response\Response;
|
//use App\Router\Response\Response;
|
||||||
use Shared\Attributes\Route;
|
//use Shared\Attributes\Route;
|
||||||
use Twig\Environment;
|
//use Twig\Environment;
|
||||||
use Data\Core\Preferences;
|
//use Data\Core\Preferences;
|
||||||
use Shared\Log;
|
//use Shared\Log;
|
||||||
|
//
|
||||||
// TODO : Remove this BaseClass
|
//// TODO : Remove this BaseClass
|
||||||
class Controller extends BaseController
|
//class Controller extends BaseController
|
||||||
{
|
//{
|
||||||
private Environment $twig;
|
//
|
||||||
protected Preferences $preference;
|
// #[Route(path: '/activity', name: 'activity', methods: ['GET'])]
|
||||||
|
// public function activity(): Response
|
||||||
public function __construct()
|
// {
|
||||||
{
|
// return $this->render('./page/activity.html.twig',[
|
||||||
session_start();
|
// 'css' => $this->preference->getCookie(),
|
||||||
$this->preference = new Preferences();
|
// 'pp' => "test2",
|
||||||
}
|
// 'user' => "Doe",
|
||||||
|
// 'role' => "Athlète",
|
||||||
#[Route(path: '/', name: 'home', methods: ['GET'])]
|
// 'friendship' => [],
|
||||||
public function index(): Response
|
// 'analyzes' => [],
|
||||||
{
|
// 'mails' => [],
|
||||||
return $this->render('./page/index.html',[
|
// 'users' => [],
|
||||||
'css' => $this->preference->getCookie(),
|
// 'infoUser' => [],
|
||||||
'pp' => "test2",
|
// 'exos' => [],
|
||||||
'user' => "Doe",
|
// 'member' => []
|
||||||
'role' => "Athlète",
|
// ]);
|
||||||
'friendship' => [],
|
// }
|
||||||
'analyzes' => [],
|
//
|
||||||
'mails' => [],
|
//
|
||||||
'users' => [],
|
// #[Route(path: '/exercices', name: 'exercices', methods: ['POST'])] // 8
|
||||||
'infoUser' => [],
|
// public function exercices(String $type, String $intensite, String $date, IRequest $req): Response
|
||||||
'exos' => [],
|
// {
|
||||||
'member' => []
|
// $exercicesArray = [
|
||||||
]);
|
// [
|
||||||
}
|
// 'date' => $date,
|
||||||
|
// 'type' => $type,
|
||||||
#[Route(path: '/analyses', name: 'analyses', methods: ['GET'])]
|
// 'intensite' => $intensite,
|
||||||
public function analyses(): Response
|
// 'status' => 'A venur',
|
||||||
{
|
// ]
|
||||||
return $this->render('./page/analyze.html.twig',[
|
// ];
|
||||||
'css' => $this->preference->getCookie(),
|
// return $this->render('./page/exercice.html.twig',[
|
||||||
'pp' => "test2",
|
// 'css' => $this->preference->getCookie(),
|
||||||
'user' => "Doe",
|
// 'pp' => "test2",
|
||||||
'role' => "Athlète",
|
// 'user' => "Doe",
|
||||||
'friendship' => [],
|
// 'role' => "Athlète",
|
||||||
'analyzes' => [],
|
// 'friendship' => [],
|
||||||
'mails' => [],
|
// 'analyzes' => [],
|
||||||
'users' => [],
|
// 'mails' => [],
|
||||||
'infoUser' => [],
|
// 'users' => [],
|
||||||
'exos' => [],
|
// 'infoUser' => [],
|
||||||
'member' => []
|
// 'exos' => $exercicesArray,
|
||||||
]);
|
// 'member' => []
|
||||||
}
|
// ]);
|
||||||
|
// }
|
||||||
#[Route(path: '/activity', name: 'activity', methods: ['GET'])]
|
//
|
||||||
public function activity(): Response
|
// #[Route(path: '/search-user', name: 'search-user', methods: ['GET'])]
|
||||||
{
|
// public function searchUser(string $username, IRequest $req): Response
|
||||||
return $this->render('./page/activity.html.twig',[
|
// {
|
||||||
'css' => $this->preference->getCookie(),
|
// $taberror = [];
|
||||||
'pp' => "test2",
|
// // FILTER
|
||||||
'user' => "Doe",
|
// $utiliArray = [
|
||||||
'role' => "Athlète",
|
// [
|
||||||
'friendship' => [],
|
// 'nom' => 'John',
|
||||||
'analyzes' => [],
|
// 'prenom' => 'Doe',
|
||||||
'mails' => [],
|
// 'img' => 'john_doe',
|
||||||
'users' => [],
|
// 'username' => 'johndoe',
|
||||||
'infoUser' => [],
|
// ],
|
||||||
'exos' => [],
|
// [
|
||||||
'member' => []
|
// 'nom' => 'Alice',
|
||||||
]);
|
// 'prenom' => 'Smith',
|
||||||
}
|
// 'img' => 'alice_smith',
|
||||||
|
// 'username' => 'alicesmith',
|
||||||
|
// ],
|
||||||
#[Route(path: '/exercices', name: 'exercices', methods: ['POST'])] // 8
|
// ];
|
||||||
public function exercices(String $type, String $intensite, String $date, IRequest $req): Response
|
// // if(!Validation::val_string($name)){
|
||||||
{
|
// try {
|
||||||
$exercicesArray = [
|
// //code...
|
||||||
[
|
// // $model->userMgr->addFriend($name);
|
||||||
'date' => $date,
|
// return $this->render('./page/addfriend.html.twig',[
|
||||||
'type' => $type,
|
// 'css' => $this->preference->getCookie(),
|
||||||
'intensite' => $intensite,
|
// 'pp' => "test2",
|
||||||
'status' => 'A venur',
|
// 'user' => "Doe",
|
||||||
]
|
// 'role' => "Athlète",
|
||||||
];
|
// 'friendship' => [],
|
||||||
return $this->render('./page/exercice.html.twig',[
|
// 'analyzes' => [],
|
||||||
'css' => $this->preference->getCookie(),
|
// 'mails' => [],
|
||||||
'pp' => "test2",
|
// 'users' => $utiliArray,
|
||||||
'user' => "Doe",
|
// 'infoUser' => [],
|
||||||
'role' => "Athlète",
|
// 'exos' => [],
|
||||||
'friendship' => [],
|
// 'member' => [],
|
||||||
'analyzes' => [],
|
// 'responce' => "Notification d'ajout envoyée à $username"
|
||||||
'mails' => [],
|
// ]);
|
||||||
'users' => [],
|
// } catch (\Throwable $th) {
|
||||||
'infoUser' => [],
|
// //throw $th;
|
||||||
'exos' => $exercicesArray,
|
// // return $this->render("addfriend.html.twig", ['tabError' => $taberror ]);
|
||||||
'member' => []
|
// }
|
||||||
]);
|
// // }
|
||||||
}
|
//
|
||||||
|
// }
|
||||||
#[Route(path: '/search-user', name: 'search-user', methods: ['GET'])]
|
//
|
||||||
public function searchUser(string $username, IRequest $req): Response
|
// #[Route(path: '/search-member', name: 'search-member', methods: ['GET'])]
|
||||||
{
|
// public function searchMember(string $username, IRequest $req): Response
|
||||||
$taberror = [];
|
// {
|
||||||
// FILTER
|
// $taberror = [];
|
||||||
$utiliArray = [
|
// // FILTER
|
||||||
[
|
// $utiliArray = [
|
||||||
'nom' => 'John',
|
// [
|
||||||
'prenom' => 'Doe',
|
// 'nom' => 'John',
|
||||||
'img' => 'john_doe',
|
// 'prenom' => 'Doe',
|
||||||
'username' => 'johndoe',
|
// 'img' => 'john_doe',
|
||||||
],
|
// 'username' => 'johndoe',
|
||||||
[
|
// ],
|
||||||
'nom' => 'Alice',
|
// [
|
||||||
'prenom' => 'Smith',
|
// 'nom' => 'Alice',
|
||||||
'img' => 'alice_smith',
|
// 'prenom' => 'Smith',
|
||||||
'username' => 'alicesmith',
|
// 'img' => 'alice_smith',
|
||||||
],
|
// 'username' => 'alicesmith',
|
||||||
];
|
// ],
|
||||||
// if(!Validation::val_string($name)){
|
// ];
|
||||||
try {
|
// // if(!Validation::val_string($name)){
|
||||||
//code...
|
// try {
|
||||||
// $model->userMgr->addFriend($name);
|
// //code...
|
||||||
return $this->render('./page/addfriend.html.twig',[
|
// // $model->userMgr->addFriend($name);
|
||||||
'css' => $this->preference->getCookie(),
|
// return $this->render('./page/addmember.html.twig',[
|
||||||
'pp' => "test2",
|
// 'css' => $this->preference->getCookie(),
|
||||||
'user' => "Doe",
|
// 'pp' => "test2",
|
||||||
'role' => "Athlète",
|
// 'user' => "Doe",
|
||||||
'friendship' => [],
|
// 'role' => "Athlète",
|
||||||
'analyzes' => [],
|
// 'friendship' => [],
|
||||||
'mails' => [],
|
// 'analyzes' => [],
|
||||||
'users' => $utiliArray,
|
// 'mails' => [],
|
||||||
'infoUser' => [],
|
// 'users' => $utiliArray,
|
||||||
'exos' => [],
|
// 'infoUser' => [],
|
||||||
'member' => [],
|
// 'exos' => [],
|
||||||
'responce' => "Notification d'ajout envoyée à $username"
|
// 'member' => [],
|
||||||
]);
|
// 'responce' => "Notification d'ajout envoyée à $username"
|
||||||
} catch (\Throwable $th) {
|
// ]);
|
||||||
//throw $th;
|
// } catch (\Throwable $th) {
|
||||||
// return $this->render("addfriend.html.twig", ['tabError' => $taberror ]);
|
// //throw $th;
|
||||||
}
|
// // return $this->render("addfriend.html.twig", ['tabError' => $taberror ]);
|
||||||
// }
|
// }
|
||||||
|
// // }
|
||||||
}
|
//
|
||||||
|
// }
|
||||||
#[Route(path: '/search-member', name: 'search-member', methods: ['GET'])]
|
//
|
||||||
public function searchMember(string $username, IRequest $req): Response
|
// #[Route(path: '/add-member', name: 'add-member', methods: ['POST'])]
|
||||||
{
|
// public function addmember(string $username, IRequest $req): Response
|
||||||
$taberror = [];
|
// {
|
||||||
// FILTER
|
// $taberror = [];
|
||||||
$utiliArray = [
|
// $utiliArray = [
|
||||||
[
|
// [
|
||||||
'nom' => 'John',
|
// 'nom' => 'John',
|
||||||
'prenom' => 'Doe',
|
// 'prenom' => 'Doe',
|
||||||
'img' => 'john_doe',
|
// 'img' => 'john_doe',
|
||||||
'username' => 'johndoe',
|
// 'username' => 'johndoe',
|
||||||
],
|
// ],
|
||||||
[
|
// [
|
||||||
'nom' => 'Alice',
|
// 'nom' => 'Alice',
|
||||||
'prenom' => 'Smith',
|
// 'prenom' => 'Smith',
|
||||||
'img' => 'alice_smith',
|
// 'img' => 'alice_smith',
|
||||||
'username' => 'alicesmith',
|
// 'username' => 'alicesmith',
|
||||||
],
|
// ],
|
||||||
];
|
// ];
|
||||||
// if(!Validation::val_string($name)){
|
// // if(!Validation::val_string($name)){
|
||||||
try {
|
// try {
|
||||||
//code...
|
// //code...
|
||||||
// $model->userMgr->addFriend($name);
|
// // $model->userMgr->addFriend($name);
|
||||||
return $this->render('./page/addmember.html.twig',[
|
// return $this->render('./page/addmember.html.twig',[
|
||||||
'css' => $this->preference->getCookie(),
|
// 'css' => $this->preference->getCookie(),
|
||||||
'pp' => "test2",
|
// 'pp' => "test2",
|
||||||
'user' => "Doe",
|
// 'user' => "Doe",
|
||||||
'role' => "Athlète",
|
// 'role' => "Athlète",
|
||||||
'friendship' => [],
|
// 'friendship' => [],
|
||||||
'analyzes' => [],
|
// 'analyzes' => [],
|
||||||
'mails' => [],
|
// 'mails' => [],
|
||||||
'users' => $utiliArray,
|
// 'users' => $utiliArray,
|
||||||
'infoUser' => [],
|
// 'infoUser' => [],
|
||||||
'exos' => [],
|
// 'exos' => [],
|
||||||
'member' => [],
|
// 'member' => [],
|
||||||
'responce' => "Notification d'ajout envoyée à $username"
|
// 'responce' => "Notification d'ajout envoyée à $username"
|
||||||
]);
|
// ]);
|
||||||
} catch (\Throwable $th) {
|
// } catch (\Throwable $th) {
|
||||||
//throw $th;
|
// //throw $th;
|
||||||
// return $this->render("addfriend.html.twig", ['tabError' => $taberror ]);
|
// // return $this->render("addfriend.html.twig", ['tabError' => $taberror ]);
|
||||||
}
|
// }
|
||||||
// }
|
// // }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
#[Route(path: '/add-member', name: 'add-member', methods: ['POST'])]
|
// #[Route(path: '/member', name: 'member', methods: ['GET'])]
|
||||||
public function addmember(string $username, IRequest $req): Response
|
// public function member(): Response
|
||||||
{
|
// {
|
||||||
$taberror = [];
|
// $utiliArray = [
|
||||||
$utiliArray = [
|
// [
|
||||||
[
|
// 'nom' => 'John',
|
||||||
'nom' => 'John',
|
// 'prenom' => 'Doe',
|
||||||
'prenom' => 'Doe',
|
// 'img' => 'john_doe',
|
||||||
'img' => 'john_doe',
|
// 'username' => 'johndoe',
|
||||||
'username' => 'johndoe',
|
// ],
|
||||||
],
|
// [
|
||||||
[
|
// 'nom' => 'Alice',
|
||||||
'nom' => 'Alice',
|
// 'prenom' => 'Smith',
|
||||||
'prenom' => 'Smith',
|
// 'img' => 'alice_smith',
|
||||||
'img' => 'alice_smith',
|
// 'username' => 'alicesmith',
|
||||||
'username' => 'alicesmith',
|
// ],
|
||||||
],
|
// ];
|
||||||
];
|
// return $this->render('./page/addmember.html.twig',[
|
||||||
// if(!Validation::val_string($name)){
|
// 'css' => $this->preference->getCookie(),
|
||||||
try {
|
// 'pp' => "test2",
|
||||||
//code...
|
// 'user' => "Doe",
|
||||||
// $model->userMgr->addFriend($name);
|
// 'role' => "Athlète",
|
||||||
return $this->render('./page/addmember.html.twig',[
|
// 'friendship' => [],
|
||||||
'css' => $this->preference->getCookie(),
|
// 'analyzes' => [],
|
||||||
'pp' => "test2",
|
// 'mails' => [],
|
||||||
'user' => "Doe",
|
// 'users' => $utiliArray,
|
||||||
'role' => "Athlète",
|
// 'infoUser' => [],
|
||||||
'friendship' => [],
|
// 'exos' => [],
|
||||||
'analyzes' => [],
|
// 'member' => [],
|
||||||
'mails' => [],
|
// ]);
|
||||||
'users' => $utiliArray,
|
// }
|
||||||
'infoUser' => [],
|
//
|
||||||
'exos' => [],
|
//
|
||||||
'member' => [],
|
// #[Route(path: '/friendlist', name: 'friendlist', methods: ['POST'])]
|
||||||
'responce' => "Notification d'ajout envoyée à $username"
|
// public function friendlist(string $username, IRequest $req): Response
|
||||||
]);
|
// {
|
||||||
} catch (\Throwable $th) {
|
// $utiliArray = [
|
||||||
//throw $th;
|
// [
|
||||||
// return $this->render("addfriend.html.twig", ['tabError' => $taberror ]);
|
// 'nom' => 'John',
|
||||||
}
|
// 'prenom' => 'Doe',
|
||||||
// }
|
// 'img' => 'john_doe',
|
||||||
|
// 'username' => 'johndoe',
|
||||||
}
|
// ],
|
||||||
|
// [
|
||||||
#[Route(path: '/member', name: 'member', methods: ['GET'])]
|
// 'nom' => 'Alice',
|
||||||
public function member(): Response
|
// 'prenom' => 'Smith',
|
||||||
{
|
// 'img' => 'alice_smith',
|
||||||
$utiliArray = [
|
// 'username' => 'alicesmith',
|
||||||
[
|
// ],
|
||||||
'nom' => 'John',
|
// ];
|
||||||
'prenom' => 'Doe',
|
// /* TODO */
|
||||||
'img' => 'john_doe',
|
//
|
||||||
'username' => 'johndoe',
|
// // -> Enlever ou bloquer un utilisateur en fonction de son username
|
||||||
],
|
//
|
||||||
[
|
// return $this->render('./page/friend.html.twig',[
|
||||||
'nom' => 'Alice',
|
// 'css' => $this->preference->getCookie(),
|
||||||
'prenom' => 'Smith',
|
// 'pp' => "test2",
|
||||||
'img' => 'alice_smith',
|
// 'user' => "Doe",
|
||||||
'username' => 'alicesmith',
|
// 'role' => "Athlète",
|
||||||
],
|
// 'friendship' => $utiliArray,
|
||||||
];
|
// 'analyzes' => [],
|
||||||
return $this->render('./page/addmember.html.twig',[
|
// 'mails' => [],
|
||||||
'css' => $this->preference->getCookie(),
|
// 'users' => [],
|
||||||
'pp' => "test2",
|
// 'infoUser' => [],
|
||||||
'user' => "Doe",
|
// 'exos' => [],
|
||||||
'role' => "Athlète",
|
// 'member' => [],
|
||||||
'friendship' => [],
|
// ]);
|
||||||
'analyzes' => [],
|
// }
|
||||||
'mails' => [],
|
//
|
||||||
'users' => $utiliArray,
|
// #[Route(path: '/friendlist', name: 'friendlist2', methods: ['GET'])]
|
||||||
'infoUser' => [],
|
// public function friendlist2(): Response
|
||||||
'exos' => [],
|
// {
|
||||||
'member' => [],
|
// $utiliArray = [
|
||||||
]);
|
// [
|
||||||
}
|
// 'nom' => 'John',
|
||||||
|
// 'prenom' => 'Doe',
|
||||||
|
// 'img' => 'test',
|
||||||
#[Route(path: '/friendlist', name: 'friendlist', methods: ['POST'])]
|
// 'status' => 'johndoe',
|
||||||
public function friendlist(string $username, IRequest $req): Response
|
// 'username' => 'jdoe',
|
||||||
{
|
// ],
|
||||||
$utiliArray = [
|
// [
|
||||||
[
|
// 'nom' => 'Alice',
|
||||||
'nom' => 'John',
|
// 'prenom' => 'Smith',
|
||||||
'prenom' => 'Doe',
|
// 'img' => 'test2',
|
||||||
'img' => 'john_doe',
|
// 'status' => 'alicesmith',
|
||||||
'username' => 'johndoe',
|
// 'username' => 'asmith',
|
||||||
],
|
// ],
|
||||||
[
|
// ];
|
||||||
'nom' => 'Alice',
|
// return $this->render('./page/friend.html.twig',[
|
||||||
'prenom' => 'Smith',
|
// 'css' => $this->preference->getCookie(),
|
||||||
'img' => 'alice_smith',
|
// 'pp' => "test2",
|
||||||
'username' => 'alicesmith',
|
// 'user' => "Doe",
|
||||||
],
|
// 'role' => "Athlète",
|
||||||
];
|
// 'friendship' => $utiliArray,
|
||||||
/* TODO */
|
// 'analyzes' => [],
|
||||||
|
// 'mails' => [],
|
||||||
// -> Enlever ou bloquer un utilisateur en fonction de son username
|
// 'users' => [],
|
||||||
|
// 'infoUser' => [],
|
||||||
return $this->render('./page/friend.html.twig',[
|
// 'exos' => [],
|
||||||
'css' => $this->preference->getCookie(),
|
// 'member' => [],
|
||||||
'pp' => "test2",
|
// ]);
|
||||||
'user' => "Doe",
|
// }
|
||||||
'role' => "Athlète",
|
//
|
||||||
'friendship' => $utiliArray,
|
// #[Route(path: '/coaching', name: 'coaching', methods: ['GET'])]
|
||||||
'analyzes' => [],
|
// public function coaching(): Response
|
||||||
'mails' => [],
|
// {
|
||||||
'users' => [],
|
// return $this->render('./page/coaching.html.twig',[
|
||||||
'infoUser' => [],
|
// 'css' => $this->preference->getCookie(),
|
||||||
'exos' => [],
|
// 'pp' => "test2",
|
||||||
'member' => [],
|
// 'user' => "Doe",
|
||||||
]);
|
// 'role' => "Athlète",
|
||||||
}
|
// 'friendship' => [],
|
||||||
|
// 'analyzes' => [],
|
||||||
#[Route(path: '/friendlist', name: 'friendlist2', methods: ['GET'])]
|
// 'mails' => [],
|
||||||
public function friendlist2(): Response
|
// 'users' => [],
|
||||||
{
|
// 'infoUser' => [],
|
||||||
$utiliArray = [
|
// 'exos' => [],
|
||||||
[
|
// 'member' => []
|
||||||
'nom' => 'John',
|
// ]);
|
||||||
'prenom' => 'Doe',
|
// }
|
||||||
'img' => 'test',
|
//
|
||||||
'status' => 'johndoe',
|
// #[Route(path: '/mail', name: 'mail', methods: ['GET'])]
|
||||||
'username' => 'jdoe',
|
// public function mail(): Response
|
||||||
],
|
// {
|
||||||
[
|
// return $this->render('./page/mail.html.twig',[
|
||||||
'nom' => 'Alice',
|
// 'css' => $this->preference->getCookie(),
|
||||||
'prenom' => 'Smith',
|
// 'pp' => "test2",
|
||||||
'img' => 'test2',
|
// 'user' => "Doe",
|
||||||
'status' => 'alicesmith',
|
// 'role' => "Athlète",
|
||||||
'username' => 'asmith',
|
// 'friendship' => [],
|
||||||
],
|
// 'analyzes' => [],
|
||||||
];
|
// 'mails' => [],
|
||||||
return $this->render('./page/friend.html.twig',[
|
// 'users' => [],
|
||||||
'css' => $this->preference->getCookie(),
|
// 'infoUser' => [],
|
||||||
'pp' => "test2",
|
// 'exos' => [],
|
||||||
'user' => "Doe",
|
// 'member' => []
|
||||||
'role' => "Athlète",
|
// ]);
|
||||||
'friendship' => $utiliArray,
|
// }
|
||||||
'analyzes' => [],
|
//
|
||||||
'mails' => [],
|
//
|
||||||
'users' => [],
|
// #[Route(path: '/profile', name: 'profile', methods: ['GET'])]
|
||||||
'infoUser' => [],
|
// public function profile(): Response
|
||||||
'exos' => [],
|
// {
|
||||||
'member' => [],
|
// return $this->render('./page/profile.html.twig',[
|
||||||
]);
|
// 'css' => $this->preference->getCookie(),
|
||||||
}
|
// 'pp' => "test2",
|
||||||
|
// 'user' => "Doe",
|
||||||
#[Route(path: '/coaching', name: 'coaching', methods: ['GET'])]
|
// 'role' => "Athlète",
|
||||||
public function coaching(): Response
|
// 'friendship' => [],
|
||||||
{
|
// 'analyzes' => [],
|
||||||
return $this->render('./page/coaching.html.twig',[
|
// 'mails' => [],
|
||||||
'css' => $this->preference->getCookie(),
|
// 'users' => [],
|
||||||
'pp' => "test2",
|
// 'infoUser' => [],
|
||||||
'user' => "Doe",
|
// 'exos' => [],
|
||||||
'role' => "Athlète",
|
// 'member' => []
|
||||||
'friendship' => [],
|
// ]);
|
||||||
'analyzes' => [],
|
// }
|
||||||
'mails' => [],
|
//
|
||||||
'users' => [],
|
//
|
||||||
'infoUser' => [],
|
// #[Route(path: '/psettings', name: 'psettings', methods: ['POST'])]
|
||||||
'exos' => [],
|
// public function psettings(string $nom,string $prenom,string $dateNaissance,string $mail,string $tel, IRequest $req): Response
|
||||||
'member' => []
|
// {
|
||||||
]);
|
//
|
||||||
}
|
//
|
||||||
|
// return $this->render('./page/settings.html.twig',[
|
||||||
#[Route(path: '/mail', name: 'mail', methods: ['GET'])]
|
// 'css' => $this->preference->getCookie(),
|
||||||
public function mail(): Response
|
// 'pp' => "test2",
|
||||||
{
|
// 'user' => $prenom,
|
||||||
return $this->render('./page/mail.html.twig',[
|
// 'role' => "Athlète",
|
||||||
'css' => $this->preference->getCookie(),
|
// 'friendship' => [],
|
||||||
'pp' => "test2",
|
// 'analyzes' => [],
|
||||||
'user' => "Doe",
|
// 'mails' => [],
|
||||||
'role' => "Athlète",
|
// 'users' => [],
|
||||||
'friendship' => [],
|
// 'infoUser' => [],
|
||||||
'analyzes' => [],
|
// 'exos' => [],
|
||||||
'mails' => [],
|
// 'member' => []
|
||||||
'users' => [],
|
// ]);
|
||||||
'infoUser' => [],
|
// }
|
||||||
'exos' => [],
|
//
|
||||||
'member' => []
|
//
|
||||||
]);
|
//
|
||||||
}
|
//
|
||||||
|
// #[Route(path: '/pass', name: 'pass', methods: ['GET'])]
|
||||||
#[Route(path: '/import', name: 'import', methods: ['GET'])]
|
// public function pass(): Response
|
||||||
public function import(): Response
|
// {
|
||||||
{
|
//
|
||||||
return $this->render('./page/import.html.twig',[
|
// // CONFIRMER LES DONNESS !!!!! IMPORTANT
|
||||||
'css' => $this->preference->getCookie(),
|
//
|
||||||
'pp' => "test2",
|
// return $this->render('./page/password.html.twig',[
|
||||||
'user' => "Doe",
|
// 'css' => $this->preference->getCookie(),
|
||||||
'role' => "Athlète",
|
// 'pp' => "test2",
|
||||||
'friendship' => [],
|
// 'user' => "Doe",
|
||||||
'analyzes' => [],
|
// 'role' => "Athlète",
|
||||||
'mails' => [],
|
// 'friendship' => [],
|
||||||
'users' => [],
|
// 'analyzes' => [],
|
||||||
'infoUser' => [],
|
// 'mails' => [],
|
||||||
'exos' => [],
|
// 'users' => [],
|
||||||
'member' => []
|
// 'infoUser' => [],
|
||||||
]);
|
// 'exos' => [],
|
||||||
}
|
// 'member' => []
|
||||||
|
// ]);
|
||||||
|
// }
|
||||||
#[Route(path: '/profile', name: 'profile', methods: ['GET'])]
|
//
|
||||||
public function profile(): Response
|
// #[Route(path: '/password', name: 'password', methods: ['POST'])]
|
||||||
{
|
// public function password(string $email, IRequest $req): Response
|
||||||
return $this->render('./page/profile.html.twig',[
|
// {
|
||||||
'css' => $this->preference->getCookie(),
|
//
|
||||||
'pp' => "test2",
|
// // CONFIRMER LES DONNESS !!!!! IMPORTANT
|
||||||
'user' => "Doe",
|
//
|
||||||
'role' => "Athlète",
|
// return $this->render('./page/login.html.twig',[
|
||||||
'friendship' => [],
|
// 'css' => $this->preference->getCookie(),
|
||||||
'analyzes' => [],
|
// 'pp' => "test2",
|
||||||
'mails' => [],
|
// 'user' => "Doe",
|
||||||
'users' => [],
|
// 'role' => "Athlète",
|
||||||
'infoUser' => [],
|
// 'friendship' => [],
|
||||||
'exos' => [],
|
// 'analyzes' => [],
|
||||||
'member' => []
|
// 'mails' => [],
|
||||||
]);
|
// 'users' => [],
|
||||||
}
|
// 'infoUser' => [],
|
||||||
|
// 'exos' => [],
|
||||||
|
// 'member' => []
|
||||||
#[Route(path: '/psettings', name: 'psettings', methods: ['POST'])]
|
// ]);
|
||||||
public function psettings(string $nom,string $prenom,string $dateNaissance,string $mail,string $tel, IRequest $req): Response
|
// }
|
||||||
{
|
//
|
||||||
|
//}
|
||||||
|
//
|
||||||
return $this->render('./page/settings.html.twig',[
|
//
|
||||||
'css' => $this->preference->getCookie(),
|
|
||||||
'pp' => "test2",
|
|
||||||
'user' => $prenom,
|
|
||||||
'role' => "Athlète",
|
|
||||||
'friendship' => [],
|
|
||||||
'analyzes' => [],
|
|
||||||
'mails' => [],
|
|
||||||
'users' => [],
|
|
||||||
'infoUser' => [],
|
|
||||||
'exos' => [],
|
|
||||||
'member' => []
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#[Route(path: '/login', name: 'login', methods: ['POST'])]
|
|
||||||
public function login(string $username,string $mdp, IRequest $req): Response
|
|
||||||
{
|
|
||||||
|
|
||||||
// CONFIRMER LES DONNESS !!!!! IMPORTANT
|
|
||||||
|
|
||||||
return $this->render('./page/home.html.twig',[
|
|
||||||
'css' => $this->preference->getCookie(),
|
|
||||||
'pp' => "test2",
|
|
||||||
'user' => "Doe",
|
|
||||||
'role' => "Athlète",
|
|
||||||
'friendship' => [],
|
|
||||||
'analyzes' => [],
|
|
||||||
'mails' => [],
|
|
||||||
'users' => [],
|
|
||||||
'infoUser' => [],
|
|
||||||
'exos' => [],
|
|
||||||
'member' => []
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[Route(path: '/log', name: 'log', methods: ['GET'])]
|
|
||||||
public function login2(): Response
|
|
||||||
{
|
|
||||||
|
|
||||||
// CONFIRMER LES DONNESS !!!!! IMPORTANT
|
|
||||||
|
|
||||||
return $this->render('./page/login.html.twig',[
|
|
||||||
'css' => $this->preference->getCookie(),
|
|
||||||
'pp' => "test2",
|
|
||||||
'user' => "Doe",
|
|
||||||
'role' => "Athlète",
|
|
||||||
'friendship' => [],
|
|
||||||
'analyzes' => [],
|
|
||||||
'mails' => [],
|
|
||||||
'users' => [],
|
|
||||||
'infoUser' => [],
|
|
||||||
'exos' => [],
|
|
||||||
'member' => []
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[Route(path: '/register', name: 'register', methods: ['POST'])]
|
|
||||||
public function register(string $username,string $mdp,string $confirmMdp,string $nom,string $prenom,string $dateNaissance,string $sexe,string $taille,string $poids, IRequest $req): Response
|
|
||||||
{
|
|
||||||
|
|
||||||
// CONFIRMER LES DONNESS !!!!! IMPORTANT
|
|
||||||
|
|
||||||
return $this->render('./page/home.html.twig',[
|
|
||||||
'css' => $this->preference->getCookie(),
|
|
||||||
'pp' => "test2",
|
|
||||||
'user' => "Doe",
|
|
||||||
'role' => "Athlète",
|
|
||||||
'friendship' => [],
|
|
||||||
'analyzes' => [],
|
|
||||||
'mails' => [],
|
|
||||||
'users' => [],
|
|
||||||
'infoUser' => [],
|
|
||||||
'exos' => [],
|
|
||||||
'member' => []
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[Route(path: '/regist', name: 'regist', methods: ['GET'])]
|
|
||||||
public function register2(): Response
|
|
||||||
{
|
|
||||||
|
|
||||||
// CONFIRMER LES DONNESS !!!!! IMPORTANT
|
|
||||||
|
|
||||||
return $this->render('./page/register.html.twig',[
|
|
||||||
'css' => $this->preference->getCookie(),
|
|
||||||
'pp' => "test2",
|
|
||||||
'user' => "Doe",
|
|
||||||
'role' => "Athlète",
|
|
||||||
'friendship' => [],
|
|
||||||
'analyzes' => [],
|
|
||||||
'mails' => [],
|
|
||||||
'users' => [],
|
|
||||||
'infoUser' => [],
|
|
||||||
'exos' => [],
|
|
||||||
'member' => []
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[Route(path: '/pass', name: 'pass', methods: ['GET'])]
|
|
||||||
public function pass(): Response
|
|
||||||
{
|
|
||||||
|
|
||||||
// CONFIRMER LES DONNESS !!!!! IMPORTANT
|
|
||||||
|
|
||||||
return $this->render('./page/password.html.twig',[
|
|
||||||
'css' => $this->preference->getCookie(),
|
|
||||||
'pp' => "test2",
|
|
||||||
'user' => "Doe",
|
|
||||||
'role' => "Athlète",
|
|
||||||
'friendship' => [],
|
|
||||||
'analyzes' => [],
|
|
||||||
'mails' => [],
|
|
||||||
'users' => [],
|
|
||||||
'infoUser' => [],
|
|
||||||
'exos' => [],
|
|
||||||
'member' => []
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[Route(path: '/password', name: 'password', methods: ['POST'])]
|
|
||||||
public function password(string $email, IRequest $req): Response
|
|
||||||
{
|
|
||||||
|
|
||||||
// CONFIRMER LES DONNESS !!!!! IMPORTANT
|
|
||||||
|
|
||||||
return $this->render('./page/login.html.twig',[
|
|
||||||
'css' => $this->preference->getCookie(),
|
|
||||||
'pp' => "test2",
|
|
||||||
'user' => "Doe",
|
|
||||||
'role' => "Athlète",
|
|
||||||
'friendship' => [],
|
|
||||||
'analyzes' => [],
|
|
||||||
'mails' => [],
|
|
||||||
'users' => [],
|
|
||||||
'infoUser' => [],
|
|
||||||
'exos' => [],
|
|
||||||
'member' => []
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,36 +1,95 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
// use App\Container;
|
use App\Container;
|
||||||
// use App\Router\Request\IRequest;
|
use App\Router\Request\IRequest;
|
||||||
// use App\Router\Response\Response;
|
use App\Router\Response\IResponse;
|
||||||
// use Shared\Attributes\Route;
|
use App\Router\Response\RedirectResponse;
|
||||||
// use Twig\Environment;
|
use App\Router\Response\Response;
|
||||||
// use Data\Core\Preferences;
|
use Manager\ActivityManager;
|
||||||
// use Shared\Log;
|
use Shared\Attributes\Route;
|
||||||
|
use Twig\Environment;
|
||||||
// class HeartRateController extends BaseController
|
use Data\Core\Preferences;
|
||||||
// {
|
use Shared\Log;
|
||||||
|
|
||||||
|
class HeartRateController extends BaseController
|
||||||
// #[Route(path: '/import', name: 'import', methods: ['GET'])]
|
{
|
||||||
// public function import(): Response
|
|
||||||
// {
|
private ActivityManager $activityMgr;
|
||||||
// return $this->render('./page/import.html.twig',[
|
|
||||||
// 'css' => $this->preference->getCookie(),
|
public function __construct(ActivityManager $manager)
|
||||||
// 'pp' => "test2",
|
{
|
||||||
// 'user' => "Doe",
|
parent::__construct();
|
||||||
// 'role' => "Athlète",
|
$this->activityMgr = $manager;
|
||||||
// 'friendship' => [],
|
}
|
||||||
// 'analyzes' => [],
|
|
||||||
// 'mails' => [],
|
#[Route(path: '/import', name: 'import', methods: ['GET'])]
|
||||||
// 'users' => [],
|
public function import(): Response
|
||||||
// 'infoUser' => [],
|
{
|
||||||
// 'exos' => [],
|
return $this->render('./page/import.html.twig', [
|
||||||
// 'member' => []
|
'css' => $this->preference->getCookie(),
|
||||||
// ]);
|
'pp' => "test2",
|
||||||
// }
|
'user' => "Doe",
|
||||||
|
'role' => "Athlète",
|
||||||
|
'friendship' => [],
|
||||||
// }
|
'analyzes' => [],
|
||||||
|
'mails' => [],
|
||||||
|
'users' => [],
|
||||||
|
'infoUser' => [],
|
||||||
|
'exos' => [],
|
||||||
|
'member' => []
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route(path: '/upload', name: 'upload', methods: ['POST'])]
|
||||||
|
public function uploadFile(string $activityType, int $effort, IRequest $req): IResponse
|
||||||
|
{
|
||||||
|
$error = $this->validateRequest($effort);
|
||||||
|
if (!empty($error)) {
|
||||||
|
return $this->renderError($error);
|
||||||
|
}
|
||||||
|
|
||||||
|
$tmp_file = $_FILES['uploaded_file']['tmp_name'];
|
||||||
|
if (!$this->isValidFile($tmp_file)) {
|
||||||
|
return $this->renderError(['Failed to get file be sure that you provide the file']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$content = file_get_contents($tmp_file);
|
||||||
|
try {
|
||||||
|
|
||||||
|
if ($this->activityMgr->uploadFile($activityType, 5, $content)) {
|
||||||
|
return new RedirectResponse('/');
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return $this->renderError([$e->getMessage()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->renderError(['Failed to save activity.']);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function validateRequest(int $effort): array
|
||||||
|
{
|
||||||
|
$error = [];
|
||||||
|
if ($effort < 0 || $effort > 5) {
|
||||||
|
$error[] = 'Invalid effort level.';
|
||||||
|
}
|
||||||
|
$fileExtension = pathinfo($_FILES['uploaded_file']['name'], PATHINFO_EXTENSION);
|
||||||
|
if ($fileExtension !== 'fit') {
|
||||||
|
$error[] = 'Invalid file type. Only .fit files are allowed.';
|
||||||
|
}
|
||||||
|
return $error;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function isValidFile(string $tmp_file): bool
|
||||||
|
{
|
||||||
|
return file_exists($tmp_file) && is_uploaded_file($tmp_file);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function renderError(array $error): Response
|
||||||
|
{
|
||||||
|
// Consolidez la logique de rendu ici
|
||||||
|
return $this->render('./error/error.html.twig', ['title'=> "Failed" , "code" => 400, "name" => "error import", "descr" => $error[0] ], new Response('$error', 400));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -1,19 +1,45 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
// use App\Container;
|
use App\Container;
|
||||||
// use App\Router\Request\IRequest;
|
use App\Router\Request\IRequest;
|
||||||
// use App\Router\Response\Response;
|
use App\Router\Response\Response;
|
||||||
// use App\Router\Response\IResponse;
|
use Shared\Attributes\Route;
|
||||||
|
use Twig\Environment;
|
||||||
|
use Data\Core\Preferences;
|
||||||
|
use Shared\Log;
|
||||||
|
|
||||||
// use Shared\Attributes\Route;
|
class SocialController extends BaseController
|
||||||
// use Twig\Environment;
|
{
|
||||||
// use Data\Core\Preferences;
|
|
||||||
// use Shared\Log;
|
|
||||||
|
|
||||||
|
private Environment $twig;
|
||||||
|
protected Preferences $preference;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
session_start();
|
||||||
|
$this->preference = new Preferences();
|
||||||
|
}
|
||||||
|
|
||||||
// #[Route(path: '/coach', name: 'coach')]
|
|
||||||
// class CoachController extends BaseController
|
#[Route(path: '/mail', name: 'mail', methods: ['GET'])]
|
||||||
// {
|
public function mail(): Response
|
||||||
|
{
|
||||||
|
return $this->render('./page/mail.html.twig',[
|
||||||
|
'css' => $this->preference->getCookie(),
|
||||||
|
'pp' => "test2",
|
||||||
|
'user' => "Doe",
|
||||||
|
'role' => "Athlète",
|
||||||
|
'friendship' => [],
|
||||||
|
'analyzes' => [],
|
||||||
|
'mails' => [],
|
||||||
|
'users' => [],
|
||||||
|
'infoUser' => [],
|
||||||
|
'exos' => [],
|
||||||
|
'member' => []
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1,51 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Database;
|
|
||||||
use Model\Activite;
|
|
||||||
|
|
||||||
class ActiviteMapper {
|
|
||||||
public function map(array $data):ActiviteEntity {
|
|
||||||
$activite = new ActiviteEntity();
|
|
||||||
$activite->setIdActivite($data['idActivite']);
|
|
||||||
$activite->setType($data['type']);
|
|
||||||
$activite->setDate($data['date']);
|
|
||||||
$activite->setHeureDebut($data['heureDebut']);
|
|
||||||
$activite->setHeureFin($data['heureFin']);
|
|
||||||
$activite->setEffortRessenti($data['effortRessenti']);
|
|
||||||
$activite->setVariabilite($data['variabilite']);
|
|
||||||
$activite->setVariance($data['variance']);
|
|
||||||
$activite->setEcartType($data['ecartType']);
|
|
||||||
$activite->setMoyenne($data['moyenne']);
|
|
||||||
$activite->setMaximum($data['maximum']);
|
|
||||||
$activite->setMinimum($data['minimum']);
|
|
||||||
$activite->setTemperatureMoyenne($data['temperatureMoyenne']);
|
|
||||||
|
|
||||||
return $activite;
|
|
||||||
}
|
|
||||||
|
|
||||||
//public function ActiviteEntityToModel(ActiviteEntity entity): Activite;
|
|
||||||
|
|
||||||
public function ActiviteEntityToModel(ActiviteEntity $activiteEntity):Activite{
|
|
||||||
|
|
||||||
$act = new Activite(
|
|
||||||
$activiteEntity->getIdActivite(),
|
|
||||||
$activiteEntity->getType(),
|
|
||||||
$activiteEntity->getDate(),
|
|
||||||
$activiteEntity->getHeureDebut(),
|
|
||||||
$activiteEntity->getHeureFin(),
|
|
||||||
$activiteEntity->getEffortRessenti(),
|
|
||||||
$activiteEntity->getVariabilite(),
|
|
||||||
$activiteEntity->getVariance(),
|
|
||||||
$activiteEntity->getEcartType(),
|
|
||||||
$activiteEntity->getMoyenne(),
|
|
||||||
$activiteEntity->getMaximum(),
|
|
||||||
$activiteEntity->getMinimum(),
|
|
||||||
$activiteEntity->getTemperatureMoyenne()
|
|
||||||
);
|
|
||||||
|
|
||||||
return $act;
|
|
||||||
}
|
|
||||||
//public function ActiviteToEntity(Activite model): ActiviteEntity;
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
@ -0,0 +1,118 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database;
|
||||||
|
use Model\Activity;
|
||||||
|
|
||||||
|
class ActivityMapper {
|
||||||
|
public function activitySqlToEntity(array $data):array
|
||||||
|
{
|
||||||
|
$activityEntities = [];
|
||||||
|
|
||||||
|
foreach ($data as $activityData) {
|
||||||
|
$activity = new ActivityEntity();
|
||||||
|
|
||||||
|
if (isset($activityData['idActivity'])) {
|
||||||
|
$activity->setIdActivity($data['idActivity']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($activityData['type'])) {
|
||||||
|
$activity->setType($data['type']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($activityData['date'])) {
|
||||||
|
$activity->setDate($data['date']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($activityData['heureDebut'])) {
|
||||||
|
$activity->setHeureDebut($data['heureDebut']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($activityData['heureFin'])) {
|
||||||
|
$activity->setHeureFin($data['heureFin']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($activityData['effortRessenti'])) {
|
||||||
|
$activity->setEffortRessenti($data['effortRessenti']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($activityData['variabilite'])) {
|
||||||
|
$activity->setVariabilite($data['variabilite']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($activityData['variance'])) {
|
||||||
|
$activity->setVariance($data['variance']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($activityData['ecartType'])) {
|
||||||
|
$activity->setEcartType($data['ecartType']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($activityData['moyenne'])) {
|
||||||
|
$activity->setMoyenne($data['moyenne']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($activityData['maximum'])) {
|
||||||
|
$activity->setMaximum($data['maximum']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($activityData['minimum'])) {
|
||||||
|
$activity->setMinimum($data['minimum']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($activityData['temperatureMoyenne'])) {
|
||||||
|
$activity->setTemperatureMoyenne($data['temperatureMoyenne']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$activityEntities[] = $activity;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $activityEntities;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
public function ActivityEntityToModel(ActivityEntity $activiteEntity):Activity{
|
||||||
|
|
||||||
|
$act = new Activity(
|
||||||
|
$activiteEntity->getIdActivity(),
|
||||||
|
$activiteEntity->getType(),
|
||||||
|
$activiteEntity->getDate(),
|
||||||
|
$activiteEntity->getHeureDebut(),
|
||||||
|
$activiteEntity->getHeureFin(),
|
||||||
|
$activiteEntity->getEffortRessenti(),
|
||||||
|
$activiteEntity->getVariabilite(),
|
||||||
|
$activiteEntity->getVariance(),
|
||||||
|
$activiteEntity->getEcartType(),
|
||||||
|
$activiteEntity->getMoyenne(),
|
||||||
|
$activiteEntity->getMaximum(),
|
||||||
|
$activiteEntity->getMinimum(),
|
||||||
|
$activiteEntity->getTemperatureMoyenne()
|
||||||
|
);
|
||||||
|
|
||||||
|
return $act;
|
||||||
|
}
|
||||||
|
//public function ActivityToEntity(Activity model): ActivityEntity;
|
||||||
|
|
||||||
|
public function activityToEntity(Activity $act):ActivityEntity{
|
||||||
|
|
||||||
|
$act = new ActivityEntity();
|
||||||
|
$act->setIdActivity($act->getIdActivity()());
|
||||||
|
$act->setType($act->getType());
|
||||||
|
$act->setDate($act->getDate());
|
||||||
|
$act->setHeureDebut($act->getHeureDebut());
|
||||||
|
$act->setHeureFin($act->getHeureFin());
|
||||||
|
$act->setEffortRessenti($act->getEffortRessenti());
|
||||||
|
$act->setVariabilite($act->getVariabilite());
|
||||||
|
$act->setVariance($act->getVariance());
|
||||||
|
$act->setEcartType($act->getEcartType());
|
||||||
|
$act->setMoyenne($act->getMoyenne());
|
||||||
|
$act->setMaximum($act->getMaximum());
|
||||||
|
$act->setMinimum($act->getMinimum());
|
||||||
|
$act->setTemperatureMoyenne($act->getTemperatureMoyenne());
|
||||||
|
|
||||||
|
return $act;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,71 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database;
|
||||||
|
|
||||||
|
class EntrainementEntity
|
||||||
|
{
|
||||||
|
private $idEntrainement;
|
||||||
|
private $date;
|
||||||
|
private $description;
|
||||||
|
private $latitude;
|
||||||
|
private $longitude;
|
||||||
|
private $feedback;
|
||||||
|
private $coachId;
|
||||||
|
|
||||||
|
public function getIdEntrainement()
|
||||||
|
{
|
||||||
|
return $this->idEntrainement;
|
||||||
|
}
|
||||||
|
public function getDate()
|
||||||
|
{
|
||||||
|
return $this->date;
|
||||||
|
}
|
||||||
|
public function getDescription()
|
||||||
|
{
|
||||||
|
return $this->description;
|
||||||
|
}
|
||||||
|
public function getLatitude()
|
||||||
|
{
|
||||||
|
return $this->latitude;
|
||||||
|
}
|
||||||
|
public function getLongitude()
|
||||||
|
{
|
||||||
|
return $this->longitude;
|
||||||
|
}
|
||||||
|
public function getFeedback()
|
||||||
|
{
|
||||||
|
return $this->feedback;
|
||||||
|
}
|
||||||
|
public function getCoachId()
|
||||||
|
{
|
||||||
|
return $this->coachId;
|
||||||
|
}
|
||||||
|
public function setIdEntrainement($idEntrainement)
|
||||||
|
{
|
||||||
|
$this->idEntrainement = $idEntrainement;
|
||||||
|
}
|
||||||
|
public function setDate($date)
|
||||||
|
{
|
||||||
|
$this->date = $date;
|
||||||
|
}
|
||||||
|
public function setDescription($description)
|
||||||
|
{
|
||||||
|
$this->description = $description;
|
||||||
|
}
|
||||||
|
public function setLatitude($latitude)
|
||||||
|
{
|
||||||
|
$this->latitude = $latitude;
|
||||||
|
}
|
||||||
|
public function setLongitude($longitude)
|
||||||
|
{
|
||||||
|
$this->longitude = $longitude;
|
||||||
|
}
|
||||||
|
public function setFeedback($feedback)
|
||||||
|
{
|
||||||
|
$this->feedback = $feedback;
|
||||||
|
}
|
||||||
|
public function setCoachId($coachId)
|
||||||
|
{
|
||||||
|
$this->coachId = $coachId;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database;
|
||||||
|
|
||||||
|
class EntrainementGateway
|
||||||
|
{
|
||||||
|
private Connexion $connection;
|
||||||
|
|
||||||
|
public function __construct(Connexion $connection) {
|
||||||
|
$this->connection = $connection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEntrainements(): array
|
||||||
|
{
|
||||||
|
$query = "SELECT * FROM Entrainement";
|
||||||
|
$res = $this->connection->executeWithErrorHandling($query);
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,74 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database;
|
||||||
|
|
||||||
|
use Model\Athlete;
|
||||||
|
use Model\Training;
|
||||||
|
use Model\User;
|
||||||
|
|
||||||
|
class EntrainementMapper
|
||||||
|
{
|
||||||
|
public function entrainementSqlToEntity(array $data): array {
|
||||||
|
$entrainementEntities = [];
|
||||||
|
|
||||||
|
foreach ($data as $entrainementData) {
|
||||||
|
$entrainement = new EntrainementEntity();
|
||||||
|
if (isset($entrainementData['idEntrainement'])) {
|
||||||
|
$entrainement->setIdEntrainement($entrainementData['idEntrainement']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($entrainementData['date'])) {
|
||||||
|
$entrainement->setDate($entrainementData['date']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($entrainementData['description'])) {
|
||||||
|
$entrainement->setDescription($entrainementData['description']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($entrainementData['latitude'])) {
|
||||||
|
$entrainement->setLatitude($entrainementData['latitude']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($entrainementData['longitude'])) {
|
||||||
|
$entrainement->setLongitude($entrainementData['longitude']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($entrainementData['feedback'])) {
|
||||||
|
$entrainement->setFeedback($entrainementData['feedback']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($entrainementData['coachId'])) {
|
||||||
|
$entrainement->setCoachId($entrainementData['coachId']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$entrainementEntities[] = $entrainement;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $entrainementEntities;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function entrainementEntityToModel(EntrainementEntity $entrainementEntity): Training {
|
||||||
|
return new Training(
|
||||||
|
$entrainementEntity->getIdEntrainement(),
|
||||||
|
$entrainementEntity->getDate(),
|
||||||
|
$entrainementEntity->getDescription(),
|
||||||
|
$entrainementEntity->getLatitude(),
|
||||||
|
$entrainementEntity->getLongitude(),
|
||||||
|
$entrainementEntity->getFeedback()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function entrainementToEntity(Training $training):EntrainementEntity{
|
||||||
|
|
||||||
|
$train = new EntrainementEntity();
|
||||||
|
$train->setIdEntrainement($training->getId());
|
||||||
|
$train->setDate($training->getDate());
|
||||||
|
$train->setDescription($training->getDescription());
|
||||||
|
$train->setLatitude($training->getLatitude());
|
||||||
|
$train->setLongitude($training->getLongitude());
|
||||||
|
$train->setFeedback($training->getFeedback());
|
||||||
|
$train->setCoachId(1);
|
||||||
|
|
||||||
|
return $train;
|
||||||
|
}
|
||||||
|
}
|
@ -1,9 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Repository;
|
namespace Repository;
|
||||||
|
use Model\User;
|
||||||
|
|
||||||
interface IUserRepository extends IGenericRepository {
|
interface IUserRepository extends IGenericRepository {
|
||||||
public function addFriend(int $user1,int $user2);
|
public function addFriend(User $user1,user $user2);
|
||||||
public function deleteFriend(int $user1,int $user2);
|
public function deleteFriend(User $user1,User $user2);
|
||||||
|
|
||||||
|
public function getItemByEmail(string $email);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,215 @@
|
|||||||
|
<?php
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
|
||||||
|
//use Database\{Connexion, AthleteGateway,AthleteEntity};
|
||||||
|
use Database\AthleteEntity;
|
||||||
|
use Database\AthleteGateway;
|
||||||
|
use Database\Connexion;
|
||||||
|
use Database\AthleteMapper;
|
||||||
|
use Database\CoachGateway;
|
||||||
|
use Database\CoachEntity;
|
||||||
|
use Database\CoachMapper;
|
||||||
|
|
||||||
|
class GatewayTest extends TestCase {
|
||||||
|
|
||||||
|
//Partie concernant les Athlètes
|
||||||
|
|
||||||
|
public function testGetAthlete() {
|
||||||
|
|
||||||
|
//$dsn = "pgsql:host=londres;port=8888;dbname=dbkemonteiro2;user=kemonteiro2;password=Mdp";
|
||||||
|
|
||||||
|
require "loginDatabase.php";
|
||||||
|
|
||||||
|
$connexion = new Connexion($dsn,$username,$password);
|
||||||
|
|
||||||
|
|
||||||
|
$athleteGateway = new AthleteGateway($connexion);
|
||||||
|
$result = $athleteGateway->getAthlete();
|
||||||
|
//var_dump($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fonctionne mais en commentaire pour pas add et del a chaque fois
|
||||||
|
public function testAddAthlete(){
|
||||||
|
$dsn = "mysql:host=londres;dbname=dbkemonteiro2;";
|
||||||
|
$username = "kemonteiro2";
|
||||||
|
$password = "#Phpmyadmin63";
|
||||||
|
|
||||||
|
$connexion = new Connexion($dsn,$username,$password);
|
||||||
|
|
||||||
|
|
||||||
|
$athleteGateway = new AthleteGateway($connexion);
|
||||||
|
|
||||||
|
$dateSpecifique = "2023-11-26";
|
||||||
|
$timestamp = strtotime($dateSpecifique);
|
||||||
|
$dateSQL = date("Y-m-d", $timestamp);
|
||||||
|
|
||||||
|
$athleteEntity = new AthleteEntity();
|
||||||
|
$athleteEntity->setNom('John');
|
||||||
|
$athleteEntity->setPrenom('Doe');
|
||||||
|
$athleteEntity->setIdAthlete(1234);
|
||||||
|
$athleteEntity->setEmail('kevin.monteiro@gmail.fr');
|
||||||
|
$athleteEntity->setSexe('H');
|
||||||
|
$athleteEntity->setTaille(169);
|
||||||
|
$athleteEntity->setPoids(69);
|
||||||
|
$athleteEntity->setMotDePasse('motdepasse');
|
||||||
|
$athleteEntity->setDateNaissance($dateSQL);
|
||||||
|
|
||||||
|
$result2 = $athleteGateway->addAthlete($athleteEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function testDeleteAthlete(){
|
||||||
|
$dsn = "mysql:host=londres;dbname=dbkemonteiro2;";
|
||||||
|
$username = "kemonteiro2";
|
||||||
|
$password = "#Phpmyadmin63";
|
||||||
|
|
||||||
|
$connexion = new Connexion($dsn,$username,$password);
|
||||||
|
|
||||||
|
$athleteGateway = new AthleteGateway($connexion);
|
||||||
|
$result = $athleteGateway->deleteAthlete( //idAthlete );
|
||||||
|
var_dump($result);
|
||||||
|
|
||||||
|
}*/
|
||||||
|
|
||||||
|
public function testUpdateAthlete(){
|
||||||
|
$dsn = "mysql:host=londres;dbname=dbkemonteiro2;";
|
||||||
|
$username = "kemonteiro2";
|
||||||
|
$password = "#Phpmyadmin63";
|
||||||
|
|
||||||
|
$connexion = new Connexion($dsn,$username,$password);
|
||||||
|
|
||||||
|
$athleteGateway = new AthleteGateway($connexion);
|
||||||
|
|
||||||
|
$dateSpecifique = "2004-08-26";
|
||||||
|
$timestamp = strtotime($dateSpecifique);
|
||||||
|
$dateSQL = date("Y-m-d", $timestamp);
|
||||||
|
|
||||||
|
$athleteEntity = new AthleteEntity();
|
||||||
|
$athleteEntity->setNom('John');
|
||||||
|
$athleteEntity->setPrenom('Doe');
|
||||||
|
$athleteEntity->setIdAthlete(13);
|
||||||
|
$athleteEntity->setEmail('kevin.monteiro@gmail.fr');
|
||||||
|
$athleteEntity->setSexe('H');
|
||||||
|
$athleteEntity->setTaille(169);
|
||||||
|
$athleteEntity->setPoids(69);
|
||||||
|
$athleteEntity->setMotDePasse('motdepasse');
|
||||||
|
$athleteEntity->setDateNaissance($dateSQL);
|
||||||
|
$athleteEntity->setIsCoach(FALSE);
|
||||||
|
$athleteEntity->setCoachId(NULL);
|
||||||
|
|
||||||
|
$athleteEntity2 = new AthleteEntity();
|
||||||
|
$athleteEntity2->setNom('Monteiro');
|
||||||
|
$athleteEntity2->setPrenom('Kevin');
|
||||||
|
$athleteEntity2->setIdAthlete(13);
|
||||||
|
$athleteEntity2->setEmail('kevin.monteiro@gmail.fr');
|
||||||
|
$athleteEntity2->setSexe('H');
|
||||||
|
$athleteEntity2->setTaille(169);
|
||||||
|
$athleteEntity2->setPoids(69);
|
||||||
|
$athleteEntity2->setMotDePasse('motdepasse');
|
||||||
|
$athleteEntity2->setDateNaissance($dateSQL);
|
||||||
|
$athleteEntity2->setIsCoach(TRUE);
|
||||||
|
$athleteEntity2->setCoachId(1);
|
||||||
|
|
||||||
|
$result = $athleteGateway->updateAthlete($athleteEntity, $athleteEntity2);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Partie concernant les Coachs
|
||||||
|
|
||||||
|
public function testGetCoach() {
|
||||||
|
|
||||||
|
//$dsn = "pgsql:host=londres;port=8888;dbname=dbkemonteiro2;user=kemonteiro2;password=Mdp";
|
||||||
|
|
||||||
|
$dsn = "mysql:host=londres;dbname=dbkemonteiro2;";
|
||||||
|
$username = "kemonteiro2";
|
||||||
|
$password = "#Phpmyadmin63";
|
||||||
|
|
||||||
|
$connexion = new Connexion($dsn,$username,$password);
|
||||||
|
|
||||||
|
|
||||||
|
$coachGateway = new CoachGateway($connexion);
|
||||||
|
$result = $coachGateway->getCoach();
|
||||||
|
var_dump($result);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
//Fonctionne PAS A PARTIR DE LA
|
||||||
|
public function testAddCoach(){
|
||||||
|
$dsn = "mysql:host=londres;dbname=dbkemonteiro2;";
|
||||||
|
$username = "kemonteiro2";
|
||||||
|
$password = "#Phpmyadmin63";
|
||||||
|
|
||||||
|
$connexion = new Connexion($dsn,$username,$password);
|
||||||
|
|
||||||
|
|
||||||
|
$coachGateway = new CoachGateway($connexion);
|
||||||
|
|
||||||
|
$dateSpecifique = "2023-11-26";
|
||||||
|
$timestamp = strtotime($dateSpecifique);
|
||||||
|
$dateSQL = date("Y-m-d", $timestamp);
|
||||||
|
|
||||||
|
$coachEntity = new CoachEntity();
|
||||||
|
$coachEntity->setNom('John');
|
||||||
|
$coachEntity->setPrenom('Doe');
|
||||||
|
$coachEntity->setIdCoach(1234);
|
||||||
|
$coachEntity->setEmail('kevin.monteiro@gmail.fr');
|
||||||
|
$coachEntity->setSexe('H');
|
||||||
|
$coachEntity->setTaille(169);
|
||||||
|
$coachEntity->setPoids(69);
|
||||||
|
$coachEntity->setMotDePasse('motdepasse');
|
||||||
|
$coachEntity->setDateNaissance($dateSQL);
|
||||||
|
|
||||||
|
$result2 = $coachGateway->addCoach($coachEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function testDeleteAthlete(){
|
||||||
|
$dsn = "mysql:host=londres;dbname=dbkemonteiro2;";
|
||||||
|
$username = "kemonteiro2";
|
||||||
|
$password = "#Phpmyadmin63";
|
||||||
|
|
||||||
|
$connexion = new Connexion($dsn,$username,$password);
|
||||||
|
|
||||||
|
$athleteGateway = new AthleteGateway($connexion);
|
||||||
|
$result = $athleteGateway->deleteAthlete( //idAthlete );
|
||||||
|
var_dump($result);
|
||||||
|
|
||||||
|
}*/
|
||||||
|
/*
|
||||||
|
public function testUpdateAthlete(){
|
||||||
|
$dsn = "mysql:host=londres;dbname=dbkemonteiro2;";
|
||||||
|
$username = "kemonteiro2";
|
||||||
|
$password = "#Phpmyadmin63";
|
||||||
|
|
||||||
|
$connexion = new Connexion($dsn,$username,$password);
|
||||||
|
|
||||||
|
$athleteGateway = new AthleteGateway($connexion);
|
||||||
|
|
||||||
|
$dateSpecifique = "2004-08-26";
|
||||||
|
$timestamp = strtotime($dateSpecifique);
|
||||||
|
$dateSQL = date("Y-m-d", $timestamp);
|
||||||
|
|
||||||
|
$athleteEntity = new AthleteEntity();
|
||||||
|
$athleteEntity->setNom('John');
|
||||||
|
$athleteEntity->setPrenom('Doe');
|
||||||
|
$athleteEntity->setIdAthlete(13);
|
||||||
|
$athleteEntity->setEmail('kevin.monteiro@gmail.fr');
|
||||||
|
$athleteEntity->setSexe('H');
|
||||||
|
$athleteEntity->setTaille(169);
|
||||||
|
$athleteEntity->setPoids(69);
|
||||||
|
$athleteEntity->setMotDePasse('motdepasse');
|
||||||
|
$athleteEntity->setDateNaissance($dateSQL);
|
||||||
|
|
||||||
|
$athleteEntity2 = new AthleteEntity();
|
||||||
|
$athleteEntity2->setNom('Monteiro');
|
||||||
|
$athleteEntity2->setPrenom('Kevin');
|
||||||
|
$athleteEntity2->setIdAthlete(13);
|
||||||
|
$athleteEntity2->setEmail('kevin.monteiro@gmail.fr');
|
||||||
|
$athleteEntity2->setSexe('H');
|
||||||
|
$athleteEntity2->setTaille(169);
|
||||||
|
$athleteEntity2->setPoids(69);
|
||||||
|
$athleteEntity2->setMotDePasse('motdepasse');
|
||||||
|
$athleteEntity2->setDateNaissance($dateSQL);
|
||||||
|
|
||||||
|
$result = $athleteGateway->updateAthlete($athleteEntity, $athleteEntity2);
|
||||||
|
}*/
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
use Model\User;
|
||||||
|
use Database\AthleteEntity;
|
||||||
|
use Database\AthleteGateway;
|
||||||
|
use Database\Connexion;
|
||||||
|
use Database\AthleteMapper;
|
||||||
|
|
||||||
|
class MapperTest extends TestCase {
|
||||||
|
|
||||||
|
public function testMapperAthlete() {
|
||||||
|
|
||||||
|
//$dsn = "pgsql:host=londres;port=8888;dbname=dbkemonteiro2;user=kemonteiro2;password=Mdp";
|
||||||
|
|
||||||
|
$dsn = "mysql:host=londres;dbname=dbkemonteiro2;";
|
||||||
|
$username = "kemonteiro2";
|
||||||
|
$password = "#Phpmyadmin63";
|
||||||
|
|
||||||
|
$connexion = new Connexion($dsn,$username,$password);
|
||||||
|
|
||||||
|
|
||||||
|
$athleteGateway = new AthleteGateway($connexion);
|
||||||
|
$result = $athleteGateway->getAthlete();
|
||||||
|
|
||||||
|
$map = new AthleteMapper ();
|
||||||
|
//SQL To AthleteEntity
|
||||||
|
$athleteEntity = $map->athleteSqlToEntity($result);
|
||||||
|
|
||||||
|
|
||||||
|
foreach($athleteEntity as $ath){
|
||||||
|
|
||||||
|
$result = $ath->getNom();
|
||||||
|
var_dump($result);
|
||||||
|
//Pour chaque AthleteEntity : Athlete Entity To User avec Role Athlete(Model)
|
||||||
|
$user = $map->athleteEntityToModel($ath);
|
||||||
|
var_dump($user->getId());
|
||||||
|
//Pour chaque Athlete du Model -> Athlete Entity
|
||||||
|
$res = $map->athleteToEntity($user);
|
||||||
|
var_dump($res->getIdAthlete());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$dsn = "psql:host=localhost;dbname=sae_3;";
|
||||||
|
$username = "Perederii";
|
||||||
|
$password = "";
|
||||||
|
|
||||||
|
?>
|