소스 검색

home: formulaire d'ajout: la saisie du groupe ne liste que les groupes possédés.

bastien 12 년 전
부모
커밋
95017a6878
2개의 변경된 파일19개의 추가작업 그리고 1개의 파일을 삭제
  1. 15 0
      src/Muzich/CoreBundle/Entity/User.php
  2. 4 1
      src/Muzich/HomeBundle/Controller/HomeController.php

+ 15 - 0
src/Muzich/CoreBundle/Entity/User.php 파일 보기

@@ -260,6 +260,21 @@ class User extends BaseUser
260 260
   {
261 261
     return $this->groups_owned;
262 262
   }
263
+
264
+  /**
265
+   * Get groups in array (id => name)
266
+   *
267
+   * @return Doctrine\Common\Collections\Collection 
268
+   */
269
+  public function getGroupsOwnedArray()
270
+  {
271
+    $groups = array();
272
+    foreach ($this->groups_owned as $group)
273
+    {
274
+      $groups[$group->getId()] = $group->getName();
275
+    }
276
+    return $groups;
277
+  }
263 278
   
264 279
   public function getSlug()
265 280
   {

+ 4 - 1
src/Muzich/HomeBundle/Controller/HomeController.php 파일 보기

@@ -21,6 +21,9 @@ class HomeController extends Controller
21 21
   public function indexAction()
22 22
   {
23 23
     $search_object = $this->getElementSearcher();
24
+    $user = $this->getUser(true, array('join' => array(
25
+      'groups_owned'
26
+    )), true);
24 27
     
25 28
     $search_form = $this->createForm(
26 29
       new ElementSearchForm(), 
@@ -35,7 +38,7 @@ class HomeController extends Controller
35 38
       array(),
36 39
       array(
37 40
         'tags' => $tags,
38
-        'groups' => $this->getGroupsArray(),
41
+        'groups' => $user->getGroupsOwnedArray(),
39 42
       )
40 43
     );
41 44