浏览代码

Evolution #404: Inscription: confirmation de l'email et conséquences

Bastien Sevajol 11 年前
父节点
当前提交
dcc9093c33

+ 3 - 2
src/Muzich/CommentBundle/Controller/CommentController.php 查看文件

@@ -5,6 +5,7 @@ namespace Muzich\CommentBundle\Controller;
5 5
 use Muzich\CoreBundle\lib\Controller;
6 6
 use Muzich\CoreBundle\Managers\CommentsManager;
7 7
 use Muzich\CoreBundle\Propagator\EventElement;
8
+use Muzich\CoreBundle\Security\Context as SecurityContext;
8 9
 
9 10
 class CommentController extends Controller
10 11
 {
@@ -299,9 +300,9 @@ class CommentController extends Controller
299 300
    */
300 301
   public function alertAction($element_id, $date, $token)
301 302
   {
302
-    if (($response = $this->mustBeConnected(true)))
303
+if (($non_condition = $this->userHaveNonConditionToMakeAction(SecurityContext::ACTION_COMMENT_ALERT)) !== false)
303 304
     {
304
-      return $response;
305
+      return $this->jsonResponseError($non_condition);
305 306
     }
306 307
     
307 308
     if (!($element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')

+ 8 - 7
src/Muzich/CoreBundle/Controller/CoreController.php 查看文件

@@ -20,6 +20,7 @@ use Muzich\CoreBundle\Managers\ElementReportManager;
20 20
 use Muzich\CoreBundle\Propagator\EventUser;
21 21
 use Muzich\CoreBundle\Entity\User;
22 22
 use Symfony\Component\HttpFoundation\Request;
23
+use Muzich\CoreBundle\Security\Context as SecurityContext;
23 24
 
24 25
 class CoreController extends Controller
25 26
 {
@@ -211,14 +212,14 @@ class CoreController extends Controller
211 212
    */
212 213
   public function elementAddAction($group_slug)
213 214
   {
214
-    if (($response = $this->mustBeConnected()))
215
+    if (($non_condition = $this->userHaveNonConditionToMakeAction(SecurityContext::ACTION_ELEMENT_ADD)) !== false)
215 216
     {
216
-      return $response;
217
+      return $this->jsonResponseError($non_condition);
217 218
     }
218 219
     
219 220
     if ($this->getRequest()->getMethod() != 'POST')
220 221
     {
221
-      throw $this->createNotFoundException('Cette ressource n\'est pas accessible');
222
+      throw $this->createNotFoundException();
222 223
     }
223 224
     
224 225
     $user = $this->getUser(true, array('join' => array('groups_owned_groups_tags')));
@@ -453,9 +454,9 @@ class CoreController extends Controller
453 454
    */
454 455
   public function addTagAction()
455 456
   {
456
-    if (($response = $this->mustBeConnected(true)))
457
+    if (($non_condition = $this->userHaveNonConditionToMakeAction(SecurityContext::ACTION_TAG_ADD)) !== false)
457 458
     {
458
-      return $response;
459
+      return $this->jsonResponseError($non_condition);
459 460
     }
460 461
     
461 462
     if (strlen((($tag_name = $this->getRequest()->request->get('tag_name')))) 
@@ -625,9 +626,9 @@ class CoreController extends Controller
625 626
    */
626 627
   public function reportElementAction($element_id, $token)
627 628
   {
628
-    if (($response = $this->mustBeConnected(true)))
629
+    if (($non_condition = $this->userHaveNonConditionToMakeAction(SecurityContext::ACTION_ELEMENT_ALERT)) !== false)
629 630
     {
630
-      return $response;
631
+      return $this->jsonResponseError($non_condition);
631 632
     }
632 633
     
633 634
     if (!($element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')

+ 4 - 9
src/Muzich/CoreBundle/Controller/ElementController.php 查看文件

@@ -450,9 +450,9 @@ class ElementController extends Controller
450 450
    */
451 451
   public function addVoteGoodAction($element_id, $token)
452 452
   {
453
-    if (($response = $this->mustBeConnected(true)))
453
+    if (($non_condition = $this->userHaveNonConditionToMakeAction(SecurityContext::ACTION_ELEMENT_NOTE)) !== false)
454 454
     {
455
-      return $response;
455
+      return $this->jsonResponseError($non_condition);
456 456
     }
457 457
     
458 458
     if (!($element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
@@ -509,9 +509,9 @@ class ElementController extends Controller
509 509
    */
510 510
   public function removeVoteGoodAction($element_id, $token)
511 511
   {
512
-    if (($response = $this->mustBeConnected(true)))
512
+    if (($non_condition = $this->userHaveNonConditionToMakeAction(SecurityContext::ACTION_ELEMENT_NOTE)) !== false)
513 513
     {
514
-      return $response;
514
+      return $this->jsonResponseError($non_condition);
515 515
     }
516 516
     
517 517
     if (!($element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
@@ -568,11 +568,6 @@ class ElementController extends Controller
568 568
    */
569 569
   public function proposeTagsOpenAction($element_id)
570 570
   {
571
-    if (($response = $this->mustBeConnected(true)))
572
-    {
573
-      return $response;
574
-    }
575
-    
576 571
     if (($non_condition = $this->userHaveNonConditionToMakeAction(SecurityContext::ACTION_ELEMENT_TAGS_PROPOSITION)) !== false)
577 572
     {
578 573
       return $this->jsonResponseError($non_condition);

+ 4 - 4
src/Muzich/CoreBundle/Resources/public/css/main.css 查看文件

@@ -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
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;
@@ -1707,7 +1707,7 @@ div.show_options {
1707 1707
     float: right;
1708 1708
 }
1709 1709
 
1710
-#container #group_add_link, #container #group_add_close_link
1710
+#container #group_add_link, #container #group_add_link_disabled, #container #group_add_close_link
1711 1711
 {
1712 1712
   font-size: 120%;
1713 1713
   float: right;

+ 18 - 23
src/Muzich/CoreBundle/Resources/public/js/TagPrompt.js 查看文件

@@ -71,39 +71,34 @@ function TagPrompt(select_tag_callback, tag_prompt_connector)
71 71
       .attr('method', 'post')
72 72
       .attr('name', 'add_tag')
73 73
       .ajaxForm(function(response) {
74
-        /*
75
-        *
76
-        */
77
-  
78
-        if (response.status == 'mustbeconnected')
79
-        {
80
-          $(location).attr('href', url_index);
81
-        }
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
+        );
82 90
   
83
-        if (response.status == 'success')
91
+        if (response.status === 'success')
84 92
         {
85 93
           var tag = new Tag(response.tag_id, response.tag_name);
86 94
           addTagToProposedTags(tag);
87 95
           addTagToSelectedTags(tag);
88 96
           _tag_prompt_connector.updateOutput(tags_selected);
89
-  
97
+
90 98
           $('#fade').fadeOut(400, function(){$('#fade').remove();});
91 99
           $('#add_tag').remove();
92 100
         }
93 101
   
94
-        if (response.status == 'error')
95
-        {
96
-          $('form[name="add_tag"]').find('ul.error_list').remove();
97
-          var ul_errors = $('<ul>').addClass('error_list');
98
-  
99
-          for (i in response.errors)
100
-          {
101
-            ul_errors.append($('<li>').append(response.errors[i]));
102
-          }
103
-  
104
-          $('form[name="add_tag"]').prepend(ul_errors);
105
-        }
106
-  
107 102
         return false;
108 103
       })
109 104
   

+ 91 - 68
src/Muzich/CoreBundle/Resources/public/js/muzich.js 查看文件

@@ -44,11 +44,11 @@ function ResponseController()
44 44
     propagate(response);
45 45
     if (response.status === 'success')
46 46
     {
47
-      success_callback();
47
+      success_callback(response);
48 48
     }
49 49
     else
50 50
     {
51
-      failure_callback();
51
+      failure_callback(response);
52 52
     }
53 53
   }
54 54
 }
@@ -1518,54 +1518,57 @@ $(document).ready(function(){
1518 1518
     $('form[name="add"]').find('img.tag_loader').show();
1519 1519
   });
1520 1520
   $('form[name="add"]').ajaxForm(function(response) {
1521
-    if (response.status == 'mustbeconnected')
1522
-    {
1523
-      $(location).attr('href', url_index);
1524
-    }
1525 1521
     
1526 1522
     $('form[name="add"] img.tag_loader').hide();
1523
+    window.ResponseController.execute(
1524
+      response,
1525
+      function(){},
1526
+      function(){}
1527
+    );
1527 1528
     
1528
-    // Si on en est a la promière étape la réponse sera des données récupérés auprès
1529
-    // des apis
1530
-    if ($('input#form_add_step').val() == '1')
1529
+    if (response.status === 'success')
1531 1530
     {
1532
-      if (element_add_proceed_data_apis(response))
1531
+      // Si on en est a la première étape la réponse sera des données récupérés auprès
1532
+      // des apis
1533
+      if ($('input#form_add_step').val() == '1')
1533 1534
       {
1534
-        // On a plus qu'a afficher les champs
1535
-        $('div#form_add_second_part').slideDown();
1536
-        $('div#form_add_first_part').slideUp();
1537
-        form_add_hide_errors();
1538
-        $('#form_add_loader').hide();
1539
-        $('input#form_add_step').val('2');
1540
-        
1541
-        // On doit avoir le slug du groupe si on ajoute a un groupe
1542
-        if (!$('input#add_element_group_page').length)
1535
+        if (element_add_proceed_data_apis(response))
1543 1536
         {
1544
-          $('form[name="add"]').attr('action', url_element_add);
1537
+          // On a plus qu'a afficher les champs
1538
+          $('div#form_add_second_part').slideDown();
1539
+          $('div#form_add_first_part').slideUp();
1540
+          form_add_hide_errors();
1541
+          $('#form_add_loader').hide();
1542
+          $('input#form_add_step').val('2');
1543
+
1544
+          // On doit avoir le slug du groupe si on ajoute a un groupe
1545
+          if (!$('input#add_element_group_page').length)
1546
+          {
1547
+            $('form[name="add"]').attr('action', url_element_add);
1548
+          }
1549
+          else
1550
+          {
1551
+            $('form[name="add"]').attr('action', url_element_add+'/'+$('input#add_element_group_page').val());
1552
+          }
1553
+          $('span#add_url_title_url').html($('input#element_add_url').val());
1554
+          // Mise a zero des tags
1555
+          window.add_tag_prompt_connector.initializeTags([]);
1556
+          $('input#element_add_need_tags').attr('checked', false);
1545 1557
         }
1546 1558
         else
1547 1559
         {
1548
-          $('form[name="add"]').attr('action', url_element_add+'/'+$('input#add_element_group_page').val());
1560
+          form_add_display_errors(response.errors);
1561
+          $('#form_add_loader').hide();
1549 1562
         }
1550
-        $('span#add_url_title_url').html($('input#element_add_url').val());
1551
-        // Mise a zero des tags
1552
-        window.add_tag_prompt_connector.initializeTags([]);
1553
-        $('input#element_add_need_tags').attr('checked', false);
1554
-      }
1555
-      else
1556
-      {
1557
-        form_add_display_errors(response.errors);
1558
-        $('#form_add_loader').hide();
1559 1563
       }
1560
-    }
1561
-    else if ($('input#form_add_step').val() == '2')
1562
-    {
1563
-      if (element_add_proceed_json_response(response))
1564
+      else if ($('input#form_add_step').val() == '2')
1564 1565
       {
1565
-        form_add_reinit();
1566
+        if (element_add_proceed_json_response(response))
1567
+        {
1568
+          form_add_reinit();
1569
+        }
1566 1570
       }
1567 1571
     }
1568
-
1569 1572
     
1570 1573
     return false;
1571 1574
   });
@@ -2193,10 +2196,12 @@ $(document).ready(function(){
2193 2196
       
2194 2197
       $.getJSON(link.attr('href'), function(response){
2195 2198
         
2196
-        if (response.status == 'mustbeconnected')
2197
-        {
2198
-          $(location).attr('href', url_index);
2199
-        }
2199
+        window.ResponseController.execute(
2200
+          response,
2201
+          function(){},
2202
+          function(){}
2203
+        );
2204
+          
2200 2205
       });
2201 2206
       
2202 2207
       $('div.question').fadeOut();
@@ -2218,21 +2223,28 @@ $(document).ready(function(){
2218 2223
     
2219 2224
     var img = $(this).find('img');
2220 2225
     var link = $(this);
2226
+    var old_img_url = img.attr('src');
2221 2227
     img.attr('src', url_img_ajax_loader);
2222 2228
     
2223 2229
     $.getJSON(link.attr('href'), function(response){
2224
-        
2225
-      if (response.status == 'mustbeconnected')
2226
-      {
2227
-        $(location).attr('href', url_index);
2228
-      }
2229 2230
       
2230
-      if (response.status == 'success')
2231
+      window.ResponseController.execute(
2232
+        response,
2233
+        function(){},
2234
+        function(){}
2235
+      );
2236
+        
2237
+      if (response.status === 'success')
2231 2238
       {
2232 2239
         link.attr('href', response.data.a.href);
2233 2240
         img.attr('src', response.data.img.src);
2234 2241
         link.parents('ul.element_thumb_actions').find('li.score').text(response.data.element.points);
2235 2242
       }
2243
+        
2244
+      if (response.status === 'error')
2245
+      {
2246
+        img.attr('src', old_img_url);
2247
+      }
2236 2248
       
2237 2249
     });
2238 2250
     
@@ -2286,22 +2298,27 @@ $(document).ready(function(){
2286 2298
       li.find('img.element_loader').hide();
2287 2299
       window.ResponseController.execute(
2288 2300
         response,
2289
-        function(){
2290
-          // On prépare le tagBox
2291
-          var table = li.find('table:first');
2292
-          li.find('div.tag_proposition').remove();
2293
-          table.after(response.html);
2301
+        function(){},
2302
+        function(){}
2303
+      );
2304
+      
2305
+      if (response.status === 'success')
2306
+      {
2307
+        // On prépare le tagBox
2308
+        var table = li.find('table:first');
2309
+        li.find('div.tag_proposition').remove();
2310
+        table.after(response.html);
2294 2311
 
2295
-          // Pour le click sur l'input de saisie de tag
2296
-          //li.find('ul.tagbox li.input input[type="text"]').formDefaults();
2312
+        // Pour le click sur l'input de saisie de tag
2313
+        //li.find('ul.tagbox li.input input[type="text"]').formDefaults();
2297 2314
 
2298
-          var options = new Array();
2299
-          options.form_name  = response.form_name;
2300
-          options.tag_init   = response.tags;
2315
+        var options = new Array();
2316
+        options.form_name  = response.form_name;
2317
+        options.tag_init   = response.tags;
2301 2318
 
2302
-          ajax_query_timestamp = null;
2319
+        ajax_query_timestamp = null;
2303 2320
 
2304
-          //$("#tags_prompt_list_"+response.form_name).tagBox(options);
2321
+        //$("#tags_prompt_list_"+response.form_name).tagBox(options);
2305 2322
 
2306 2323
         // On rend ce formulaire ajaxFormable
2307 2324
         $('form[name="'+response.form_name+'"] input[type="submit"]').live('click', function(){
@@ -2335,13 +2352,8 @@ $(document).ready(function(){
2335 2352
 
2336 2353
             li.find('div.tag_proposition div.tags_prompt').prepend(ul_errors);
2337 2354
           }
2338
-
2339 2355
         });
2340
-        },
2341
-        function(){
2342
-          
2343
-        }
2344
-      );
2356
+      }
2345 2357
       
2346 2358
 //      if (response.status === 'mustbeconnected')
2347 2359
 //      {
@@ -2453,10 +2465,12 @@ $(document).ready(function(){
2453 2465
       
2454 2466
       $.getJSON(link.attr('href'), function(response){
2455 2467
         
2456
-        if (response.status == 'mustbeconnected')
2457
-        {
2458
-          $(location).attr('href', url_index);
2459
-        }
2468
+        window.ResponseController.execute(
2469
+          response,
2470
+          function(){},
2471
+          function(){}
2472
+        );
2473
+        
2460 2474
       });
2461 2475
       
2462 2476
       $('div.question').fadeOut();
@@ -2961,6 +2975,14 @@ $(document).ready(function(){
2961 2975
      });
2962 2976
    });
2963 2977
    
2978
+   /*
2979
+    * Buttons for open email confirmation request
2980
+    */
2981
+   
2982
+   $('a#group_add_link_disabled.mustconfirmemail').click(function(){
2983
+     open_ajax_popin(url_email_not_confirmed, function(){});
2984
+   });
2985
+   
2964 2986
 });
2965 2987
 
2966 2988
 function open_ajax_popin(url, callback)
@@ -2985,6 +3007,7 @@ function open_ajax_popin(url, callback)
2985 3007
       }
2986 3008
     }
2987 3009
   });
3010
+  $('html, body').animate({ scrollTop: 0 }, 'fast');
2988 3011
 }
2989 3012
 
2990 3013
 function open_connection_or_subscription_window(open_login_part)

+ 6 - 0
src/Muzich/GroupBundle/Controller/DefaultController.php 查看文件

@@ -8,6 +8,7 @@ use Muzich\CoreBundle\Entity\Group;
8 8
 use Muzich\CoreBundle\Form\Group\GroupForm;
9 9
 use Symfony\Component\HttpFoundation\Request;
10 10
 use Muzich\CoreBundle\Managers\GroupManager;
11
+use Muzich\CoreBundle\Security\Context as SecurityContext;
11 12
 
12 13
 class DefaultController extends Controller
13 14
 {
@@ -53,6 +54,11 @@ class DefaultController extends Controller
53 54
   {
54 55
     $user = $this->getUser();
55 56
     
57
+if (($non_condition = $this->userHaveNonConditionToMakeAction(SecurityContext::ACTION_GROUP_ADD)) !== false)
58
+    {
59
+      throw $this->createNotFoundException();
60
+    }
61
+    
56 62
     /**
57 63
      * Bug lors des tests: L'user n'est pas 'lié' a celui en base par doctrine.
58 64
      * Docrine le voit si on faire une requete directe.

+ 15 - 8
src/Muzich/GroupBundle/Resources/views/Default/myList.html.twig 查看文件

@@ -7,14 +7,21 @@
7 7
 
8 8
   <div class="top_tools">
9 9
     
10
-    <a href="#" id="group_add_link" class="button gradient justtopright">
11
-      {{ 'group.add_group'|trans({}, 'navigationui') }}
12
-      <img src="{{ asset('/img/icon_dart_right_white.png') }}" alt="" />
13
-    </a>
14
-    <a href="#" id="group_add_close_link" class="button gradient justtopright" style="display: none;">
15
-      {{ 'group.add_group_box.close'|trans({}, 'navigationui') }}
16
-      <img src="{{ asset('/img/icon_dart_left_white.png') }}" alt="" />
17
-    </a>
10
+    {% if app.user.emailConfirmed %}
11
+      <a href="#" id="group_add_link" class="button gradient justtopright">
12
+        {{ 'group.add_group'|trans({}, 'navigationui') }}
13
+        <img src="{{ asset('/img/icon_dart_right_white.png') }}" alt="" />
14
+      </a>
15
+      <a href="#" id="group_add_close_link" class="button gradient justtopright" style="display: none;">
16
+        {{ 'group.add_group_box.close'|trans({}, 'navigationui') }}
17
+        <img src="{{ asset('/img/icon_dart_left_white.png') }}" alt="" />
18
+      </a>
19
+    {% else %}
20
+      <a href="#" id="group_add_link_disabled" class="button gradient justtopright mustconfirmemail">
21
+        {{ 'group.add_group'|trans({}, 'navigationui') }}
22
+        <img src="{{ asset('/img/icon_dart_right_white.png') }}" alt="" />
23
+      </a>
24
+    {% endif %}
18 25
     
19 26
   </div>
20 27