Browse Source

Evolution #350: reSharing

Sevajol Bastien 12 years ago
parent
commit
c382e5cd1e

+ 1 - 0
app/Resources/translations/elements.fr.yml View File

21
   name:
21
   name:
22
     who:                envoyé par <a href="%owner_url%">%owner_name%</a>
22
     who:                envoyé par <a href="%owner_url%">%owner_name%</a>
23
     whoandgroup:        envoyé par <a href="%owner_url%">%owner_name%</a> dans le groupe <a href="%group_url%">%group_name%</a>
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
   link:                 Ouvrir la page d'origine
25
   link:                 Ouvrir la page d'origine
25
   edit:
26
   edit:
26
     link:               Modifier
27
     link:               Modifier

+ 1 - 1
app/Resources/translations/userui.fr.yml View File

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

+ 15 - 7
src/Muzich/CoreBundle/Resources/views/SearchElement/element.html.twig View File

58
           href="{{ path('ajax_element_propose_tags_open', {'element_id' : element.id}) }}">
58
           href="{{ path('ajax_element_propose_tags_open', {'element_id' : element.id}) }}">
59
           <img src="{{ asset('bundles/muzichcore/img/1333484018_rss-tag.png') }}" alt="tags_proposition" />
59
           <img src="{{ asset('bundles/muzichcore/img/1333484018_rss-tag.png') }}" alt="tags_proposition" />
60
         </a>
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
         <a title="{{ 'element.report.link_title'|trans({}, 'userui') }}" 
68
         <a title="{{ 'element.report.link_title'|trans({}, 'userui') }}" 
63
           class="element_report" 
69
           class="element_report" 
64
           href="{{ path('ajax_report_element', {'element_id':element.id, 'token':app.user.getPersonalHash}) }}">
70
           href="{{ path('ajax_report_element', {'element_id':element.id, 'token':app.user.getPersonalHash}) }}">
65
           <img src="{{ asset('bundles/muzichcore/img/1331832708_comment_alert.png') }}" alt="report" />
71
           <img src="{{ asset('bundles/muzichcore/img/1331832708_comment_alert.png') }}" alt="report" />
66
         </a>
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
       {% endif %}
74
       {% endif %}
75
       
75
       
111
             '%owner_name%' : element.owner.name
111
             '%owner_name%' : element.owner.name
112
           }, 'elements') }}
112
           }, 'elements') }}
113
         {% endif %}
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
       {% endautoescape %}
123
       {% endautoescape %}
115
-      {{ element.created.date|date_or_relative_date }}
116
       
124
       
117
       <div class="loader">
125
       <div class="loader">
118
         <img class="element_loader" style="display: none;" src="{{ asset('/bundles/muzichcore/img/ajax-loader.gif') }}" alt="loading"/>
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 View File

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

+ 45 - 0
src/Muzich/CoreBundle/Tests/Controller/ElementControllerTest.php View File

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 View File

497
       return $output;
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 View File


+ 9 - 4
web/bundles/muzichcore/js/muzich.js View File

214
 // fonction de nettoyage des tags
214
 // fonction de nettoyage des tags
215
 function remove_tags(form_name)
215
 function remove_tags(form_name)
216
 {
216
 {
217
-  tagsAddeds[form_name] = new Array();
217
+  //tagsAddeds[form_name] = new Array();
218
   $('form[name="'+form_name+'"] ul.tagbox li.tag').remove();
218
   $('form[name="'+form_name+'"] ul.tagbox li.tag').remove();
219
   $('form[name="'+form_name+'"] input.tagBox_tags_ids').val('');
219
   $('form[name="'+form_name+'"] input.tagBox_tags_ids').val('');
220
   $('div#tags_prompt_'+form_name+' ul.tagbox li.input input[type="text"]')
220
   $('div#tags_prompt_'+form_name+' ul.tagbox li.input input[type="text"]')
2045
     cancelAnswer : string_elementreshare_confirm_no,
2045
     cancelAnswer : string_elementreshare_confirm_no,
2046
     onYes: function(link){
2046
     onYes: function(link){
2047
       
2047
       
2048
+      $('div.question').fadeOut();
2048
       $.getJSON(link.attr('href'), function(response){
2049
       $.getJSON(link.attr('href'), function(response){
2049
         
2050
         
2050
         if (response.status == 'mustbeconnected')
2051
         if (response.status == 'mustbeconnected')
2052
           $(location).attr('href', url_index);
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
         return false;
2063
         return false;
2058
-        
2059
       });
2064
       });
2060
       
2065
       
2061
       
2066