Parcourir la source

Evolution #706: TagPrompt tool: favoris: anonyme

Bastien Sevajol il y a 11 ans
Parent
révision
e38faab305

+ 7 - 0
src/Muzich/CoreBundle/Controller/CoreController.php Voir le fichier

@@ -433,18 +433,25 @@ class CoreController extends Controller
433 433
    */
434 434
   public function getDefaultTagsAction($favorites = false)
435 435
   {    
436
+    if ($favorites && ($non_condition = $this->userHaveNonConditionToMakeAction(SecurityContext::ACTION_GET_FAVORITES_TAGS)) !== false)
437
+    {
438
+      return $this->jsonResponseError($non_condition);
439
+    }
440
+    
436 441
     $last_tags = $this->get("session")->get('user.element_search.last_tags');
437 442
     if (!count($last_tags) || $favorites)
438 443
     {
439 444
       $es = $this->getElementSearcher(null, true);
440 445
       return $this->jsonResponse(array(
441 446
         'response' => 'success',
447
+        'status' => 'success',
442 448
         'tags'     => $es->getTags()
443 449
       ));
444 450
     }
445 451
     
446 452
     return $this->jsonResponse(array(
447 453
         'response' => 'success',
454
+        'status' => 'success',
448 455
         'tags'     => $last_tags
449 456
       ));
450 457
   }

+ 4 - 0
src/Muzich/CoreBundle/Security/Context.php Voir le fichier

@@ -17,6 +17,7 @@ class Context
17 17
   const ACTION_COMMENT_ALERT = 7;
18 18
   const ACTION_USER_FOLLOW = 8;
19 19
   const ACTION_TAG_ADD = 9;
20
+  const ACTION_GET_FAVORITES_TAGS = 10;
20 21
   
21 22
   const AFFECT_CANT_MAKE = 0;
22 23
   const AFFECT_NO_SCORING = 1;
@@ -62,6 +63,9 @@ class Context
62 63
       ),
63 64
       self::ACTION_USER_FOLLOW => array(
64 65
         self::CONDITION_USER_NOT_CONNECTED
66
+      ),
67
+      self::ACTION_GET_FAVORITES_TAGS => array(
68
+        self::CONDITION_USER_NOT_CONNECTED
65 69
       )
66 70
     ),
67 71
     self::AFFECT_NO_SCORING => array(

+ 5 - 0
src/Muzich/CoreBundle/Tests/Controller/AnonymousTest.php Voir le fichier

@@ -88,6 +88,11 @@ class NoPassTest extends FunctionalTest
88 88
       SecurityContext::CONDITION_USER_NOT_CONNECTED,
89 89
       $match
90 90
     );
91
+    $this->security_context_test->testUserCantMakeActionStatus( 
92
+      SecurityContext::ACTION_GET_FAVORITES_TAGS, 
93
+      SecurityContext::CONDITION_USER_NOT_CONNECTED,
94
+      $match
95
+    );
91 96
   }
92 97
   
93 98
   protected function registerUser($email)

+ 2 - 0
src/Muzich/CoreBundle/Tests/Security/ContextTest.php Voir le fichier

@@ -68,6 +68,7 @@ class ContextTest extends \PHPUnit_Framework_TestCase
68 68
     $this->assertFalse($secutiry_context->canMakeAction(SecurityContext::ACTION_GROUP_ADD));
69 69
     $this->assertFalse($secutiry_context->canMakeAction(SecurityContext::ACTION_USER_FOLLOW));
70 70
     $this->assertFalse($secutiry_context->canMakeAction(SecurityContext::ACTION_ELEMENT_ADD_TO_FAVORITES));
71
+    $this->assertFalse($secutiry_context->canMakeAction(SecurityContext::ACTION_GET_FAVORITES_TAGS));
71 72
     
72 73
     $this->assertEquals('UserNotConnected', $secutiry_context->actionIsAffectedBy(SecurityContext::AFFECT_CANT_MAKE, SecurityContext::ACTION_ELEMENT_ADD));
73 74
     $this->assertEquals('UserNotConnected', $secutiry_context->actionIsAffectedBy(SecurityContext::AFFECT_CANT_MAKE, SecurityContext::ACTION_ELEMENT_NOTE));
@@ -79,6 +80,7 @@ class ContextTest extends \PHPUnit_Framework_TestCase
79 80
     $this->assertEquals('UserNotConnected', $secutiry_context->actionIsAffectedBy(SecurityContext::AFFECT_CANT_MAKE, SecurityContext::ACTION_ELEMENT_TAGS_PROPOSITION));
80 81
     $this->assertEquals('UserNotConnected', $secutiry_context->actionIsAffectedBy(SecurityContext::AFFECT_CANT_MAKE, SecurityContext::ACTION_GROUP_ADD));
81 82
     $this->assertEquals('UserNotConnected', $secutiry_context->actionIsAffectedBy(SecurityContext::AFFECT_CANT_MAKE, SecurityContext::ACTION_ELEMENT_ADD_TO_FAVORITES));
83
+    $this->assertEquals('UserNotConnected', $secutiry_context->actionIsAffectedBy(SecurityContext::AFFECT_CANT_MAKE, SecurityContext::ACTION_GET_FAVORITES_TAGS));
82 84
   }
83 85
   
84 86
 }

+ 3 - 0
src/Muzich/CoreBundle/Tests/lib/Security/Context.php Voir le fichier

@@ -75,6 +75,9 @@ class Context
75 75
       case SecurityContext::ACTION_USER_FOLLOW:
76 76
         return $this->security_context_tests->followUserResponseIs($success, $condition);
77 77
       break;
78
+      case SecurityContext::ACTION_GET_FAVORITES_TAGS:
79
+        return $this->security_context_tests->getFavoritesTagsResponseIs($success, $condition);
80
+      break;
78 81
       default:
79 82
         throw new \Exception('Action unknow');
80 83
     }

+ 14 - 0
src/Muzich/CoreBundle/Tests/lib/Security/ContextTestCases.php Voir le fichier

@@ -224,4 +224,18 @@ class ContextTestCases
224 224
     );
225 225
   }
226 226
   
227
+  public function getFavoritesTagsResponseIs($success, $condition)
228
+  {
229
+    return $this->responseSatisfyConditions(
230
+      $this->getAjaxRequestContentResponse(
231
+        'GET',
232
+        $this->test->generateUrl('ajax_get_favorites_tags', array(
233
+          'favorites' => true
234
+        ))
235
+      ), 
236
+      $success, 
237
+      $condition
238
+    );
239
+  }
240
+  
227 241
 }