Browse Source

Ajout de commentaires

bastien 13 years ago
parent
commit
a063226222

+ 40 - 3
src/Muzich/CommentBundle/Controller/CommentController.php View File

9
 class CommentController extends Controller
9
 class CommentController extends Controller
10
 {
10
 {
11
   
11
   
12
+  /**
13
+   * Action d'ajouter un commentaire.
14
+   * 
15
+   * @param int $element_id
16
+   * @param string $token
17
+   * @return \Symfony\Component\HttpFoundation\Response 
18
+   */
12
   public function addAction($element_id, $token)
19
   public function addAction($element_id, $token)
13
   {
20
   {
14
     if (($response = $this->mustBeConnected(true)))
21
     if (($response = $this->mustBeConnected(true)))
83
          
90
          
84
   }
91
   }
85
   
92
   
93
+  /**
94
+   * Suppression d'un commentaire
95
+   *
96
+   * @param type $element_id
97
+   * @param type $date
98
+   * @param type $token
99
+   * @return \Symfony\Component\HttpFoundation\Response 
100
+   */
86
   public function deleteAction($element_id, $date, $token)
101
   public function deleteAction($element_id, $date, $token)
87
   {
102
   {
88
     if (($response = $this->mustBeConnected(true)))
103
     if (($response = $this->mustBeConnected(true)))
102
     // On met a jour les commentaires
117
     // On met a jour les commentaires
103
     $cm = new CommentsManager($element->getComments());
118
     $cm = new CommentsManager($element->getComments());
104
     
119
     
105
-    
120
+    // On utilise le comment manager pour supprimer le commentaire de la liste
106
     if (!$cm->delete($this->getUserId(), $date))
121
     if (!$cm->delete($this->getUserId(), $date))
107
     {
122
     {
123
+      // Si il n'a pas été trouvé on répond une erreur
108
       return $this->jsonResponse(array(
124
       return $this->jsonResponse(array(
109
         'status' => 'error',
125
         'status' => 'error',
110
         'errors' => array($this->trans(
126
         'errors' => array($this->trans(
115
       )));
131
       )));
116
     }
132
     }
117
     
133
     
134
+    // Si tout c'est bien passé on met a jour l'attribut de l'élément
118
     $element->setComments($cm->get());
135
     $element->setComments($cm->get());
119
       
136
       
120
     $this->getDoctrine()->getEntityManager()->persist($element);
137
     $this->getDoctrine()->getEntityManager()->persist($element);
125
     ));
142
     ));
126
   }
143
   }
127
   
144
   
145
+  /**
146
+   * Modification d'un commentaire, ouverture du formulaire 
147
+   * 
148
+   * @param int $element_id
149
+   * @param string $date (Y-m-d H:i:s u)
150
+   * @param string $token
151
+   * @return Response 
152
+   */
128
   public function editAction($element_id, $date, $token)
153
   public function editAction($element_id, $date, $token)
129
   {
154
   {
130
     if (($response = $this->mustBeConnected(true)))
155
     if (($response = $this->mustBeConnected(true)))
141
       ));
166
       ));
142
     }
167
     }
143
     
168
     
169
+    // On utilise le gestionnaire de commentaire
144
     $cm = new CommentsManager($element->getComments());
170
     $cm = new CommentsManager($element->getComments());
171
+    // On récupére le commentaire visé
145
     $comment = $cm->get($cm->getIndex($this->getUserId(), $date));
172
     $comment = $cm->get($cm->getIndex($this->getUserId(), $date));
146
-    
173
+    // On rpépare la réponse html (formulaire)
147
     $html = $this->render('MuzichCommentBundle:Comment:edit.html.twig', array(
174
     $html = $this->render('MuzichCommentBundle:Comment:edit.html.twig', array(
148
       'comment'     => $comment,
175
       'comment'     => $comment,
149
       'element_id'  => $element->getId(),
176
       'element_id'  => $element->getId(),
150
       'date'        => $date
177
       'date'        => $date
151
     ))->getContent();
178
     ))->getContent();
152
-    
179
+    // On retourne le tout
153
     return $this->jsonResponse(array(
180
     return $this->jsonResponse(array(
154
       'status' => 'success',
181
       'status' => 'success',
155
       'html'   => $html
182
       'html'   => $html
156
     ));
183
     ));
157
   }
184
   }
158
   
185
   
186
+  /**
187
+   * Mise a jour du commentaire. On précise dom_id pour retrouver facilement le 
188
+   * commentaire dans le dom lorsque js récupére la réponse.
189
+   * 
190
+   * @param int $element_id
191
+   * @param string $date (Y-m-d H:i:s u)
192
+   * @param string $token
193
+   * @param string $dom_id
194
+   * @return type 
195
+   */
159
   public function updateAction($element_id, $date, $token, $dom_id)
196
   public function updateAction($element_id, $date, $token, $dom_id)
160
   {
197
   {
161
     if (($response = $this->mustBeConnected(true)))
198
     if (($response = $this->mustBeConnected(true)))

+ 11 - 1
src/Muzich/CoreBundle/Actions/User/Event.php View File

6
 use Muzich\CoreBundle\Entity\Event as EventEntity;
6
 use Muzich\CoreBundle\Entity\Event as EventEntity;
7
 
7
 
8
 /**
8
 /**
9
- * Description of Reputation
9
+ * Refactorisation d'actions lié aux événement de l'utilisateur
10
  *
10
  *
11
  * @author bux
11
  * @author bux
12
  */
12
  */
26
     $this->event = $event;
26
     $this->event = $event;
27
   }
27
   }
28
   
28
   
29
+  /*
30
+   * Mise a jour de l'objet Eevnt
31
+   */
29
   public function updateEvent($element_id)
32
   public function updateEvent($element_id)
30
   {
33
   {
31
     $this->event->addId($element_id);
34
     $this->event->addId($element_id);
32
   }
35
   }
33
   
36
   
37
+  /**
38
+   * Création d'un objet Event
39
+   * 
40
+   * @param string $type
41
+   * @param int $element_id 
42
+   */
34
   public function createEvent($type, $element_id)
43
   public function createEvent($type, $element_id)
35
   {
44
   {
36
     $this->event->addId($element_id);
45
     $this->event->addId($element_id);
37
     $this->event->setType($type);
46
     $this->event->setType($type);
38
     $this->event->setUser($this->user);
47
     $this->event->setUser($this->user);
39
   }
48
   }
49
+  
40
 }
50
 }

+ 11 - 1
src/Muzich/CoreBundle/Actions/User/Reputation.php View File

5
 use Muzich\CoreBundle\Entity\User;
5
 use Muzich\CoreBundle\Entity\User;
6
 
6
 
7
 /**
7
 /**
8
- * Description of Reputation
8
+ * Refactorisation d'actions lié a la réputation de l'utilisateur
9
  *
9
  *
10
  * @author bux
10
  * @author bux
11
  */
11
  */
23
     $this->user = $user;
23
     $this->user = $user;
24
   }
24
   }
25
   
25
   
26
+  /**
27
+   * Ajoute des points a l'objet User
28
+   * 
29
+   * @param int $points 
30
+   */
26
   public function addPoints($points)
31
   public function addPoints($points)
27
   {
32
   {
28
     $this->user->setReputation($this->user->getReputation()+$points);
33
     $this->user->setReputation($this->user->getReputation()+$points);
29
   }
34
   }
30
   
35
   
36
+  /**
37
+   * Retirer des points a l'objet User
38
+   * 
39
+   * @param int $points 
40
+   */
31
   public function removePoints($points)
41
   public function removePoints($points)
32
   {
42
   {
33
     $this->user->setReputation($this->user->getReputation()-$points);
43
     $this->user->setReputation($this->user->getReputation()-$points);

+ 51 - 0
src/Muzich/CoreBundle/Controller/CoreController.php View File

367
     return $groups;
367
     return $groups;
368
   }
368
   }
369
   
369
   
370
+  /**
371
+   * Action non ajax nettoyant la liste de tags du chercheur d'éléments
372
+   * 
373
+   * @return RedirectResponse 
374
+   */
370
   public function filterClearAction()
375
   public function filterClearAction()
371
   {
376
   {
372
     $es = $this->getElementSearcher();
377
     $es = $this->getElementSearcher();
375
     return $this->redirect($this->container->get('request')->headers->get('referer'));
380
     return $this->redirect($this->container->get('request')->headers->get('referer'));
376
   }
381
   }
377
   
382
   
383
+  /**
384
+   * Action non ajax de selection de ses tags favoris pour le chercheur d'élément
385
+   * 
386
+   * @return RedirectResponse 
387
+   */
378
   public function filterMytagsAction()
388
   public function filterMytagsAction()
379
   {
389
   {
380
     $this->getElementSearcher(null, true);
390
     $this->getElementSearcher(null, true);
381
     return $this->redirect($this->container->get('request')->headers->get('referer'));
391
     return $this->redirect($this->container->get('request')->headers->get('referer'));
382
   }
392
   }
383
   
393
   
394
+  /**
395
+   * Action de récupération ajax de l'id des tags favoris de son profil
396
+   * 
397
+   * @return Response 
398
+   */
384
   public function getFavoriteTagsAction()
399
   public function getFavoriteTagsAction()
385
   {
400
   {
386
     if (($response = $this->mustBeConnected()))
401
     if (($response = $this->mustBeConnected()))
417
     ));
432
     ));
418
   }
433
   }
419
   
434
   
435
+  /**
436
+   * Action ajax qui ajoute le tags précisé en paramétre aux tags favoris de
437
+   * l'utilisateur.
438
+   * 
439
+   * @param int $tag_id
440
+   * @param string $token
441
+   * @return Response 
442
+   */
420
   public function addTagToFavoritesAction($tag_id, $token)
443
   public function addTagToFavoritesAction($tag_id, $token)
421
   {
444
   {
422
     if (($response = $this->mustBeConnected(true)))
445
     if (($response = $this->mustBeConnected(true)))
446
       )->getSingleResult();
469
       )->getSingleResult();
447
     }
470
     }
448
     
471
     
472
+    // On contrôle au préalable que le tag ne fait pas déjà partie des favoris de 
473
+    // l'utilisateur
449
     if (!$this->getDoctrine()->getRepository('MuzichCoreBundle:UsersTagsFavorites')
474
     if (!$this->getDoctrine()->getRepository('MuzichCoreBundle:UsersTagsFavorites')
450
       ->findOneBy(array(
475
       ->findOneBy(array(
451
         'user' => $this->getUserId(),
476
         'user' => $this->getUserId(),
452
         'tag'  => $tag->getId()
477
         'tag'  => $tag->getId()
453
       )))
478
       )))
454
     {
479
     {
480
+      // Si il ne l'est pas, on créer ce nouvel objet de relation
455
       $fav = new UsersTagsFavorites();
481
       $fav = new UsersTagsFavorites();
456
       $fav->setTag($tag);
482
       $fav->setTag($tag);
457
       $fav->setUser($user);
483
       $fav->setUser($user);
465
     ));
491
     ));
466
   }
492
   }
467
   
493
   
494
+  /**
495
+   * Cette action (ajax) configure l'appartenance d'un élément a un groupe.
496
+   * Le groupe et l'élément doivent appartenir a l'utilisateur en cours.
497
+   * 
498
+   * @param int $element_id
499
+   * @param int $group_id
500
+   * @param string $token
501
+   * @return Response 
502
+   */
468
   public function setElementGroupAction($element_id, $group_id, $token)
503
   public function setElementGroupAction($element_id, $group_id, $token)
469
   {
504
   {
470
     if (($response = $this->mustBeConnected(true)))
505
     if (($response = $this->mustBeConnected(true)))
511
     ));
546
     ));
512
   }
547
   }
513
   
548
   
549
+  /**
550
+   * Action (ajax) permettant de signaler un élément comme contenu non approprié.
551
+   * 
552
+   * @param int $element_id
553
+   * @param string $token
554
+   * @return Response 
555
+   */
514
   public function reportElementAction($element_id, $token)
556
   public function reportElementAction($element_id, $token)
515
   {
557
   {
516
     if (($response = $this->mustBeConnected(true)))
558
     if (($response = $this->mustBeConnected(true)))
528
       ));
570
       ));
529
     }
571
     }
530
     
572
     
573
+    // On utilise le manager de rapport
531
     $erm = new ElementReportManager($element);
574
     $erm = new ElementReportManager($element);
532
     $erm->add($this->getUser());
575
     $erm->add($this->getUser());
533
     
576
     
540
     
583
     
541
   }
584
   }
542
   
585
   
586
+  /**
587
+   * Il arrive que l'on configure le chercheur d'élément de façon a ce qu'il
588
+   * affiche une liste d'élément précis (collection d'id). Cette action
589
+   * supprime cette configuration de façon a ce que le chercheur fonctionne 
590
+   * normalement.
591
+   * 
592
+   * @return type 
593
+   */
543
   public function filterRemoveIdsAction()
594
   public function filterRemoveIdsAction()
544
   {
595
   {
545
     if (($response = $this->mustBeConnected(true)))
596
     if (($response = $this->mustBeConnected(true)))

+ 48 - 3
src/Muzich/CoreBundle/Controller/ElementController.php View File

10
 {
10
 {
11
   
11
   
12
   /**
12
   /**
13
-   *
14
-   * @param type $element_id
13
+   * Cette méthode est utilisé pour récupérer un objet Element tout en levant
14
+   * une erreur si il n'existe pas ou si il n'appartient pas a l'utilisateur en 
15
+   * cours.
16
+   * 
17
+   * @param int $element_id
15
    * @return Muzich\CoreBundle\Entity\Element 
18
    * @return Muzich\CoreBundle\Entity\Element 
16
    */
19
    */
17
   protected function checkExistingAndOwned($element_id)
20
   protected function checkExistingAndOwned($element_id)
31
   }
34
   }
32
   
35
   
33
   /**
36
   /**
37
+   * Action d'ouverture du formulaire de modification d'un élément.
34
    * 
38
    * 
39
+   * @param int $element_id
40
+   * @return Response
35
    */
41
    */
36
   public function editAction($element_id)
42
   public function editAction($element_id)
37
   {
43
   {
42
     
48
     
43
     $element = $this->checkExistingAndOwned($element_id);
49
     $element = $this->checkExistingAndOwned($element_id);
44
     
50
     
51
+    // On doit faire un chmilblik avec les tags pour
52
+    // utiliser le javascript de tags (tagPrompt)
53
+    // sur le formulaire
45
     $element_tags = $element->getTags();
54
     $element_tags = $element->getTags();
46
     $element->setTags($element->getTagsIdsJson());
55
     $element->setTags($element->getTagsIdsJson());
47
     $form = $this->getAddForm($element);
56
     $form = $this->getAddForm($element);
79
   }
88
   }
80
   
89
   
81
   /**
90
   /**
82
-   *
91
+   * Mise a jour des données d'un élément.
92
+   * 
93
+   * @param int $element_id
94
+   * @param string $dom_id
95
+   * @return Response 
83
    */
96
    */
84
   public function updateAction($element_id, $dom_id)
97
   public function updateAction($element_id, $dom_id)
85
   {
98
   {
114
     {
127
     {
115
       $status = 'success';
128
       $status = 'success';
116
       $em = $this->getDoctrine()->getEntityManager();
129
       $em = $this->getDoctrine()->getEntityManager();
130
+      // On utilise le manager d'élément
117
       $factory = new ElementManager($element, $em, $this->container);
131
       $factory = new ElementManager($element, $em, $this->container);
118
       $factory->proceedFill($user);
132
       $factory->proceedFill($user);
119
       // Si il y avais un groupe on le remet
133
       // Si il y avais un groupe on le remet
168
     ));
182
     ));
169
   }
183
   }
170
   
184
   
185
+  /**
186
+   * Suppression d'un élément. 
187
+   * 
188
+   * @param int $element_id
189
+   * @return Response 
190
+   */
171
   public function removeAction($element_id)
191
   public function removeAction($element_id)
172
   {
192
   {
173
     if (($response = $this->mustBeConnected()))
193
     if (($response = $this->mustBeConnected()))
199
     }
219
     }
200
   }
220
   }
201
   
221
   
222
+  /**
223
+   * Cette procédure retourne le lien a afficher sur la page home permettant
224
+   * d'afficher des élément apparus entre temps.
225
+   * 
226
+   * @param int $count
227
+   * @return type 
228
+   */
202
   protected function getcountNewMessage($count)
229
   protected function getcountNewMessage($count)
203
   {
230
   {
204
     if ($count == 1)
231
     if ($count == 1)
345
     ));
372
     ));
346
   }
373
   }
347
   
374
   
375
+  /**
376
+   * Action (ajax) ajoutant son vote "good" sur un élément
377
+   * 
378
+   * @param int $element_id
379
+   * @param string $token
380
+   * @return Response 
381
+   */
348
   public function addVoteGoodAction($element_id, $token)
382
   public function addVoteGoodAction($element_id, $token)
349
   {
383
   {
350
     if (($response = $this->mustBeConnected(true)))
384
     if (($response = $this->mustBeConnected(true)))
369
       ));
403
       ));
370
     }
404
     }
371
     
405
     
406
+    // On ajoute un vote a l'élément
372
     $element->addVoteGood($this->getUser()->getId());
407
     $element->addVoteGood($this->getUser()->getId());
408
+    // Puis on lance les actions propagés par ce vote
373
     $event = new EventElementScore($this->container);
409
     $event = new EventElementScore($this->container);
374
     $event->onePointAdded($element);
410
     $event->onePointAdded($element);
375
     
411
     
395
     ));
431
     ));
396
   }
432
   }
397
   
433
   
434
+  /**
435
+   * Action (ajax) de retrait de son vote good
436
+   * 
437
+   * @param int $element_id
438
+   * @param string $token
439
+   * @return Response 
440
+   */
398
   public function removeVoteGoodAction($element_id, $token)
441
   public function removeVoteGoodAction($element_id, $token)
399
   {
442
   {
400
     if (($response = $this->mustBeConnected(true)))
443
     if (($response = $this->mustBeConnected(true)))
419
       ));
462
       ));
420
     }
463
     }
421
     
464
     
465
+    // Retrait du vote good
422
     $element->removeVoteGood($this->getUser()->getId());
466
     $element->removeVoteGood($this->getUser()->getId());
467
+    // Puis on lance les actions propagés par retrait de vote
423
     $event = new EventElementScore($this->container);
468
     $event = new EventElementScore($this->container);
424
     $event->onePointRemoved($element);
469
     $event->onePointRemoved($element);
425
     
470
     

+ 30 - 3
src/Muzich/CoreBundle/Controller/SearchController.php View File

13
 class SearchController extends Controller
13
 class SearchController extends Controller
14
 {
14
 {
15
   
15
   
16
+  /**
17
+   * Procédure qui construit un réponse json contenant le html
18
+   * par defalt de la liste d'élément.
19
+   * 
20
+   * @param Collection $elements
21
+   * @param boolean $invertcolors
22
+   * @param sring $message
23
+   * @return Response 
24
+   */
16
   protected function searchElementsMore($elements, $invertcolors, $message)
25
   protected function searchElementsMore($elements, $invertcolors, $message)
17
   {
26
   {
18
     
27
     
115
     }
124
     }
116
   }
125
   }
117
   
126
   
127
+  /**
128
+   * Action (ajax) de récupération d'éléments en plus
129
+   * [a check pour être sur] N'EST PLUS UTILISE
130
+   *
131
+   * @param string $type
132
+   * @param string $object_id
133
+   * @param int $id_limit
134
+   * @param boolean $invertcolors
135
+   * @return Response 
136
+   */
118
   public function searchElementsShowAction($type, $object_id, $id_limit, $invertcolors)
137
   public function searchElementsShowAction($type, $object_id, $id_limit, $invertcolors)
119
   {
138
   {
120
     if ($this->getRequest()->isXmlHttpRequest())
139
     if ($this->getRequest()->isXmlHttpRequest())
164
   }
183
   }
165
     
184
     
166
   /**
185
   /**
167
-   *
168
-   * @param string $string_search 
186
+   * Procédure (ajax) de recherche de tags. Essentielement utilisé dans 
187
+   * le tagPrompt.
188
+   * 
189
+   * @param string $string_search
190
+   * @param int $timestamp
191
+   * @return Response 
169
    */
192
    */
170
   public function searchTagAction($string_search, $timestamp)
193
   public function searchTagAction($string_search, $timestamp)
171
   {
194
   {
178
     {
201
     {
179
       if (strlen(trim($string_search)) > 1)
202
       if (strlen(trim($string_search)) > 1)
180
       {
203
       {
204
+        // On utilise l'objet TagLike
181
         $TagLike = new TagLike($this->getDoctrine());
205
         $TagLike = new TagLike($this->getDoctrine());
206
+        // Pour trier nos tags d'une manière plus humaine
182
         $sort_response = $TagLike->getSimilarTags($string_search, $this->getUserId());
207
         $sort_response = $TagLike->getSimilarTags($string_search, $this->getUserId());
183
       
208
       
184
         $status = 'success';
209
         $status = 'success';
216
   }
241
   }
217
   
242
   
218
   /**
243
   /**
219
-   *
244
+   * Récupére l'id d'un tag (ajax)
245
+   * [A check] mais ne doit et n'est plus utilisé.
246
+   * 
220
    * @param type $string_search
247
    * @param type $string_search
221
    * @return Response 
248
    * @return Response 
222
    */
249
    */

+ 27 - 0
src/Muzich/CoreBundle/Entity/Element.php View File

497
     }
497
     }
498
   }
498
   }
499
   
499
   
500
+  /**
501
+   * Retourne le nombre de fois que cet élément a été msi en favoris 
502
+   * 
503
+   * @return int
504
+   */
500
   public function getCountFavorite()
505
   public function getCountFavorite()
501
   {
506
   {
502
     return count($this->elements_favorites);
507
     return count($this->elements_favorites);
512
 //    $this->tags->removeElement($tag);
517
 //    $this->tags->removeElement($tag);
513
 //  }
518
 //  }
514
   
519
   
520
+  /**
521
+   * Répond vrai si le tag transmis fait partis des tags de l'élément
522
+   * 
523
+   * @param Tag $tag_t
524
+   * @return boolean 
525
+   */
515
   public function hasTag(Tag $tag_t)
526
   public function hasTag(Tag $tag_t)
516
   {
527
   {
517
     foreach ($this->getTags() as $tag)
528
     foreach ($this->getTags() as $tag)
549
     $this->vote_good_ids = json_encode($votes_ids);
560
     $this->vote_good_ids = json_encode($votes_ids);
550
   }
561
   }
551
   
562
   
563
+  /**
564
+   * ajoute le vote de l'user_id aux votes good
565
+   * 
566
+   * @param int $user_id 
567
+   */
552
   public function addVoteGood($user_id)
568
   public function addVoteGood($user_id)
553
   {
569
   {
554
     $votes = $this->getVoteGoodIds();
570
     $votes = $this->getVoteGoodIds();
565
     $this->setVoteGoodIds($votes);
581
     $this->setVoteGoodIds($votes);
566
   }
582
   }
567
   
583
   
584
+  /**
585
+   * Retire le vote_good de l'user_id
586
+   * 
587
+   * @param int $user_id 
588
+   */
568
   public function removeVoteGood($user_id)
589
   public function removeVoteGood($user_id)
569
   {
590
   {
570
     if (count($votes = $this->getVoteGoodIds()))
591
     if (count($votes = $this->getVoteGoodIds()))
583
     }
604
     }
584
   }
605
   }
585
   
606
   
607
+  /**
608
+   * Répond vrai si l'user_id a déjà voté good.
609
+   * 
610
+   * @param int $user_id
611
+   * @return boolean 
612
+   */
586
   public function hasVoteGood($user_id)
613
   public function hasVoteGood($user_id)
587
   {
614
   {
588
     if (count($votes = $this->getVoteGoodIds()))
615
     if (count($votes = $this->getVoteGoodIds()))

+ 11 - 0
src/Muzich/CoreBundle/Entity/Event.php View File

116
    * 
116
    * 
117
    */
117
    */
118
   
118
   
119
+  /**
120
+   * Ajoute l'identifiant a la liste d'identifiant
121
+   * 
122
+   * @param int $id 
123
+   */
119
   public function addId($id)
124
   public function addId($id)
120
   {
125
   {
121
     $ids = $this->getIds();
126
     $ids = $this->getIds();
132
     $this->setIds($ids);
137
     $this->setIds($ids);
133
   }
138
   }
134
     
139
     
140
+  /**
141
+   * Répond vrai si l'id transmis fait partis des ids
142
+   * 
143
+   * @param int $id_check
144
+   * @return boolean 
145
+   */
135
   public function hasId($id_check)
146
   public function hasId($id_check)
136
   {
147
   {
137
     if (count($ids = $this->getIds()))
148
     if (count($ids = $this->getIds()))

+ 28 - 4
src/Muzich/CoreBundle/Managers/CommentsManager.php View File

3
 namespace Muzich\CoreBundle\Managers;
3
 namespace Muzich\CoreBundle\Managers;
4
 
4
 
5
 /**
5
 /**
6
+ * Gestionnaire de commentaires.
7
+ * Les commentaires sont stocké en base sous forme de tableau json afin d'économiser
8
+ * relations entre tables. Ce menager per de gérer le tableau de commentaire
9
+ * plus facilement.
10
+ * 
6
  * @author bux
11
  * @author bux
7
  */
12
  */
8
 class CommentsManager
13
 class CommentsManager
16
   }
21
   }
17
   
22
   
18
   /**
23
   /**
19
-   *
24
+   * Ajouter un commentaire au tableau.
25
+   * 
20
    * @param \Muzich\CoreBundle\Entity\User $user
26
    * @param \Muzich\CoreBundle\Entity\User $user
21
    * @param String $comment
27
    * @param String $comment
22
    * @param String $date 
28
    * @param String $date 
49
     return $this->get(count($this->comments)-1);
55
     return $this->get(count($this->comments)-1);
50
   }
56
   }
51
   
57
   
58
+  /**
59
+   * Mise a jour d'un commentaire parmis le tableau. On l'identifie ici par son
60
+   * auteur et sa date de publication.
61
+   * 
62
+   * @param \Muzich\CoreBundle\Entity\User $user
63
+   * @param date $date (Y-m-d H:i:s u)
64
+   * @param string $comment_c 
65
+   */
52
   public function update($user, $date, $comment_c)
66
   public function update($user, $date, $comment_c)
53
   {
67
   {
54
     $comments = array();
68
     $comments = array();
77
   }
91
   }
78
   
92
   
79
   /**
93
   /**
80
-   *
94
+   * Suppression d'un commentaire. Si il a été trouvé on retourne vrai.
95
+   * 
81
    * @param int $user_id
96
    * @param int $user_id
82
-   * @param string $date
97
+   * @param string $date (Y-m-d H:i:s u)
83
    * @return boolean 
98
    * @return boolean 
84
    */
99
    */
85
   public function delete($user_id, $date)
100
   public function delete($user_id, $date)
101
     return $found;
116
     return $found;
102
   }
117
   }
103
   
118
   
119
+  /**
120
+   * Permet de récupérer l'index d'un commentaire dans le tableau de commentaires.
121
+   * Si le commentaire n'est pas trouvé on retourne null.
122
+   * 
123
+   * @param int $user_id
124
+   * @param  string $date (Y-m-d H:i:s u)
125
+   * @return int 
126
+   */
104
   public function getIndex($user_id, $date)
127
   public function getIndex($user_id, $date)
105
   {
128
   {
106
     foreach ($this->comments as $i => $comment)
129
     foreach ($this->comments as $i => $comment)
114
   }
137
   }
115
   
138
   
116
   /**
139
   /**
117
-   *
140
+   * Retourne un commentaire en fonction de son index dans le tableau.
141
+   * 
118
    * @return array
142
    * @return array
119
    */
143
    */
120
   public function get($index = null)
144
   public function get($index = null)

+ 4 - 1
src/Muzich/CoreBundle/Managers/ElementReportManager.php View File

5
 use Muzich\CoreBundle\Entity\User;
5
 use Muzich\CoreBundle\Entity\User;
6
 
6
 
7
 /**
7
 /**
8
+ * Manager de rapport sur elements
9
+ * 
8
  * @author bux
10
  * @author bux
9
  */
11
  */
10
 class ElementReportManager
12
 class ElementReportManager
18
   }
20
   }
19
   
21
   
20
   /**
22
   /**
21
-   *
23
+   * Ajouter un rapport
24
+   * 
22
    * @param \Muzich\CoreBundle\Entity\User $user
25
    * @param \Muzich\CoreBundle\Entity\User $user
23
    * @param String $comment
26
    * @param String $comment
24
    * @param String $date 
27
    * @param String $date 

+ 9 - 1
src/Muzich/CoreBundle/Propagator/EventElementComment.php View File

8
 use Muzich\CoreBundle\Entity\Event;
8
 use Muzich\CoreBundle\Entity\Event;
9
 
9
 
10
 /**
10
 /**
11
- * Description of EventElementScore
11
+ * Propagateur d'événement concernant les Commentaires d'éléments
12
  *
12
  *
13
  * @author bux
13
  * @author bux
14
  */
14
  */
15
 class EventElementComment extends EventPropagator
15
 class EventElementComment extends EventPropagator
16
 {  
16
 {  
17
   
17
   
18
+  /**
19
+   * Cette procédure doit être appelé après l'ajout d'un commentaire sur un 
20
+   * événement. Actuellement il:
21
+   * * Met a jour ou créer un objet événement (nouveau commentaire) pour le
22
+   *   propriétaire de l'élément.
23
+   * 
24
+   * @param Element $element 
25
+   */
18
   public function commentAdded(Element $element)
26
   public function commentAdded(Element $element)
19
   {    
27
   {    
20
     $em = $this->container->get('doctrine')->getEntityManager();
28
     $em = $this->container->get('doctrine')->getEntityManager();

+ 1 - 1
src/Muzich/CoreBundle/Propagator/EventElementScore.php View File

7
 use Muzich\CoreBundle\Actions\User\Reputation as UserReputation;
7
 use Muzich\CoreBundle\Actions\User\Reputation as UserReputation;
8
 
8
 
9
 /**
9
 /**
10
- * Description of EventElementScore
10
+ * Propagateur d'événement liés aux score des éléments
11
  *
11
  *
12
  * @author bux
12
  * @author bux
13
  */
13
  */

+ 39 - 6
src/Muzich/CoreBundle/lib/Controller.php View File

87
   }
87
   }
88
   
88
   
89
   /**
89
   /**
90
-   * Retourne l'objet User.
90
+   * Retourne l'objet User. Il est possible de préciser de quel manière récupérer 
91
+   * l'utilisateur:
91
    * 
92
    * 
93
+   * $user = $this->getUser(true, array('join' => array(
94
+   *   'groups_owned'
95
+   * )));
96
+   * 
97
+   * ou de forcer sa (re)récupération en base (sinon c'est l'objet static qui est renvoyé)
98
+   * 
99
+   * @param boolean $personal_query
92
    * @param array $params
100
    * @param array $params
93
-   * @return User
101
+   * @param boolean $force_refresh
102
+   * @return type 
94
    */
103
    */
95
   protected function getUser($personal_query = false, $params = array(), $force_refresh = false)
104
   protected function getUser($personal_query = false, $params = array(), $force_refresh = false)
96
   {
105
   {
264
     }
273
     }
265
   }
274
   }
266
   
275
   
276
+  /**
277
+   * Retourne le formulaire de recherche
278
+   * 
279
+   * @param \Muzich\CoreBundle\Searcher\Searcher $search_object
280
+   * @return \Symfony\Component\Form\Form
281
+   */
267
   protected function getSearchForm($search_object)
282
   protected function getSearchForm($search_object)
268
   {
283
   {
269
     return $this->createForm(
284
     return $this->createForm(
273
     );
288
     );
274
   }
289
   }
275
   
290
   
291
+  /**
292
+   * Retourne le formulaire d'ajout d'élément
293
+   * 
294
+   * @param \Muzich\CoreBundle\Searcher\Searcher $search_object
295
+   * @return \Symfony\Component\Form\Form
296
+   */
276
   protected function getAddForm($element = array())
297
   protected function getAddForm($element = array())
277
   {
298
   {
278
     return $this->createForm(
299
     return $this->createForm(
283
   }
304
   }
284
   
305
   
285
   /**
306
   /**
286
-   * Retourne une réponse contenant du json
307
+   * Retourne une réponse contenant et de type json
287
    * 
308
    * 
288
    * @param array $content
309
    * @param array $content
289
    * @return Response 
310
    * @return Response 
295
     return $response;
316
     return $response;
296
   }
317
   }
297
   
318
   
319
+  /**
320
+   * Permet d'utiliser la méthode Assert que l'on utilise dans les templates
321
+   * afin d'avoir une url correcte vers une ressource web (img, js, ...)
322
+   * 
323
+   * @param string $path
324
+   * @param string $packageName
325
+   * @return string 
326
+   */
298
   protected function getAssetUrl($path, $packageName = null)
327
   protected function getAssetUrl($path, $packageName = null)
299
   {
328
   {
300
     return $this->container->get('templating.helper.assets')->getUrl($path, $packageName);
329
     return $this->container->get('templating.helper.assets')->getUrl($path, $packageName);
301
   }
330
   }
302
   
331
   
303
   /**
332
   /**
304
-   *
305
-   * @param strin $string
333
+   * Retourne une traduction effectué par le translator
334
+   * 
335
+   * @param string $string
306
    * @param array $params
336
    * @param array $params
307
    * @param string $package
337
    * @param string $package
308
    * @return string 
338
    * @return string 
313
   }
343
   }
314
   
344
   
315
   /**
345
   /**
316
-   *
346
+   * Permet de récupérer un objet réponse si l'utilisateur doit être connecté
347
+   * pour accéder a cette ressource. On peux préciser $and_ajax pour que
348
+   * la requete de type ajax soit une nécéssité.
349
+   * 
317
    * @return Response
350
    * @return Response
318
    */
351
    */
319
   protected function mustBeConnected($and_ajax = false)
352
   protected function mustBeConnected($and_ajax = false)