Browse Source

Evolution #151: Evenements

bastien 12 years ago
parent
commit
30e2b72ec4

+ 1 - 1
src/Muzich/CoreBundle/Entity/Event.php View File

@@ -18,7 +18,7 @@ use Gedmo\Mapping\Annotation as Gedmo;
18 18
 class Event
19 19
 {
20 20
   
21
-  const TYPE_COMMENT_ADDED_OWNED_ELEMENT = "com.add.ow.e";
21
+  const TYPE_COMMENT_ADDED_ELEMENT = "com.adde.ele";
22 22
   
23 23
   /**
24 24
    * @ORM\Id

+ 13 - 1
src/Muzich/CoreBundle/Extension/MyTwigExtension.php View File

@@ -24,7 +24,8 @@ class MyTwigExtension extends \Twig_Extension {
24 24
   
25 25
   public function getFunctions() {
26 26
     return array(
27
-      'date_or_relative_date'  => new \Twig_Filter_Method($this, 'date_or_relative_date')
27
+      'date_or_relative_date'  => new \Twig_Filter_Method($this, 'date_or_relative_date'),
28
+      'event_const'  => new \Twig_Filter_Method($this, 'event_const')
28 29
     );
29 30
   }
30 31
   
@@ -115,5 +116,16 @@ class MyTwigExtension extends \Twig_Extension {
115 116
     $date = str_replace(':', '', $date);
116 117
     return $date;
117 118
   }
119
+  
120
+  public function event_const($const_name)
121
+  {
122
+    switch ($const_name)
123
+    {
124
+      case 'TYPE_COMMENT_ADDED_ELEMENT':
125
+        return \Muzich\CoreBundle\Entity\Event::TYPE_COMMENT_ADDED_ELEMENT;
126
+      break;
127
+    }
128
+    return null;
129
+  }
118 130
 
119 131
 }

+ 2 - 2
src/Muzich/CoreBundle/Propagator/EventElementComment.php View File

@@ -27,7 +27,7 @@ class EventElementComment extends EventPropagator
27 27
           (e.view = \'FALSE\' OR e.view = \'0\')'
28 28
       )->setParameters(array(
29 29
         'uid' => $element->getOwner()->getId(),
30
-        'type' => Event::TYPE_COMMENT_ADDED_OWNED_ELEMENT
30
+        'type' => Event::TYPE_COMMENT_ADDED_ELEMENT
31 31
       ))->getSingleResult()
32 32
       ;
33 33
       $new = false;
@@ -42,7 +42,7 @@ class EventElementComment extends EventPropagator
42 42
     if ($new)
43 43
     {
44 44
       $uea->createEvent(
45
-        Event::TYPE_COMMENT_ADDED_OWNED_ELEMENT,
45
+        Event::TYPE_COMMENT_ADDED_ELEMENT,
46 46
         $element->getId()
47 47
       );
48 48
     }

+ 22 - 1
src/Muzich/CoreBundle/Repository/EventRepository.php View File

@@ -4,7 +4,28 @@ namespace Muzich\CoreBundle\Repository;
4 4
 
5 5
 use Doctrine\ORM\EntityRepository;
6 6
 
7
-class ElementRepository extends EntityRepository
7
+class EventRepository extends EntityRepository
8 8
 {
9
+  
10
+  public function getNotViewEvents($user_id)
11
+  {
12
+    $events = array();
13
+    $result = $this->getEntityManager()
14
+      ->createQuery('
15
+        SELECT e FROM MuzichCoreBundle:Event e
16
+        WHERE e.user = :uid AND 
17
+        (e.view = \'FALSE\' OR e.view = \'0\')'
18
+      )
19
+      ->setParameter('uid', $user_id)
20
+      ->getArrayResult()
21
+    ;
9 22
     
23
+    foreach ($result as $event)
24
+    {
25
+      $events[$event['type']] = $event;
26
+    }
27
+    
28
+    return $events;
29
+  }
30
+  
10 31
 }

+ 7 - 3
src/Muzich/CoreBundle/Resources/views/layout.html.twig View File

@@ -75,13 +75,17 @@
75 75
       </p>
76 76
     </div>
77 77
   </noscript>
78
-  
78
+      
79 79
   <div id="container">
80
+    
81
+    {% if is_granted("IS_AUTHENTICATED_REMEMBERED") %}
82
+      {% render "MuzichUserBundle:User:infoBar" %}
83
+    {% endif %}
84
+    
80 85
     {% block main_content %}{% endblock %}
81 86
     {% block fos_user_content %}{% endblock %}
82 87
   </div>
83
-  
84
-  
88
+    
85 89
   {% for key, flash in app.session.getFlashes() %}
86 90
     <div class="{{ key }} message">
87 91
       <a class="message-close" href="#" title="fermer"><img alt="close" src="{{ asset('bundles/muzichcore/img/1317386146_cancel.png') }}" /></a>

+ 11 - 0
src/Muzich/UserBundle/Controller/UserController.php View File

@@ -566,5 +566,16 @@ class UserController extends Controller
566 566
       'status' => 'success'
567 567
     ));
568 568
   }
569
+  
570
+  public function infoBarAction()
571
+  {
572
+    $events = $this->getDoctrine()->getRepository('MuzichCoreBundle:Event')
573
+      ->getNotViewEvents($this->getUserId())
574
+    ;
575
+    
576
+    return $this->render('MuzichUserBundle:Info:bar.html.twig', array(
577
+      'events' => $events
578
+    ));
579
+  }
569 580
     
570 581
 }

+ 17 - 0
src/Muzich/UserBundle/Resources/views/Info/bar.html.twig View File

@@ -0,0 +1,17 @@
1
+<div id="events">
2
+    
3
+    <div class="score">
4
+      <img src="{{ asset('bundles/muzichcore/img/1332286466_stock_scores.png') }}" alt="" />
5
+      <span>{{ app.user.reputation }}</span>
6
+    </div>
7
+    
8
+    <div class="comments">
9
+      <img src="{{ asset('bundles/muzichcore/img/1332286007_comments_reply.png') }}" alt="" />
10
+      {% if events[event_const('TYPE_COMMENT_ADDED_ELEMENT')] is defined %}
11
+        <span>{{ events[event_const('TYPE_COMMENT_ADDED_ELEMENT')].count }}</span>
12
+      {% else %}
13
+        <span>0</span>
14
+      {% endif %}
15
+    </div>
16
+  
17
+  </div>

+ 45 - 0
web/bundles/muzichcore/css/main.css View File

@@ -1097,4 +1097,49 @@ div.reputation span.score
1097 1097
 {
1098 1098
   font-size: 125%;
1099 1099
   font-weight: bold;
1100
+}
1101
+
1102
+div#events
1103
+{
1104
+  width: 62px;
1105
+  position: absolute;
1106
+  margin-top: 50px;
1107
+  margin-left: 650px;
1108
+  background-color: white;
1109
+  padding: 4px;
1110
+  
1111
+  border-top: 0px solid #d5d5d5;
1112
+  border-right: 0px solid #d5d5d5;
1113
+  border-bottom: 0px solid #d5d5d5;
1114
+  border-left: none;
1115
+  border-radius: 0px 5px 5px 0px;
1116
+  -moz-border-radius: 0px 5px 5px 0px;
1117
+  -webkit-border-radius: 0px 5px 5px 0px;
1118
+  
1119
+  -webkit-box-shadow: 2px 2px 2px #666;
1120
+  -moz-box-shadow: 2px 2px 2px #666 ;
1121
+  box-shadow: 2px 2px 2px #666;
1122
+}
1123
+
1124
+div#events div.score img
1125
+{
1126
+  margin-bottom: -5px;
1127
+}
1128
+
1129
+div#events div.score span
1130
+{
1131
+  font-weight: bold;
1132
+  padding-bottom: 2px;
1133
+}
1134
+
1135
+div#events div.comments img
1136
+{
1137
+  margin-left: 3px;
1138
+  margin-bottom: -4px;
1139
+}
1140
+
1141
+div#events div.comments span
1142
+{
1143
+  font-weight: bold;
1144
+  margin-left: 5px;
1100 1145
 }

BIN
web/bundles/muzichcore/img/1332286007_comments_reply.png View File


BIN
web/bundles/muzichcore/img/1332286466_stock_scores.png View File