Browse Source

Merge branch 'feature/viewprofile' into unstable

bastien 13 years ago
parent
commit
e690b620ce

+ 17 - 12
src/Muzich/CoreBundle/Controller/CoreController.php View File

3
 namespace Muzich\CoreBundle\Controller;
3
 namespace Muzich\CoreBundle\Controller;
4
 
4
 
5
 use Muzich\CoreBundle\lib\Controller;
5
 use Muzich\CoreBundle\lib\Controller;
6
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
6
+//use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
7
 use Muzich\CoreBundle\Entity\FollowUser;
7
 use Muzich\CoreBundle\Entity\FollowUser;
8
-use Doctrine\ORM\Query;
8
+use Muzich\CoreBundle\Entity\FollowGroup;
9
+//use Doctrine\ORM\Query;
9
 
10
 
10
 class CoreController extends Controller
11
 class CoreController extends Controller
11
 {
12
 {
26
     }
27
     }
27
     
28
     
28
     $em = $this->getDoctrine()->getEntityManager();
29
     $em = $this->getDoctrine()->getEntityManager();
29
-    $FollowUser = $em
30
+    $Follow = $em
30
       ->getRepository('MuzichCoreBundle:Follow' . ucfirst($type))
31
       ->getRepository('MuzichCoreBundle:Follow' . ucfirst($type))
31
       ->findOneBy(
32
       ->findOneBy(
32
         array(
33
         array(
36
       )
37
       )
37
     ;
38
     ;
38
     
39
     
39
-    if ($FollowUser)
40
+    if ($Follow)
40
     {
41
     {
41
       // L'utilisateur suis déjà, on doit détruire l'entité
42
       // L'utilisateur suis déjà, on doit détruire l'entité
42
-      $em->remove($FollowUser);
43
+      $em->remove($Follow);
43
       $em->flush();
44
       $em->flush();
44
     }
45
     }
45
     else
46
     else
46
     {
47
     {
47
-      $followed_user = $em->getRepository('MuzichCoreBundle:User')->find($id);
48
+      $followed = $em->getRepository('MuzichCoreBundle:'.ucfirst($type))->find($id);
48
 
49
 
49
-      if (!$followed_user) {
50
-          throw $this->createNotFoundException('No user found for id '.$id);
50
+      if (!$followed) {
51
+          throw $this->createNotFoundException('No '.$type.' found for id '.$id);
51
       }
52
       }
52
       
53
       
53
-      $FollowUser = new FollowUser();
54
-      $FollowUser->setFollowed($followed_user);
55
-      $FollowUser->setFollower($user);
56
       
54
       
57
-      $em->persist($FollowUser);
55
+      if ($type == 'user') { $Follow = new FollowUser(); }
56
+      else { $Follow = new FollowGroup(); }
57
+      $Follow->setFollower($user);
58
+      if ($type == 'user') { $Follow->setFollowed($followed); }
59
+      else { $Follow->setGroup($followed); }
60
+      
61
+      
62
+      $em->persist($Follow);
58
       $em->flush();
63
       $em->flush();
59
     }
64
     }
60
     
65
     

+ 5 - 7
src/Muzich/HomeBundle/Resources/views/Show/showGroup.html.twig View File

4
 
4
 
5
 {% block content %}
5
 {% block content %}
6
 
6
 
7
-  {% if following %}
8
-    <a href="" class="follow_link following" >
7
+  <a href="{{ path('follow', { 'type': 'group', 'id': group.id, 'token': user.personalHash }) }}" class="follow_link following" >
8
+    {% if following %}
9
       Ne plus suivre
9
       Ne plus suivre
10
-    </a>
11
-  {% else %}
12
-    <a href="" class="follow_link notfollowing" >
10
+    {% else %}
13
       Suivre
11
       Suivre
14
-    </a>
15
-  {% endif %}
12
+    {% endif %}
13
+  </a>
16
     
14
     
17
   <h2>{{ group.name }}</h2>
15
   <h2>{{ group.name }}</h2>
18
   
16