ソースを参照

Evolution #350: reSharing

Sevajol Bastien 12 年 前
コミット
c382e5cd1e

+ 1 - 0
app/Resources/translations/elements.fr.yml ファイルの表示

@@ -21,6 +21,7 @@ element:
21 21
   name:
22 22
     who:                envoyé par <a href="%owner_url%">%owner_name%</a>
23 23
     whoandgroup:        envoyé par <a href="%owner_url%">%owner_name%</a> dans le groupe <a href="%group_url%">%group_name%</a>
24
+    reshare:            (re-partagé d'un partage de <a href="%owner_url%">%owner_name%</a>)
24 25
   link:                 Ouvrir la page d'origine
25 26
   edit:
26 27
     link:               Modifier

+ 1 - 1
app/Resources/translations/userui.fr.yml ファイルの表示

@@ -134,7 +134,7 @@ element:
134 134
   reshare:
135 135
     link_title:        Re-partager
136 136
     confirm: 
137
-      sentence:          Re-partager ce partage ?
137
+      sentence:          Re-partager ce partage dans votre flux ?
138 138
       yes:               Oui
139 139
       no:                Non
140 140
     

+ 15 - 7
src/Muzich/CoreBundle/Resources/views/SearchElement/element.html.twig ファイルの表示

@@ -58,18 +58,18 @@
58 58
           href="{{ path('ajax_element_propose_tags_open', {'element_id' : element.id}) }}">
59 59
           <img src="{{ asset('bundles/muzichcore/img/1333484018_rss-tag.png') }}" alt="tags_proposition" />
60 60
         </a>
61
+        
62
+        <a title="{{ 'element.reshare.link_title'|trans({}, 'userui') }}" 
63
+          class="element_reshare" 
64
+          href="{{ path('ajax_reshare_element', {'element_id':element.id, 'token':app.user.getPersonalHash('reshare_'~element.id)}) }}">
65
+          <img src="{{ asset('bundles/muzichcore/img/1349338086_adept_update.png') }}" alt="re" />
66
+        </a>
61 67
       
62 68
         <a title="{{ 'element.report.link_title'|trans({}, 'userui') }}" 
63 69
           class="element_report" 
64 70
           href="{{ path('ajax_report_element', {'element_id':element.id, 'token':app.user.getPersonalHash}) }}">
65 71
           <img src="{{ asset('bundles/muzichcore/img/1331832708_comment_alert.png') }}" alt="report" />
66 72
         </a>
67
-        
68
-        <a title="{{ 'element.reshare.link_title'|trans({}, 'userui') }}" 
69
-          class="element_reshare" 
70
-          href="{{ path('ajax_reshare_element', {'element_id':element.id, 'token':app.user.getPersonalHash('reshare_'~element.id)}) }}">
71
-          <img src="{{ asset('bundles/muzichcore/img/') }}" alt="re" />
72
-        </a>
73 73
       
74 74
       {% endif %}
75 75
       
@@ -111,8 +111,16 @@
111 111
             '%owner_name%' : element.owner.name
112 112
           }, 'elements') }}
113 113
         {% endif %}
114
+      
115
+        {{ element.created.date|date_or_relative_date }}
116
+      
117
+        {% if element.parent %}
118
+          {{ 'element.name.reshare'|trans({
119
+            '%owner_url%'  : path('show_user', {'slug': element.parent.owner.slug}),
120
+            '%owner_name%' : element.parent.owner.name
121
+          }, 'elements') }}
122
+        {% endif %}
114 123
       {% endautoescape %}
115
-      {{ element.created.date|date_or_relative_date }}
116 124
       
117 125
       <div class="loader">
118 126
         <img class="element_loader" style="display: none;" src="{{ asset('/bundles/muzichcore/img/ajax-loader.gif') }}" alt="loading"/>

+ 3 - 1
src/Muzich/CoreBundle/Searcher/ElementSearcherQueryBuilder.php ファイルの表示

@@ -358,9 +358,11 @@ class ElementSearcherQueryBuilder
358 358
     
359 359
     // On prépare la requete des elements
360 360
     $this->query_elements = $this->em->createQueryBuilder()
361
-      ->select('e', 't', 'o', 'g', 'fav')
361
+      ->select('e', 'p', 'po', 't', 'o', 'g', 'fav')
362 362
       ->from('MuzichCoreBundle:Element', 'e')
363 363
       ->leftJoin('e.group', 'g')
364
+      ->leftJoin('e.parent', 'p')
365
+      ->leftJoin('p.owner', 'po')
364 366
       ->leftJoin('e.tags', 't', Join::WITH, 
365 367
         "(t.tomoderate = 'FALSE' OR t.tomoderate IS NULL OR t.privateids LIKE :uidt)")
366 368
       ->leftJoin('e.elements_favorites', 'fav', Join::WITH,

+ 45 - 0
src/Muzich/CoreBundle/Tests/Controller/ElementControllerTest.php ファイルの表示

@@ -1194,4 +1194,49 @@ class ElementControllerTest extends FunctionalTest
1194 1194
     
1195 1195
   }
1196 1196
   
1197
+  public function testResharing()
1198
+  {
1199
+    $this->client = self::createClient();
1200
+    $this->connectUser('paul', 'toor');
1201
+    
1202
+    $paul = $this->getUser();
1203
+    
1204
+    // Cet élément a été partagé par bux
1205
+    $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
1206
+      ->findOneByName('AZYD AZYLUM Live au Café Provisoire')
1207
+    ;
1208
+    
1209
+    // On effectue la requete ajax
1210
+    // paul propose une serie de tags
1211
+    $crawler = $this->client->request(
1212
+      'POST', 
1213
+      $this->generateUrl('ajax_reshare_element', 
1214
+        array(
1215
+          'element_id' => $element->getId(), 
1216
+          'token' => $paul->getPersonalHash('reshare_'.$element->getId())
1217
+       )
1218
+      ), 
1219
+      array(), 
1220
+      array(), 
1221
+      array('HTTP_X-Requested-With' => 'XMLHttpRequest')
1222
+    );
1223
+    
1224
+    $this->isResponseSuccess();
1225
+    // tout c'est bien passé
1226
+    $response = json_decode($this->client->getResponse()->getContent(), true);
1227
+    $this->assertEquals($response['status'], 'success');
1228
+    
1229
+    // L'objet est en base
1230
+    $element_reshared = $this->findOneBy('Element', array(
1231
+      'name'   => 'AZYD AZYLUM Live au Café Provisoire',
1232
+      'owner'  => $paul->getId(),
1233
+      'parent' => $element->getId()
1234
+    ));
1235
+    
1236
+    // L'objet est bien en base
1237
+    $this->assertTrue(!is_null($element_reshared));
1238
+    
1239
+    
1240
+  }
1241
+  
1197 1242
 }

+ 23 - 0
src/Muzich/CoreBundle/lib/FunctionalTest.php ファイルの表示

@@ -497,4 +497,27 @@ class FunctionalTest extends WebTestCase
497 497
       return $output;
498 498
   }
499 499
   
500
+  /**
501
+   *
502
+   * @return \Doctrine\ORM\EntityManager 
503
+   */
504
+  protected function getEntityManager()
505
+  {
506
+    return $this->getDoctrine()->getEntityManager();
507
+  }
508
+  
509
+  /**
510
+   * Raccourcis de findOneBy
511
+   * 
512
+   * @param string $entityName
513
+   * @param array $params
514
+   * @return object 
515
+   */
516
+  protected function findOneBy($entityName, array $params)
517
+  {
518
+    return $this->getEntityManager()->getRepository('MuzichCoreBundle:'.$entityName)
519
+      ->findOneBy($params);
520
+  }
521
+  
522
+  
500 523
 }

BIN
web/bundles/muzichcore/img/1349338086_adept_update.png ファイルの表示


+ 9 - 4
web/bundles/muzichcore/js/muzich.js ファイルの表示

@@ -214,7 +214,7 @@ function explode (delimiter, string, limit) {
214 214
 // fonction de nettoyage des tags
215 215
 function remove_tags(form_name)
216 216
 {
217
-  tagsAddeds[form_name] = new Array();
217
+  //tagsAddeds[form_name] = new Array();
218 218
   $('form[name="'+form_name+'"] ul.tagbox li.tag').remove();
219 219
   $('form[name="'+form_name+'"] input.tagBox_tags_ids').val('');
220 220
   $('div#tags_prompt_'+form_name+' ul.tagbox li.input input[type="text"]')
@@ -2045,6 +2045,7 @@ $(document).ready(function(){
2045 2045
     cancelAnswer : string_elementreshare_confirm_no,
2046 2046
     onYes: function(link){
2047 2047
       
2048
+      $('div.question').fadeOut();
2048 2049
       $.getJSON(link.attr('href'), function(response){
2049 2050
         
2050 2051
         if (response.status == 'mustbeconnected')
@@ -2052,10 +2053,14 @@ $(document).ready(function(){
2052 2053
           $(location).attr('href', url_index);
2053 2054
         }
2054 2055
         
2055
-        element_add_proceed_json_response(response);
2056
-        $('div.question').fadeOut();
2056
+        // On affiche l'élément que si on voit que le formulaire est sur la page
2057
+        // Sinon c'est qu'on est sur une page ou on a pas normalement la possibilité
2058
+        // d'ajouetr un élément.
2059
+        if ($('form[name="add"]').length)
2060
+        {
2061
+          element_add_proceed_json_response(response);
2062
+        }
2057 2063
         return false;
2058
-        
2059 2064
       });
2060 2065
       
2061 2066