Bladeren bron

Evolution #738: Playlist

Bastien Sevajol 11 jaren geleden
bovenliggende
commit
c79c2c1509

+ 74 - 73
composer.lock Bestand weergeven

@@ -8,12 +8,12 @@
8 8
             "source": {
9 9
                 "type": "git",
10 10
                 "url": "https://github.com/symfony2admingenerator/AdmingeneratorGeneratorBundle.git",
11
-                "reference": "294adb5a1766445e2f2fd3f28c28279084c38435"
11
+                "reference": "e9372a26ff8e84d20d37657aa0e9ea6d6d3d9387"
12 12
             },
13 13
             "dist": {
14 14
                 "type": "zip",
15
-                "url": "https://api.github.com/repos/symfony2admingenerator/AdmingeneratorGeneratorBundle/zipball/294adb5a1766445e2f2fd3f28c28279084c38435",
16
-                "reference": "294adb5a1766445e2f2fd3f28c28279084c38435",
15
+                "url": "https://api.github.com/repos/symfony2admingenerator/AdmingeneratorGeneratorBundle/zipball/e9372a26ff8e84d20d37657aa0e9ea6d6d3d9387",
16
+                "reference": "e9372a26ff8e84d20d37657aa0e9ea6d6d3d9387",
17 17
                 "shasum": ""
18 18
             },
19 19
             "require": {
@@ -33,7 +33,7 @@
33 33
                 "avalanche123/imagine-bundle": "Image manipulation using Imagine and Twig Filters",
34 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-05-14 12:00:41",
36
+            "time": "2013-06-01 07:47:44",
37 37
             "type": "symfony-bundle",
38 38
             "extra": {
39 39
                 "branch-alias": {
@@ -546,27 +546,27 @@
546 546
             "source": {
547 547
                 "type": "git",
548 548
                 "url": "https://github.com/FriendsOfSymfony/FOSFacebookBundle.git",
549
-                "reference": "9c93669fd8f93941602d348daa58273c29be229f"
549
+                "reference": "7baeffd6b998a9e365e36ae2ff32675b32c84170"
550 550
             },
551 551
             "dist": {
552 552
                 "type": "zip",
553
-                "url": "https://api.github.com/repos/FriendsOfSymfony/FOSFacebookBundle/zipball/9c93669fd8f93941602d348daa58273c29be229f",
554
-                "reference": "9c93669fd8f93941602d348daa58273c29be229f",
553
+                "url": "https://api.github.com/repos/FriendsOfSymfony/FOSFacebookBundle/zipball/7baeffd6b998a9e365e36ae2ff32675b32c84170",
554
+                "reference": "7baeffd6b998a9e365e36ae2ff32675b32c84170",
555 555
                 "shasum": ""
556 556
             },
557 557
             "require": {
558 558
                 "facebook/php-sdk": "3.2.*",
559 559
                 "php": ">=5.3.2",
560
-                "symfony/http-foundation": ">=2.1,<2.3",
561
-                "symfony/security": ">=2.1,<2.3"
560
+                "symfony/http-foundation": ">=2.1,<2.4",
561
+                "symfony/security": ">=2.1,<2.4"
562 562
             },
563 563
             "require-dev": {
564 564
                 "phpunit/phpunit": "3.7.*",
565
-                "symfony/framework-bundle": ">=2.1,<2.3",
566
-                "symfony/security-bundle": ">=2.1,<2.3",
567
-                "symfony/twig-bundle": ">=2.1,<2.3"
565
+                "symfony/framework-bundle": ">=2.1,<2.4",
566
+                "symfony/security-bundle": ">=2.1,<2.4",
567
+                "symfony/twig-bundle": ">=2.1,<2.4"
568 568
             },
569
-            "time": "2013-05-14 18:06:07",
569
+            "time": "2013-06-05 01:23:11",
570 570
             "type": "symfony-bundle",
571 571
             "extra": {
572 572
                 "branch-alias": {
@@ -666,16 +666,16 @@
666 666
         },
667 667
         {
668 668
             "name": "gedmo/doctrine-extensions",
669
-            "version": "v2.3.5",
669
+            "version": "v2.3.6",
670 670
             "source": {
671 671
                 "type": "git",
672 672
                 "url": "https://github.com/l3pp4rd/DoctrineExtensions.git",
673
-                "reference": "v2.3.5"
673
+                "reference": "v2.3.6"
674 674
             },
675 675
             "dist": {
676 676
                 "type": "zip",
677
-                "url": "https://api.github.com/repos/l3pp4rd/DoctrineExtensions/zipball/v2.3.5",
678
-                "reference": "v2.3.5",
677
+                "url": "https://api.github.com/repos/l3pp4rd/DoctrineExtensions/zipball/v2.3.6",
678
+                "reference": "v2.3.6",
679 679
                 "shasum": ""
680 680
             },
681 681
             "require": {
@@ -683,10 +683,11 @@
683 683
                 "php": ">=5.3.2"
684 684
             },
685 685
             "require-dev": {
686
-                "doctrine/dbal": ">=2.2",
687
-                "doctrine/mongodb": "1.0.1",
688
-                "doctrine/mongodb-odm": "1.0.0-BETA7",
689
-                "doctrine/orm": ">=2.2",
686
+                "doctrine/common": ">=2.4.0-BETA2",
687
+                "doctrine/dbal": ">=2.4.0-BETA2",
688
+                "doctrine/mongodb": ">=1.0.2",
689
+                "doctrine/mongodb-odm": ">=1.0.0-BETA8",
690
+                "doctrine/orm": ">=2.4.0-BETA2",
690 691
                 "symfony/yaml": "2.*"
691 692
             },
692 693
             "suggest": {
@@ -695,7 +696,7 @@
695 696
                 "doctrine/mongodb-odm": ">=1.0.0-BETA7",
696 697
                 "doctrine/orm": ">=2.3.2"
697 698
             },
698
-            "time": "2013-03-05 06:32:22",
699
+            "time": "2013-05-21 12:09:55",
699 700
             "type": "library",
700 701
             "extra": {
701 702
                 "branch-alias": {
@@ -750,19 +751,19 @@
750 751
             "source": {
751 752
                 "type": "git",
752 753
                 "url": "https://github.com/Gregwar/ImageBundle.git",
753
-                "reference": "d6d8c1aa8c4fe03a9b8470d2bf195c4dbf89643b"
754
+                "reference": "ae746b296768cc63c7f3478446dc5bf5d36812d4"
754 755
             },
755 756
             "dist": {
756 757
                 "type": "zip",
757
-                "url": "https://api.github.com/repos/Gregwar/ImageBundle/zipball/d6d8c1aa8c4fe03a9b8470d2bf195c4dbf89643b",
758
-                "reference": "d6d8c1aa8c4fe03a9b8470d2bf195c4dbf89643b",
758
+                "url": "https://api.github.com/repos/Gregwar/ImageBundle/zipball/ae746b296768cc63c7f3478446dc5bf5d36812d4",
759
+                "reference": "ae746b296768cc63c7f3478446dc5bf5d36812d4",
759 760
                 "shasum": ""
760 761
             },
761 762
             "require": {
762 763
                 "ext-gd": "*",
763 764
                 "php": ">=5.3.0"
764 765
             },
765
-            "time": "2013-05-09 10:44:43",
766
+            "time": "2013-06-02 20:38:56",
766 767
             "type": "symfony-bundle",
767 768
             "autoload": {
768 769
                 "psr-0": {
@@ -1158,24 +1159,24 @@
1158 1159
         },
1159 1160
         {
1160 1161
             "name": "knplabs/knp-menu-bundle",
1161
-            "version": "v1.1.1",
1162
+            "version": "v1.1.2",
1162 1163
             "target-dir": "Knp/Bundle/MenuBundle",
1163 1164
             "source": {
1164 1165
                 "type": "git",
1165 1166
                 "url": "https://github.com/KnpLabs/KnpMenuBundle.git",
1166
-                "reference": "v1.1.1"
1167
+                "reference": "v1.1.2"
1167 1168
             },
1168 1169
             "dist": {
1169 1170
                 "type": "zip",
1170
-                "url": "https://api.github.com/repos/KnpLabs/KnpMenuBundle/zipball/v1.1.1",
1171
-                "reference": "v1.1.1",
1171
+                "url": "https://api.github.com/repos/KnpLabs/KnpMenuBundle/zipball/v1.1.2",
1172
+                "reference": "v1.1.2",
1172 1173
                 "shasum": ""
1173 1174
             },
1174 1175
             "require": {
1175
-                "knplabs/knp-menu": "1.1.*",
1176
-                "symfony/framework-bundle": ">=2.0,<2.3-dev"
1176
+                "knplabs/knp-menu": ">=1.1,<2.0",
1177
+                "symfony/framework-bundle": ">=2.0,<3.0"
1177 1178
             },
1178
-            "time": "2012-11-28 20:05:09",
1179
+            "time": "2013-05-25 10:20:03",
1179 1180
             "type": "symfony-bundle",
1180 1181
             "autoload": {
1181 1182
                 "psr-0": {
@@ -1207,16 +1208,16 @@
1207 1208
         },
1208 1209
         {
1209 1210
             "name": "kriswallsmith/assetic",
1210
-            "version": "dev-master",
1211
+            "version": "1.1.x-dev",
1211 1212
             "source": {
1212 1213
                 "type": "git",
1213 1214
                 "url": "https://github.com/kriswallsmith/assetic.git",
1214
-                "reference": "5441014f28b8fe024c547fb7a15cd737c6cb1a05"
1215
+                "reference": "1b4b9ab32355b0d377b8baba73d37ab9872ab60b"
1215 1216
             },
1216 1217
             "dist": {
1217 1218
                 "type": "zip",
1218
-                "url": "https://api.github.com/repos/kriswallsmith/assetic/zipball/5441014f28b8fe024c547fb7a15cd737c6cb1a05",
1219
-                "reference": "5441014f28b8fe024c547fb7a15cd737c6cb1a05",
1219
+                "url": "https://api.github.com/repos/kriswallsmith/assetic/zipball/1b4b9ab32355b0d377b8baba73d37ab9872ab60b",
1220
+                "reference": "1b4b9ab32355b0d377b8baba73d37ab9872ab60b",
1220 1221
                 "shasum": ""
1221 1222
             },
1222 1223
             "require": {
@@ -1242,11 +1243,11 @@
1242 1243
                 "ptachoire/cssembed": "Assetic provides the integration with phpcssembed to embed data uris",
1243 1244
                 "twig/twig": "Assetic provides the integration with the Twig templating engine"
1244 1245
             },
1245
-            "time": "2013-05-18 16:31:41",
1246
+            "time": "2013-06-04 03:51:00",
1246 1247
             "type": "library",
1247 1248
             "extra": {
1248 1249
                 "branch-alias": {
1249
-                    "dev-master": "1.2-dev"
1250
+                    "dev-master": "1.1-dev"
1250 1251
                 }
1251 1252
             },
1252 1253
             "autoload": {
@@ -1396,17 +1397,17 @@
1396 1397
         },
1397 1398
         {
1398 1399
             "name": "sensio/distribution-bundle",
1399
-            "version": "v2.1.10",
1400
+            "version": "v2.1.11",
1400 1401
             "target-dir": "Sensio/Bundle/DistributionBundle",
1401 1402
             "source": {
1402 1403
                 "type": "git",
1403
-                "url": "https://github.com/sensio/SensioDistributionBundle.git",
1404
-                "reference": "v2.1.10"
1404
+                "url": "https://github.com/sensiolabs/SensioDistributionBundle.git",
1405
+                "reference": "v2.1.11"
1405 1406
             },
1406 1407
             "dist": {
1407 1408
                 "type": "zip",
1408
-                "url": "https://api.github.com/repos/sensio/SensioDistributionBundle/zipball/v2.1.10",
1409
-                "reference": "v2.1.10",
1409
+                "url": "https://api.github.com/repos/sensiolabs/SensioDistributionBundle/zipball/v2.1.11",
1410
+                "reference": "v2.1.11",
1410 1411
                 "shasum": ""
1411 1412
             },
1412 1413
             "require": {
@@ -1442,17 +1443,17 @@
1442 1443
         },
1443 1444
         {
1444 1445
             "name": "sensio/framework-extra-bundle",
1445
-            "version": "v2.1.10",
1446
+            "version": "v2.1.11",
1446 1447
             "target-dir": "Sensio/Bundle/FrameworkExtraBundle",
1447 1448
             "source": {
1448 1449
                 "type": "git",
1449
-                "url": "https://github.com/sensio/SensioFrameworkExtraBundle.git",
1450
-                "reference": "v2.1.10"
1450
+                "url": "https://github.com/sensiolabs/SensioFrameworkExtraBundle.git",
1451
+                "reference": "v2.1.11"
1451 1452
             },
1452 1453
             "dist": {
1453 1454
                 "type": "zip",
1454
-                "url": "https://api.github.com/repos/sensio/SensioFrameworkExtraBundle/zipball/v2.1.10",
1455
-                "reference": "v2.1.10",
1455
+                "url": "https://api.github.com/repos/sensiolabs/SensioFrameworkExtraBundle/zipball/v2.1.11",
1456
+                "reference": "v2.1.11",
1456 1457
                 "shasum": ""
1457 1458
             },
1458 1459
             "require": {
@@ -1489,17 +1490,17 @@
1489 1490
         },
1490 1491
         {
1491 1492
             "name": "sensio/generator-bundle",
1492
-            "version": "v2.1.10",
1493
+            "version": "v2.1.11",
1493 1494
             "target-dir": "Sensio/Bundle/GeneratorBundle",
1494 1495
             "source": {
1495 1496
                 "type": "git",
1496
-                "url": "https://github.com/sensio/SensioGeneratorBundle.git",
1497
-                "reference": "v2.1.10"
1497
+                "url": "https://github.com/sensiolabs/SensioGeneratorBundle.git",
1498
+                "reference": "v2.1.11"
1498 1499
             },
1499 1500
             "dist": {
1500 1501
                 "type": "zip",
1501
-                "url": "https://api.github.com/repos/sensio/SensioGeneratorBundle/zipball/v2.1.10",
1502
-                "reference": "v2.1.10",
1502
+                "url": "https://api.github.com/repos/sensiolabs/SensioGeneratorBundle/zipball/v2.1.11",
1503
+                "reference": "v2.1.11",
1503 1504
                 "shasum": ""
1504 1505
             },
1505 1506
             "require": {
@@ -1992,37 +1993,37 @@
1992 1993
         },
1993 1994
         {
1994 1995
             "name": "symfony/assetic-bundle",
1995
-            "version": "v2.1.2",
1996
+            "version": "v2.1.3",
1996 1997
             "target-dir": "Symfony/Bundle/AsseticBundle",
1997 1998
             "source": {
1998 1999
                 "type": "git",
1999 2000
                 "url": "https://github.com/symfony/AsseticBundle.git",
2000
-                "reference": "v2.1.2"
2001
+                "reference": "v2.1.3"
2001 2002
             },
2002 2003
             "dist": {
2003 2004
                 "type": "zip",
2004
-                "url": "https://api.github.com/repos/symfony/AsseticBundle/zipball/v2.1.2",
2005
-                "reference": "v2.1.2",
2005
+                "url": "https://api.github.com/repos/symfony/AsseticBundle/zipball/v2.1.3",
2006
+                "reference": "v2.1.3",
2006 2007
                 "shasum": ""
2007 2008
             },
2008 2009
             "require": {
2009
-                "kriswallsmith/assetic": "1.1.*",
2010
+                "kriswallsmith/assetic": ">=1.1.0-alpha4,<1.2-dev",
2010 2011
                 "php": ">=5.3.0",
2011
-                "symfony/framework-bundle": ">=2.1.0,<2.3-dev"
2012
+                "symfony/framework-bundle": ">=2.1,<3.0"
2012 2013
             },
2013 2014
             "require-dev": {
2014
-                "symfony/class-loader": ">=2.1.0,<2.3-dev",
2015
-                "symfony/console": ">=2.1.0,<2.3-dev",
2016
-                "symfony/css-selector": ">=2.1.0,<2.3-dev",
2017
-                "symfony/dom-crawler": ">=2.1.0,<2.3-dev",
2018
-                "symfony/form": ">=2.1.0,<2.3-dev",
2019
-                "symfony/twig-bundle": ">=2.1.0,<2.3-dev",
2020
-                "symfony/yaml": ">=2.1.0,<2.3-dev"
2015
+                "symfony/class-loader": ">=2.1,<3.0",
2016
+                "symfony/console": ">=2.1,<3.0",
2017
+                "symfony/css-selector": ">=2.1,<3.0",
2018
+                "symfony/dom-crawler": ">=2.1,<3.0",
2019
+                "symfony/form": ">=2.1,<3.0",
2020
+                "symfony/twig-bundle": ">=2.1,<3.0",
2021
+                "symfony/yaml": ">=2.1,<3.0"
2021 2022
             },
2022 2023
             "suggest": {
2023
-                "symfony/twig-bundle": ">=2.1.0,<2.3-dev"
2024
+                "symfony/twig-bundle": "~2.1"
2024 2025
             },
2025
-            "time": "2013-02-23 22:29:21",
2026
+            "time": "2013-03-25 20:16:21",
2026 2027
             "type": "symfony-bundle",
2027 2028
             "extra": {
2028 2029
                 "branch-alias": {
@@ -2114,17 +2115,17 @@
2114 2115
         },
2115 2116
         {
2116 2117
             "name": "symfony/swiftmailer-bundle",
2117
-            "version": "v2.1.10",
2118
+            "version": "v2.1.11",
2118 2119
             "target-dir": "Symfony/Bundle/SwiftmailerBundle",
2119 2120
             "source": {
2120 2121
                 "type": "git",
2121 2122
                 "url": "https://github.com/symfony/SwiftmailerBundle.git",
2122
-                "reference": "v2.1.10"
2123
+                "reference": "v2.1.11"
2123 2124
             },
2124 2125
             "dist": {
2125 2126
                 "type": "zip",
2126
-                "url": "https://api.github.com/repos/symfony/SwiftmailerBundle/zipball/v2.1.10",
2127
-                "reference": "v2.1.10",
2127
+                "url": "https://api.github.com/repos/symfony/SwiftmailerBundle/zipball/v2.1.11",
2128
+                "reference": "v2.1.11",
2128 2129
                 "shasum": ""
2129 2130
             },
2130 2131
             "require": {

+ 1 - 1
src/Muzich/CoreBundle/Entity/Playlist.php Bestand weergeven

@@ -100,7 +100,7 @@ class Playlist
100 100
     return $this->owner;
101 101
   }
102 102
   
103
-  public function setOwner(User $owner)
103
+  public function setOwner(User $owner = null)
104 104
   {
105 105
     $this->owner = $owner;
106 106
   }

+ 36 - 0
src/Muzich/CoreBundle/Security/Context.php Bestand weergeven

@@ -19,6 +19,18 @@ class Context
19 19
   const ACTION_TAG_ADD = 9;
20 20
   const ACTION_GET_FAVORITES_TAGS = 10;
21 21
   
22
+  const ACTION_PLAYLIST_SHOW = 11;
23
+  const ACTION_PLAYLIST_DATA_AUTOPLAY = 12;
24
+  const ACTION_PLAYLIST_ADD_ELEMENT = 13;
25
+  const ACTION_PLAYLIST_UPDATE_ORDER = 14;
26
+  const ACTION_PLAYLIST_REMOVE_ELEMENT = 15;
27
+  const ACTION_PLAYLIST_ADD_PROMPT = 16;
28
+  const ACTION_PLAYLIST_CREATE = 17;
29
+  const ACTION_PLAYLIST_COPY = 18;
30
+  const ACTION_PLAYLIST_DELETE = 19;
31
+  const ACTION_PLAYLIST_UNPICK = 20;
32
+  const ACTION_PLAYLIST_PICK = 21;
33
+  
22 34
   const AFFECT_CANT_MAKE = 0;
23 35
   const AFFECT_NO_SCORING = 1;
24 36
   
@@ -66,6 +78,30 @@ class Context
66 78
       ),
67 79
       self::ACTION_GET_FAVORITES_TAGS => array(
68 80
         self::CONDITION_USER_NOT_CONNECTED
81
+      ),
82
+      self::ACTION_PLAYLIST_ADD_ELEMENT => array(
83
+        self::CONDITION_USER_NOT_CONNECTED
84
+      ),
85
+      self::ACTION_PLAYLIST_UPDATE_ORDER => array(
86
+        self::CONDITION_USER_NOT_CONNECTED  
87
+      ),
88
+      self::ACTION_PLAYLIST_REMOVE_ELEMENT => array(
89
+        self::CONDITION_USER_NOT_CONNECTED  
90
+      ),
91
+      self::ACTION_PLAYLIST_CREATE => array(
92
+        self::CONDITION_USER_NOT_CONNECTED  
93
+      ),
94
+      self::ACTION_PLAYLIST_COPY => array(
95
+        self::CONDITION_USER_NOT_CONNECTED  
96
+      ),
97
+      self::ACTION_PLAYLIST_DELETE => array(
98
+        self::CONDITION_USER_NOT_CONNECTED  
99
+      ),
100
+      self::ACTION_PLAYLIST_UNPICK => array(
101
+        self::CONDITION_USER_NOT_CONNECTED  
102
+      ),
103
+      self::ACTION_PLAYLIST_PICK => array(
104
+        self::CONDITION_USER_NOT_CONNECTED  
69 105
       )
70 106
     ),
71 107
     self::AFFECT_NO_SCORING => array(

+ 7 - 0
src/Muzich/CoreBundle/Tests/Controller/PlaylistControllerTest.php Bestand weergeven

@@ -0,0 +1,7 @@
1
+<?php
2
+
3
+/*
4
+ * To change this template, choose Tools | Templates
5
+ * and open the template in the editor.
6
+ */
7
+?>

+ 25 - 1
src/Muzich/PlaylistBundle/Controller/EditController.php Bestand weergeven

@@ -3,8 +3,8 @@
3 3
 namespace Muzich\PlaylistBundle\Controller;
4 4
 
5 5
 use Muzich\CoreBundle\lib\Controller;
6
-use Muzich\CoreBundle\Entity\Playlist;
7 6
 use Symfony\Component\HttpFoundation\Request;
7
+use Muzich\CoreBundle\Security\Context as SecurityContext;
8 8
 
9 9
 class EditController extends Controller
10 10
 {
@@ -12,6 +12,9 @@ class EditController extends Controller
12 12
   // TODO: Cette méthode ET les autres: Mettre à jour avec le gestionnaire d'accès (Security)
13 13
   public function updateOrderAction(Request $request, $playlist_id)
14 14
   {
15
+    if (($uncondition = $this->userHaveNonConditionToMakeAction(SecurityContext::ACTION_PLAYLIST_UPDATE_ORDER)) !== false)
16
+      return $this->jsonResponseError($uncondition);
17
+    
15 18
     $playlist_manager = $this->getPlaylistManager();
16 19
     if (!($playlist = $playlist_manager->findOwnedPlaylistWithId($playlist_id, $this->getUser())) || !$request->get('elements'))
17 20
       return $this->jsonNotFoundResponse();
@@ -23,6 +26,9 @@ class EditController extends Controller
23 26
   
24 27
   public function removeElementAction($playlist_id, $element_id)
25 28
   {
29
+    if (($uncondition = $this->userHaveNonConditionToMakeAction(SecurityContext::ACTION_PLAYLIST_REMOVE_ELEMENT)) !== false)
30
+      return $this->jsonResponseError($uncondition);
31
+    
26 32
     $playlist_manager = $this->getPlaylistManager();
27 33
     if (!($playlist = $playlist_manager->findOwnedPlaylistWithId($playlist_id, $this->getUser())))
28 34
       return $this->jsonNotFoundResponse();
@@ -34,6 +40,9 @@ class EditController extends Controller
34 40
   
35 41
   public function addElementAction($playlist_id, $element_id)
36 42
   {
43
+    if (($uncondition = $this->userHaveNonConditionToMakeAction(SecurityContext::ACTION_PLAYLIST_ADD_ELEMENT)) !== false)
44
+      return $this->jsonResponseError($uncondition);
45
+    
37 46
     $playlist_manager = $this->getPlaylistManager();
38 47
     if (!($playlist = $playlist_manager->findOwnedPlaylistWithId($playlist_id, $this->getUser()))
39 48
         || !($element = $this->getElementWithId($element_id)))
@@ -46,6 +55,9 @@ class EditController extends Controller
46 55
   
47 56
   public function addElementAndCreateAction(Request $request, $element_id)
48 57
   {
58
+    if (($uncondition = $this->userHaveNonConditionToMakeAction(SecurityContext::ACTION_PLAYLIST_CREATE)) !== false)
59
+      return $this->jsonResponseError($uncondition);
60
+    
49 61
     if (!($element = $this->getElementWithId($element_id)))
50 62
       return $this->jsonNotFoundResponse();
51 63
     
@@ -68,6 +80,9 @@ class EditController extends Controller
68 80
   
69 81
   public function addElementAndCopyAction($playlist_id, $element_id)
70 82
   {
83
+    if (($uncondition = $this->userHaveNonConditionToMakeAction(SecurityContext::ACTION_PLAYLIST_COPY)) !== false)
84
+      return $this->jsonResponseError($uncondition);
85
+    
71 86
     if (!($element = $this->getElementWithId($element_id)))
72 87
       return $this->jsonNotFoundResponse();
73 88
     
@@ -84,6 +99,9 @@ class EditController extends Controller
84 99
   
85 100
   public function deleteAction($playlist_id)
86 101
   {
102
+    if (($uncondition = $this->userHaveNonConditionToMakeAction(SecurityContext::ACTION_PLAYLIST_DELETE)) !== false)
103
+      return $this->jsonResponseError($uncondition);
104
+    
87 105
     if (!($playlist = $this->getPlaylistManager()->findOwnedPlaylistWithId($playlist_id, $this->getUser())))
88 106
       throw $this->createNotFoundException();
89 107
     
@@ -95,6 +113,9 @@ class EditController extends Controller
95 113
   
96 114
   public function unpickAction($playlist_id)
97 115
   {
116
+    if (($uncondition = $this->userHaveNonConditionToMakeAction(SecurityContext::ACTION_PLAYLIST_UNPICK)) !== false)
117
+      return $this->jsonResponseError($uncondition);
118
+    
98 119
     $playlist_manager = $this->getPlaylistManager();
99 120
     
100 121
     if (!($playlist = $playlist_manager->findPlaylistWithId($playlist_id, $this->getUser())))
@@ -108,6 +129,9 @@ class EditController extends Controller
108 129
   
109 130
   public function pickAction($playlist_id)
110 131
   {
132
+    if (($uncondition = $this->userHaveNonConditionToMakeAction(SecurityContext::ACTION_PLAYLIST_PICK)) !== false)
133
+      return $this->jsonResponseError($uncondition);
134
+    
111 135
     if (!($playlist = $this->getPlaylistManager()->findOneAccessiblePlaylistWithId($playlist_id)))
112 136
       return $this->jsonNotFoundResponse();
113 137
     

+ 13 - 4
src/Muzich/PlaylistBundle/Controller/ShowController.php Bestand weergeven

@@ -3,18 +3,19 @@
3 3
 namespace Muzich\PlaylistBundle\Controller;
4 4
 
5 5
 use Muzich\CoreBundle\lib\Controller;
6
-use Muzich\CoreBundle\Entity\Playlist;
7 6
 use Muzich\CoreBundle\lib\AutoplayManager;
7
+use Muzich\CoreBundle\Security\Context as SecurityContext;
8 8
 
9 9
 class ShowController extends Controller
10 10
 {
11 11
   
12 12
   public function userAction($user_slug)
13 13
   {
14
+    if (($uncondition = $this->userHaveNonConditionToMakeAction(SecurityContext::ACTION_PLAYLIST_SHOW)) !== false)
15
+      return $this->jsonResponseError($uncondition);
16
+    
14 17
     if (!($viewed_user = $this->findUserWithSlug($user_slug)))
15
-    {
16 18
       throw $this->createNotFoundException();
17
-    }
18 19
     
19 20
     return $this->render('MuzichPlaylistBundle:Show:user.html.twig', array(
20 21
       'viewed_user' => $viewed_user,
@@ -24,6 +25,9 @@ class ShowController extends Controller
24 25
   
25 26
   public function showAction($user_slug, $playlist_id)
26 27
   {
28
+    if (($uncondition = $this->userHaveNonConditionToMakeAction(SecurityContext::ACTION_PLAYLIST_SHOW)) !== false)
29
+      return $this->jsonResponseError($uncondition);
30
+    
27 31
     if (!($viewed_user = $this->findUserWithSlug($user_slug)))
28 32
       throw $this->createNotFoundException();
29 33
     
@@ -38,8 +42,10 @@ class ShowController extends Controller
38 42
   
39 43
   public function getAutoplayDataAction($playlist_id, $offset = null)
40 44
   {
41
-    $playlist_manager = $this->getPlaylistManager();
45
+    if (($uncondition = $this->userHaveNonConditionToMakeAction(SecurityContext::ACTION_PLAYLIST_DATA_AUTOPLAY)) !== false)
46
+      return $this->jsonResponseError($uncondition);
42 47
     
48
+    $playlist_manager = $this->getPlaylistManager();
43 49
     if (!($playlist = $playlist_manager->findOneAccessiblePlaylistWithId($playlist_id, $this->getUserOrNullIfVisitor())))
44 50
       throw $this->createNotFoundException();
45 51
     
@@ -53,6 +59,9 @@ class ShowController extends Controller
53 59
   
54 60
   public function getAddElementPromptAction($element_id)
55 61
   {
62
+    if (($uncondition = $this->userHaveNonConditionToMakeAction(SecurityContext::ACTION_PLAYLIST_ADD_PROMPT)) !== false)
63
+      return $this->jsonResponseError($uncondition);
64
+    
56 65
     return $this->jsonSuccessResponse(
57 66
       $this->render('MuzichPlaylistBundle:Show:prompt.html.twig', array(
58 67
         'form'       => $this->getPlaylistForm()->createView(),

+ 27 - 6
web/bundles/muzichcore/css/main.css Bestand weergeven

@@ -455,7 +455,7 @@ ul.element_links_actions li:last-child
455 455
   margin-left: 0px;
456 456
 }
457 457
   
458
-.elements ul.element_tags li, ul#autoplay_element ul.element_tags li
458
+.elements ul.element_tags li, ul#autoplay_element ul.element_tags li, ul.elements ul.element_tags li
459 459
 {
460 460
   display: inline;
461 461
   font-size: 90%;
@@ -493,7 +493,7 @@ ul.element_tags .button
493 493
 
494 494
 }
495 495
 
496
-a.button.element_tag, ul.tagbox li.tag, ul.search_tag_list li, ul#favorite_tags li
496
+a.button.element_tag, ul.tagbox li.tag, ul.search_tag_list li, ul#favorite_tags li, ul.tags_cloud li
497 497
 {
498 498
   padding: 6px;
499 499
   border: none;
@@ -915,7 +915,7 @@ ul.tagbox li.tag
915 915
   padding-right: 18px;
916 916
 }
917 917
 
918
-ul.tagbox li.tag, ul#favorite_tags li
918
+ul.tagbox li.tag, ul#favorite_tags li, ul.tags_cloud li
919 919
 {
920 920
   border-radius: 3px 3px 3px 3px;
921 921
   display: inline-block;
@@ -1382,7 +1382,7 @@ ul#autoplay_element
1382 1382
   padding: 0px;
1383 1383
 }
1384 1384
 
1385
-ul#autoplay_element li
1385
+ul#autoplay_element li, ul.elements li
1386 1386
 {
1387 1387
   list-style-type: none;
1388 1388
 }
@@ -1399,7 +1399,7 @@ ul.tagbox li {
1399 1399
 margin:0;
1400 1400
 }
1401 1401
 
1402
-ul#favorite_tags
1402
+ul#favorite_tags, ul.tags_cloud
1403 1403
 {
1404 1404
   padding:0;
1405 1405
   margin-top:10px;
@@ -1408,7 +1408,7 @@ ul#favorite_tags
1408 1408
   list-style-type:none;
1409 1409
 }
1410 1410
 
1411
-ul#favorite_tags li a
1411
+ul#favorite_tags li a, ul.tags_cloud li a
1412 1412
 {
1413 1413
   color: white;
1414 1414
 }
@@ -2219,4 +2219,25 @@ div#facebook_login
2219 2219
 div#login_box
2220 2220
 {
2221 2221
   margin-top: 23px;
2222
+}
2223
+
2224
+ul.playlists ul.tags_cloud
2225
+{
2226
+  margin-top: 5px;
2227
+  margin-bottom: 5px;
2228
+}
2229
+
2230
+ul.playlists ul.tags_cloud li
2231
+{
2232
+  font-size: 11px;
2233
+  font-weight: normal;
2234
+  padding: 4px;
2235
+}
2236
+
2237
+div.playlists_prompt
2238
+{
2239
+  padding: 10px;
2240
+  border: 1px solid red;
2241
+  width: 320px;
2242
+  background-color: white;
2222 2243
 }

+ 12 - 1
web/bundles/muzichcore/js/autoplay.js Bestand weergeven

@@ -73,10 +73,15 @@ function Autoplay()
73 73
   {
74 74
     $('#autoplay_element_loader').show();
75 75
     JQueryJson(url_element_dom_get_one_autoplay+'/'+element_id, {}, function(response){
76
+      
77
+      $('#autoplay_element_loader').hide();
76 78
       if (response.status == 'success')
77 79
       {
78 80
         $('li#autoplay_element_container').html(response.data);
79
-        $('#autoplay_element_loader').hide();
81
+      }
82
+      else
83
+      {
84
+        $('li#autoplay_element_container').html('');
80 85
       }
81 86
     });
82 87
   }
@@ -139,6 +144,12 @@ $(document).ready(function() {
139 144
     return false;
140 145
   });
141 146
   
147
+  $('a.autoplay_playlist').live('click', function(){
148
+    window.autoplay.start($(this));
149
+    $('html, body').animate({ scrollTop: 0 }, 'fast');
150
+    return false;
151
+  });
152
+  
142 153
   $('a#autoplay_previous').click(function(){window.autoplay.playPrevious()});
143 154
   
144 155
   $('a#autoplay_next').click(function(){window.autoplay.playNext()});

+ 142 - 0
web/bundles/muzichcore/js/muzich.js Bestand weergeven

@@ -3087,6 +3087,148 @@ $(document).ready(function(){
3087 3087
    });
3088 3088
    
3089 3089
    
3090
+   /**
3091
+    *PLAYLISTS
3092
+    */
3093
+   
3094
+  $('ul.playlist_elements li a.open_element').live('click', function(){
3095
+    
3096
+    // Pour le moment
3097
+    return false;
3098
+    
3099
+    var line = $(this).parents('li.playlist_element');
3100
+    
3101
+    $.getJSON($(this).attr('href'), function(response) {
3102
+      
3103
+      window.ResponseController.execute(
3104
+        response,
3105
+        function(){},
3106
+        function(){}
3107
+      );
3108
+      
3109
+      if (response.status == 'success')
3110
+      {
3111
+        line.append('<ul class="elements"><li class="element">' + response.data + '</li></ul>');
3112
+      }
3113
+      
3114
+    });
3115
+    
3116
+    return false;
3117
+  });
3118
+  
3119
+  $('ul.playlist_elements').sortable({
3120
+    update: function( event, ui ) {
3121
+      
3122
+      var form = ui.item.parents('form')
3123
+      
3124
+      $.ajax({
3125
+       type: 'POST',
3126
+       url: form.attr('action'),
3127
+       data: form.serialize(),
3128
+       success: function(response) {
3129
+        
3130
+          window.ResponseController.execute(
3131
+            response,
3132
+            function(){},
3133
+            function(){}
3134
+          );
3135
+          
3136
+          
3137
+        },
3138
+       dataType: "json"
3139
+     });
3140
+      
3141
+    }
3142
+  });
3143
+  
3144
+  $('ul.elements a.add_to_playlist').live('click', function(event){
3145
+    
3146
+    $('div.playlists_prompt').remove();
3147
+    var prompt = $('<div class="playlists_prompt"><img class="loader" src="/bundles/muzichcore/img/ajax-loader.gif" alt="loading..." /></div>');
3148
+    $('body').append(prompt);
3149
+    
3150
+    prompt.position({
3151
+      my: "left+3 bottom+0",
3152
+      of: event,
3153
+      collision: "fit"
3154
+    });
3155
+    
3156
+    $.getJSON($(this).attr('href'), function(response) {
3157
+      window.ResponseController.execute(
3158
+        response,
3159
+        function(){},
3160
+        function(){}
3161
+      );
3162
+      
3163
+      prompt.find('img.loader').hide();
3164
+      if (response.status == 'success')
3165
+      {
3166
+        prompt.append(response.data);
3167
+        prompt.find('div.create_playlist form').ajaxForm(function(response){
3168
+          window.ResponseController.execute(
3169
+            response,
3170
+            function(){},
3171
+            function(){}
3172
+          );
3173
+          
3174
+          if (response.status == 'success')
3175
+          {
3176
+            $('div.playlists_prompt').remove();
3177
+          }
3178
+          
3179
+          if (response.status == 'error')
3180
+          {
3181
+            prompt.find('div.create_playlist form').html(response.data);
3182
+          }
3183
+          
3184
+        });
3185
+      }
3186
+      
3187
+    });
3188
+    
3189
+    return false;
3190
+  });
3191
+  
3192
+  $('a.add_element_to_playlist').live('click', function(){
3193
+    $.getJSON($(this).attr('href'), function(response) {
3194
+      window.ResponseController.execute(
3195
+        response,
3196
+        function(){},
3197
+        function(){}
3198
+      );
3199
+    });
3200
+    
3201
+    $(this).parents('div.playlists_prompt').remove();
3202
+    return false;
3203
+  });
3204
+  
3205
+  $('a.playlist_pick').live('click', function(){
3206
+    $.getJSON($(this).attr('href'), function(response) {
3207
+      window.ResponseController.execute(
3208
+        response,
3209
+        function(){},
3210
+        function(){}
3211
+      );
3212
+    });
3213
+    
3214
+    return false;
3215
+  });
3216
+  
3217
+  
3218
+  $('ul.playlist_elements a.remove_element').live('click', function () {
3219
+    
3220
+    $.getJSON($(this).attr('href'), function(response) {
3221
+      window.ResponseController.execute(
3222
+        response,
3223
+        function(){},
3224
+        function(){}
3225
+      );
3226
+    });
3227
+    
3228
+    $(this).parents('li.playlist_element').remove();
3229
+    return false;
3230
+  });
3231
+   
3090 3232
 });
3091 3233
 
3092 3234
 function open_ajax_popin(url, callback)