瀏覽代碼

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

Bastien Sevajol 11 年之前
父節點
當前提交
3716d16bb4

+ 8 - 0
src/Muzich/CoreBundle/DataFixtures/ORM/LoadUsersElementsFavoritesData.php 查看文件

@@ -36,7 +36,15 @@ class LoadUsersElementsFavoritesData  extends AbstractFixture implements Ordered
36 36
     $favorite = new UsersElementsFavorites();
37 37
     $favorite->setUser($user);
38 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 46
     $this->entity_manager->persist($favorite);
47
+    $this->entity_manager->persist($element);
40 48
     //$this->addReference('user_tag_'.$user->getId().'_'.$tag->getId(), $userTag);
41 49
   }
42 50
   

+ 16 - 0
src/Muzich/CoreBundle/Entity/Element.php 查看文件

@@ -260,14 +260,18 @@ class Element
260 260
   protected $count_report;
261 261
   
262 262
   /**
263
+<<<<<<< HEAD
263 264
 <<<<<<< Updated upstream
264 265
 =======
266
+=======
267
+>>>>>>> feature/v0.9.8.2/score
265 268
    * @ORM\Column(type="integer", nullable=true)
266 269
    * @var int 
267 270
    */
268 271
   protected $count_favorited;
269 272
   
270 273
   /**
274
+<<<<<<< HEAD
271 275
    * @ORM\Column(type="integer", nullable=true)
272 276
    * @var int 
273 277
    */
@@ -275,6 +279,8 @@ class Element
275 279
   
276 280
   /**
277 281
 >>>>>>> Stashed changes
282
+=======
283
+>>>>>>> feature/v0.9.8.2/score
278 284
    * @ORM\Column(type="boolean", nullable=false)
279 285
    * @var int 
280 286
    */
@@ -834,6 +840,16 @@ class Element
834 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 853
   public function getVoteGoodIds()
838 854
   {
839 855
     return json_decode($this->vote_good_ids, true);

+ 8 - 6
src/Muzich/CoreBundle/Propagator/EventElement.php 查看文件

@@ -110,9 +110,10 @@ class EventElement extends EventPropagator
110 110
     $security_context = new SecurityContext($added_by_user);
111 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 119
     $uea = new UserEventAction($element->getOwner(), $this->container);
@@ -131,9 +132,10 @@ class EventElement extends EventPropagator
131 132
     $security_context = new SecurityContext($removed_by_user);
132 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 查看文件

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