Browse Source

Anomalie #142: Tags favoris

bastien 13 years ago
parent
commit
a579241954

+ 4 - 2
src/Muzich/CoreBundle/Repository/GroupRepository.php View File

76
    * 
76
    * 
77
    * @return doctrine_collection
77
    * @return doctrine_collection
78
    */
78
    */
79
-  public function getElementsTags($group_id)
79
+  public function getElementsTags($group_id, $current_user_id)
80
   {
80
   {
81
     return $this->getEntityManager()
81
     return $this->getEntityManager()
82
       ->createQuery('
82
       ->createQuery('
83
         SELECT t FROM MuzichCoreBundle:Tag t
83
         SELECT t FROM MuzichCoreBundle:Tag t
84
         LEFT JOIN t.elements e
84
         LEFT JOIN t.elements e
85
         WHERE e.group = :gid
85
         WHERE e.group = :gid
86
+        AND (t.tomoderate = \'FALSE\' OR t.tomoderate IS NULL
87
+          OR t.privateids LIKE :uidt)
86
         ORDER BY t.name ASC'
88
         ORDER BY t.name ASC'
87
       )
89
       )
88
-      ->setParameter('gid', $group_id)
90
+      ->setParameters(array('gid' => $group_id, 'uidt' => '%"'.$current_user_id.'"%'))
89
       ->getResult()
91
       ->getResult()
90
     ;
92
     ;
91
   }
93
   }

+ 2 - 2
src/Muzich/CoreBundle/Repository/UserRepository.php View File

185
    * 
185
    * 
186
    * @return doctrine_collection
186
    * @return doctrine_collection
187
    */
187
    */
188
-  public function getElementsTags($user_id)
188
+  public function getElementsTags($user_id, $current_user_id)
189
   {
189
   {
190
     return $this->getEntityManager()
190
     return $this->getEntityManager()
191
       ->createQuery('
191
       ->createQuery('
196
           OR t.privateids LIKE :uidt)
196
           OR t.privateids LIKE :uidt)
197
         ORDER BY t.name ASC'
197
         ORDER BY t.name ASC'
198
       )
198
       )
199
-      ->setParameters(array('uid' => $user_id, 'uidt' => '%"'.$user_id.'"%'))
199
+      ->setParameters(array('uid' => $user_id, 'uidt' => '%"'.$current_user_id.'"%'))
200
       ->getResult()
200
       ->getResult()
201
     ;
201
     ;
202
   }
202
   }

+ 2 - 2
src/Muzich/CoreBundle/Repository/UsersElementsFavoritesRepository.php View File

12
    * 
12
    * 
13
    * @return doctrine_collection
13
    * @return doctrine_collection
14
    */
14
    */
15
-  public function getTags($user_id)
15
+  public function getTags($user_id, $current_user_id)
16
   {
16
   {
17
     return $this->getEntityManager()
17
     return $this->getEntityManager()
18
       ->createQuery('
18
       ->createQuery('
24
           OR t.privateids LIKE :uidt)
24
           OR t.privateids LIKE :uidt)
25
         ORDER BY t.name ASC'
25
         ORDER BY t.name ASC'
26
       )
26
       )
27
-      ->setParameters(array('uid' => $user_id, 'uidt' => '%"'.$user_id.'"%'))
27
+      ->setParameters(array('uid' => $user_id, 'uidt' => '%"'.$current_user_id.'"%'))
28
       ->getResult()
28
       ->getResult()
29
     ;
29
     ;
30
   }
30
   }

+ 2 - 2
src/Muzich/CoreBundle/Tests/Controller/ShowControllerTest.php View File

46
       ->findOneByName('Antropod - Polakatek')
46
       ->findOneByName('Antropod - Polakatek')
47
     ;
47
     ;
48
     $tags = $this->getDoctrine()->getRepository('MuzichCoreBundle:User')
48
     $tags = $this->getDoctrine()->getRepository('MuzichCoreBundle:User')
49
-      ->getElementsTags($bux->getId())      
49
+      ->getElementsTags($bux->getId(), $bux->getId())      
50
     ;
50
     ;
51
     
51
     
52
     $ids = array();
52
     $ids = array();
123
       ->findOneByName('PsyElement 1')
123
       ->findOneByName('PsyElement 1')
124
     ;
124
     ;
125
     $tags = $this->getDoctrine()->getRepository('MuzichCoreBundle:Group')
125
     $tags = $this->getDoctrine()->getRepository('MuzichCoreBundle:Group')
126
-      ->getElementsTags($fan_de_psy->getId())      
126
+      ->getElementsTags($fan_de_psy->getId(), $bux->getId())      
127
     ;
127
     ;
128
     
128
     
129
     $ids = array();
129
     $ids = array();

+ 6 - 6
src/Muzich/CoreBundle/Tests/Tag/TagReadTest.php View File

151
     $rtags = array('Electro', 'Hardcore', 'Hardtek', 'Metal');
151
     $rtags = array('Electro', 'Hardcore', 'Hardtek', 'Metal');
152
     
152
     
153
     $tags = $this->getTagsNamesForQuery($this->getDoctrine()->getRepository('MuzichCoreBundle:User')
153
     $tags = $this->getTagsNamesForQuery($this->getDoctrine()->getRepository('MuzichCoreBundle:User')
154
-      ->getElementsTags($bux->getId())      
154
+      ->getElementsTags($bux->getId(), $bux->getId())      
155
     );
155
     );
156
     
156
     
157
     $this->assertEquals($rtags, $tags);
157
     $this->assertEquals($rtags, $tags);
160
     $rtags = array('Beatbox', 'Chanteuse', 'Dubstep', 'Medieval');
160
     $rtags = array('Beatbox', 'Chanteuse', 'Dubstep', 'Medieval');
161
     
161
     
162
     $tags = $this->getTagsNamesForQuery($this->getDoctrine()->getRepository('MuzichCoreBundle:User')
162
     $tags = $this->getTagsNamesForQuery($this->getDoctrine()->getRepository('MuzichCoreBundle:User')
163
-      ->getElementsTags($joelle->getId())      
163
+      ->getElementsTags($joelle->getId(), $joelle->getId())      
164
     );
164
     );
165
     
165
     
166
     $this->assertEquals($rtags, $tags);
166
     $this->assertEquals($rtags, $tags);
169
     $rtags = array('Hardtek', 'Psytrance', 'Tribe');
169
     $rtags = array('Hardtek', 'Psytrance', 'Tribe');
170
     
170
     
171
     $tags = $this->getTagsNamesForQuery($this->getDoctrine()->getRepository('MuzichCoreBundle:User')
171
     $tags = $this->getTagsNamesForQuery($this->getDoctrine()->getRepository('MuzichCoreBundle:User')
172
-      ->getElementsTags($paul->getId())      
172
+      ->getElementsTags($paul->getId(), $paul->getId())      
173
     );
173
     );
174
     
174
     
175
     $this->assertEquals($rtags, $tags);
175
     $this->assertEquals($rtags, $tags);
186
     $rtags = array('Hardtek');
186
     $rtags = array('Hardtek');
187
     
187
     
188
     $tags = $this->getTagsNamesForQuery($this->getDoctrine()->getRepository('MuzichCoreBundle:UsersElementsFavorites')
188
     $tags = $this->getTagsNamesForQuery($this->getDoctrine()->getRepository('MuzichCoreBundle:UsersElementsFavorites')
189
-      ->getTags($bux->getId())          
189
+      ->getTags($bux->getId(), $bux->getId())          
190
     );
190
     );
191
     
191
     
192
     $this->assertEquals($rtags, $tags);
192
     $this->assertEquals($rtags, $tags);
195
     $rtags = null;
195
     $rtags = null;
196
     
196
     
197
     $tags = $this->getTagsNamesForQuery($this->getDoctrine()->getRepository('MuzichCoreBundle:UsersElementsFavorites')
197
     $tags = $this->getTagsNamesForQuery($this->getDoctrine()->getRepository('MuzichCoreBundle:UsersElementsFavorites')
198
-      ->getTags($joelle->getId())           
198
+      ->getTags($joelle->getId(), $joelle->getId())           
199
     );
199
     );
200
     
200
     
201
     $this->assertEquals($rtags, $tags);
201
     $this->assertEquals($rtags, $tags);
204
     $rtags = array('Hardtek', 'Tribe');
204
     $rtags = array('Hardtek', 'Tribe');
205
     
205
     
206
     $tags = $this->getTagsNamesForQuery($this->getDoctrine()->getRepository('MuzichCoreBundle:UsersElementsFavorites')
206
     $tags = $this->getTagsNamesForQuery($this->getDoctrine()->getRepository('MuzichCoreBundle:UsersElementsFavorites')
207
-      ->getTags($paul->getId())          
207
+      ->getTags($paul->getId(), $paul->getId())
208
     );
208
     );
209
     
209
     
210
     $this->assertEquals($rtags, $tags);
210
     $this->assertEquals($rtags, $tags);

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

149
     ));
149
     ));
150
     
150
     
151
     $tags = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersElementsFavorites')
151
     $tags = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersElementsFavorites')
152
-      ->getTags($this->getUserId())      
152
+      ->getTags($this->getUserId(), $this->getUserId())      
153
     ;
153
     ;
154
     
154
     
155
     $tags_id = array();
155
     $tags_id = array();
183
     ));
183
     ));
184
     
184
     
185
     $tags = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersElementsFavorites')
185
     $tags = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersElementsFavorites')
186
-      ->getTags($viewed_user->getId())      
186
+      ->getTags($viewed_user->getId(), $this->getUserId())      
187
     ;
187
     ;
188
     
188
     
189
     $tags_id = array();
189
     $tags_id = array();

+ 2 - 2
src/Muzich/HomeBundle/Controller/ShowController.php View File

27
     ));
27
     ));
28
     
28
     
29
     $tags = $this->getDoctrine()->getRepository('MuzichCoreBundle:User')
29
     $tags = $this->getDoctrine()->getRepository('MuzichCoreBundle:User')
30
-      ->getElementsTags($viewed_user->getId())      
30
+      ->getElementsTags($viewed_user->getId(), $this->getUserId())      
31
     ;
31
     ;
32
     
32
     
33
     $tags_id = array();
33
     $tags_id = array();
71
     }
71
     }
72
     
72
     
73
     $tags = $this->getDoctrine()->getRepository('MuzichCoreBundle:Group')
73
     $tags = $this->getDoctrine()->getRepository('MuzichCoreBundle:Group')
74
-      ->getElementsTags($group->getId())      
74
+      ->getElementsTags($group->getId(), $this->getUserId())      
75
     ;
75
     ;
76
     
76
     
77
     $tags_id = array();
77
     $tags_id = array();