modifs concerning notifs + watches
authorx2000habouzit <x2000habouzit>
Sat, 6 Nov 2004 17:22:11 +0000 (17:22 +0000)
committerx2000habouzit <x2000habouzit>
Sat, 6 Nov 2004 17:22:11 +0000 (17:22 +0000)
htdocs/advanced_search.php
htdocs/carnet/notifs.php
htdocs/search.php
include/notifs.inc.php
templates/carnet/notifs.tpl
templates/include/minifiche.tpl
templates/include/minifiche_pvt.tpl

index baca075..beb77cc 100644 (file)
@@ -18,7 +18,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: advanced_search.php,v 1.26 2004-11-05 14:34:03 x2000habouzit Exp $
+        $Id: advanced_search.php,v 1.27 2004-11-06 17:22:11 x2000habouzit Exp $
  ***************************************************************************/
 
 require("auto.prepend.inc.php");
@@ -112,11 +112,13 @@ else {
                        u.promo,
                        a.alias AS forlife,
                        '.$globals->search_result_fields.'
-                       c.uid AS contact
+                       c.uid AS contact,
+                       w.ni_id AS contact
                  FROM  auth_user_md5  AS u
           '.$fields->get_select_statement().'
             LEFT JOIN  aliases        AS a ON (u.user_id = a.id AND a.type="a_vie")
             LEFT JOIN  contacts       AS c ON (c.uid='.((array_key_exists('uid',$_SESSION))?$_SESSION['uid']:0).' AND c.contact=u.user_id)
+            LEFT JOIN  watch_nonins   AS w ON (w.ni_id=u.user_id AND w.uid='.((array_key_exists('uid',$_SESSION))?$_SESSION['uid']:0).')
             '.$globals->search_result_where_statement.'
                 '.(($where!='')?('WHERE '.$where):'').'
              ORDER BY  '.(logged() && !empty($_REQUEST['mod_date_sort']) ? 'date DESC,' :'')
index 22f1556..0bb3ca1 100644 (file)
@@ -18,7 +18,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: notifs.php,v 1.5 2004-11-06 16:08:27 x2000habouzit Exp $
+        $Id: notifs.php,v 1.6 2004-11-06 17:22:12 x2000habouzit Exp $
  ***************************************************************************/
 
 require("auto.prepend.inc.php");
@@ -54,6 +54,10 @@ if(isset($_REQUEST['promo'])) {
     }
 }
 
+if(isset($_REQUEST['del_nonins'])) $watch->_nonins->del($_REQUEST['del_nonins']);
+if(isset($_REQUEST['add_nonins'])) $watch->_nonins->add($_REQUEST['add_nonins']);
+if(isset($_REQUEST['subs'])) $watch->_subs->update('sub');
+
 $page->assign_by_ref('watch', $watch);
 $page->assign_by_ref('err', $err);
 
index 39b7324..6f8de05 100644 (file)
@@ -18,7 +18,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: search.php,v 1.46 2004-11-05 14:34:03 x2000habouzit Exp $
+        $Id: search.php,v 1.47 2004-11-06 17:22:11 x2000habouzit Exp $
  ***************************************************************************/
 
 require("auto.prepend.inc.php");
@@ -55,12 +55,12 @@ if (array_key_exists('quick', $_REQUEST)) {
                        a.alias AS forlife,
                        '.$globals->search_result_fields.'
                        c.uid AS contact,
-                      w.arg AS watch
+                      w.ni_id AS watch
                  FROM  auth_user_md5  AS r
             LEFT JOIN  auth_user_md5  AS u   ON (u.matricule=r.matricule)
             LEFT JOIN  aliases        AS a   ON (u.user_id = a.id AND a.type="a_vie")
             LEFT JOIN  contacts       AS c   ON (c.uid='.((array_key_exists('uid',$_SESSION))?$_SESSION['uid']:0).' AND c.contact=u.user_id)
-            LEFT JOIN  watch          AS w   ON (w.arg=u.user_id AND w.user_id='.((array_key_exists('uid',$_SESSION))?$_SESSION['uid']:0).' AND w.type="non-inscrit")
+            LEFT JOIN  watch_nonins   AS w   ON (w.ni_id=u.user_id AND w.uid='.((array_key_exists('uid',$_SESSION))?$_SESSION['uid']:0).')
             '.$globals->search_result_where_statement.'
                 WHERE  '.$fields->get_where_statement().'
              ORDER BY  '.(logged() && !empty($_REQUEST['mod_date_sort']) ? 'date DESC,' :'')
@@ -68,6 +68,7 @@ if (array_key_exists('quick', $_REQUEST)) {
                 LIMIT  '.$offset->value.','.$globals->search_results_per_page;
 
     $page->mysql_assign($sql, 'resultats', 'nb_resultats','nb_resultats_total');
+    echo mysql_error();
     
     $nbpages = ($page->get_template_vars('nb_resultats_total')-1)/$globals->search_results_per_page;
     $page->assign('offsets',range(0,$nbpages));
index f70188e..781eadf 100644 (file)
@@ -18,7 +18,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: notifs.inc.php,v 1.6 2004-11-06 16:08:27 x2000habouzit Exp $
+        $Id: notifs.inc.php,v 1.7 2004-11-06 17:22:12 x2000habouzit Exp $
  ***************************************************************************/
 
 require_once('diogenes.flagset.inc.php');
@@ -27,7 +27,7 @@ class Watch {
     var $_uid;
     var $_promos;
     var $_nonins;
-    var $_cats;
+    var $_cats = Array();
     var $_subs;
     var $watch_contacts;
     var $watch_last;
@@ -37,32 +37,36 @@ class Watch {
        $this->_uid = $uid;
        $this->_promos = new PromoNotifs($uid);
        $this->_nonins = new NoninsNotifs($uid);
-       $this->_cats = new WatchCat();
        $this->_subs = new WatchSub($uid);
        $res = $globals->db->query("SELECT watch_contacts,watch_last FROM auth_user_quick WHERE user_id='$uid'");
        list($this->watch_contacts, $this->watch_last) = mysql_fetch_row($res);
        mysql_free_result($res);
+       
+       $res = $globals->db->query("SELECT * FROM watch_cat");
+       while($tmp = mysql_fetch_assoc($res)) $this->_cats[$tmp['id']] = $tmp;
+       mysql_free_result($res);
     }
 
+    function cats() {
+       return $this->_cats;
+    }
+
+    function subs($i) {
+       return $this->_subs->_data[$i];
+    }
+    
     function promos() {
        return $this->_promos->toRanges();
     }
-}
-
-class WatchCat {
-    var $_data = Array();
     
-    function WatchCat() {
-       global $globals;
-       $res = $globals->db->query("SELECT * FROM watch_cat");
-       while($tmp = mysql_fetch_assoc($res)) $this->_data[$tmp['id']] = $tmp;
-       mysql_free_result($res);
+    function nonins() {
+       return $this->_nonins->_data;
     }
 }
 
 class WatchSub {
     var $_uid;
-    var $_data;
+    var $_data = Array();
 
     function WatchSub($uid) {
        $this->_uid = $uid;
@@ -71,6 +75,19 @@ class WatchSub {
        while(list($c) = mysql_fetch_row($res)) $this->_data[$c] = $c;
        mysql_free_result($res);
     }
+
+    function update($ind) {
+       global $globals;
+       $this->_data = Array();
+       $globals->db->query("DELETE FROM watch_sub WHERE uid='{$this->_uid}'");
+       foreach($_REQUEST[$ind] as $key=>$val) {
+           $globals->db->query("INSERT INTO  watch_sub
+                                     SELECT  '{$this->_uid}',id
+                                       FROM  watch_cat
+                                      WHERE  id='$key'");
+           if(mysql_affected_rows()) $this->_data[$key] = $key;
+       }
+    }
 }
 
 class PromoNotifs {
@@ -171,7 +188,7 @@ class NoninsNotifs {
     function add($p) {
        global $globals;
        $globals->db->query("INSERT INTO watch_nonins (uid,ni_id) VALUES('{$this->_uid}','$p')");
-       $res = $globals->db->query("SELECT  prenom,IF(u.epouse='',u.nom,u.epouse),promo,user_id
+       $res = $globals->db->query("SELECT  prenom,IF(epouse='',nom,epouse) AS nom,promo,user_id
                                      FROM  auth_user_md5
                                     WHERE  user_id='$p'");
        $this->_data["$p"] = mysql_fetch_assoc($res);
index e043c73..d94b813 100644 (file)
@@ -17,7 +17,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: notifs.tpl,v 1.10 2004-11-06 16:08:28 x2000habouzit Exp $
+        $Id: notifs.tpl,v 1.11 2004-11-06 17:22:12 x2000habouzit Exp $
  ***************************************************************************}
 
 {dynamic}
@@ -35,13 +35,22 @@ S'il n'y a rien 
 <ul>
   <li>d'être notifié lorsque tes contacts changent leur fiche</li>
   <li>d'être notifié lorsque un de tes contacts décède</li>
-  <li>si tu le désires, lorsque tu es notifié du décès d'un de tes camarades, il peut être automatiquement retiré de ta liste de contact.
-  (dans ce cas ta liste de contact est vidée de tous les camarades qui sont décédés)
-  </li>
 </ul>
 
 <form action="{$smarty.server.PHP_SELF}" method="post">
   <fieldset>
+    <legend>Événements à surveiller</legend>
+    {foreach from=$watch->cats() item=s key=i}
+    <input type='checkbox' name='sub[{$i}]' {if $watch->subs($i)}checked="checked"{/if} /> {$s.short}<br />
+    {/foreach}
+  </fieldset>
+  <div class='center'>
+    <input type='submit' name='subs' value='valider' />
+  </div>
+</form>
+
+<form action="{$smarty.server.PHP_SELF}" method="post">
+  <fieldset>
     <legend>Contacts</legend>
     <input type='checkbox' name='contacts' {if $watch->watch_contacts}checked="checked"{/if} /> Surveiller mes contacts<br />
   </fieldset>
@@ -97,14 +106,14 @@ et cliquer sur les icones <img src="{"images/ajouter.gif"|url}" alt="Ajouter" />
 <table class='tinybicol' cellpadding="0" cellspacing="0">
   <tr>
     <td>
-      {if $notifs->nonins|@count eq 0}
+      {if $watch->nonins()|@count eq 0}
       <p>Tu ne surveilles actuellement aucun non-inscrit.</p>
-      {elseif $notifs->nonins|@count}
-      <p>Tu surveilles {if $notifs->nonins|@count eq 1}le non-inscrit{else}les non-inscrits{/if} :</p>
+      {elseif $watch->nonins()|@count}
+      <p>Tu surveilles {if $watch->nonins()|@count eq 1}le non-inscrit{else}les non-inscrits{/if} :</p>
       <ul>
-        {foreach from=$notifs->nonins item=p}
+        {foreach from=$watch->nonins() item=p}
         <li>
-        {$p.prenom} {$p.nom} ({$p.promo}) <a href="?del_nonins={$p.uid}"><img src="{"images/retirer.gif"|url}" alt="retirer" /></a>
+        {$p.prenom} {$p.nom} ({$p.promo}) <a href="?del_nonins={$p.user_id}"><img src="{"images/retirer.gif"|url}" alt="retirer" /></a>
         </li>
         {/foreach}
       </ul>
index d7d5197..baa294c 100644 (file)
@@ -17,7 +17,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: minifiche.tpl,v 1.11 2004-11-05 14:34:05 x2000habouzit Exp $
+        $Id: minifiche.tpl,v 1.12 2004-11-06 17:22:13 x2000habouzit Exp $
  ***************************************************************************}
 
 
     {/if}
     {/min_auth}
   </div>
-  {if $inscrit || $c.dcd}
   <div class="appli">
-    {strip}
     {if $c.iso3166}
     <img src='{"images/"|url}flags/{$c.iso3166}.gif' alt='{$c.nat}' height='14' title='{$c.nat}' />&nbsp;
     {/if}
-    (X {$c.promo}
-    {if $c.app0text},
+    (X {$c.promo}{if $c.app0text},
       {applis_fmt type=$c.app0type text=$c.app0text url=$c.app0url}
-    {/if}
-    {if $c.app1text},
+    {/if}{if $c.app1text},
       {applis_fmt type=$c.app1type text=$c.app1text url=$c.app1url}
     {/if})
-    {if $c.dcd}&nbsp;décédé le {$c.deces}{/if}
-    {/strip}
+    {if $c.dcd}décédé le {$c.deces}{/if}
+    {min_auth level="cookie"}
+    {if !$c.dcd && !$inscrit}
+    <a href="javascript:x()" onclick="popWin('marketing/public.php?num={$c.matricule}')">clique ici si tu connais son adresse email !
+    </a>
+    {/if}
+    {/min_auth}
   </div>
-  {/if}
   {min_auth level="cookie"}
   {include file="include/minifiche_pvt.tpl"}
   {/min_auth}
index 54c13cc..d23e6e8 100644 (file)
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: minifiche_pvt.tpl,v 1.12 2004-11-05 14:34:05 x2000habouzit Exp $
+        $Id: minifiche_pvt.tpl,v 1.13 2004-11-06 17:22:13 x2000habouzit Exp $
  ***************************************************************************}
 
 
 {if !$inscrit}
   {if !$c.dcd}
-  <div class="appli">
-    &nbsp;<a href="javascript:x()" onclick="popWin('marketing/public.php?num={$c.matricule}')">
-      clique ici si tu connais son adresse email !
-    </a>
-  </div>
   <div class='bits'>
     {if $show_action eq ajouter}
     <a href="{"carnet/notifs.php"|url}?add_nonins={$c.user_id}">{*