Browse Source

bugfix: compteur points element

bastien 13 years ago
parent
commit
91615c499f
2 changed files with 4 additions and 24 deletions
  1. 2 2
      src/Muzich/CoreBundle/Entity/Element.php
  2. 2 22
      src/Muzich/CoreBundle/Entity/Event.php

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

@@ -560,8 +560,8 @@ class Element
560 560
     if (!$this->hasVoteGood($user_id))
561 561
     {
562 562
       $votes[] = (string)$user_id;
563
+      $this->setPoints(count($votes));
563 564
     }
564
-    $this->setPoints($this->getPoints()+1);
565 565
     $this->setVoteGoodIds($votes);
566 566
   }
567 567
   
@@ -578,7 +578,7 @@ class Element
578 578
         }
579 579
       }
580 580
       
581
-      $this->setPoints($this->getPoints()-1);
581
+      $this->setPoints(count($votes_n));
582 582
       $this->setVoteGoodIds($votes_n);
583 583
     }
584 584
   }

+ 2 - 22
src/Muzich/CoreBundle/Entity/Event.php View File

@@ -146,31 +146,11 @@ class Event
146 146
     if (!$this->hasId($id))
147 147
     {
148 148
       $ids[] = (string)$id;
149
-      $this->setCount($this->getCount()+1);
149
+      $this->setCount(count($ids));
150 150
     }
151 151
     $this->setIds($ids);
152 152
   }
153
-  
154
-  public function removeVoteGood($id_remove)
155
-  {
156
-    if (count($ids = $this->getIds()))
157
-    {
158
-      $ids_n = array();
159
-      foreach ($ids as $id)
160
-      {
161
-        if ($id != $id_remove)
162
-        {
163
-          $ids_n[] = (string)$id;
164
-        }
165
-        else
166
-        {
167
-          $this->setCount($this->getCount()-1);
168
-        }
169
-      }
170
-      $this->setIds($ids_n);
171
-    }
172
-  }
173
-  
153
+    
174 154
   public function hasId($id_check)
175 155
   {
176 156
     if (count($ids = $this->getIds()))