Browse Source

bug fix: Création d'un groupe (tags en json pas décodés) et redirection après validation d'un element sur la page showGroup

bastien 13 years ago
parent
commit
525bccf8c4

+ 43 - 14
src/Muzich/CoreBundle/Controller/CoreController.php View File

@@ -210,20 +210,49 @@ class CoreController extends Controller
210 210
       else
211 211
       {
212 212
 
213
-        $search_object = $this->getElementSearcher();
214
-        $search_form = $this->getSearchForm($search_object);
215
-        $add_form = $this->getAddForm();
216
-
217
-        return $this->render('MuzichHomeBundle:Home:index.html.twig', array(
218
-          'search_tags_id'   => $search_object->getTags(),
219
-          'user'             => $this->getUser(),
220
-          'add_form'         => $add_form->createView(),
221
-          'add_form_name'    => $add_form->getName(),
222
-          'search_form'      => $search_form->createView(),
223
-          'search_form_name' => $search_form->getName(),
224
-          'elements'         => $search_object->getElements($this->getDoctrine(), $this->getUserId()),
225
-          'more_count'       => $this->container->getParameter('search_default_count')*2
226
-        ));
213
+        if (!$group_slug)
214
+        {
215
+          $search_object = $this->getElementSearcher();
216
+          $search_form = $this->getSearchForm($search_object);
217
+          $add_form = $form;
218
+
219
+          return $this->render('MuzichHomeBundle:Home:index.html.twig', array(
220
+            'search_tags_id'   => $search_object->getTags(),
221
+            'user'             => $this->getUser(),
222
+            'add_form'         => $add_form->createView(),
223
+            'add_form_name'    => $add_form->getName(),
224
+            'search_form'      => $search_form->createView(),
225
+            'search_form_name' => $search_form->getName(),
226
+            'elements'         => $search_object->getElements($this->getDoctrine(), $this->getUserId()),
227
+            'more_count'       => $this->container->getParameter('search_default_count')*2
228
+          ));
229
+        }
230
+        else
231
+        {
232
+          $group = $this->findGroupWithSlug($group_slug);
233
+        
234
+          $search_object = $this->createSearchObject(array(
235
+            'group_id'  => $group->getId()
236
+          ));
237
+
238
+          ($group->getOwner()->getId() == $this->getUserId()) ? $his = true : $his = false;
239
+          if ($his || $group->getOpen())
240
+          {      
241
+            $add_form = $form;
242
+          }
243
+
244
+          return $this->render('MuzichHomeBundle:Show:showGroup.html.twig', array(
245
+            'group'         => $group,
246
+            'his_group'     => ($group->getOwner()->getId() == $this->getUserId()) ? true : false,
247
+            'elements'      => $search_object->getElements($this->getDoctrine(), $this->getUserId()),
248
+            'following'     => $this->getUser()->isFollowingGroupByQuery($this->getDoctrine(), $group->getId()),
249
+            'user'          => $this->getUser(),
250
+            'add_form'      => (isset($add_form)) ? $add_form->createView() : null,
251
+            'add_form_name' => (isset($add_form)) ? $add_form->getName() : null,
252
+            'more_count'    => null,
253
+            'more_route'    => 'show_group_more'
254
+          ));
255
+        }
227 256
 
228 257
       }
229 258
 

+ 1 - 1
src/Muzich/GroupBundle/Controller/DefaultController.php View File

@@ -75,7 +75,7 @@ class DefaultController extends Controller
75 75
     if ($form_new->isValid())
76 76
     {
77 77
       $factory = new GroupManager($new_group, $em, $this->container);
78
-      $factory->proceedTags($new_group->getTags());
78
+      $factory->proceedTags(json_decode($new_group->getTags()));
79 79
       
80 80
       $em->persist($new_group);
81 81
       $em->flush();

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

@@ -57,14 +57,15 @@ class ShowController extends Controller
57 57
     }
58 58
     
59 59
     return array(
60
-      'group'     => $group,
61
-      'his_group' => ($group->getOwner()->getId() == $this->getUserId()) ? true : false,
62
-      'elements'  => $search_object->getElements($this->getDoctrine(), $this->getUserId()),
63
-      'following' => $this->getUser()->isFollowingGroupByQuery($this->getDoctrine(), $group->getId()),
64
-      'user'      => $this->getUser(),
65
-      'add_form'  => (isset($add_form)) ? $add_form->createView() : null,
66
-      'more_count'=> ($count)?$count+$this->container->getParameter('search_default_count'):$this->container->getParameter('search_default_count')*2,
67
-      'more_route'=> 'show_group_more'
60
+      'group'         => $group,
61
+      'his_group'     => ($group->getOwner()->getId() == $this->getUserId()) ? true : false,
62
+      'elements'      => $search_object->getElements($this->getDoctrine(), $this->getUserId()),
63
+      'following'     => $this->getUser()->isFollowingGroupByQuery($this->getDoctrine(), $group->getId()),
64
+      'user'          => $this->getUser(),
65
+      'add_form'      => (isset($add_form)) ? $add_form->createView() : null,
66
+      'add_form_name' => (isset($add_form)) ? $add_form->getName() : null,
67
+      'more_count'    => ($count)?$count+$this->container->getParameter('search_default_count'):$this->container->getParameter('search_default_count')*2,
68
+      'more_route'    => 'show_group_more'
68 69
     );
69 70
   }
70 71
   

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

@@ -29,7 +29,7 @@
29 29
   
30 30
     <form action="{{ path('element_add', {'group_slug' : group.slug}) }}" method="post" {{ form_enctype(add_form) }}>
31 31
 
32
-      {% include "MuzichCoreBundle:Element:form.add.html.twig" with { 'form': add_form } %}
32
+      {% include "MuzichCoreBundle:Element:form.add.html.twig" with { 'form': add_form, 'form_name': add_form_name } %}
33 33
 
34 34
       <p>
35 35
         <i>