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

Evolution #711: Anonyme: page profil user & user favoris

Bastien Sevajol пре 12 година
родитељ
комит
61be636650

+ 1 - 1
composer.json Прегледај датотеку

26
         "doctrine/doctrine-fixtures-bundle": "dev-master",
26
         "doctrine/doctrine-fixtures-bundle": "dev-master",
27
         "stof/doctrine-extensions-bundle": "dev-master",  
27
         "stof/doctrine-extensions-bundle": "dev-master",  
28
         "gregwar/image-bundle": "dev-master",
28
         "gregwar/image-bundle": "dev-master",
29
-        "cedriclombardot/admingenerator-generator-bundle": "1.0.*@dev",
29
+        "cedriclombardot/admingenerator-generator-bundle": "2.1.*@dev",
30
         "cedriclombardot/twig-generator": "dev-master",
30
         "cedriclombardot/twig-generator": "dev-master",
31
         "white-october/pagerfanta-bundle": "1.0.*@dev",
31
         "white-october/pagerfanta-bundle": "1.0.*@dev",
32
         "pagerfanta/pagerfanta": "1.0.*@dev",
32
         "pagerfanta/pagerfanta": "1.0.*@dev",

+ 35 - 32
composer.lock Прегледај датотеку

1
 {
1
 {
2
-    "hash": "de4530fc22c2b2f2da7b60c62cbf96f6",
2
+    "hash": "dd5c41c30319b0b4e3eff5370c6bedd2",
3
     "packages": [
3
     "packages": [
4
         {
4
         {
5
             "name": "cedriclombardot/admingenerator-generator-bundle",
5
             "name": "cedriclombardot/admingenerator-generator-bundle",
6
-            "version": "dev-master",
6
+            "version": "2.1.x-dev",
7
             "target-dir": "Admingenerator/GeneratorBundle",
7
             "target-dir": "Admingenerator/GeneratorBundle",
8
             "source": {
8
             "source": {
9
                 "type": "git",
9
                 "type": "git",
10
                 "url": "https://github.com/symfony2admingenerator/AdmingeneratorGeneratorBundle.git",
10
                 "url": "https://github.com/symfony2admingenerator/AdmingeneratorGeneratorBundle.git",
11
-                "reference": "6fea0cc8aa814f877c3b1ae535a7addbfb904bc2"
11
+                "reference": "1b2ea73c01a5b3d39ae8dd545e46966b5bb1a1e3"
12
             },
12
             },
13
             "dist": {
13
             "dist": {
14
                 "type": "zip",
14
                 "type": "zip",
15
-                "url": "https://api.github.com/repos/symfony2admingenerator/AdmingeneratorGeneratorBundle/zipball/6fea0cc8aa814f877c3b1ae535a7addbfb904bc2",
16
-                "reference": "6fea0cc8aa814f877c3b1ae535a7addbfb904bc2",
15
+                "url": "https://api.github.com/repos/symfony2admingenerator/AdmingeneratorGeneratorBundle/zipball/1b2ea73c01a5b3d39ae8dd545e46966b5bb1a1e3",
16
+                "reference": "1b2ea73c01a5b3d39ae8dd545e46966b5bb1a1e3",
17
                 "shasum": ""
17
                 "shasum": ""
18
             },
18
             },
19
             "require": {
19
             "require": {
33
                 "avalanche123/imagine-bundle": "Image manipulation using Imagine and Twig Filters",
33
                 "avalanche123/imagine-bundle": "Image manipulation using Imagine and Twig Filters",
34
                 "cedriclombardot/admingenerator-user-bundle": "Help you to overwrite the base layout of FOSUserBundle or others giving a parameter key of the container"
34
                 "cedriclombardot/admingenerator-user-bundle": "Help you to overwrite the base layout of FOSUserBundle or others giving a parameter key of the container"
35
             },
35
             },
36
-            "time": "2013-04-23 06:32:11",
36
+            "time": "2013-04-14 09:22:28",
37
             "type": "symfony-bundle",
37
             "type": "symfony-bundle",
38
             "extra": {
38
             "extra": {
39
                 "branch-alias": {
39
                 "branch-alias": {
167
                 {
167
                 {
168
                     "name": "Johannes Schmitt",
168
                     "name": "Johannes Schmitt",
169
                     "email": "schmittjoh@gmail.com",
169
                     "email": "schmittjoh@gmail.com",
170
-                    "homepage": "https://github.com/schmittjoh",
170
+                    "homepage": "http://jmsyst.com",
171
                     "role": "Developer of wrapped JMSSerializerBundle"
171
                     "role": "Developer of wrapped JMSSerializerBundle"
172
                 }
172
                 }
173
             ],
173
             ],
375
             "source": {
375
             "source": {
376
                 "type": "git",
376
                 "type": "git",
377
                 "url": "https://github.com/doctrine/DoctrineFixturesBundle.git",
377
                 "url": "https://github.com/doctrine/DoctrineFixturesBundle.git",
378
-                "reference": "275540d96599baec19fa3292c4d06c5cd4eefd06"
378
+                "reference": "5696cd636df7cbfaf4d1c45ed2922438968cf890"
379
             },
379
             },
380
             "dist": {
380
             "dist": {
381
                 "type": "zip",
381
                 "type": "zip",
382
-                "url": "https://api.github.com/repos/doctrine/DoctrineFixturesBundle/zipball/275540d96599baec19fa3292c4d06c5cd4eefd06",
383
-                "reference": "275540d96599baec19fa3292c4d06c5cd4eefd06",
382
+                "url": "https://api.github.com/repos/doctrine/DoctrineFixturesBundle/zipball/5696cd636df7cbfaf4d1c45ed2922438968cf890",
383
+                "reference": "5696cd636df7cbfaf4d1c45ed2922438968cf890",
384
                 "shasum": ""
384
                 "shasum": ""
385
             },
385
             },
386
             "require": {
386
             "require": {
387
                 "doctrine/data-fixtures": "*",
387
                 "doctrine/data-fixtures": "*",
388
                 "doctrine/doctrine-bundle": ">=1.0,<2.0",
388
                 "doctrine/doctrine-bundle": ">=1.0,<2.0",
389
                 "php": ">=5.3.2",
389
                 "php": ">=5.3.2",
390
-                "symfony/doctrine-bridge": ">=2.1.0,<2.3-dev"
390
+                "symfony/doctrine-bridge": ">=2.1.0,<2.4-dev"
391
             },
391
             },
392
-            "time": "2013-02-12 11:13:27",
392
+            "time": "2013-04-27 11:57:35",
393
             "type": "symfony-bundle",
393
             "type": "symfony-bundle",
394
             "extra": {
394
             "extra": {
395
                 "branch-alias": {
395
                 "branch-alias": {
686
         },
686
         },
687
         {
687
         {
688
             "name": "jdorn/sql-formatter",
688
             "name": "jdorn/sql-formatter",
689
-            "version": "v1.2.0",
689
+            "version": "v1.2.9",
690
             "source": {
690
             "source": {
691
                 "type": "git",
691
                 "type": "git",
692
-                "url": "git://github.com/jdorn/sql-formatter.git",
693
-                "reference": "v1.2.0"
692
+                "url": "https://github.com/jdorn/sql-formatter.git",
693
+                "reference": "v1.2.9"
694
             },
694
             },
695
             "dist": {
695
             "dist": {
696
                 "type": "zip",
696
                 "type": "zip",
697
-                "url": "https://github.com/jdorn/sql-formatter/archive/v1.2.0.zip",
698
-                "reference": "v1.2.0",
697
+                "url": "https://api.github.com/repos/jdorn/sql-formatter/zipball/v1.2.9",
698
+                "reference": "v1.2.9",
699
                 "shasum": ""
699
                 "shasum": ""
700
             },
700
             },
701
             "require": {
701
             "require": {
702
                 "php": ">=5.2.4"
702
                 "php": ">=5.2.4"
703
             },
703
             },
704
-            "time": "2012-12-22 21:46:50",
704
+            "require-dev": {
705
+                "phpunit/phpunit": "3.7.*"
706
+            },
707
+            "time": "2013-04-26 18:42:52",
705
             "type": "library",
708
             "type": "library",
706
             "extra": {
709
             "extra": {
707
                 "branch-alias": {
710
                 "branch-alias": {
715
             },
718
             },
716
             "notification-url": "https://packagist.org/downloads/",
719
             "notification-url": "https://packagist.org/downloads/",
717
             "license": [
720
             "license": [
718
-                "LGPL"
721
+                "MIT"
719
             ],
722
             ],
720
             "authors": [
723
             "authors": [
721
                 {
724
                 {
765
                 {
768
                 {
766
                     "name": "Johannes M. Schmitt",
769
                     "name": "Johannes M. Schmitt",
767
                     "email": "schmittjoh@gmail.com",
770
                     "email": "schmittjoh@gmail.com",
768
-                    "homepage": "https://github.com/schmittjoh",
771
+                    "homepage": "http://jmsyst.com",
769
                     "role": "Developer of wrapped JMSSerializerBundle"
772
                     "role": "Developer of wrapped JMSSerializerBundle"
770
                 }
773
                 }
771
             ],
774
             ],
866
                 {
869
                 {
867
                     "name": "Johannes M. Schmitt",
870
                     "name": "Johannes M. Schmitt",
868
                     "email": "schmittjoh@gmail.com",
871
                     "email": "schmittjoh@gmail.com",
869
-                    "homepage": "https://github.com/schmittjoh",
872
+                    "homepage": "http://jmsyst.com",
870
                     "role": "Developer of wrapped JMSSerializerBundle"
873
                     "role": "Developer of wrapped JMSSerializerBundle"
871
                 }
874
                 }
872
             ],
875
             ],
909
                 {
912
                 {
910
                     "name": "Johannes M. Schmitt",
913
                     "name": "Johannes M. Schmitt",
911
                     "email": "schmittjoh@gmail.com",
914
                     "email": "schmittjoh@gmail.com",
912
-                    "homepage": "https://github.com/schmittjoh",
915
+                    "homepage": "http://jmsyst.com",
913
                     "role": "Developer of wrapped JMSSerializerBundle"
916
                     "role": "Developer of wrapped JMSSerializerBundle"
914
                 }
917
                 }
915
             ],
918
             ],
972
                 {
975
                 {
973
                     "name": "Johannes M. Schmitt",
976
                     "name": "Johannes M. Schmitt",
974
                     "email": "schmittjoh@gmail.com",
977
                     "email": "schmittjoh@gmail.com",
975
-                    "homepage": "https://github.com/schmittjoh",
978
+                    "homepage": "http://jmsyst.com",
976
                     "role": "Developer of wrapped JMSSerializerBundle"
979
                     "role": "Developer of wrapped JMSSerializerBundle"
977
                 }
980
                 }
978
             ],
981
             ],
1105
             "source": {
1108
             "source": {
1106
                 "type": "git",
1109
                 "type": "git",
1107
                 "url": "https://github.com/kriswallsmith/assetic.git",
1110
                 "url": "https://github.com/kriswallsmith/assetic.git",
1108
-                "reference": "0a55a9ba70bd9250899ad77deceaf8cb9e145371"
1111
+                "reference": "1b17f9a239276f24344f9f7d7be8293f6dca4e19"
1109
             },
1112
             },
1110
             "dist": {
1113
             "dist": {
1111
                 "type": "zip",
1114
                 "type": "zip",
1112
-                "url": "https://api.github.com/repos/kriswallsmith/assetic/zipball/0a55a9ba70bd9250899ad77deceaf8cb9e145371",
1113
-                "reference": "0a55a9ba70bd9250899ad77deceaf8cb9e145371",
1115
+                "url": "https://api.github.com/repos/kriswallsmith/assetic/zipball/1b17f9a239276f24344f9f7d7be8293f6dca4e19",
1116
+                "reference": "1b17f9a239276f24344f9f7d7be8293f6dca4e19",
1114
                 "shasum": ""
1117
                 "shasum": ""
1115
             },
1118
             },
1116
             "require": {
1119
             "require": {
1136
                 "ptachoire/cssembed": "Assetic provides the integration with phpcssembed to embed data uris",
1139
                 "ptachoire/cssembed": "Assetic provides the integration with phpcssembed to embed data uris",
1137
                 "twig/twig": "Assetic provides the integration with the Twig templating engine"
1140
                 "twig/twig": "Assetic provides the integration with the Twig templating engine"
1138
             },
1141
             },
1139
-            "time": "2013-04-02 21:36:28",
1142
+            "time": "2013-04-27 14:32:20",
1140
             "type": "library",
1143
             "type": "library",
1141
             "extra": {
1144
             "extra": {
1142
                 "branch-alias": {
1145
                 "branch-alias": {
1483
             "source": {
1486
             "source": {
1484
                 "type": "git",
1487
                 "type": "git",
1485
                 "url": "https://github.com/sonata-project/SonataAdminBundle.git",
1488
                 "url": "https://github.com/sonata-project/SonataAdminBundle.git",
1486
-                "reference": "041174991a1d3c6725e1603c389b5767261972c7"
1489
+                "reference": "c611614f23d5d42257747ae81bcc36df86216bae"
1487
             },
1490
             },
1488
             "dist": {
1491
             "dist": {
1489
                 "type": "zip",
1492
                 "type": "zip",
1490
-                "url": "https://api.github.com/repos/sonata-project/SonataAdminBundle/zipball/041174991a1d3c6725e1603c389b5767261972c7",
1491
-                "reference": "041174991a1d3c6725e1603c389b5767261972c7",
1493
+                "url": "https://api.github.com/repos/sonata-project/SonataAdminBundle/zipball/c611614f23d5d42257747ae81bcc36df86216bae",
1494
+                "reference": "c611614f23d5d42257747ae81bcc36df86216bae",
1492
                 "shasum": ""
1495
                 "shasum": ""
1493
             },
1496
             },
1494
             "require": {
1497
             "require": {
1515
                 "sonata-project/doctrine-orm-admin-bundle": "2.1.*@dev",
1518
                 "sonata-project/doctrine-orm-admin-bundle": "2.1.*@dev",
1516
                 "sonata-project/intl-bundle": "2.1.*"
1519
                 "sonata-project/intl-bundle": "2.1.*"
1517
             },
1520
             },
1518
-            "time": "2013-04-11 21:38:12",
1521
+            "time": "2013-05-03 19:57:10",
1519
             "type": "symfony-bundle",
1522
             "type": "symfony-bundle",
1520
             "extra": {
1523
             "extra": {
1521
                 "branch-alias": {
1524
                 "branch-alias": {
1540
                 },
1543
                 },
1541
                 {
1544
                 {
1542
                     "name": "Sonata Community",
1545
                     "name": "Sonata Community",
1543
-                    "homepage": "https://github.com/sonata-project/SonataDoctrineMongoDBAdminBundle/contributors"
1546
+                    "homepage": "https://github.com/sonata-project/SonataAdminBundle/contributors"
1544
                 }
1547
                 }
1545
             ],
1548
             ],
1546
             "description": "Symfony SonataAdminBundle",
1549
             "description": "Symfony SonataAdminBundle",

+ 10 - 2
src/Muzich/CoreBundle/Repository/GroupRepository.php Прегледај датотеку

79
    */
79
    */
80
   public function getElementsTags($group_id, $current_user_id)
80
   public function getElementsTags($group_id, $current_user_id)
81
   {
81
   {
82
+    $parameters = array('gid' => $group_id);
83
+    $current_user_sql = '';
84
+    if ($current_user_id)
85
+    {
86
+      $parameters['uidt'] = '%"'.$current_user_id.'"%';
87
+      $current_user_sql = 'OR t.privateids LIKE :uidt';
88
+    }
89
+    
82
     return $this->getEntityManager()
90
     return $this->getEntityManager()
83
       ->createQuery('
91
       ->createQuery('
84
         SELECT t FROM MuzichCoreBundle:Tag t
92
         SELECT t FROM MuzichCoreBundle:Tag t
85
         LEFT JOIN t.elements e
93
         LEFT JOIN t.elements e
86
         WHERE e.group = :gid
94
         WHERE e.group = :gid
87
         AND (t.tomoderate = \'FALSE\' OR t.tomoderate IS NULL
95
         AND (t.tomoderate = \'FALSE\' OR t.tomoderate IS NULL
88
-          OR t.privateids LIKE :uidt)
96
+          '.$current_user_sql.')
89
         ORDER BY t.name ASC'
97
         ORDER BY t.name ASC'
90
       )
98
       )
91
-      ->setParameters(array('gid' => $group_id, 'uidt' => '%"'.$current_user_id.'"%'))
99
+      ->setParameters($parameters)
92
       ->getResult()
100
       ->getResult()
93
     ;
101
     ;
94
   }
102
   }

+ 10 - 2
src/Muzich/CoreBundle/Repository/UserRepository.php Прегледај датотеку

194
    */
194
    */
195
   public function getElementsTags($user_id, $current_user_id)
195
   public function getElementsTags($user_id, $current_user_id)
196
   {
196
   {
197
+    $parameters = array('uid' => $user_id);
198
+    $current_user_sql = '';
199
+    if ($current_user_id)
200
+    {
201
+      $parameters['uidt'] = '%"'.$current_user_id.'"%';
202
+      $current_user_sql = 'OR t.privateids LIKE :uidt';
203
+    }
204
+    
197
     return $this->getEntityManager()
205
     return $this->getEntityManager()
198
       ->createQuery('
206
       ->createQuery('
199
         SELECT t FROM MuzichCoreBundle:Tag t
207
         SELECT t FROM MuzichCoreBundle:Tag t
200
         LEFT JOIN t.elements e
208
         LEFT JOIN t.elements e
201
         WHERE e.owner = :uid
209
         WHERE e.owner = :uid
202
         AND (t.tomoderate = \'FALSE\' OR t.tomoderate IS NULL
210
         AND (t.tomoderate = \'FALSE\' OR t.tomoderate IS NULL
203
-          OR t.privateids LIKE :uidt)
211
+          '.$current_user_sql.')
204
         ORDER BY t.name ASC'
212
         ORDER BY t.name ASC'
205
       )
213
       )
206
-      ->setParameters(array('uid' => $user_id, 'uidt' => '%"'.$current_user_id.'"%'))
214
+      ->setParameters($parameters)
207
       ->getResult()
215
       ->getResult()
208
     ;
216
     ;
209
   }
217
   }

+ 4 - 0
src/Muzich/CoreBundle/Resources/config/security.yml Прегледај датотеку

96
         - { path: ^/(?:fr|en)$, role: IS_AUTHENTICATED_ANONYMOUSLY }
96
         - { path: ^/(?:fr|en)$, role: IS_AUTHENTICATED_ANONYMOUSLY }
97
         - { path: ^/(?:fr|en)/$, role: IS_AUTHENTICATED_ANONYMOUSLY }
97
         - { path: ^/(?:fr|en)/$, role: IS_AUTHENTICATED_ANONYMOUSLY }
98
         - { path: ^/$, role: IS_AUTHENTICATED_ANONYMOUSLY }
98
         - { path: ^/$, role: IS_AUTHENTICATED_ANONYMOUSLY }
99
+        - { path: ^//user, role: IS_AUTHENTICATED_ANONYMOUSLY }
100
+        - { path: ^/(?:fr|en)/user, role: IS_AUTHENTICATED_ANONYMOUSLY }
101
+        - { path: ^//group, role: IS_AUTHENTICATED_ANONYMOUSLY }
102
+        - { path: ^/(?:fr|en)/group, role: IS_AUTHENTICATED_ANONYMOUSLY }
99
                                         
103
                                         
100
         - { path: ^/, roles: ROLE_USER }
104
         - { path: ^/, roles: ROLE_USER }
101
         
105
         

+ 5 - 10
src/Muzich/FavoriteBundle/Controller/FavoriteController.php Прегледај датотеку

212
     ));
212
     ));
213
     
213
     
214
     $tags = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersElementsFavorites')
214
     $tags = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersElementsFavorites')
215
-      ->getTags($viewed_user->getId(), $this->getUserId())      
215
+      ->getTags($viewed_user->getId(), $this->getUserId(true))      
216
     ;
216
     ;
217
     
217
     
218
     $tags_id = array();
218
     $tags_id = array();
226
       'tags_id_json'  => json_encode($tags_id),
226
       'tags_id_json'  => json_encode($tags_id),
227
       'user'          => $this->getUser(),
227
       'user'          => $this->getUser(),
228
       'viewed_user'   => $viewed_user,
228
       'viewed_user'   => $viewed_user,
229
-      'elements'      => $search_object->getElements($this->getDoctrine(), $this->getUserId())
229
+      'elements'      => $search_object->getElements($this->getDoctrine(), $this->getUserId(true))
230
     );
230
     );
231
   }
231
   }
232
   
232
   
233
   public function getElementsAction($user_id, $tags_ids_json, $id_limit = null)
233
   public function getElementsAction($user_id, $tags_ids_json, $id_limit = null)
234
   {
234
   {
235
-    if (($response = $this->mustBeConnected()))
236
-    {
237
-      return $response;
238
-    }
239
-    
240
     $autoplay_context = 'favorite_user';
235
     $autoplay_context = 'favorite_user';
241
-    if ($user_id == $this->getUserId())
236
+    if ($user_id == $this->getUserId(true))
242
     {
237
     {
243
       $autoplay_context = 'favorite_my';
238
       $autoplay_context = 'favorite_my';
244
     }
239
     }
272
     );
267
     );
273
     
268
     
274
     $viewed_user = $this->getUser();
269
     $viewed_user = $this->getUser();
275
-    if ($user_id != $this->getUserId())
270
+    if ($user_id != $this->getUserId(true))
276
     {
271
     {
277
       $viewed_user = $this->getDoctrine()->getEntityManager()->getRepository('MuzichCoreBundle:User')
272
       $viewed_user = $this->getDoctrine()->getEntityManager()->getRepository('MuzichCoreBundle:User')
278
         ->findOneById($user_id, array())->getSingleResult();
273
         ->findOneById($user_id, array())->getSingleResult();
279
     }
274
     }
280
     
275
     
281
-    $elements = $search_object->getElements($this->getDoctrine(), $this->getUserId());
276
+    $elements = $search_object->getElements($this->getDoctrine(), $this->getUserId(true));
282
     $count = count($elements);
277
     $count = count($elements);
283
     $html = '';
278
     $html = '';
284
     if ($count)
279
     if ($count)

+ 13 - 18
src/Muzich/HomeBundle/Controller/ShowController.php Прегледај датотеку

29
     ));
29
     ));
30
     
30
     
31
     $tags = $this->getDoctrine()->getRepository('MuzichCoreBundle:User')
31
     $tags = $this->getDoctrine()->getRepository('MuzichCoreBundle:User')
32
-      ->getElementsTags($viewed_user->getId(), $this->getUserId())      
32
+      ->getElementsTags($viewed_user->getId(), $this->getUserId(true))      
33
     ;
33
     ;
34
     
34
     
35
     // Organisation des tags en fonction de leurs utilisation
35
     // Organisation des tags en fonction de leurs utilisation
63
       'tags'            => $tags,
63
       'tags'            => $tags,
64
       'tags_id_json'    => json_encode($tags_id),
64
       'tags_id_json'    => json_encode($tags_id),
65
       'viewed_user'     => $viewed_user,
65
       'viewed_user'     => $viewed_user,
66
-      'elements'        => $search_object->getElements($this->getDoctrine(), $this->getUserId()),
67
-      'following'       => $this->getUser()->isFollowingUserByQuery($this->getDoctrine(), $viewed_user->getId()),
66
+      'elements'        => $search_object->getElements($this->getDoctrine(), $this->getUserId(true)),
67
+      'following'       => (!$this->isVisitor())?$this->getUser()->isFollowingUserByQuery($this->getDoctrine(), $viewed_user->getId()):false,
68
       'user'            => $this->getUser(),
68
       'user'            => $this->getUser(),
69
       'more_count'      => ($count)?$count+$this->container->getParameter('search_default_count'):$this->container->getParameter('search_default_count')*2,
69
       'more_count'      => ($count)?$count+$this->container->getParameter('search_default_count'):$this->container->getParameter('search_default_count')*2,
70
       'more_route'      => 'show_user_more',
70
       'more_route'      => 'show_user_more',
71
-      'topmenu_active'  => ($viewed_user->getId() == $this->getUserId()) ? 'myfeeds' : 'public',
71
+      'topmenu_active'  => ($viewed_user->getId() == $this->getUserId(true)) ? 'myfeeds' : 'public',
72
       'count_owned'     => count($element_ids_owned),
72
       'count_owned'     => count($element_ids_owned),
73
       'count_favorited' => $count_favorited,
73
       'count_favorited' => $count_favorited,
74
       'count_favorited_users' => $count_favorited_users,
74
       'count_favorited_users' => $count_favorited_users,
75
       'count_followers' => $count_followers,
75
       'count_followers' => $count_followers,
76
-      'add_form'        => ($this->getUserId() == $viewed_user->getId())?$this->getAddForm()->createView():null,
76
+      'add_form'        => ($this->getUserId(true) == $viewed_user->getId())?$this->getAddForm()->createView():null,
77
       'add_form_name'   => 'add'
77
       'add_form_name'   => 'add'
78
     );
78
     );
79
   }
79
   }
93
       'count'     => ($count)?$count:$this->container->getParameter('search_default_count')
93
       'count'     => ($count)?$count:$this->container->getParameter('search_default_count')
94
     ));
94
     ));
95
     
95
     
96
-    ($group->getOwner()->getId() == $this->getUserId()) ? $his = true : $his = false;
96
+    ($group->getOwner()->getId() == $this->getUserId(true)) ? $his = true : $his = false;
97
     if ($his || $group->getOpen())
97
     if ($his || $group->getOpen())
98
     {      
98
     {      
99
       $add_form = $this->getAddForm();
99
       $add_form = $this->getAddForm();
100
     }
100
     }
101
     
101
     
102
     $tags = $this->getDoctrine()->getRepository('MuzichCoreBundle:Group')
102
     $tags = $this->getDoctrine()->getRepository('MuzichCoreBundle:Group')
103
-      ->getElementsTags($group->getId(), $this->getUserId())      
103
+      ->getElementsTags($group->getId(), $this->getUserId(true))      
104
     ;
104
     ;
105
     
105
     
106
     $tags_id = array();
106
     $tags_id = array();
129
       'tags'          => $tags,
129
       'tags'          => $tags,
130
       'tags_id_json'  => json_encode($tags_id),
130
       'tags_id_json'  => json_encode($tags_id),
131
       'group'         => $group,
131
       'group'         => $group,
132
-      'his_group'     => ($group->getOwner()->getId() == $this->getUserId()) ? true : false,
133
-      'elements'      => $search_object->getElements($this->getDoctrine(), $this->getUserId()),
134
-      'following'     => $this->getUser()->isFollowingGroupByQuery($this->getDoctrine(), $group->getId()),
132
+      'his_group'     => ($group->getOwner()->getId() == $this->getUserId(true)) ? true : false,
133
+      'elements'      => $search_object->getElements($this->getDoctrine(), $this->getUserId(true)),
134
+      'following'     => (!$this->isVisitor())?$this->getUser()->isFollowingGroupByQuery($this->getDoctrine(), $group->getId()):false,
135
       'user'          => $this->getUser(),
135
       'user'          => $this->getUser(),
136
       'add_form'      => (isset($add_form)) ? $add_form->createView() : null,
136
       'add_form'      => (isset($add_form)) ? $add_form->createView() : null,
137
       'add_form_name' => (isset($add_form)) ? 'add' : null,
137
       'add_form_name' => (isset($add_form)) ? 'add' : null,
145
   }
145
   }
146
   
146
   
147
   public function getElementsAction($type, $object_id, $tags_ids_json, $id_limit = null)
147
   public function getElementsAction($type, $object_id, $tags_ids_json, $id_limit = null)
148
-  {
149
-    if (($response = $this->mustBeConnected()))
150
-    {
151
-      return $response;
152
-    }
153
-    
148
+  { 
154
     if ($type != 'user' && $type != 'group')
149
     if ($type != 'user' && $type != 'group')
155
     {
150
     {
156
       throw new \Exception("Wrong Type.");
151
       throw new \Exception("Wrong Type.");
157
     }
152
     }
158
     
153
     
159
     $viewed_user = null;
154
     $viewed_user = null;
160
-    if ($type == 'user' && $object_id == $this->getUserId())
155
+    if ($type == 'user' && $object_id == $this->getUserId(true))
161
     {
156
     {
162
       $object = $viewed_user = $this->getUser();
157
       $object = $viewed_user = $this->getUser();
163
     }
158
     }
199
       'elements'
194
       'elements'
200
     );
195
     );
201
     
196
     
202
-    $elements = $search_object->getElements($this->getDoctrine(), $this->getUserId());
197
+    $elements = $search_object->getElements($this->getDoctrine(), $this->getUserId(true));
203
     $count = count($elements);
198
     $count = count($elements);
204
     $html = '';
199
     $html = '';
205
     if ($count)
200
     if ($count)

+ 10 - 8
src/Muzich/HomeBundle/Resources/views/Show/showGroup.html.twig Прегледај датотеку

19
         </a>
19
         </a>
20
       {% endif %}
20
       {% endif %}
21
       
21
       
22
-      <a href="{{ path('follow', { 'type': 'group', 'id': group.id, 'token': user.personalHash(group.id) }) }}" 
23
-         class="follow_link button darkbutton {% if following %}following{% else %}notfollowing{% endif %}">
24
-        {% if following %}
25
-          {{ 'group.following'|trans({}, 'groups') }}
26
-        {% else %}
27
-          {{ 'group.follow'|trans({}, 'groups') }}
28
-        {% endif %}
29
-      </a>
22
+      {% if app.user %}
23
+        <a href="{{ path('follow', { 'type': 'group', 'id': group.id, 'token': app.user.personalHash(group.id) }) }}" 
24
+           class="follow_link button darkbutton {% if following %}following{% else %}notfollowing{% endif %}">
25
+          {% if following %}
26
+            {{ 'group.following'|trans({}, 'groups') }}
27
+          {% else %}
28
+            {{ 'group.follow'|trans({}, 'groups') }}
29
+          {% endif %}
30
+        </a>
31
+      {% endif %}
30
       
32
       
31
     </div>
33
     </div>
32
       
34
       

+ 21 - 15
src/Muzich/HomeBundle/Resources/views/Show/showUser.html.twig Прегледај датотеку

7
 
7
 
8
   <div class="top_tools">
8
   <div class="top_tools">
9
     
9
     
10
-    {% if app.user.id == viewed_user.id %}
11
-      {% include 'MuzichCoreBundle:Component:element_add_buttons_topright.html.twig' %}
12
-    {% endif %}
10
+    {% if app.user %}
11
+      {% if app.user.id == viewed_user.id %}
12
+        {% include 'MuzichCoreBundle:Component:element_add_buttons_topright.html.twig' %}
13
+      {% endif %}
14
+    {% endif  %}
13
     
15
     
14
     <div class="show_options">
16
     <div class="show_options">
15
             
17
             
16
-      {% if app.user.id != viewed_user.id %}
17
-        <a href="{{ path('follow', { 'type': 'user', 'id': viewed_user.id, 'token': user.personalHash(viewed_user.id) }) }}" 
18
-           class="follow_link button darkbutton {% if following %}following{% else %}notfollowing{% endif %}" >
19
-          {% if following %}
20
-            {{ 'user.following'|trans({}, 'users') }}
21
-          {% else %}
22
-            {{ 'user.follow'|trans({}, 'users') }}
23
-          {% endif %}
24
-        </a>
18
+      {% if app.user %}
19
+        {% if app.user.id != viewed_user.id %}
20
+          <a href="{{ path('follow', { 'type': 'user', 'id': viewed_user.id, 'token': user.personalHash(viewed_user.id) }) }}" 
21
+             class="follow_link button darkbutton {% if following %}following{% else %}notfollowing{% endif %}" >
22
+            {% if following %}
23
+              {{ 'user.following'|trans({}, 'users') }}
24
+            {% else %}
25
+              {{ 'user.follow'|trans({}, 'users') }}
26
+            {% endif %}
27
+          </a>
28
+        {% endif %}
25
       {% endif %}
29
       {% endif %}
26
       
30
       
27
       <a class="button darkbutton" href="{{ path('favorite_user_list', {'slug' : viewed_user.slug}) }}" >
31
       <a class="button darkbutton" href="{{ path('favorite_user_list', {'slug' : viewed_user.slug}) }}" >
32
     
36
     
33
     <h1>{{ 'user.show.title'|trans({'%name%' : viewed_user.name}, 'users') }}</h1>
37
     <h1>{{ 'user.show.title'|trans({'%name%' : viewed_user.name}, 'users') }}</h1>
34
   
38
   
35
-    {% if app.user.id == viewed_user.id %}
36
-      {% include 'MuzichCoreBundle:Component:element_add_box.html.twig'  %}
37
-    {% endif %}
39
+    {% if app.user %}
40
+      {% if app.user.id == viewed_user.id %}
41
+        {% include 'MuzichCoreBundle:Component:element_add_box.html.twig'  %}
42
+      {% endif %}
43
+    {% endif  %}
38
     
44
     
39
     <div class="reputation">
45
     <div class="reputation">
40
       
46