Преглед изворни кода

bugfix: compteur points element

bastien пре 13 година
родитељ
комит
91615c499f
2 измењених фајлова са 4 додато и 24 уклоњено
  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 Прегледај датотеку

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

+ 2 - 22
src/Muzich/CoreBundle/Entity/Event.php Прегледај датотеку

146
     if (!$this->hasId($id))
146
     if (!$this->hasId($id))
147
     {
147
     {
148
       $ids[] = (string)$id;
148
       $ids[] = (string)$id;
149
-      $this->setCount($this->getCount()+1);
149
+      $this->setCount(count($ids));
150
     }
150
     }
151
     $this->setIds($ids);
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
   public function hasId($id_check)
154
   public function hasId($id_check)
175
   {
155
   {
176
     if (count($ids = $this->getIds()))
156
     if (count($ids = $this->getIds()))