Browse Source

Mise en place auth facebook. TODO: Reste a placer joliement le bouton.

Bastien Sevajol 11 years ago
parent
commit
299649958f

+ 1 - 0
app/AppKernel.php View File

@@ -32,6 +32,7 @@ class AppKernel extends Kernel
32 32
             new Knp\Bundle\MenuBundle\KnpMenuBundle(),
33 33
             new WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle(),
34 34
             new Shtumi\UsefulBundle\ShtumiUsefulBundle(),
35
+            new FOS\FacebookBundle\FOSFacebookBundle(),
35 36
             
36 37
             new Muzich\CoreBundle\MuzichCoreBundle(),
37 38
             new Muzich\UserBundle\MuzichUserBundle(),

+ 6 - 0
app/config/routing.yml View File

@@ -1,3 +1,9 @@
1
+_security_check:
2
+  pattern:  /login_facebook_check
3
+  
4
+_security_logout:
5
+    pattern:  /logout
6
+
1 7
 MuzichIndexBundle:
2 8
   resource: "@MuzichIndexBundle/Resources/config/routing.yml"
3 9
   prefix: /

+ 2 - 1
composer.json View File

@@ -34,7 +34,8 @@
34 34
         "sonata-project/doctrine-orm-admin-bundle": "2.1.*@dev",
35 35
         "sonata-project/admin-bundle": "2.1.*@dev",
36 36
         "sonata-project/jquery-bundle": "1.8.*@dev",
37
-        "sonata-project/block-bundle": "2.1.*@dev"
37
+        "sonata-project/block-bundle": "2.1.*@dev",
38
+        "friendsofsymfony/facebook-bundle": "dev-master"
38 39
     },
39 40
     "scripts": {
40 41
         "post-install-cmd": [

+ 106 - 2
composer.lock View File

@@ -1,5 +1,5 @@
1 1
 {
2
-    "hash": "dd5c41c30319b0b4e3eff5370c6bedd2",
2
+    "hash": "d7a4e5394285af2257f72f7356506599",
3 3
     "packages": [
4 4
         {
5 5
             "name": "cedriclombardot/admingenerator-generator-bundle",
@@ -497,6 +497,109 @@
497 497
             ]
498 498
         },
499 499
         {
500
+            "name": "facebook/php-sdk",
501
+            "version": "v3.2.2",
502
+            "source": {
503
+                "type": "git",
504
+                "url": "https://github.com/facebook/facebook-php-sdk.git",
505
+                "reference": "v3.2.2"
506
+            },
507
+            "dist": {
508
+                "type": "zip",
509
+                "url": "https://api.github.com/repos/facebook/facebook-php-sdk/zipball/v3.2.2",
510
+                "reference": "v3.2.2",
511
+                "shasum": ""
512
+            },
513
+            "require": {
514
+                "ext-curl": "*",
515
+                "ext-json": "*",
516
+                "php": ">=5.2.0"
517
+            },
518
+            "time": "2013-01-15 21:37:15",
519
+            "type": "library",
520
+            "autoload": {
521
+                "classmap": [
522
+                    "src"
523
+                ]
524
+            },
525
+            "notification-url": "https://packagist.org/downloads/",
526
+            "license": [
527
+                "Apache2"
528
+            ],
529
+            "authors": [
530
+                {
531
+                    "name": "Facebook",
532
+                    "homepage": "https://github.com/facebook/facebook-php-sdk/contributors"
533
+                }
534
+            ],
535
+            "description": "Facebook PHP SDK",
536
+            "homepage": "https://github.com/facebook/facebook-php-sdk",
537
+            "keywords": [
538
+                "facebook",
539
+                "sdk"
540
+            ]
541
+        },
542
+        {
543
+            "name": "friendsofsymfony/facebook-bundle",
544
+            "version": "dev-master",
545
+            "target-dir": "FOS/FacebookBundle",
546
+            "source": {
547
+                "type": "git",
548
+                "url": "https://github.com/FriendsOfSymfony/FOSFacebookBundle.git",
549
+                "reference": "9c93669fd8f93941602d348daa58273c29be229f"
550
+            },
551
+            "dist": {
552
+                "type": "zip",
553
+                "url": "https://api.github.com/repos/FriendsOfSymfony/FOSFacebookBundle/zipball/9c93669fd8f93941602d348daa58273c29be229f",
554
+                "reference": "9c93669fd8f93941602d348daa58273c29be229f",
555
+                "shasum": ""
556
+            },
557
+            "require": {
558
+                "facebook/php-sdk": "3.2.*",
559
+                "php": ">=5.3.2",
560
+                "symfony/http-foundation": ">=2.1,<2.3",
561
+                "symfony/security": ">=2.1,<2.3"
562
+            },
563
+            "require-dev": {
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"
568
+            },
569
+            "time": "2013-05-14 18:06:07",
570
+            "type": "symfony-bundle",
571
+            "extra": {
572
+                "branch-alias": {
573
+                    "dev-master": "1.1.x-dev"
574
+                }
575
+            },
576
+            "autoload": {
577
+                "psr-0": {
578
+                    "FOS\\FacebookBundle": ""
579
+                }
580
+            },
581
+            "notification-url": "https://packagist.org/downloads/",
582
+            "license": [
583
+                "MIT"
584
+            ],
585
+            "authors": [
586
+                {
587
+                    "name": "Kris Wallsmith",
588
+                    "email": "kris.wallsmith@gmail.com",
589
+                    "homepage": "http://kriswallsmith.net/"
590
+                },
591
+                {
592
+                    "name": "FriendsOfSymfony Community",
593
+                    "homepage": "https://github.com/friendsofsymfony/FOSFacebookBundle/contributors"
594
+                }
595
+            ],
596
+            "description": "Integrate the Facebook Platform into your Symfony2 application.",
597
+            "homepage": "http://friendsofsymfony.github.com",
598
+            "keywords": [
599
+                "facebook"
600
+            ]
601
+        },
602
+        {
500 603
             "name": "friendsofsymfony/user-bundle",
501 604
             "version": "v1.3.1",
502 605
             "target-dir": "FOS/UserBundle",
@@ -2317,6 +2420,7 @@
2317 2420
         "sonata-project/doctrine-orm-admin-bundle": 20,
2318 2421
         "sonata-project/admin-bundle": 20,
2319 2422
         "sonata-project/jquery-bundle": 20,
2320
-        "sonata-project/block-bundle": 20
2423
+        "sonata-project/block-bundle": 20,
2424
+        "friendsofsymfony/facebook-bundle": 20
2321 2425
     }
2322 2426
 }

+ 30 - 0
src/Muzich/CoreBundle/Entity/User.php View File

@@ -281,6 +281,9 @@ class User extends BaseUser
281 281
    */
282 282
   private $password_set = true;
283 283
   
284
+  /** @ORM\Column(name="facebook_id", type="string", length=255, nullable=true) */
285
+  protected $facebook_id;
286
+  
284 287
   /**
285 288
    * 
286 289
    */
@@ -1172,4 +1175,31 @@ class User extends BaseUser
1172 1175
     $this->setPasswordSet(true);
1173 1176
   }
1174 1177
   
1178
+  /** @return void */
1179
+  public function setFacebookId($facebook_id)
1180
+  {
1181
+    $this->facebook_id = $facebook_id;
1182
+    $this->setUsername($facebook_id);
1183
+    $this->setUsernameUpdatable(true);
1184
+    $this->salt = '';
1185
+  }
1186
+
1187
+  /** @return string */
1188
+  public function getFacebookId()
1189
+  {
1190
+    return $this->facebook_id;
1191
+  }
1192
+  
1193
+  /** @param Array */
1194
+  public function setFBData($fbdata) // C'est dans cette méthode que vous ajouterez vos informations
1195
+  {
1196
+    if (isset($fbdata['id'])) {
1197
+      $this->setFacebookId($fbdata['id']);
1198
+      $this->addRole('ROLE_FACEBOOK');
1199
+    }
1200
+    if (isset($fbdata['email'])) {
1201
+      $this->setEmail($fbdata['email']);
1202
+    }
1203
+  }
1204
+  
1175 1205
 }

+ 10 - 3
src/Muzich/CoreBundle/Resources/config/security.yml View File

@@ -1,4 +1,4 @@
1
-parameters:
1
+#parameters:
2 2
     # ... other parameters
3 3
     #security.acl.permission.map.class: Sonata\AdminBundle\Security\Acl\Permission\AdminPermissionMap
4 4
     
@@ -6,6 +6,8 @@ security:
6 6
     providers:
7 7
         fos_userbundle:
8 8
             id: fos_user.user_provider.username_email
9
+        my_facebook_provider:
10
+            id: my_user.facebook_provider
9 11
     encoders:
10 12
         "FOS\UserBundle\Model\UserInterface":
11 13
             algorithm: sha512
@@ -22,8 +24,13 @@ security:
22 24
                 check_path:     /login_check
23 25
                 failure_path:   null
24 26
                 default_target_path: home
25
-                success_handler: security.authentication.success_handler
26
-                failure_handler: security.authentication.failure_handler
27
+                success_handler: muzich.security.authentication.success_handler
28
+                failure_handler: muzich.security.authentication.failure_handler
29
+            fos_facebook:
30
+                app_url: "%api_facebook_name%"
31
+                server_url: "%api_facebook_server%"
32
+                check_path: /login_facebook_check
33
+                provider: my_facebook_provider
27 34
                 
28 35
             logout:
29 36
                 path:   /logout

+ 5 - 0
src/Muzich/CoreBundle/Resources/public/js/muzich.js View File

@@ -3171,12 +3171,17 @@ function open_connection_or_subscription_window(open_login_part)
3171 3171
         }
3172 3172
       });
3173 3173
       
3174
+      $('div#facebook_login').prependTo('div#helpbox');
3175
+      $('div#facebook_login').show();
3176
+      
3174 3177
     });
3175 3178
   }
3176 3179
 }
3177 3180
 
3178 3181
 function close_popin()
3179 3182
 {
3183
+  $('div#facebook_login').hide();
3184
+  $('div#facebook_login').appendTo('body');
3180 3185
   // Fond gris
3181 3186
   $('#fade').fadeOut(1000, function(){$('#fade').remove();});
3182 3187
   // On cache le lecteur

+ 23 - 0
src/Muzich/CoreBundle/Resources/views/Component/facebook.html.twig View File

@@ -0,0 +1,23 @@
1
+{{ facebook_initialize({'xfbml': true, 'culture': 'fr_FR', 'fbAsyncInit': 'onFbInit();'}) }}
2
+<script type="text/javascript" > // Script for FOSFacebookBundle
3
+function goLogIn(){
4
+    window.location = "{{ path('_security_check') }}";
5
+}
6
+
7
+function onFbInit() {
8
+    if (typeof(FB) != 'undefined' && FB != null ) {
9
+        FB.Event.subscribe('auth.statusChange', function(response) {
10
+            if (response.session || response.authResponse) {
11
+                setTimeout(goLogIn, 50);
12
+            } else {
13
+                window.location = "{{ path('_security_logout') }}";
14
+            }
15
+        });
16
+    }
17
+}
18
+</script>
19
+
20
+<div id="facebook_login" style="display: none;">
21
+  {{ facebook_login_button({'autologoutlink': false}) }}
22
+</div>
23
+  

+ 2 - 1
src/Muzich/CoreBundle/Resources/views/layout.html.twig View File

@@ -1,5 +1,5 @@
1 1
 <!doctype html>
2
-<html>
2
+<html xmlns:fb="http://www.facebook.com/2008/fbml">
3 3
   <head>
4 4
     <title>Muzi.ch - {% block title %}{% endblock %}</title>
5 5
     {% include 'MuzichCoreBundle:Layout:head.html.twig' %}
@@ -8,6 +8,7 @@
8 8
   </head>
9 9
   <body>
10 10
     
11
+    {% include 'MuzichCoreBundle:Component:facebook.html.twig' %}
11 12
     {% include 'MuzichCoreBundle:Layout:noscript.html.twig' %}
12 13
     {% include 'MuzichCoreBundle:Autoplay:autoplay.html.twig' %}
13 14
   

+ 80 - 0
src/Muzich/CoreBundle/Security/User/Provider/FacebookProvider.php View File

@@ -0,0 +1,80 @@
1
+<?php
2
+
3
+namespace Muzich\CoreBundle\Security\User\Provider;
4
+
5
+use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
6
+use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
7
+use Symfony\Component\Security\Core\User\UserProviderInterface;
8
+use Symfony\Component\Security\Core\User\UserInterface;
9
+
10
+use \BaseFacebook;
11
+use \FacebookApiException;
12
+
13
+class FacebookProvider implements UserProviderInterface
14
+{
15
+    /**
16
+     * @var \Facebook
17
+     */
18
+    protected $facebook;
19
+    protected $userManager;
20
+    protected $validator;
21
+
22
+    public function __construct(BaseFacebook $facebook, $userManager, $validator)
23
+    {
24
+        $this->facebook = $facebook;
25
+        $this->userManager = $userManager;
26
+        $this->validator = $validator;
27
+    }
28
+
29
+    public function supportsClass($class)
30
+    {
31
+        return $this->userManager->supportsClass($class);
32
+    }
33
+
34
+    public function findUserByFbId($fbId)
35
+    {
36
+        return $this->userManager->findUserBy(array('facebook_id' => $fbId));
37
+    }
38
+
39
+    public function loadUserByUsername($username)
40
+    {
41
+        $user = $this->findUserByFbId($username);
42
+
43
+        try {
44
+            $fbdata = $this->facebook->api('/me');
45
+        } catch (FacebookApiException $e) {
46
+            throw new UsernameNotFoundException('The user is not authenticated on facebook');
47
+            $fbdata = null;
48
+        }
49
+
50
+        if (!empty($fbdata)) {
51
+            if (empty($user)) {
52
+                $user = $this->userManager->createUser();
53
+                $user->setEnabled(true);
54
+                $user->setPassword('');
55
+
56
+                $user->setFBData($fbdata); // Ici on passe les données Facebook à notre classe User afin de la mettre à jour
57
+            }
58
+
59
+            if (count($this->validator->validate($user, 'Facebook'))) {
60
+                throw new UsernameNotFoundException('The facebook user could not be stored');
61
+            }
62
+            $this->userManager->updateUser($user);
63
+        }
64
+
65
+        if (empty($user)) {
66
+            throw new UsernameNotFoundException('The user is not authenticated on facebook');
67
+        }
68
+
69
+        return $user;
70
+    }
71
+
72
+    public function refreshUser(UserInterface $user)
73
+    {
74
+        if (!$this->supportsClass(get_class($user)) || !$user->getFacebookId()) {
75
+            throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_class($user)));
76
+        }
77
+
78
+        return $this->loadUserByUsername($user->getFacebookId());
79
+    }
80
+}

+ 1 - 1
src/Muzich/UserBundle/Resources/views/Account/subscribe_or_login.html.twig View File

@@ -20,4 +20,4 @@
20 20
   
21 21
   {% include "MuzichUserBundle:Registration:register.html.twig" %}
22 22
   
23
-</div>
23
+</div>

+ 1 - 4
web/bundles/admingeneratorgenerator/javascripts/double_list.js View File

@@ -2,12 +2,9 @@ var sfDoubleList =
2 2
 {
3 3
   init: function(id, className)
4 4
   {
5
-    if(id == null)
6
-    return;
7
-    
8 5
     form = sfDoubleList.get_current_form(id);
9 6
 
10
-      callback = function() { sfDoubleList.submit(form, className) };
7
+    callback = function() { sfDoubleList.submit(form, className) };
11 8
 
12 9
     if (form.addEventListener)
13 10
     {

+ 176 - 15
web/bundles/muzichcore/css/main.css View File

@@ -544,7 +544,7 @@ img.tag_add_to_favorites
544 544
   margin-left: 1px;
545 545
 }
546 546
 
547
-td.element_content a.display_comments, td.element_content a.add_comment, td.element_content a.hide_comments, div.comments a.add_comment
547
+td.element_content a.display_comments, td.element_content a.add_comment, td.element_content a.add_comment_disabled, td.element_content a.hide_comments, div.comments a.add_comment
548 548
 {
549 549
   color: #404040;
550 550
 }
@@ -948,7 +948,7 @@ ul#favorite_tags li
948 948
   margin-right: 0px;
949 949
 }
950 950
 
951
-#element_add_link, #element_add_close_link, #group_add_link, #group_add_close_link, #registration_link, #login_link, #know_more
951
+#element_add_link, #element_add_close_link, #group_add_link, #group_add_link_disabled, #group_add_close_link, #registration_link, #login_link, #know_more, #launch_tour
952 952
 {
953 953
   float: right;
954 954
   margin-top: -58px;
@@ -975,13 +975,13 @@ ul#favorite_tags li
975 975
   margin-top: -68px;
976 976
 }
977 977
 
978
-#element_add_link img, #element_add_close_link img, #group_add_link img, #group_add_close_link img, #registration_link img, #login_link img
978
+#element_add_link img, #element_add_close_link img, #group_add_link img, #group_add_link_disabled img, #group_add_close_link img, #registration_link img, #login_link img
979 979
 {
980 980
   margin-bottom: -5px;
981 981
     margin-right: -5px;
982 982
 }
983 983
 
984
-#element_add_link.justtopright, #element_add_close_link.justtopright, #group_add_link.justtopright, #group_add_close_link.justtopright
984
+#element_add_link.justtopright, #element_add_close_link.justtopright, #group_add_link.justtopright, #group_add_link_disabled.justtopright, #group_add_close_link.justtopright
985 985
 {
986 986
   margin-top: 0px;
987 987
   margin-right: 0px;
@@ -1261,6 +1261,11 @@ div.search_tag_list ul.search_tag_list li.new
1261 1261
 {
1262 1262
   color: black;
1263 1263
 }
1264
+
1265
+#helpbox div.search_tag_list ul.search_tag_list li.new a
1266
+{
1267
+  color: black;
1268
+}
1264 1269
   
1265 1270
 
1266 1271
 div.search_tag_list ul.search_tag_list li:hover
@@ -1510,12 +1515,17 @@ div#group_add_box input[type="submit"]
1510 1515
 
1511 1516
 div#registration_box input.niceinput
1512 1517
 {
1513
-  width: 430px;
1518
+  width: 250px;
1514 1519
 }
1515 1520
 
1516 1521
 div#registration_box label
1517 1522
 {
1518
-  width: 170px;
1523
+  width: 70px;
1524
+}
1525
+
1526
+div#registration_box input[type="submit"]
1527
+{
1528
+  float: right;
1519 1529
 }
1520 1530
 
1521 1531
 div#registration_box div.field
@@ -1707,7 +1717,7 @@ div.show_options {
1707 1717
     float: right;
1708 1718
 }
1709 1719
 
1710
-#container #group_add_link, #container #group_add_close_link
1720
+#container #group_add_link, #container #group_add_link_disabled, #container #group_add_close_link
1711 1721
 {
1712 1722
   font-size: 120%;
1713 1723
   float: right;
@@ -1857,7 +1867,17 @@ p.group_description
1857 1867
 
1858 1868
 #login_box input[id="username"], #login_box input[id="password"]
1859 1869
 {
1860
-  width: 230px;
1870
+  width: 228px;
1871
+}
1872
+
1873
+#login_box div.login
1874
+{
1875
+  margin-top: 8px;
1876
+}
1877
+
1878
+#login_box div.textcenter
1879
+{
1880
+  margin-top: 12px;
1861 1881
 }
1862 1882
 
1863 1883
 /*#registration_link, #login_link
@@ -1996,12 +2016,13 @@ div#tourControls a#tourEnd
1996 2016
   float: right;
1997 2017
 }
1998 2018
 
1999
-a.tags_prompt_helpbox
2019
+a.tag_prompt_tool
2000 2020
 {
2001
-  float: left;
2021
+  float: right;
2002 2022
   margin-bottom: 0;
2003 2023
   margin-left: 0px;
2004 2024
   margin-top: 5px;
2025
+  margin-right: 11px;
2005 2026
 }
2006 2027
 
2007 2028
 form#address_update input.intext
@@ -2015,11 +2036,12 @@ div#form_add_thumb img
2015 2036
   height: 100px;
2016 2037
 }
2017 2038
   
2018
-#know_more
2039
+#know_more, #launch_tour
2019 2040
 {
2020
-  float: left;
2021
-  margin-left: -11px;
2022
-  margin-top: -67px;
2041
+  float: none;
2042
+  margin-bottom: 16px;
2043
+  margin-top: 0;
2044
+  width: 269px;
2023 2045
 }
2024 2046
 
2025 2047
 div.helpbox_image_container
@@ -2045,4 +2067,143 @@ div.helpbox_image_container img
2045 2067
 
2046 2068
 .fotter_muzich_little{
2047 2069
   font-size: 9px;
2048
-}
2070
+}
2071
+
2072
+div.side_margin_top
2073
+{
2074
+  margin-top: 25px;
2075
+}
2076
+
2077
+p.accept_cgu
2078
+{
2079
+  font-size: 11px;
2080
+}
2081
+
2082
+li.user_name a
2083
+{
2084
+  color: inherit;
2085
+}
2086
+
2087
+li.user_name a:hover
2088
+{
2089
+  text-decoration: underline;
2090
+}
2091
+
2092
+@-webkit-keyframes clignote
2093
+{
2094
+  0%{box-shadow:0px 0px 10px #909090;}
2095
+  50%{box-shadow:0px 0px 2px #909090;}
2096
+  100%{box-shadow:0px 0px 10px #909090;}
2097
+}
2098
+
2099
+@-moz-keyframes clignote
2100
+{
2101
+  0%{box-shadow:0px 0px 10px #909090;}
2102
+  50%{box-shadow:0px 0px 2px #909090;}
2103
+  100%{box-shadow:0px 0px 10px #909090;}
2104
+}
2105
+
2106
+@-ms-keyframes clignote
2107
+{
2108
+  0%{box-shadow:0px 0px 10px #909090;}
2109
+  50%{box-shadow:0px 0px 2px #909090;}
2110
+  100%{box-shadow:0px 0px 10px #909090;}
2111
+}
2112
+
2113
+@-o-keyframes clignote
2114
+{
2115
+  0%{box-shadow:0px 0px 10px #909090;}
2116
+  50%{box-shadow:0px 0px 2px #909090;}
2117
+  100%{box-shadow:0px 0px 10px #909090;}
2118
+}
2119
+
2120
+@keyframes clignote
2121
+{
2122
+  0%{box-shadow:0px 0px 10px #909090;}
2123
+  50%{box-shadow:0px 0px 2px #909090;}
2124
+  100%{box-shadow:0px 0px 10px #909090;}
2125
+}
2126
+
2127
+
2128
+.flashing
2129
+{
2130
+  font-weight: bold;
2131
+  text-shadow: 0 1px 0 white;
2132
+  border-radius: 3px;
2133
+  padding: 5px 10px;
2134
+  box-shadow:0px 0px 10px #909090;
2135
+  
2136
+  -webkit-animation-name: clignote;
2137
+  -webkit-animation-duration: 1s;
2138
+  -webkit-animation-iteration-count:infinite;
2139
+  
2140
+  -moz-animation-name: clignote;
2141
+  -moz-animation-duration: 1s;
2142
+  -moz-animation-iteration-count:infinite;
2143
+  
2144
+  -ms-animation-name: clignote;
2145
+  -ms-animation-duration: 1s;
2146
+  -ms-animation-iteration-count:infinite;
2147
+  
2148
+  -o-animation-name: clignote;
2149
+  -o-animation-duration: 1s;
2150
+  -o-animation-iteration-count:infinite;
2151
+  
2152
+  animation-name: clignote;
2153
+  animation-duration: 1s;
2154
+  animation-iteration-count:infinite;
2155
+}
2156
+
2157
+div.myaccount_part.flashing
2158
+{
2159
+  padding: 2px;
2160
+}
2161
+
2162
+div.choose_password
2163
+{
2164
+  text-align: center;
2165
+}
2166
+
2167
+div.center
2168
+{
2169
+  text-align: center;
2170
+}
2171
+
2172
+div#email_not_confirmed_box input
2173
+{
2174
+  margin: 10px;
2175
+}
2176
+
2177
+div#email_not_confirmed_box p.info
2178
+{
2179
+  font-style: italic;
2180
+}
2181
+
2182
+span.message_success
2183
+{
2184
+  font-weight: bold;
2185
+  color: green;
2186
+}
2187
+
2188
+span.message_error
2189
+{
2190
+  font-weight: bold;
2191
+  color: red;
2192
+}
2193
+
2194
+div#helpbox input.tag_prompt
2195
+{
2196
+  width: 480px;
2197
+}
2198
+
2199
+div#helpbox input.button
2200
+{
2201
+  float: right;
2202
+  margin-right: 11px;
2203
+  margin-top: 5px;
2204
+}
2205
+
2206
+div#helpbox div.center input.button
2207
+{
2208
+  float: none;
2209
+}

+ 31 - 28
web/bundles/muzichcore/js/TagPrompt.js View File

@@ -35,7 +35,14 @@ function TagPrompt(select_tag_callback, tag_prompt_connector)
35 35
   {
36 36
     if (!tag_id)
37 37
     {
38
-      openTagSubmission(tag_name);
38
+      if (!visitor)
39
+      {
40
+        openTagSubmission(tag_name);
41
+      }
42
+      else
43
+      {
44
+        open_connection_or_subscription_window();
45
+      }
39 46
     }
40 47
     else
41 48
     {
@@ -64,39 +71,34 @@ function TagPrompt(select_tag_callback, tag_prompt_connector)
64 71
       .attr('method', 'post')
65 72
       .attr('name', 'add_tag')
66 73
       .ajaxForm(function(response) {
67
-        /*
68
-        *
69
-        */
70
-  
71
-        if (response.status == 'mustbeconnected')
72
-        {
73
-          $(location).attr('href', url_index);
74
-        }
74
+       
75
+        window.ResponseController.execute(
76
+          response,
77
+          function(){},
78
+          function(response){
79
+            $('form[name="add_tag"]').find('ul.error_list').remove();
80
+            var ul_errors = $('<ul>').addClass('error_list');
81
+
82
+            for (i in response.errors)
83
+            {
84
+              ul_errors.append($('<li>').append(response.errors[i]));
85
+            }
86
+
87
+            $('form[name="add_tag"]').prepend(ul_errors);
88
+          }
89
+        );
75 90
   
76
-        if (response.status == 'success')
91
+        if (response.status === 'success')
77 92
         {
78 93
           var tag = new Tag(response.tag_id, response.tag_name);
79 94
           addTagToProposedTags(tag);
80 95
           addTagToSelectedTags(tag);
81 96
           _tag_prompt_connector.updateOutput(tags_selected);
82
-  
97
+
83 98
           $('#fade').fadeOut(400, function(){$('#fade').remove();});
84 99
           $('#add_tag').remove();
85 100
         }
86 101
   
87
-        if (response.status == 'error')
88
-        {
89
-          $('form[name="add_tag"]').find('ul.error_list').remove();
90
-          var ul_errors = $('<ul>').addClass('error_list');
91
-  
92
-          for (i in response.errors)
93
-          {
94
-            ul_errors.append($('<li>').append(response.errors[i]));
95
-          }
96
-  
97
-          $('form[name="add_tag"]').prepend(ul_errors);
98
-        }
99
-  
100 102
         return false;
101 103
       })
102 104
   
@@ -174,10 +176,11 @@ function TagPrompt(select_tag_callback, tag_prompt_connector)
174 176
         *
175 177
         */
176 178
   
177
-        if (response.status == 'mustbeconnected')
178
-        {
179
-          $(location).attr('href', url_index);
180
-        }
179
+        window.ResponseController.execute(
180
+          response,
181
+          function(){},
182
+          function(){}
183
+        );
181 184
   
182 185
         if (response.status == 'success')
183 186
         {

File diff suppressed because it is too large
+ 511 - 226
web/bundles/muzichcore/js/muzich.js