Browse Source

Merge branch 'feature/v0.9.8.2/score' into stable/v0.9.8.2

Bastien Sevajol 11 years ago
parent
commit
3716d16bb4

+ 8 - 0
src/Muzich/CoreBundle/DataFixtures/ORM/LoadUsersElementsFavoritesData.php View File

36
     $favorite = new UsersElementsFavorites();
36
     $favorite = new UsersElementsFavorites();
37
     $favorite->setUser($user);
37
     $favorite->setUser($user);
38
     $favorite->setElement($element);
38
     $favorite->setElement($element);
39
+    
40
+    if ($element->getOwner()->getId() != $user->getId())
41
+    {
42
+      $element->addPoints($this->container->getParameter('reputation_element_favorite_value'));
43
+      $element->increaseCountFavorited();
44
+    }
45
+    
39
     $this->entity_manager->persist($favorite);
46
     $this->entity_manager->persist($favorite);
47
+    $this->entity_manager->persist($element);
40
     //$this->addReference('user_tag_'.$user->getId().'_'.$tag->getId(), $userTag);
48
     //$this->addReference('user_tag_'.$user->getId().'_'.$tag->getId(), $userTag);
41
   }
49
   }
42
   
50
   

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

260
   protected $count_report;
260
   protected $count_report;
261
   
261
   
262
   /**
262
   /**
263
+<<<<<<< HEAD
263
 <<<<<<< Updated upstream
264
 <<<<<<< Updated upstream
264
 =======
265
 =======
266
+=======
267
+>>>>>>> feature/v0.9.8.2/score
265
    * @ORM\Column(type="integer", nullable=true)
268
    * @ORM\Column(type="integer", nullable=true)
266
    * @var int 
269
    * @var int 
267
    */
270
    */
268
   protected $count_favorited;
271
   protected $count_favorited;
269
   
272
   
270
   /**
273
   /**
274
+<<<<<<< HEAD
271
    * @ORM\Column(type="integer", nullable=true)
275
    * @ORM\Column(type="integer", nullable=true)
272
    * @var int 
276
    * @var int 
273
    */
277
    */
275
   
279
   
276
   /**
280
   /**
277
 >>>>>>> Stashed changes
281
 >>>>>>> Stashed changes
282
+=======
283
+>>>>>>> feature/v0.9.8.2/score
278
    * @ORM\Column(type="boolean", nullable=false)
284
    * @ORM\Column(type="boolean", nullable=false)
279
    * @var int 
285
    * @var int 
280
    */
286
    */
834
     $this->points = $points;
840
     $this->points = $points;
835
   }
841
   }
836
   
842
   
843
+  public function addPoints($points)
844
+  {
845
+    $this->points = $this->getPoints()+$points;
846
+  }
847
+  
848
+  public function removePoints($points)
849
+  {
850
+    $this->points = $this->getPoints()-$points;
851
+  }
852
+  
837
   public function getVoteGoodIds()
853
   public function getVoteGoodIds()
838
   {
854
   {
839
     return json_decode($this->vote_good_ids, true);
855
     return json_decode($this->vote_good_ids, true);

+ 8 - 6
src/Muzich/CoreBundle/Propagator/EventElement.php View File

110
     $security_context = new SecurityContext($added_by_user);
110
     $security_context = new SecurityContext($added_by_user);
111
     if (!$security_context->actionIsAffectedBy(SecurityContext::AFFECT_NO_SCORING, SecurityContext::ACTION_ELEMENT_ADD_TO_FAVORITES))
111
     if (!$security_context->actionIsAffectedBy(SecurityContext::AFFECT_NO_SCORING, SecurityContext::ACTION_ELEMENT_ADD_TO_FAVORITES))
112
     {
112
     {
113
-      $ur->addPoints(
114
-        $this->container->getParameter('reputation_element_favorite_value')
115
-      );
113
+      $score_action = $this->container->getParameter('reputation_element_favorite_value');
114
+      $ur->addPoints($score_action);
115
+      $element->addPoints($score_action);
116
+      $element->increaseCountFavorited();
116
     }
117
     }
117
     
118
     
118
     $uea = new UserEventAction($element->getOwner(), $this->container);
119
     $uea = new UserEventAction($element->getOwner(), $this->container);
131
     $security_context = new SecurityContext($removed_by_user);
132
     $security_context = new SecurityContext($removed_by_user);
132
     if (!$security_context->actionIsAffectedBy(SecurityContext::AFFECT_NO_SCORING, SecurityContext::ACTION_ELEMENT_ADD_TO_FAVORITES))
133
     if (!$security_context->actionIsAffectedBy(SecurityContext::AFFECT_NO_SCORING, SecurityContext::ACTION_ELEMENT_ADD_TO_FAVORITES))
133
     {
134
     {
134
-      $ur->removePoints(
135
-        $this->container->getParameter('reputation_element_favorite_value')
136
-      );
135
+      $score_action = $this->container->getParameter('reputation_element_favorite_value');
136
+      $ur->removePoints($score_action);
137
+      $element->removePoints($score_action);
138
+      $element->uncreaseCountFavorited();
137
     }
139
     }
138
   }
140
   }
139
   
141
   

+ 2 - 0
src/Muzich/FavoriteBundle/Controller/FavoriteController.php View File

60
         $event = new EventElement($this->container);
60
         $event = new EventElement($this->container);
61
         $event->addedToFavorites($element, $user);
61
         $event->addedToFavorites($element, $user);
62
         $em->persist($user);
62
         $em->persist($user);
63
+        $em->persist($element);
63
       }
64
       }
64
       
65
       
65
       // On signale que cet user a modifié sa liste de favoris
66
       // On signale que cet user a modifié sa liste de favoris
129
       $user->setData(User::DATA_FAV_UPDATED, true);
130
       $user->setData(User::DATA_FAV_UPDATED, true);
130
       
131
       
131
       $em->persist($element->getOwner());
132
       $em->persist($element->getOwner());
133
+      $em->persist($element);
132
       $em->remove($fav);
134
       $em->remove($fav);
133
       $em->flush();
135
       $em->flush();
134
     }
136
     }