diff --git a/README.md b/README.md
index 0036eb1..f6aeb7b 100644
--- a/README.md
+++ b/README.md
@@ -12,6 +12,8 @@ Puis effectuer les changement suivants
- Renommer sso/filtres/nineskeletor.ini en sso/filtres/nineXXXX.ini
- Renommer sso/filtres/nineskeletor_apps.ini en sso/filtres/nineXXXX_apps.ini
- Modifier sso/filtres/nineXXXX_apps.ini et remplacer tout les nineskeletor en nineXXXX
+- Renommer tmpl/nineskeletor.cron en tmpl/nineXXXX.cron
+- Modifier tmpl/nineXXXX.cron et remplacer tout les nineskeletor en nineXXXX
- Renommer tmpl/nineskeletor-apache.conf en tmpl/nineXXXX-apache.conf
- Modifier tmpl/nineXXXX-apache.conf et remplacer tout les nineskeletor en nineXXXX
- Renommer tmpl/nineskeletor-db.yml en tmpl/nineXXXX-db.yml
@@ -21,6 +23,7 @@ Puis effectuer les changement suivants
- Modifier src/webpack.config.js et remplacer tout les nineskeletor en nineXXXX
- Renommer tmpl/nineskeletor-proxy.sh en tmpl/nineXXXX-proxy.sh
- Modifier Makefile et remplacer tout les nineskeletor en nineXXXX
+- Remplacer logo public/images/logo.png
2= Compilier les asset
installer npm
diff --git a/src/nineskeletor-1.0/config/packages/doctrine_migrations.yaml b/src/nineskeletor-1.0/config/packages/doctrine_migrations.yaml
index 3bf0fbc..49c3517 100644
--- a/src/nineskeletor-1.0/config/packages/doctrine_migrations.yaml
+++ b/src/nineskeletor-1.0/config/packages/doctrine_migrations.yaml
@@ -1,5 +1,3 @@
doctrine_migrations:
- dir_name: '%kernel.project_dir%/src/Migrations'
- # namespace is arbitrary but should be different from App\Migrations
- # as migrations classes should NOT be autoloaded
- namespace: DoctrineMigrations
+ migrations_paths:
+ 'DoctrineMigrations': '%kernel.project_dir%/src/Migrations'
\ No newline at end of file
diff --git a/src/nineskeletor-1.0/config/routes.yaml b/src/nineskeletor-1.0/config/routes.yaml
index 8299d64..b429c86 100644
--- a/src/nineskeletor-1.0/config/routes.yaml
+++ b/src/nineskeletor-1.0/config/routes.yaml
@@ -3,6 +3,10 @@ app_home:
path: /
defaults: { _controller: App\Controller\HomeController:home }
+app_admin:
+ path: /admin/home
+ defaults: { _controller: App\Controller\HomeController:admin }
+
app_ckeditor_upload:
path: /user/activity/upload
defaults: { _controller: App\Controller\HomeController:upload }
@@ -105,103 +109,3 @@ app_group_delete:
app_group_select:
path: /user/group/select
defaults: { _controller: App\Controller\GroupController:select }
-
-#== Activity ========================================================================================================
-app_activity:
- path: /user/activity
- defaults: { _controller: App\Controller\ActivityController:list }
-
-app_activity_submit:
- path: /master/activity/submit
- defaults: { _controller: App\Controller\ActivityController:submit }
-
-app_activity_update:
- path: /master/activity/update/{id}
- defaults: { _controller: App\Controller\ActivityController:update }
-
-app_activity_delete:
- path: /master/activity/delete/{id}
- defaults: { _controller: App\Controller\ActivityController:delete }
-
-app_activity_archive:
- path: /master/activity/archive/{id}
- defaults: { _controller: App\Controller\ActivityController:archive }
-
-app_activity_activeactivity:
- path: /user/activity/activeactivity
- defaults: { _controller: App\Controller\ActivityController:activeactivity }
-
-#== Answer ========================================================================================================
-app_answer_update:
- path: /user/answer/update/{id}
- defaults: { _controller: App\Controller\AnswerController:update }
-
-app_answer_view:
- path: /master/answer/view/{id}
- defaults: { _controller: App\Controller\AnswerController:view }
-
-app_answer_select:
- path: /master/answer/select
- defaults: { _controller: App\Controller\AnswerController:select }
-
-#== Document ========================================================================================================
-app_document_upload:
- path: /user/document/{entity}/{id}/upload
- defaults: { _controller: App\Controller\DocumentController:upload }
-
-app_document_record:
- path: /user/document/{entity}/{id}/record
- defaults: { _controller: App\Controller\DocumentController:record }
-
-app_document_recordupload:
- path: /user/document/{entity}/{id}/recordupload
- defaults: { _controller: App\Controller\DocumentController:recordupload }
-
-app_document_listmaster:
- path: /user/document/{entity}/{id}/listmaster
- defaults: { _controller: App\Controller\DocumentController:list, master: true }
-
-app_document_listuser:
- path: /user/document/{entity}/{id}/listuser
- defaults: { _controller: App\Controller\DocumentController:list, master: false }
-
-app_document_view:
- path: /user/document/{entity}/{id}/view
- defaults: { _controller: App\Controller\DocumentController:view }
-
-app_document_show:
- path: /user/document/{entity}/{id}/show
- defaults: { _controller: App\Controller\DocumentController:show }
-
-app_document_update:
- path: /user/document/{entity}/{id}/update
- defaults: { _controller: App\Controller\DocumentController:update }
-
-app_document_delete:
- path: /user/document/{entity}/{id}/delete
- defaults: { _controller: App\Controller\DocumentController:delete }
-
-#== Message ========================================================================================================
-app_message_unread:
- path: /user/message/unread
- defaults: { _controller: App\Controller\MessageController:unread }
-
-app_message:
- path: /user/message/{id}
- defaults: { _controller: App\Controller\MessageController:message }
-
-app_message_load:
- path: /user/message/{id}/load
- defaults: { _controller: App\Controller\MessageController:load }
-
-app_message_delete:
- path: /user/message/{id}/delete
- defaults: { _controller: App\Controller\MessageController:delete }
-
-app_message_submit:
- path: /user/message/{id}/submit
- defaults: { _controller: App\Controller\MessageController:submit }
-
-app_message_group:
- path: /master/message/{id}/group
- defaults: { _controller: App\Controller\MessageController:messagegroup }
diff --git a/src/nineskeletor-1.0/public/images/logo.png b/src/nineskeletor-1.0/public/images/logo.png
index 7596de6..db76093 100644
Binary files a/src/nineskeletor-1.0/public/images/logo.png and b/src/nineskeletor-1.0/public/images/logo.png differ
diff --git a/src/nineskeletor-1.0/src/Controller/ActivityController.php b/src/nineskeletor-1.0/src/Controller/ActivityController.php
deleted file mode 100755
index 06d9d24..0000000
--- a/src/nineskeletor-1.0/src/Controller/ActivityController.php
+++ /dev/null
@@ -1,397 +0,0 @@
-mail = $mail; }
-
- public function list(Request $request)
- {
- $em = $this->getDoctrine()->getManager();
- $user=$this->getUser();
- $activeactivity=$this->get('session')->get('activeactivity');
-
- // View master
- if ($user->hasRole('ROLE_ADMIN')||$user->hasRole('ROLE_MASTER')) {
- $datas = $em->getRepository($this->entity)->findAllMasterActivityActive($user,$activeactivity);
-
- return $this->render($this->render.'list.html.twig',[
- $this->data."s" => $datas,
- "useheader" => true,
- "usesidebar" => ($this->getUser()->hasRole("ROLE_ADMIN")),
- ]);
- }
- // View student
- elseif($user->hasRole('ROLE_STUDENT')) {
- $user=$this->getUser();
-
- // Recherche de l'ensemble des activités distribuées des groupes de l'utilisateur
- $datas=new ArrayCollection();
- foreach($user->getGroups() as $group) {
- $activitys = $em->getRepository($this->entity)->findAllGroupActivityActive($group,$activeactivity);
-
- foreach($activitys as $activity) {
- if($activeactivity&&$activity->getStatus()==10) continue;
- if(!$activeactivity&&$activity->getStatus()<10) continue;
-
-
- // Recherche d'une réponse pour l'utilistaeur
- $answer=$em->getRepository("App:Answer")->findOneBy(["user"=>$user, "activity" => $activity]);
-
- // Si pas de réponse on initialise une réponse à vue
- if(!$answer) {
- $answer=new Answer();
- $answer->setStatus(0);
- $answer->setUser($user);
- $answer->setActivity($activity);
- $em->persist($answer);
- $em->flush();
- }
-
- // Si réponse non vu on la place en vu
- if($answer->getStatus()==-1) {
- $answer->setStatus(0);
- $em->persist($answer);
- $em->flush();
-
- // Message
- $message = new Message;
- $message->setMessage("Vu");
- $message->setDeletable(false);
- $message->setUser($user);
- $message->setAnswer($answer);
- $message->addReader($user);
- $em->persist($message);
- $em->flush();
- }
-
- $activity->setAnsweruser($answer);
- $datas->add($activity);
- }
- }
- return $this->render('Answer/list.html.twig',[
- $this->data."s" => $datas,
- "useheader" => true,
- "usesidebar" => ($this->getUser()->hasRole("ROLE_ADMIN")),
- ]);
- }
- }
-
- public function submit(Request $request)
- {
- // Initialisation de l'enregistrement
- $em = $this->getDoctrine()->getManager();
- $data = new Entity();
- $data->setStatus(0);
-
- // Création du formulaire
- $form = $this->createForm(Form::class,$data,array("mode"=>"submit","status"=>$data->getStatus()));
-
- // Récupération des data du formulaire
- $form->handleRequest($request);
-
- // Sur erreur
- $this->getErrorForm(null,$form,$request,$data,"submit");
-
- // Sur validation
- if ($form->get('submit')->isClicked() && $form->isValid()) {
- $data = $form->getData();
- $data->setUser($this->getUser());
- $em->persist($data);
- $em->flush();
-
- // Retour à la liste
- return $this->redirectToRoute($this->route."_update",["id"=>$data->getId()]);
- }
-
- // Affichage du formulaire
- return $this->render($this->render.'edit.html.twig', [
- 'useheader' => true,
- 'usesidebar' => ($this->getUser()->hasRole("ROLE_ADMIN")),
- $this->data => $data,
- 'mode' => 'submit',
- 'form' => $form->createView()
- ]);
- }
-
- public function update($id,Request $request)
- {
- // Initialisation de l'enregistrement
- $em = $this->getDoctrine()->getManager();
- $data=$em->getRepository($this->entity)->find($id);
-
- // Controle accès
- if(!$data)
- return $this->redirectToRoute($this->route);
- else {
- if(!$this->getUser()->Hasrole("ROLE_ADMIN")&&$this->getUser()!=$data->getUser())
- return $this->redirectToRoute($this->route);
- }
-
- // Création du formulaire
- $form = $this->createForm(Form::class,$data,array("mode"=>"update","status"=>$data->getStatus()));
-
- // Récupération des data du formulaire
- $form->handleRequest($request);
-
- // Sur erreur
- $this->getErrorForm(null,$form,$request,$data,"update");
-
- $valid=false;
- if($form->isSubmitted()&&$form->isValid()) {
- if($form->get('submit')->isClicked())
- $valid=true;
-
- if ($form->has('distribution') && $form->get('distribution')->isClicked())
- $valid=true;
-
- if ($form->has('archiving') && $form->get('archiving')->isClicked())
- $valid=true;
- }
-
- // Sur validation
- if ($valid) {
- $data = $form->getData();
-
- // Distribution de l'activité
- if ($form->has('distribution') && $form->get('distribution')->isClicked()) {
- // Si réouverture
- if($data->getStatus()==10) {
- // Message
- foreach($data->getAnswers() as $answer) {
- $message=new Message;
- $message->setMessage("Réouverture de l'Activité");
- $message->setDeletable(false);
- $message->setUser($data->getUser());
- $message->setAnswer($answer);
- $message->addReader($data->getUser());
- $em->persist($message);
- $em->flush();
-
- // Notification par mail de la distribution de l'activité
- $to = $answer->getUser()->getEmail();
- $from = $data->getUser()->getEmail();
- $subject="Nineschool : Réouverture de l'activité";
- $body ="Activité = ".$data->getName()."
";
- $body.="Professeur = ".$data->getUser()->getDisplayname()."
";
- $body.="Matière = ".$data->getSubject()."
";
- $body.="Url = ".$this->generateUrl('app_answer_update', ["id"=>$answer->getId()], UrlGeneratorInterface::ABSOLUTE_URL);
-
- $this->mail->sendEmail($subject, $body, $to, $from);
- }
- }
-
- // Passage à distribuer
- $data->setStatus(1);
- }
-
- // Archivage de l'activité
- if ($form->has('archiving') && $form->get('archiving')->isClicked()) {
- $data->setStatus(10);
-
- // Message
- foreach($data->getAnswers() as $answer) {
- $message=new Message;
- $message->setMessage("Archivage de l'Activité");
- $message->setDeletable(false);
- $message->setUser($data->getUser());
- $message->setAnswer($answer);
- $message->addReader($data->getUser());
- $message->addReader($answer->getUser());
- $em->persist($message);
- $em->flush();
-
- }
- }
-
- $em->persist($data);
- $em->flush();
-
- // On initialise une réponse pour l'ensemble des élèves
- if($data->getStatus()>0&&$data->getStatus()<10)
- $this->initAnswer($data);
-
- // Retour à la liste
- return $this->redirectToRoute($this->route);
- }
-
- // Affichage du formulaire
- return $this->render($this->render.'edit.html.twig', [
- 'useheader' => true,
- 'usesidebar' => ($this->getUser()->hasRole("ROLE_ADMIN")),
- $this->data => $data,
- 'mode' => 'update',
- 'form' => $form->createView()
- ]);
- }
-
- public function delete($id,Request $request)
- {
- // Initialisation de l'enregistrement
- $em = $this->getDoctrine()->getManager();
- $data=$em->getRepository($this->entity)->find($id);
-
- // Controle accès
- if(!$data)
- return $this->redirectToRoute($this->route);
- else {
- if(!$this->getUser()->Hasrole("ROLE_ADMIN")&&$this->getUser()!=$data->getUser())
- return $this->redirectToRoute($this->route);
- }
-
- // Controle avant suppression
- $haveerror=false;
- if($data->getStatus()!=0&&$data->getStatus()!=10) {
- $request->getSession()->getFlashBag()->add("error", 'Cette activité a été distribué vous ne pouvez plus la supprimer');
- $haveerror=true;
- }
-
- if($haveerror) {
- return $this->redirectToRoute($this->route."_update",["id"=>$id]);
- }
- else {
- $em->remove($data);
- $em->flush();
-
- // Retour à la liste
- return $this->redirectToRoute($this->route);
- }
- }
-
- public function archive($id,Request $request)
- {
- // Initialisation de l'enregistrement
- $em = $this->getDoctrine()->getManager();
- $data=$em->getRepository($this->entity)->find($id);
-
- // Controle accès
- if(!$data)
- return $this->redirectToRoute($this->route);
- else {
- if(!$this->getUser()->Hasrole("ROLE_ADMIN")&&$this->getUser()!=$data->getUser())
- return $this->redirectToRoute($this->route);
- }
-
- // Message
- foreach($data->getAnswers() as $answer) {
- $message=new Message;
- $message->setMessage("Archivage de l'Activité");
- $message->setDeletable(false);
- $message->setUser($data->getUser());
- $message->setAnswer($answer);
- $message->addReader($data->getUser());
- $message->addReader($answer->getUser());
- $em->persist($message);
- $em->flush();
- }
-
- $data->setStatus(10);
- $em->persist($data);
- $em->flush();
-
- // Retour à la liste
- return $this->redirectToRoute($this->route);
- }
-
- protected function initAnswer($activity) {
- $em = $this->getDoctrine()->getManager();
-
- // Pour chaque élève
- $group=$activity->getGroup();
- foreach($group->getUsers() as $user) {
- // Existe-t-il une réponse pour l'élève
- if($user->hasRole("ROLE_STUDENT")) {
- $answer=$em->getRepository("App:Answer")->findOneBy(["user"=>$user,"activity"=>$activity]);
- if(!$answer) {
- $answer=new Answer;
- $answer->setActivity($activity);
- $answer->setUser($user);
- $answer->setStatus(-1);
-
- $em->persist($answer);
- $em->flush();
-
- // Message
- $message=new Message;
- $message->setMessage("Distribution de l'Activité");
- $message->setDeletable(false);
- $message->setUser($activity->getUser());
- $message->setAnswer($answer);
- $message->addReader($activity->getUser());
-
- $em->persist($message);
- $em->flush();
-
- // Notification par mail de la distribution de l'activité
- $to = $user->getEmail();
- $from = $activity->getUser()->getEmail();
- $subject="Nineschool : Nouvelle Activité à réaliser";
- $body ="Activité = ".$activity->getName()."
";
- $body.="Professeur = ".$activity->getUser()->getDisplayname()."
";
- $body.="Matière = ".$activity->getSubject()."
";
- $body.="Url = ".$this->generateUrl('app_answer_update', ["id"=>$answer->getId()], UrlGeneratorInterface::ABSOLUTE_URL);
-
- $this->mail->sendEmail($subject, $body, $to, $from);
- }
- }
- }
- }
-
- public function activeactivity() {
- $this->get('session')->set('activeactivity',!$this->get('session')->get('activeactivity'));
- return $this->redirectToRoute($this->route);
- }
-
- protected function getErrorForm($id,$form,$request,$data,$mode) {
- if ($form->get('submit')->isClicked()&&$mode=="delete") {
- }
-
- if ($form->get('submit')->isClicked() && $mode=="submit") {
- }
-
- if ($form->has('archiving') && $form->get('archiving')->isClicked()) {
- // On s'assure que l'ensemble des réponses sont corrigés sinon message de conformation
- $ok=true;
- foreach($data->getAnswers() as $answer) {
- if($answer->getStatus()!=15) {
- $ok=false;
- }
- }
- if(!$ok) {
- $url=$this->generateUrl('app_activity_archive', ["id"=>$data->getId()]);
- $form->addError(new FormError("L'ensemble des activités non pas été corrigées. Souhaitez-vous archiver l'activité malgré tout ?
Forcer l'Archivage"));
- }
- }
-
- if (($form->get('submit')->isClicked() || ($form->has('archiving') && $form->get('archiving')->isClicked()) ) && !$form->isValid()) {
- $this->get('session')->getFlashBag()->clear();
-
- $errors = $form->getErrors();
- foreach( $errors as $error ) {
- $request->getSession()->getFlashBag()->add("error", $error->getMessage());
- }
- }
- }
-}
diff --git a/src/nineskeletor-1.0/src/Controller/AnswerController.php b/src/nineskeletor-1.0/src/Controller/AnswerController.php
deleted file mode 100755
index 62e2d97..0000000
--- a/src/nineskeletor-1.0/src/Controller/AnswerController.php
+++ /dev/null
@@ -1,283 +0,0 @@
-mail = $mail; }
-
- public function update($id,Request $request)
- {
- // Initialisation de l'enregistrement
- $em = $this->getDoctrine()->getManager();
- $data=$em->getRepository($this->entity)->find($id);
-
- // Controle accès
- if(!$data)
- return $this->redirectToRoute($this->route);
- else {
- if(!$this->getUser()->Hasrole("ROLE_ADMIN")&&$this->getUser()!=$data->getActivity()->getUser()&&$this->getUser()!=$data->getUser())
- return $this->redirectToRoute($this->route);
- }
-
- // Passer la réponse en cours si l'utilisateur en cours est l'élève
- if($this->getUser()==$data->getUser()&&$data->getStatus()==0) {
- $data->setStatus(1);
- $em->persist($data);
- $em->flush();
-
- // Message
- $message = new Message;
- $message->setMessage("En cours");
- $message->setDeletable(false);
- $message->setUser($data->getUser());
- $message->setAnswer($data);
- $message->addReader($data->getUser());
- $em->persist($message);
- $em->flush();
- }
-
- // Création du formulaire
- $form = $this->createForm(Form::class,$data,array("mode"=>"update","status"=>$data->getStatus(),"activitystatus"=>$data->getActivity()->getStatus()));
-
- // Récupération des data du formulaire
- $form->handleRequest($request);
-
- // Sur erreur
- $this->getErrorForm(null,$form,$request,$data,"update");
-
- $valid=false;
- if($form->isSubmitted()&&$form->isValid()) {
- if($form->get('submit')->isClicked())
- $valid=true;
-
- if ($form->has('returned') && $form->get('returned')->isClicked())
- $valid=true;
- }
-
- // Sur validation
- if ($valid) {
- $data = $form->getData();
-
- // Retour de la réponse
- if ($form->has('returned') && $form->get('returned')->isClicked()){
- $data->setStatus(10);
-
- // Message
- $message=new Message;
- $message->setMessage("Activité rendue");
- $message->setDeletable(false);
- $message->setUser($data->getUser());
- $message->setAnswer($data);
- $message->addReader($data->getUser());
-
- $em->persist($message);
- $em->flush();
-
- // Notification par mail du rendu de l'activité
- $to = $data->getActivity()->getUser()->getEmail();
- $from = $data->getUser()->getEmail();
- $subject="Nineschool : Activité rendue";
- $body ="Activité = ".$data->getActivity()->getName()."
";
- $body.="Elève = ".$data->getUser()->getDisplayname()."
";
- $body.="Matière = ".$data->getActivity()->getSubject()."
";
- $body.="Url = ".$this->generateUrl('app_answer_view', ["id"=>$data->getId()], UrlGeneratorInterface::ABSOLUTE_URL);
-
- $this->mail->sendEmail($subject, $body, $to, $from);
- }
-
-
- $em->persist($data);
- $em->flush();
-
- // Retour à la liste
- return $this->redirectToRoute("app_activity");
- }
-
- // Affichage du formulaire
- return $this->render($this->render.'edit.html.twig', [
- 'useheader' => true,
- 'usesidebar' => ($this->getUser()->hasRole("ROLE_ADMIN")),
- $this->data => $data,
- 'mode' => 'update',
- 'form' => $form->createView()
- ]);
- }
-
- public function view($id,Request $request) {
- // Initialisation de l'enregistrement
- $em = $this->getDoctrine()->getManager();
- $data=$em->getRepository($this->entity)->find($id);
-
- // Controle accès
- if(!$data)
- return $this->redirectToRoute($this->route);
- else {
- if(!$this->getUser()->Hasrole("ROLE_ADMIN")&&$this->getUser()!=$data->getActivity()->getUser())
- return $this->redirectToRoute($this->route);
- }
-
- // Création du formulaire
- $form = $this->createForm(Corrected::class,$data,array("mode"=>"update","status"=>$data->getStatus(),"activitystatus"=>$data->getActivity()->getStatus()));
-
- // Récupération des data du formulaire
- $form->handleRequest($request);
-
- // Sur erreur
- $this->getErrorForm(null,$form,$request,$data,"update");
-
- $valid=false;
- if($form->isSubmitted()&&$form->isValid()) {
- if($form->get('submit')->isClicked())
- $valid=true;
-
- if ($form->has('corrected') && $form->get('corrected')->isClicked())
- $valid=true;
-
- if ($form->has('canceled') && $form->get('canceled')->isClicked())
- $valid=true;
- }
-
- // Sur validation
- if ($valid) {
- $data = $form->getData();
-
- // Retour de la réponse
- if ($form->has('corrected') && $form->get('corrected')->isClicked()) {
- $data->setStatus(15);
-
- // Message
- $message=new Message;
- $message->setMessage("Activité corrigée");
- $message->setDeletable(false);
- $message->setUser($this->getUser());
- $message->setAnswer($data);
- $message->addReader($this->getUser());
-
- $em->persist($message);
- $em->flush();
-
- // Notification par mail de la correction de l'activité
- $to = $data->getActivity()->getUser()->getEmail();
- $from = $data->getUser()->getEmail();
- $subject="Nineschool : Activité réouverte";
- $body ="Activité = ".$data->getActivity()->getName()."
";
- $body.="Professeur = ".$data->getActivity()->getUser()->getDisplayname()."
";
- $body.="Matière = ".$data->getActivity()->getSubject()."
";
- $body.="Url = ".$this->generateUrl('app_answer_update', ["id"=>$data->getId()], UrlGeneratorInterface::ABSOLUTE_URL);
-
- $this->mail->sendEmail($subject, $body, $to, $from);
- }
-
- // Annuler le rendu de l'élève
- if ($form->has('canceled') && $form->get('canceled')->isClicked()) {
- $data->setStatus(2);
-
- // Message
- $message=new Message;
- $message->setMessage("Activité réouverte");
- $message->setDeletable(false);
- $message->setUser($this->getUser());
- $message->setAnswer($data);
- $message->addReader($this->getUser());
-
- $em->persist($message);
- $em->flush();
-
- // Notification par mail de la réouverture de l'activité
- $to = $data->getActivity()->getUser()->getEmail();
- $from = $data->getUser()->getEmail();
- $subject="Nineschool : Activité réouverte";
- $body ="Activité = ".$data->getActivity()->getName()."
";
- $body.="Professeur = ".$data->getActivity()->getUser()->getDisplayname()."
";
- $body.="Matière = ".$data->getActivity()->getSubject()."
";
- $body.="Url = ".$this->generateUrl('app_answer_update', ["id"=>$data->getId()], UrlGeneratorInterface::ABSOLUTE_URL);
-
- $this->mail->sendEmail($subject, $body, $to, $from);
- }
-
-
- $em->persist($data);
- $em->flush();
-
- // Retour à la liste
- return $this->redirectToRoute("app_activity");
- }
-
- // Affichage du formulaire
- return $this->render($this->render.'view.html.twig', [
- 'useheader' => true,
- 'usesidebar' => ($this->getUser()->hasRole("ROLE_ADMIN")),
- $this->data => $data,
- 'mode' => 'update',
- 'form' => $form->createView()
- ]);
- }
-
- public function select(Request $request) {
- // S'assurer que c'est un appel ajax
- if (!$request->isXmlHttpRequest()) {
- return new JsonResponse(array('message' => 'Interdit'), 400);
- }
-
- $output=array();
- $em = $this->getDoctrine()->getManager();
- $page_limit=$request->query->get('page_limit');
- $q=$request->query->get('q');
- $id=$request->query->get('activity');
-
- $activity=$em->getRepository("App:Activity")->find($id);
- if(!$activity) {
- $response = new Response(json_encode($ret_string));
- $response->headers->set('Content-Type', 'application/json');
- return $response;
- }
-
- $datas=$activity->getAnswers();
- foreach($datas as $data) {
- array_push($output,array("id"=>$data->getId(),"text"=>$data->getDisplayname()));
- }
-
- $ret_string["results"]=$output;
- $response = new Response(json_encode($ret_string));
- $response->headers->set('Content-Type', 'application/json');
- return $response;
- }
-
- protected function getErrorForm($id,$form,$request,$data,$mode) {
- if ($form->get('submit')->isClicked()&&$mode=="delete") {
- }
-
- if ($form->get('submit')->isClicked() && $mode=="submit") {
- }
-
- if ($form->get('submit')->isClicked() && !$form->isValid()) {
- $this->get('session')->getFlashBag()->clear();
-
- $errors = $form->getErrors();
- foreach( $errors as $error ) {
- $request->getSession()->getFlashBag()->add("error", $error->getMessage());
- }
- }
- }
-}
diff --git a/src/nineskeletor-1.0/src/Controller/DocumentController.php b/src/nineskeletor-1.0/src/Controller/DocumentController.php
deleted file mode 100755
index 3893e0d..0000000
--- a/src/nineskeletor-1.0/src/Controller/DocumentController.php
+++ /dev/null
@@ -1,493 +0,0 @@
-ctrlAccessentity($entity,$id,"update")) return $this->redirectToRoute("app_activity");
-
- // Rendu
- return $this->render($this->render.'upload.html.twig',[
- 'useheader' => false,
- 'usesidebar' => false,
- 'entity' => $entity,
- 'id' => $id,
- ]);
- }
-
- public function record($entity,$id)
- {
- // Controles d'accès en fonction de l'entité d'arrivé
- if(!$this->ctrlAccessentity($entity,$id,"update")) return $this->redirectToRoute("app_activity");
-
- // Rendu
- return $this->render($this->render.'record.html.twig',[
- 'useheader' => false,
- 'usesidebar' => false,
- 'entity' => $entity,
- 'id' => $id,
- ]);
- }
-
- public function recordupload($entity,$id,Request $request)
- {
- // Controles d'accès en fonction de l'entité d'arrivé
- if(!$this->ctrlAccessentity($entity,$id,"update")) return $this->redirectToRoute("app_activity");
-
- // Récupérper l'enregistrement
- $content = $request->getContent();
- $name = $request->get('name');
-
- // Destination
- $directory = $this->getParameter('kernel.project_dir')."/uploads/document/".$entity."/".$id;
- $filename = uniqid().".ogg";
-
- // Ecrire sur le filesystem
- $fs = new Filesystem();
- $fs->mkdir($directory);
- $fp = fopen($directory."/".$filename, 'wb');
- fwrite($fp, $content);
- fclose($fp);
-
- // Création du document
- $em = $this->getDoctrine()->getManager();
- $document=new Entity();
- $document->setName($name);
- $document->setFilename($filename);
- $document->setRoworder(99999);
- $document->setExtention("ogg");
- $document->setMinetype("video/webm");
- $document->setHavethumb(false);
- $document->setEntity($entity);
-
-
- // Rattacher le document à l'entity
- switch($entity) {
- case "activity":
- $activity=$em->getRepository("App:Activity")->find($id);
- $document->setActivity($activity);
- break;
-
- case "corrected":
- $corrected=$em->getRepository("App:Activity")->find($id);
- $document->setCorrected($corrected);
- break;
-
- case "answer":
- $answer=$em->getRepository("App:Answer")->find($id);
- $document->setAnswer($answer);
- break;
-
- case "answercorrected":
- $answer=$em->getRepository("App:Answer")->find($id);
- $document->setAnswercorrected($answer);
- break;
- }
-
- // Sauvegarde
- $em->persist($document);
- $em->flush();
-
- // Retour
- return new Response(json_encode([]));
- }
-
- public function list($entity,$id,$master) {
- // Controles d'accès en fonction de l'entité d'arrivé
- if(!$this->ctrlAccessentity($entity,$id,"view")) return $this->redirectToRoute("app_activity");
-
- // Récupérer les documents
- $em = $this->getDoctrine()->getManager();
- $documents=null;
- switch($entity) {
- case "activity":
- $activity=$em->getRepository("App:Activity")->find($id);
- if($activity) {
- $documents=$em->getRepository("App:Document")->findBy(["activity"=>$activity]);
- if($activity->getStatus()!=0) $master=false;
- }
- break;
-
- case "corrected":
- $corrected=$em->getRepository("App:Activity")->find($id);
- if($corrected) {
- $documents=$em->getRepository("App:Document")->findBy(["corrected"=>$corrected]);
- if($corrected->getStatus()==10) $master=false;
- }
-
- break;
-
- case "answer":
- $answer=$em->getRepository("App:Answer")->find($id);
- if($answer) {
- $documents=$em->getRepository("App:Document")->findBy(["answer"=>$answer]);
- if($answer->getStatus()>=10)
- $master=false;
- if($answer->getActivity()->getStatus()==10)
- $master=false;
- }
- break;
-
- case "answercorrected":
- $answercorrected=$em->getRepository("App:Answer")->find($id);
- if($answercorrected) {
- $documents=$em->getRepository("App:Document")->findBy(["answercorrected"=>$answercorrected]);
- if($answercorrected->getStatus()>=15)
- $master=false;
- if($answercorrected->getActivity()->getStatus()==10)
- $master=false;
- }
- break;
- }
-
- // Construire le tableau d'id
- $output=[];
-
- foreach($documents as $document) {
- $tmp=[
- "id"=>$document->getId(),
- "html"=>$this->thumb($document->getId(),$master),
- ];
-
- array_push($output,$tmp);
-
- }
-
- // Retour
- return new Response(json_encode($output));
- }
-
- public function thumb($id,$master)
- {
- $em = $this->getDoctrine()->getManager();
- $data=$em->getRepository($this->entity)->find($id);
-
- $title=$data->getName();
- $filename=$data->getFilename();
- $description=$data->getDescription();
- $extention=$data->getExtention();
- $minetype=$data->getMinetype();
- $minefamily=explode("/",$minetype)[0];
-
- switch($data->getEntity()) {
- case "activity" : $identity=$data->getActivity()->getId(); break;
- case "corrected" : $identity=$data->getCorrected()->getId(); break;
- case "answer" : $identity=$data->getAnswer()->getId(); break;
- case "answercorrected" : $identity=$data->getAnswercorrected()->getId(); break;
- }
- if($data->getHavethumb()) {
- $directory = $this->getParameter('kernel.project_dir') . '/uploads/document/'.$data->getEntity()."/".$identity;
- $dataimg = file_get_contents($directory."/thumb/".$filename);
- $url="data:image/" . $extention . ";base64," . base64_encode($dataimg);
- }
- else {
- $url="/".$this->getParameter("appAlias")."/images/files/".$extention.".png";
- }
-
-
- return $this->renderView($this->render.'render.html.twig',[
- 'entity' => $data->getEntity(),
- 'id' => $id,
- 'title' => $title,
- 'description' => $description,
- 'url' => $url,
- 'extention' => $extention,
- 'minefamily' => $minefamily,
- 'master' => $master,
- ]);
- }
-
- public function view($entity,$id) {
- // Controles d'accès sur le document
- if(!$this->ctrlAccessdocument($entity,$id,"view")) return $this->redirectToRoute("app_activity");
-
- $em = $this->getDoctrine()->getManager();
- $data=$em->getRepository($this->entity)->find($id);
-
- switch($data->getEntity()) {
- case "activity" : $identity=$data->getActivity()->getId(); break;
- case "corrected" : $identity=$data->getCorrected()->getId(); break;
- case "answer" : $identity=$data->getAnswer()->getId(); break;
- case "answercorrected" : $identity=$data->getAnswercorrected()->getId(); break;
- }
-
- $directory= $this->getParameter('kernel.project_dir') . '/uploads/document/'.$entity."/".$identity;
- $url=$directory."/".$data->getFilename();
- $file = new file($url);
-
- $minetype=$file->getMimeType();
- $minefamily=explode("/",$minetype)[0];
-
- if($minefamily=="text" || $minefamily=="image") {
- $image="";
- if($minefamily=="image") {
- $image = "data:image/" . $file->getExtension() . ";base64," . base64_encode(file_get_contents($url));
- }
-
- return $this->render($this->render.'view.html.twig',[
- 'useheader' => false,
- 'usesidebar' => false,
- 'entity' => $entity,
- 'id' => $id,
- 'minefamily' => $minefamily,
- 'image' => $image
- ]);
- }
- else {
- $response = new BinaryFileResponse($file);
- $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_INLINE);
-
- return $response;
- }
- }
-
- public function show($entity,$id) {
- // Controles d'accès sur le document
- if(!$this->ctrlAccessdocument($entity,$id,"view")) return $this->redirectToRoute("app_activity");
-
- $em = $this->getDoctrine()->getManager();
- $data=$em->getRepository($this->entity)->find($id);
-
- switch($data->getEntity()) {
- case "activity" : $identity=$data->getActivity()->getId(); break;
- case "corrected" : $identity=$data->getCorrected()->getId(); break;
- case "answer" : $identity=$data->getAnswer()->getId(); break;
- case "answercorrected" : $identity=$data->getAnswercorrected()->getId(); break;
- }
-
- $directory= $this->getParameter('kernel.project_dir') . '/uploads/document/'.$entity."/".$identity;
- $url=$directory."/".$data->getFilename();
- $file = new file($url);
-
- $response = new BinaryFileResponse($file);
- //$response->setContentDisposition(ResponseHeaderBag::DISPOSITION_INLINE);
- $name= ($data->getName()==$data->getFilename()?$data->getFilename():$data->getName().'.'.$data->getExtention());
- $response->setContentDisposition(
- ResponseHeaderBag::DISPOSITION_ATTACHMENT,
- $name
- );
-
- return $response;
- }
-
- public function update($entity,$id,Request $request)
- {
- // Controles d'accès sur le document
- if(!$this->ctrlAccessdocument($entity,$id,"update")) return $this->redirectToRoute("app_activity");
-
- // Initialisation de l'enregistrement
- $em = $this->getDoctrine()->getManager();
- $data=$em->getRepository($this->entity)->find($id);
-
- // Création du formulaire
- $form = $this->createForm(Form::class,$data,array("mode"=>"update"));
-
- // Récupération des data du formulaire
- $form->handleRequest($request);
-
- // Sur validation
- if ($form->get('submit')->isClicked() && $form->isValid()) {
- $data = $form->getData();
- $em->persist($data);
- $em->flush();
-
- return $this->render($this->render.'close.html.twig');
- }
-
- // Affichage du formulaire
- return $this->render($this->render.'edit.html.twig', [
- 'useheader' => false,
- 'usesidebar' => false,
- $this->data => $data,
- 'mode' => 'update',
- 'form' => $form->createView(),
- ]);
- }
-
- public function delete($entity,$id,Request $request)
- {
- // Controles d'accès sur le document
- if(!$this->ctrlAccessdocument($entity,$id,"update")) return $this->redirectToRoute("app_activity");
-
- // Initialisation de l'enregistrement
- $em = $this->getDoctrine()->getManager();
- $data=$em->getRepository($this->entity)->find($id);
-
- // Création du formulaire
- $form = $this->createForm(Form::class,$data,array("mode"=>"update"));
-
- // Récupération des data du formulaire
- $form->handleRequest($request);
-
- if($data) {
- $em->remove($data);
- $em->flush();
-
- return $this->render($this->render.'close.html.twig');
- }
-
- // Affichage du formulaire
- return $this->render($this->render.'edit.html.twig', [
- 'useheader' => false,
- 'usesidebar' => false,
- $this->data => $data,
- 'mode' => 'update',
- 'form' => $form->createView(),
- ]);
- }
-
- private function ctrlAccessentity($entity,$id,$mode) {
- // Initialisation de l'enregistrement
- $em = $this->getDoctrine()->getManager();
-
- switch($entity) {
- case "activity" :
- $data=$em->getRepository("App:Activity")->find($id);
- if(!$data) return false;
-
- $group=$data->getGroup();
- $user=$this->getUser();
- $isadmin=($user->Hasrole("ROLE_ADMIN"));
- $ismaster=($user==$data->getUser());
- $ismember=($group->getUsers()->contains($this->getUser()));
-
- // Test visualisation = tout les membres du groupes peuvent voir l'énoncé
- if(!$isadmin && !$ismaster && !$ismember)
- return false;
-
- // Membre = Test visualisation activité que si activité non brouillon
- if(!$isadmin && !$ismaster && $ismember) {
- if($data->getStatus()==0)
- return false;
- }
-
- // Test modification = Impossible de modifier un document si activité non brouillon
- if ($mode=="update" && ((!$isadmin && !$ismaster) || $data->getStatus()>0))
- return false;
- break;
-
- case "corrected":
- $data=$em->getRepository("App:Activity")->find($id);
- if(!$data) return false;
-
- $group=$data->getGroup();
- $user=$this->getUser();
- $isadmin=($user->Hasrole("ROLE_ADMIN"));
- $ismaster=($user==$data->getUser());
- $ismember=($group->getUsers()->contains($this->getUser()));
-
- // Test visualisation
- if(!$isadmin && !$ismaster && !$ismember)
- return false;
-
- // Membre = Visualisation uniquement si sa réponse est corrigée
- if(!$isadmin && !$ismaster && $ismember) {
- $answer=$em->getRepository("App:Answer")->findOneBy(["activity"=>$data,"user"=>$user]);
- if(!$answer || $answer->getStatus()<15)
- return false;
- }
-
- // Test modification = Impossible de modifier un document si activité close
- if ($mode=="update" && ((!$isadmin && !$ismaster) || $data->getStatus()==10))
- return false;
- break;
-
- case "answer":
- $data=$em->getRepository("App:Answer")->find($id);
- if(!$data) return false;
-
- $user=$this->getUser();
- $isadmin=($user->Hasrole("ROLE_ADMIN"));
- $ismaster=($user==$data->getActivity()->getUser());
- $isuser=($user==$data->getUser());
-
- // Test visualisation
- if(!$isadmin && !$ismaster && !$isuser)
- return false;
-
- // Test modification = Impossible de modifier un document si réponse rendues ou activité non distribut
- if ($mode=="update" && ((!$isadmin && !$isuser) || $data->getStatus()>=10 || $data->getActivity()->getStatus()!=1))
- return false;
- break;
-
- case "answercorrected":
- $data=$em->getRepository("App:Answer")->find($id);
- if(!$data) return false;
-
- $user=$this->getUser();
- $isadmin=($user->Hasrole("ROLE_ADMIN"));
- $ismaster=($user==$data->getActivity()->getUser());
- $isuser=($user==$data->getUser());
-
- // Test visualisation
- if(!$isadmin && !$ismaster && !$isuser)
- return false;
-
- // Membre = Visualisation uniquement si sa réponse est rendu
- if(!$isadmin && !$ismaster && $isuser) {
- if($data->getStatus()<10)
- return false;
- }
-
- // Test modification = Impossible de modifier un document si réponse corrigées
- if ($mode=="update" && ((!$isadmin && !$ismaster) || $data->getStatus()>=15 || $data->getActivity()->getStatus()!=1) )
- return false;
- break;
- }
-
- return true;
- }
-
- private function ctrlAccessdocument($entity,$id,$mode) {
- // Initialisation de l'enregistrement
- $em = $this->getDoctrine()->getManager();
-
- $document=$em->getRepository($this->entity)->find($id);
- if(!$document) return false;
-
- switch($entity) {
- case "activity" :
- $data=$document->getActivity();
- return $this->ctrlAccessentity($entity,$data->getId(),$mode);
- break;
-
- case "corrected":
- $data=$document->getCorrected();
- return $this->ctrlAccessentity($entity,$data->getId(),$mode);
- break;
-
- case "answer" :
- $data=$document->getAnswer();
- return $this->ctrlAccessentity($entity,$data->getId(),$mode);
- break;
-
- case "answercorrected" :
- $data=$document->getAnswercorrected();
- return $this->ctrlAccessentity($entity,$data->getId(),$mode);
- break;
- }
-
- return true;
- }
-
-}
diff --git a/src/nineskeletor-1.0/src/Controller/HomeController.php b/src/nineskeletor-1.0/src/Controller/HomeController.php
index c71ad54..f967d4f 100755
--- a/src/nineskeletor-1.0/src/Controller/HomeController.php
+++ b/src/nineskeletor-1.0/src/Controller/HomeController.php
@@ -11,14 +11,18 @@ class HomeController extends AbstractController
{
public function home()
{
- return $this->redirectToRoute("app_activity");
-
- /*
return $this->render('Home/home.html.twig',[
"useheader" => true,
- "usesidebar" => ($this->getUser()?$this->getUser()->hasRole("ROLE_ADMIN"):false),
+ "usesidebar" => false,
+ ]);
+ }
+
+ public function admin()
+ {
+ return $this->render('Home/admin.html.twig',[
+ "useheader" => true,
+ "usesidebar" => true,
]);
- */
}
public function upload(Request $request,$access=null) {
diff --git a/src/nineskeletor-1.0/src/Controller/MessageController.php b/src/nineskeletor-1.0/src/Controller/MessageController.php
deleted file mode 100755
index 97d98ca..0000000
--- a/src/nineskeletor-1.0/src/Controller/MessageController.php
+++ /dev/null
@@ -1,268 +0,0 @@
-getDoctrine()->getManager();
-
- // Création du formulaire
- $data=new Entity;
- $form = $this->createForm(Form::class,$data,array("mode"=>"submit"));
-
- // Récupération des data du formulaire
- $form->handleRequest($request);
-
-
- return $this->render('Message/message.html.twig',[
- 'id' => $id,
- 'form' => $form->createView()
- ]);
- }
-
- public function messagegroup($id, Request $request) {
- $em = $this->getDoctrine()->getManager();
-
- // Création du formulaire
- $activity=$em->getRepository("App:Activity")->find($id);
- if(!$activity) return $this->redirectToRoute("app_activity");
-
- // Formulaire
- $form = $this->createForm(Activitymessage::class,$activity,array("mode"=>"submit","id"=>$activity->getId()));
-
- // Récupération des data du formulaire
- $form->handleRequest($request);
-
- // Sur validation
- if ($form->get('submit')->isClicked() && $form->isValid()) {
- $data = $form->getData();
- $message = $form->get("message")->getData();
-
- if($message) {
- foreach($data->getAnswers() as $answer) {
- $data=new Entity;
- $data->setMessage($message);
- $data->setUser($this->getUser());
- $data->addReader($this->getUser());
- $data->setDeletable(true);
- $data->setAnswer($answer);
-
- $em->persist($data);
- $em->flush();
- }
- }
-
- // Fermeture de la popup
- return $this->render($this->render.'close.html.twig');
- }
-
- return $this->render('Message/group.html.twig',[
- 'id' => $id,
- 'activity' => $activity,
- 'form' => $form->createView()
- ]);
- }
-
- public function load($id,Request $request) {
- return new Response(json_encode($this->getMessages($id)));
- }
-
- public function submit($id,Request $request) {
- $em = $this->getDoctrine()->getManager();
- $answer=$em->getRepository("App:Answer")->find($id);
- if(!$answer) {
- $output=["return"=>"KO","error"=>"Utilisateur inconnu"];
- return new Response(json_encode($output));
- }
- // Controler que l'on peut créer mesage sur la answer
-
- // Récupérer les datas envoyés en post
- $html = $request->request->get('html');
-
- // Création du message
- $data = new Entity();
- $data->setUser($this->getUser());
- $data->setAnswer($answer);
- $data->setMessage($html);
- $data->setDeletable(true);
- $em->persist($data);
- $em->flush();
-
- // Si on génère le message c'est qu'il est forcement lu
- $data->addReader($this->getUser());
-
- return new Response(json_encode($this->getMessages($id)));
- }
-
- public function unread() {
- $em = $this->getDoctrine()->getManager();
- $user=$this->getUser();
- $output=[];
-
- // View master
- if ($user->hasRole('ROLE_ADMIN')||$user->hasRole('ROLE_MASTER')) {
- // Sur chaque activité de l'activité
- $activitys = $em->getRepository("App:Activity")->findBy(["user"=>$user]);
- foreach($activitys as $activity) {
- // Sur chaque réponse de l'activité
- $answers = $em->getRepository("App:Answer")->findBy(["activity"=>$activity]);
- foreach($answers as $answer) {
- // Statut de la réponse
- switch($answer->getStatus()) {
- case -1: $status = "non vu"; break;
- case 0: $status = "vu"; break;
- case 1: $status = "en cours"; break;
- case 2: $status = "réouvert"; break;
- case 10: $status = "rendu"; break;
- case 15: $status = "corrigé"; break;
- }
-
- // Initialisation du tableau des messages non lus
- $tmp = [
- "id" => $answer->getId(),
- "cpt" => 0,
- "status" => $status
- ];
-
- // Sur chaque message de la réponse
- $messages = $em->getRepository("App:Message")->findBy(["answer"=>$answer]);
- foreach($messages as $message) {
- $readers=$message->getReaders();
- if(!$readers->contains($user))
- $tmp["cpt"]=$tmp["cpt"]+1;
- }
- array_push($output,$tmp);
- }
- }
- }
- // View student
- elseif($user->hasRole('ROLE_STUDENT')) {
- $answers = $em->getRepository("App:Answer")->findBy(["user"=>$user]);
- foreach($answers as $answer) {
- // Statut de la réponse
- switch($answer->getStatus()) {
- case -1: $status = "non vu"; break;
- case 0: $status = "vu"; break;
- case 1: $status = "en cours"; break;
- case 2: $status = "réouvert"; break;
- case 10: $status = "rendu"; break;
- case 15: $status = "corrigé"; break;
- }
-
- // Initialisation du tableau des messages non lus
- $tmp = [
- "id" => $answer->getId(),
- "cpt" => 0,
- "status" => $status
- ];
-
- // Sur chaque message de la réponse
- $messages = $em->getRepository("App:Message")->findBy(["answer"=>$answer]);
- foreach($messages as $message) {
- $readers=$message->getReaders();
- if(!$readers->contains($user))
- $tmp["cpt"]=$tmp["cpt"]+1;
- }
- array_push($output,$tmp);
- }
- }
-
- return new Response(json_encode($output));
- }
-
- private function getMessages($id) {
- $em = $this->getDoctrine()->getManager();
-
- $datas=$em->getRepository($this->entity)->findBy(["answer"=>$id],["submitdate"=>"DESC"]);
-
- $return=[];
- foreach($datas as $data) {
- $user=$this->getUser();
- $isadmin=($user->Hasrole("ROLE_ADMIN"));
- $ismaster=($user==$data->getAnswer()->getActivity()->getUser());
- $isuser=($user==$data->getUser());
-
- //Si le message est supprimable : seul le propriétaire peut supprimer
- $deletable=$data->getDeletable();
- if($deletable) {
- if(!$isadmin&&!$ismaster&&!$isuser) $deletable=false;
- }
- else{
- // Un admin peut tout supprimer
- if($isadmin) $deletable=true;
- }
-
- // Si on liste le message c'est qu'il est lu
- $readers=$data->getReaders();
- if(!$readers->contains($user)) {
- $data->addReader($user);
- $em->persist($data);
- $em->flush();
- }
-
- $tmp = [
- "id" => $data->getId(),
- "message" => $data->getMessage(),
- "submitdate" => $data->getSubmitdate()->format("d/m/Y H:i"),
- "userdisplayname" => $data->getUser()->getDisplayname(),
- "deletable" => $deletable
- ];
- array_push($return,$tmp);
- }
-
- return $return;
- }
-
- public function delete($id) {
- $em = $this->getDoctrine()->getManager();
- $data=$em->getRepository($this->entity)->find($id);
- if(!$data) {
- $output=["return"=>"KO","error"=>"Message non retrouvé"];
- return new Response(json_encode($output));
- }
-
- $user=$this->getUser();
- $isadmin=($user->Hasrole("ROLE_ADMIN"));
- $ismaster=($user==$data->getAnswer()->getActivity()->getUser());
- $isuser=($user==$data->getUser());
-
- //Si le message est supprimable : seul le propriétaire peut supprimer
- $deletable=$data->getDeletable();
- if($deletable) {
- if(!$isadmin&&!$ismaster&&!$isuser) $deletable=false;
- }
- else{
- // Un admin peut tout supprimer
- if($isadmin) $deletable=true;
- }
-
- if(!$deletable) {
- $output=["return"=>"KO","error"=>"Message non supprimable"];
- return new Response(json_encode($output));
- }
-
- $em->remove($data);
- $em->flush();
-
- return new Response(json_encode([]));
- }
-}
diff --git a/src/nineskeletor-1.0/src/Controller/SecurityController.php b/src/nineskeletor-1.0/src/Controller/SecurityController.php
index a2a197b..0861cd7 100755
--- a/src/nineskeletor-1.0/src/Controller/SecurityController.php
+++ b/src/nineskeletor-1.0/src/Controller/SecurityController.php
@@ -158,7 +158,8 @@ class SecurityController extends AbstractController
$this->get('session')->invalidate();
// Init Client CAS
- \phpCAS::setDebug('/var/www/html/schedule/var/log/cas.log');
+ $alias=$this->getParameter('appAlias');
+ \phpCAS::setDebug('/var/www/html/'.$alias.'/var/log/cas.log');
\phpCAS::client(CAS_VERSION_2_0, $this->getParameter('casHost'), intval($this->getParameter('casPort')), is_null($this->getParameter('casPath')) ? '' : $this->getParameter('casPath'), false);
\phpCAS::setNoCasServerValidation();
diff --git a/src/nineskeletor-1.0/src/Entity/Activity.php b/src/nineskeletor-1.0/src/Entity/Activity.php
deleted file mode 100644
index b53ec25..0000000
--- a/src/nineskeletor-1.0/src/Entity/Activity.php
+++ /dev/null
@@ -1,282 +0,0 @@
-answeruser;
- }
- public function setAnsweruser(?Answer $answer): self
- {
- $this->answeruser = $answer;
-
- return $this;
- }
-
- public function __construct()
- {
- $this->activitydocuments = new ArrayCollection();
- $this->correcteddocuments = new ArrayCollection();
- $this->answers = new ArrayCollection();
- }
-
- public function getId(): ?int
- {
- return $this->id;
- }
-
- public function getName(): ?string
- {
- return $this->name;
- }
-
- public function setName(string $name): self
- {
- $this->name = $name;
-
- return $this;
- }
-
- public function getSubject(): ?string
- {
- return $this->subject;
- }
-
- public function setSubject(?string $subject): self
- {
- $this->subject = $subject;
-
- return $this;
- }
-
- public function getStatus(): ?int
- {
- return $this->status;
- }
-
- public function setStatus(int $status): self
- {
- $this->status = $status;
-
- return $this;
- }
-
- public function getActivity(): ?string
- {
- return $this->activity;
- }
-
- public function setActivity(?string $activity): self
- {
- $this->activity = $activity;
-
- return $this;
- }
-
- public function getCorrected(): ?string
- {
- return $this->corrected;
- }
-
- public function setCorrected(?string $corrected): self
- {
- $this->corrected = $corrected;
-
- return $this;
- }
-
- public function getUser(): ?User
- {
- return $this->user;
- }
-
- public function setUser(?User $user): self
- {
- $this->user = $user;
-
- return $this;
- }
-
- public function getGroup(): ?Group
- {
- return $this->group;
- }
-
- public function setGroup(?Group $group): self
- {
- $this->group = $group;
-
- return $this;
- }
-
- /**
- * @return Collection|Document[]
- */
- public function getActivitydocuments(): Collection
- {
- return $this->activitydocuments;
- }
-
- public function addActivitydocument(Document $activitydocument): self
- {
- if (!$this->activitydocuments->contains($activitydocument)) {
- $this->activitydocuments[] = $activitydocument;
- $activitydocument->setActivity($this);
- }
-
- return $this;
- }
-
- public function removeActivitydocument(Document $activitydocument): self
- {
- if ($this->activitydocuments->contains($activitydocument)) {
- $this->activitydocuments->removeElement($activitydocument);
- // set the owning side to null (unless already changed)
- if ($activitydocument->getActivity() === $this) {
- $activitydocument->setActivity(null);
- }
- }
-
- return $this;
- }
-
- /**
- * @return Collection|Document[]
- */
- public function getCorrecteddocuments(): Collection
- {
- return $this->correcteddocuments;
- }
-
- public function addCorrecteddocument(Document $correcteddocument): self
- {
- if (!$this->correcteddocuments->contains($correcteddocument)) {
- $this->correcteddocuments[] = $correcteddocument;
- $correcteddocument->setCorrected($this);
- }
-
- return $this;
- }
-
- public function removeCorrecteddocument(Document $correcteddocument): self
- {
- if ($this->correcteddocuments->contains($correcteddocument)) {
- $this->correcteddocuments->removeElement($correcteddocument);
- // set the owning side to null (unless already changed)
- if ($correcteddocument->getCorrected() === $this) {
- $correcteddocument->setCorrected(null);
- }
- }
-
- return $this;
- }
-
- /**
- * @return Collection|Answer[]
- */
- public function getAnswers(): Collection
- {
- return $this->answers;
- }
-
- public function addAnswer(Answer $answer): self
- {
- if (!$this->answers->contains($answer)) {
- $this->answers[] = $answer;
- $answer->setActivity($this);
- }
-
- return $this;
- }
-
- public function removeAnswer(Answer $answer): self
- {
- if ($this->answers->contains($answer)) {
- $this->answers->removeElement($answer);
- // set the owning side to null (unless already changed)
- if ($answer->getActivity() === $this) {
- $answer->setActivity(null);
- }
- }
-
- return $this;
- }
-
-
-
-}
\ No newline at end of file
diff --git a/src/nineskeletor-1.0/src/Entity/Answer.php b/src/nineskeletor-1.0/src/Entity/Answer.php
deleted file mode 100644
index baaa7e2..0000000
--- a/src/nineskeletor-1.0/src/Entity/Answer.php
+++ /dev/null
@@ -1,238 +0,0 @@
-user->getDisplayname();
- }
-
- public function __construct()
- {
- $this->answerdocuments = new ArrayCollection();
- $this->answercorrecteddocuments = new ArrayCollection();
- $this->messages = new ArrayCollection();
- }
-
- public function getId(): ?int
- {
- return $this->id;
- }
-
- public function getStatus(): ?int
- {
- return $this->status;
- }
-
- public function setStatus(int $status): self
- {
- $this->status = $status;
-
- return $this;
- }
-
- public function getAnswer(): ?string
- {
- return $this->answer;
- }
-
- public function setAnswer(?string $answer): self
- {
- $this->answer = $answer;
-
- return $this;
- }
-
- public function getAnswercorrected(): ?string
- {
- return $this->answercorrected;
- }
-
- public function setAnswercorrected(?string $answercorrected): self
- {
- $this->answercorrected = $answercorrected;
-
- return $this;
- }
-
- public function getUser(): ?User
- {
- return $this->user;
- }
-
- public function setUser(?User $user): self
- {
- $this->user = $user;
-
- return $this;
- }
-
- /**
- * @return Collection|Document[]
- */
- public function getAnswerdocuments(): Collection
- {
- return $this->answerdocuments;
- }
-
- public function addAnswerdocument(Document $answerdocument): self
- {
- if (!$this->answerdocuments->contains($answerdocument)) {
- $this->answerdocuments[] = $answerdocument;
- $answerdocument->setAnswer($this);
- }
-
- return $this;
- }
-
- public function removeAnswerdocument(Document $answerdocument): self
- {
- if ($this->answerdocuments->contains($answerdocument)) {
- $this->answerdocuments->removeElement($answerdocument);
- // set the owning side to null (unless already changed)
- if ($answerdocument->getAnswer() === $this) {
- $answerdocument->setAnswer(null);
- }
- }
-
- return $this;
- }
-
- /**
- * @return Collection|Document[]
- */
- public function getAnswercorrecteddocuments(): Collection
- {
- return $this->answercorrecteddocuments;
- }
-
- public function addAnswercorrecteddocument(Document $answercorrecteddocument): self
- {
- if (!$this->answercorrecteddocuments->contains($answercorrecteddocument)) {
- $this->answercorrecteddocuments[] = $answercorrecteddocument;
- $answercorrecteddocument->setAnswercorrected($this);
- }
-
- return $this;
- }
-
- public function removeAnswercorrecteddocument(Document $answercorrecteddocument): self
- {
- if ($this->answercorrecteddocuments->contains($answercorrecteddocument)) {
- $this->answercorrecteddocuments->removeElement($answercorrecteddocument);
- // set the owning side to null (unless already changed)
- if ($answercorrecteddocument->getAnswercorrected() === $this) {
- $answercorrecteddocument->setAnswercorrected(null);
- }
- }
-
- return $this;
- }
-
- public function getActivity(): ?Activity
- {
- return $this->activity;
- }
-
- public function setActivity(?Activity $activity): self
- {
- $this->activity = $activity;
-
- return $this;
- }
-
- /**
- * @return Collection|Message[]
- */
- public function getMessages(): Collection
- {
- return $this->messages;
- }
-
- public function addMessage(Message $message): self
- {
- if (!$this->messages->contains($message)) {
- $this->messages[] = $message;
- $message->setAnswer($this);
- }
-
- return $this;
- }
-
- public function removeMessage(Message $message): self
- {
- if ($this->messages->contains($message)) {
- $this->messages->removeElement($message);
- // set the owning side to null (unless already changed)
- if ($message->getAnswer() === $this) {
- $message->setAnswer(null);
- }
- }
-
- return $this;
- }
-
-
-
-}
\ No newline at end of file
diff --git a/src/nineskeletor-1.0/src/Entity/Document.php b/src/nineskeletor-1.0/src/Entity/Document.php
deleted file mode 100644
index f630c4b..0000000
--- a/src/nineskeletor-1.0/src/Entity/Document.php
+++ /dev/null
@@ -1,242 +0,0 @@
-id;
- }
-
- public function getName(): ?string
- {
- return $this->name;
- }
-
- public function setName(string $name): self
- {
- $this->name = $name;
-
- return $this;
- }
-
- public function getFilename(): ?string
- {
- return $this->filename;
- }
-
- public function setFilename(string $filename): self
- {
- $this->filename = $filename;
-
- return $this;
- }
-
- public function getDescription(): ?string
- {
- return $this->description;
- }
-
- public function setDescription(?string $description): self
- {
- $this->description = $description;
-
- return $this;
- }
-
- public function getEntity(): ?string
- {
- return $this->entity;
- }
-
- public function setEntity(string $entity): self
- {
- $this->entity = $entity;
-
- return $this;
- }
-
- public function getRoworder(): ?int
- {
- return $this->roworder;
- }
-
- public function setRoworder(int $roworder): self
- {
- $this->roworder = $roworder;
-
- return $this;
- }
-
- public function getExtention(): ?string
- {
- return $this->extention;
- }
-
- public function setExtention(string $extention): self
- {
- $this->extention = $extention;
-
- return $this;
- }
-
- public function getMinetype(): ?string
- {
- return $this->minetype;
- }
-
- public function setMinetype(string $minetype): self
- {
- $this->minetype = $minetype;
-
- return $this;
- }
-
- public function getHavethumb(): ?bool
- {
- return $this->havethumb;
- }
-
- public function setHavethumb(bool $havethumb): self
- {
- $this->havethumb = $havethumb;
-
- return $this;
- }
-
- public function getActivity(): ?Activity
- {
- return $this->activity;
- }
-
- public function setActivity(?Activity $activity): self
- {
- $this->activity = $activity;
-
- return $this;
- }
-
- public function getCorrected(): ?Activity
- {
- return $this->corrected;
- }
-
- public function setCorrected(?Activity $corrected): self
- {
- $this->corrected = $corrected;
-
- return $this;
- }
-
- public function getAnswer(): ?Answer
- {
- return $this->answer;
- }
-
- public function setAnswer(?Answer $answer): self
- {
- $this->answer = $answer;
-
- return $this;
- }
-
- public function getAnswercorrected(): ?Answer
- {
- return $this->answercorrected;
- }
-
- public function setAnswercorrected(?Answer $answercorrected): self
- {
- $this->answercorrected = $answercorrected;
-
- return $this;
- }
-
-
-}
\ No newline at end of file
diff --git a/src/nineskeletor-1.0/src/Entity/Group.php b/src/nineskeletor-1.0/src/Entity/Group.php
index fb8aaa6..9fd0973 100644
--- a/src/nineskeletor-1.0/src/Entity/Group.php
+++ b/src/nineskeletor-1.0/src/Entity/Group.php
@@ -6,12 +6,14 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
+use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* Group
- *
- * @ORM\Table(name="groupe")
+ *
* @ORM\Entity(repositoryClass="App\Repository\GroupRepository")
+ * @ORM\Table(name="groupe",uniqueConstraints={@ORM\UniqueConstraint(name="name", columns={"name"})}))
+ * @UniqueEntity("name", message="Ce nom de groupe existe dèja")
*/
class Group
{
@@ -38,15 +40,9 @@ class Group
*/
protected $users;
- /**
- * @ORM\OneToMany(targetEntity="Activity", mappedBy="group", cascade={"persist"}, orphanRemoval=true)
- */
- private $activitys;
-
public function __construct()
{
$this->users = new ArrayCollection();
- $this->activitys = new ArrayCollection();
}
public function getId(): ?int
@@ -106,37 +102,4 @@ class Group
return $this;
}
- /**
- * @return Collection|Activity[]
- */
- public function getActivitys(): Collection
- {
- return $this->activitys;
- }
-
- public function addActivity(Activity $activity): self
- {
- if (!$this->activitys->contains($activity)) {
- $this->activitys[] = $activity;
- $activity->setGroup($this);
- }
-
- return $this;
- }
-
- public function removeActivity(Activity $activity): self
- {
- if ($this->activitys->contains($activity)) {
- $this->activitys->removeElement($activity);
- // set the owning side to null (unless already changed)
- if ($activity->getGroup() === $this) {
- $activity->setGroup(null);
- }
- }
-
- return $this;
- }
-
-
-
}
\ No newline at end of file
diff --git a/src/nineskeletor-1.0/src/Entity/Message.php b/src/nineskeletor-1.0/src/Entity/Message.php
deleted file mode 100644
index 1a0577f..0000000
--- a/src/nineskeletor-1.0/src/Entity/Message.php
+++ /dev/null
@@ -1,156 +0,0 @@
-submitdate = new \DateTime();
- $this->readers = new ArrayCollection();
- }
-
- public function getId(): ?int
- {
- return $this->id;
- }
-
- public function getMessage(): ?string
- {
- return $this->message;
- }
-
- public function setMessage(string $message): self
- {
- $this->message = $message;
-
- return $this;
- }
-
- public function getSubmitdate(): ?\DateTimeInterface
- {
- return $this->submitdate;
- }
-
- public function setSubmitdate(\DateTimeInterface $submitdate): self
- {
- $this->submitdate = $submitdate;
-
- return $this;
- }
-
- public function getDeletable(): ?bool
- {
- return $this->deletable;
- }
-
- public function setDeletable(bool $deletable): self
- {
- $this->deletable = $deletable;
-
- return $this;
- }
-
- public function getAnswer(): ?Answer
- {
- return $this->answer;
- }
-
- public function setAnswer(?Answer $answer): self
- {
- $this->answer = $answer;
-
- return $this;
- }
-
- public function getUser(): ?User
- {
- return $this->user;
- }
-
- public function setUser(?User $user): self
- {
- $this->user = $user;
-
- return $this;
- }
-
- /**
- * @return Collection|User[]
- */
- public function getReaders(): Collection
- {
- return $this->readers;
- }
-
- public function addReader(User $reader): self
- {
- if (!$this->readers->contains($reader)) {
- $this->readers[] = $reader;
- }
-
- return $this;
- }
-
- public function removeReader(User $reader): self
- {
- if ($this->readers->contains($reader)) {
- $this->readers->removeElement($reader);
- }
-
- return $this;
- }
-
-}
diff --git a/src/nineskeletor-1.0/src/Entity/User.php b/src/nineskeletor-1.0/src/Entity/User.php
index 2cac5ca..623feed 100644
--- a/src/nineskeletor-1.0/src/Entity/User.php
+++ b/src/nineskeletor-1.0/src/Entity/User.php
@@ -13,7 +13,7 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
* User
*
* @ORM\Entity(repositoryClass="App\Repository\UserRepository")
- * @ORM\Table(name="user",indexes={@ORM\Index(name="username", columns={"username"})})
+ * @ORM\Table(name="user",uniqueConstraints={@ORM\UniqueConstraint(name="username", columns={"username"})})
* @UniqueEntity("username", message="Ce nom d'utilisateur existe dèja")
*/
@@ -90,34 +90,10 @@ class User implements UserInterface, \Serializable
*/
private $groups;
- /**
- * @ORM\OneToMany(targetEntity="Activity", mappedBy="user", cascade={"persist"}, orphanRemoval=true)
- */
- private $activitys;
-
- /**
- * @ORM\OneToMany(targetEntity="Answer", mappedBy="user", cascade={"persist"}, orphanRemoval=true)
- */
- private $answers;
-
- /**
- * @ORM\OneToMany(targetEntity="Message", mappedBy="user", cascade={"persist"}, orphanRemoval=true)
- */
- private $messages;
-
- /**
- * @ORM\ManyToMany(targetEntity="Message", mappedBy="readers")
- */
- protected $messagereaders;
public function __construct()
{
$this->groups = new ArrayCollection();
- $this->activitys = new ArrayCollection();
- $this->anwsers = new ArrayCollection();
- $this->answers = new ArrayCollection();
- $this->messages = new ArrayCollection();
- $this->messagereaders = new ArrayCollection();
}
public function getUsername(): ?string
@@ -310,125 +286,4 @@ class User implements UserInterface, \Serializable
return $this;
}
- /**
- * @return Collection|Activity[]
- */
- public function getActivitys(): Collection
- {
- return $this->activitys;
- }
-
- public function addActivity(Activity $activity): self
- {
- if (!$this->activitys->contains($activity)) {
- $this->activitys[] = $activity;
- $activity->setUser($this);
- }
-
- return $this;
- }
-
- public function removeActivity(Activity $activity): self
- {
- if ($this->activitys->contains($activity)) {
- $this->activitys->removeElement($activity);
- // set the owning side to null (unless already changed)
- if ($activity->getUser() === $this) {
- $activity->setUser(null);
- }
- }
-
- return $this;
- }
-
- /**
- * @return Collection|Answer[]
- */
- public function getAnswers(): Collection
- {
- return $this->answers;
- }
-
- public function addAnswer(Answer $answer): self
- {
- if (!$this->answers->contains($answer)) {
- $this->answers[] = $answer;
- $answer->setUser($this);
- }
-
- return $this;
- }
-
- public function removeAnswer(Answer $answer): self
- {
- if ($this->answers->contains($answer)) {
- $this->answers->removeElement($answer);
- // set the owning side to null (unless already changed)
- if ($answer->getUser() === $this) {
- $answer->setUser(null);
- }
- }
-
- return $this;
- }
-
- /**
- * @return Collection|Message[]
- */
- public function getMessages(): Collection
- {
- return $this->messages;
- }
-
- public function addMessage(Message $message): self
- {
- if (!$this->messages->contains($message)) {
- $this->messages[] = $message;
- $message->setUser($this);
- }
-
- return $this;
- }
-
- public function removeMessage(Message $message): self
- {
- if ($this->messages->contains($message)) {
- $this->messages->removeElement($message);
- // set the owning side to null (unless already changed)
- if ($message->getUser() === $this) {
- $message->setUser(null);
- }
- }
-
- return $this;
- }
-
- /**
- * @return Collection|Message[]
- */
- public function getMessagereaders(): Collection
- {
- return $this->messagereaders;
- }
-
- public function addMessagereader(Message $messagereader): self
- {
- if (!$this->messagereaders->contains($messagereader)) {
- $this->messagereaders[] = $messagereader;
- $messagereader->addReader($this);
- }
-
- return $this;
- }
-
- public function removeMessagereader(Message $messagereader): self
- {
- if ($this->messagereaders->contains($messagereader)) {
- $this->messagereaders->removeElement($messagereader);
- $messagereader->removeReader($this);
- }
-
- return $this;
- }
-
}
diff --git a/src/nineskeletor-1.0/src/Repository/ActivityRepository.php b/src/nineskeletor-1.0/src/Repository/ActivityRepository.php
deleted file mode 100644
index 11afe54..0000000
--- a/src/nineskeletor-1.0/src/Repository/ActivityRepository.php
+++ /dev/null
@@ -1,42 +0,0 @@
-createQueryBuilder('activity')
- ->Where('activity.user=:user')
- ->setParameter('user',$user);
-
- if($activeactivity)
- $qb->andWhere('activity.status<10');
- else
- $qb->andWhere('activity.status=10');
-
- return $qb->getQuery()->getResult();
- }
-
- public function findAllGroupActivityActive($group,$activeactivity) {
- $qb = $this->createQueryBuilder('activity')
- ->Where('activity.group=:group')
- ->setParameter('group',$group);
-
- if($activeactivity)
- $qb->andWhere('activity.status=1');
- else
- $qb->andWhere('activity.status=10');
-
- return $qb->getQuery()->getResult();
- }
-
-}
diff --git a/src/nineskeletor-1.0/src/Repository/AnswerRepository.php b/src/nineskeletor-1.0/src/Repository/AnswerRepository.php
deleted file mode 100644
index 16d7f1a..0000000
--- a/src/nineskeletor-1.0/src/Repository/AnswerRepository.php
+++ /dev/null
@@ -1,15 +0,0 @@
-
- {% if mode=="update" %}
- Modification ACTIVITE
- {% elseif mode=="submit" %}
- Création ACTIVITE
- {% endif %}
-
-
- {{ form_widget(form.submit) }}
-
- Annuler
-
- {% if mode=="update" %}
- {% if activity.status==0 or activity.status==10%}
-
- Supprimer
-
- {% else %}
- {{ form_widget(form.archiving) }}
- {% endif %}
-
- {% if form.distribution is defined %}
- {{ form_widget(form.distribution) }}
- {% endif %}
-
- {% endif %}
-
-
-
- {% if app.session.flashbag.has('error') %}
-
Action | -Nom | -Statut | -Groupe | -Elèves | -
---|---|---|---|---|
- - - | -{{activity.name}} | -- {% if activity.status == 0 %} - brouillon - {% elseif activity.status == 1 %} - distribué - {% else %} - clos - {% endif %} - | -{{activity.group.name}} | -
- {% set answerusers = [] %}
-
- {% for answer in activity.answers %}
- {% set answerusers = answerusers|merge([answer.user.id]) %}
-
- 0
- {{ answer.user.displayname }} =
-
-
- - {% endfor %} - - {% if activity.status > 0 %} - {% for user in activity.group.users %} - {% if user.id not in answerusers and "ROLE_STUDENT" in user.roles %} - 0{{ user.displayname }} = non vu - {% endif %} - {% endfor %} - {% endif %} - |
-