Can set events as being important
authorx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Mon, 5 Mar 2007 15:49:22 +0000 (15:49 +0000)
committerx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Mon, 5 Mar 2007 15:49:22 +0000 (15:49 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1549 839d8a87-29fc-0310-9880-83ba4fa771e5

ChangeLog
modules/events.php
modules/lists.php
modules/search.php
modules/xnetgrp.php
templates/events/form.tpl
templates/events/index.tpl

index 9c18bc5..a28925b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -9,6 +9,7 @@ New:
 
     * Events:
         - #643: Sort menu                                                  -FRU
+        - Can set events as important                                      -FRU
 
     * Search:
         - Search Engine IE7 compatible                                     -FRU
index 96885f8..71eaaa2 100644 (file)
@@ -26,11 +26,11 @@ class EventsModule extends PLModule
         return array(
             'events'         => $this->make_hook('ev',        AUTH_COOKIE),
             'rss'            => $this->make_hook('rss', AUTH_PUBLIC),
-            'events/preview' => $this->make_hook('preview', AUTH_PUBLIC, '', NO_AUTH),
+            'events/preview' => $this->make_hook('preview', AUTH_PUBLIC, 'user', NO_AUTH),
             'events/submit'  => $this->make_hook('ev_submit', AUTH_MDP),
             'admin/events'   => $this->make_hook('admin_events',     AUTH_MDP, 'admin'),
 
-            'ajax/tips'      => $this->make_hook('tips',      AUTH_COOKIE, '', NO_AUTH),
+            'ajax/tips'      => $this->make_hook('tips',      AUTH_COOKIE, 'user', NO_AUTH),
             'admin/tips'     => $this->make_hook('admin_tips', AUTH_MDP, 'admin'),
         );
     }
@@ -89,7 +89,7 @@ class EventsModule extends PLModule
         $sql = "SELECT  e.id,e.titre, ev.user_id IS NULL AS nonlu
                   FROM  evenements    AS e
             LEFT JOIN   evenements_vus AS ev ON (e.id = ev.evt_id AND ev.user_id = {?})
-                 WHERE  FIND_IN_SET(e.flags, 'valide') AND peremption >= NOW()
+                 WHERE  FIND_IN_SET('valide', e.flags) AND peremption >= NOW()
                         AND (e.promo_min = 0 || e.promo_min <= {?})
                         AND (e.promo_max = 0 || e.promo_max >= {?})
                         AND $where
@@ -103,7 +103,7 @@ class EventsModule extends PLModule
             INNER JOIN  auth_user_md5  AS a ON e.user_id=a.user_id
             INNER JOIN  aliases        AS l ON ( a.user_id=l.id AND l.type='a_vie' )
              LEFT JOIN  evenements_vus AS ev ON (e.id = ev.evt_id AND ev.user_id = {?})
-                 WHERE  FIND_IN_SET(e.flags, 'valide') AND peremption >= NOW()
+                 WHERE  FIND_IN_SET('valide', e.flags) AND peremption >= NOW()
                         AND (e.promo_min = 0 || e.promo_min <= {?})
                         AND (e.promo_max = 0 || e.promo_max >= {?})
                         AND ev.user_id IS NULL
@@ -175,13 +175,17 @@ class EventsModule extends PLModule
         }
 
         $array = array();
-        $this->get_events('e.creation_date > DATE_SUB(CURDATE(), INTERVAL 2 DAY)',
+        $this->get_events('FIND_IN_SET(\'important\', e.flags)', 'e.creation_date DESC', $array, 'important');
+        $this->get_events('e.creation_date > DATE_SUB(CURDATE(), INTERVAL 2 DAY)
+                          AND NOT FIND_IN_SET(\'important\', e.flags)',
                           'e.creation_date DESC', $array, 'news');
         $this->get_events('e.peremption < DATE_ADD(CURDATE(), INTERVAL 2 DAY)
-                          AND e.creation_date <= DATE_SUB(CURDATE(), INTERVAL 2 DAY)',
+                          AND e.creation_date <= DATE_SUB(CURDATE(), INTERVAL 2 DAY)
+                          AND NOT FIND_IN_SET(\'important\', e.flags)',
                           'e.peremption, e.creation_date DESC', $array, 'end');
         $this->get_events('e.peremption >= DATE_ADD(CURDATE(), INTERVAL 2 DAY)
-                          AND e.creation_date <= DATE_SUB(CURDATE(), INTERVAL 2 DAY)',
+                          AND e.creation_date <= DATE_SUB(CURDATE(), INTERVAL 2 DAY)
+                          AND NOT FIND_IN_SET(\'important\', e.flags)',
                           'e.peremption, e.creation_date DESC', $array, 'body');
         $page->assign_by_ref('events', $array);
     }
@@ -334,26 +338,36 @@ class EventsModule extends PLModule
                 $page->trig("L'intervalle de promotions $promo_min -> $promo_max n'est pas valide");
                 $action = 'edit';
             } else {
+                $res = XDB::query('SELECT flags FROM evenements WHERE id = {?}', $eid);
+                $flags = new FlagSet($res->fetchOneCell());
+                if (Post::v('important')) {
+                    $flags->addFlag('important');
+                } else {
+                    $flags->rmFlag('important');
+                } 
                 XDB::execute('UPDATE evenements
                                  SET creation_date = creation_date, 
-                                     titre={?}, texte={?}, peremption={?}, promo_min={?}, promo_max={?}
+                                     titre={?}, texte={?}, peremption={?}, promo_min={?}, promo_max={?},
+                                     flags = {?}
                                WHERE id = {?}', 
                               Post::v('titre'), Post::v('texte'), Post::v('peremption'),
-                              Post::v('promo_min'), Post::v('promo_max'), $eid);
+                              Post::v('promo_min'), Post::v('promo_max'),
+                              $flags->flags(), $eid);
             }    
         }
 
         if ($action == 'edit') {
-            $res = XDB::query('SELECT titre, texte, peremption, promo_min, promo_max
+            $res = XDB::query('SELECT titre, texte, peremption, promo_min, promo_max, FIND_IN_SET(\'important\', flags)
                                  FROM evenements
                                 WHERE id={?}', $eid);
-            list($titre, $texte, $peremption, $promo_min, $promo_max) = $res->fetchOneRow();
+            list($titre, $texte, $peremption, $promo_min, $promo_max, $important) = $res->fetchOneRow();
             $page->assign('titre',$titre);
             $page->assign('texte',$texte);
             $page->assign('texte_html', pl_entity_decode($texte));
             $page->assign('promo_min',$promo_min);
             $page->assign('promo_max',$promo_max);
             $page->assign('peremption',$peremption);
+            $page->assign('important', $important);
 
             $select = "";
             for ($i = 1 ; $i < 30 ; $i++) {
@@ -417,6 +431,7 @@ class EventsModule extends PLModule
             $page->assign('evs', XDB::iterator($sql));
         }
         $page->assign('arch', $arch);
+        $page->assign('admin_evts', true);
     }   
 }
 
index cfd66e1..16c5016 100644 (file)
@@ -27,7 +27,7 @@ class ListsModule extends PLModule
     {
         return array(
             'lists'           => $this->make_hook('lists',     AUTH_MDP),
-            'lists/ajax'      => $this->make_hook('ajax',      AUTH_MDP, '', NO_AUTH),
+            'lists/ajax'      => $this->make_hook('ajax',      AUTH_MDP, 'user', NO_AUTH),
             'lists/create'    => $this->make_hook('create',    AUTH_MDP),
 
             'lists/members'   => $this->make_hook('members',   AUTH_COOKIE),
@@ -42,7 +42,7 @@ class ListsModule extends PLModule
 
             'lists/soptions'  => $this->make_hook('soptions',  AUTH_MDP),
             'lists/check'     => $this->make_hook('check',     AUTH_MDP),
-            'admin/lists'     => $this->make_hook('admin_all',     AUTH_MDP, 'admin'),
+            'admin/lists'     => $this->make_hook('admin_all', AUTH_MDP, 'admin'),
         );
     }
 
index b960b69..5b188d4 100644 (file)
@@ -26,8 +26,8 @@ class SearchModule extends PLModule
         return array(
             'search'     => $this->make_hook('quick', AUTH_PUBLIC),
             'search/adv' => $this->make_hook('advanced', AUTH_COOKIE),
-            'search/ajax/region'  => $this->make_hook('region', AUTH_COOKIE, '', NO_AUTH),
-            'search/ajax/grade'   => $this->make_hook('grade',  AUTH_COOKIE, '', NO_AUTH),
+            'search/ajax/region'  => $this->make_hook('region', AUTH_COOKIE, 'user', NO_AUTH),
+            'search/ajax/grade'   => $this->make_hook('grade',  AUTH_COOKIE, 'user', NO_AUTH),
             'advanced_search.php' => $this->make_hook('redir_advanced', AUTH_PUBLIC),
         );
     }
index 5c7939e..e0da41d 100644 (file)
@@ -96,7 +96,7 @@ class XnetGrpModule extends PLModule
             '%grp/member/new'
                  => $this->make_hook('admin_member_new', AUTH_MDP),
             '%grp/member/new/ajax'
-                 => $this->make_hook('admin_member_new_ajax', AUTH_MDP, '', NO_AUTH),         
+                 => $this->make_hook('admin_member_new_ajax', AUTH_MDP, 'user', NO_AUTH),         
             '%grp/member/del'
                  => $this->make_hook('admin_member_del', AUTH_MDP),
 
index 9a2f6a9..5a22651 100644 (file)
         </select>
       </td>
     </tr>
+    {if $admin_evts}
+    <tr>
+      <td class="titre">
+        Importance
+      </td>
+      <td>
+        <input type="checkbox" name="important" {if $important}checked="checked"{/if}/> Marquer cette annonce comme très importante
+      </td>
+    </tr>
+    {/if}
   </table>
 
   <div class="center" {if !trim($texte) || !trim($titre)}style="display: none"{/if} id="valid">
index 06de324..c2d7e21 100644 (file)
@@ -108,7 +108,9 @@ Bienvenue {$smarty.session.prenom}
     {if $smarty.foreach.events.total neq 1}
     <tr class="pair" style="height: 18px">
       <td class="half titre" style="height: 18px; padding-top: 1px; padding-bottom: 1px;">
-        {if $category eq 'news'}
+        {if $category eq 'important'}
+          {icon name=error} Informations prioritaires&nbsp;:
+        {elseif $category eq 'news'}
           {icon name=bell} Nouvelles annonces&nbsp;:
         {elseif $category eq 'end'}
           {icon name=clock} Dernières minutes&nbsp;:
@@ -166,7 +168,9 @@ Bienvenue {$smarty.session.prenom}
     <tr>
       <th>
         <div style="float: left">
-          {if $category eq 'news'}
+          {if $category eq 'important'}
+            {icon name=error title="Important"}
+          {elseif $category eq 'news'}
             {icon name=bell title="Nouvelle annonce"}
           {elseif $category eq 'end'}
             {icon name=clock title="Bientôt fini"}