not done, but I want to save my work
authorx2000habouzit <x2000habouzit>
Sat, 6 Nov 2004 18:18:44 +0000 (18:18 +0000)
committerx2000habouzit <x2000habouzit>
Sat, 6 Nov 2004 18:18:44 +0000 (18:18 +0000)
htdocs/carnet/panel.php [new file with mode: 0644]
include/notifs.inc.php
include/xorg.session.inc.php
templates/carnet/index.tpl
templates/carnet/panel.tpl [new file with mode: 0644]

diff --git a/htdocs/carnet/panel.php b/htdocs/carnet/panel.php
new file mode 100644 (file)
index 0000000..e12f61b
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2004 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or      *
+ *  (at your option) any later version.                                    *
+ *                                                                         *
+ *  This program is distributed in the hope that it will be useful,        *
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
+ *  GNU General Public License for more details.                           *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program; if not, write to the Free Software            *
+ *  Foundation, Inc.,                                                      *
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
+ ***************************************************************************
+        $Id: panel.php,v 1.1 2004-11-06 18:18:44 x2000habouzit Exp $
+ ***************************************************************************/
+
+require("auto.prepend.inc.php");
+new_skinned_page('carnet/panel.tpl', AUTH_COOKIE);
+require('notifs.inc.php');
+
+$notifs = new Notifs($_SESSION['uid']);
+
+$page->assign_by_ref('notifs', $notifs);
+
+$page->run();
+
+?>
index 2b76c7f..8b2615b 100644 (file)
@@ -18,7 +18,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: notifs.inc.php,v 1.8 2004-11-06 17:37:22 x2000habouzit Exp $
+        $Id: notifs.inc.php,v 1.9 2004-11-06 18:18:44 x2000habouzit Exp $
  ***************************************************************************/
 
 define("WATCH_FICHE", 1);
@@ -26,6 +26,7 @@ define("WATCH_INSCR", 2);
 define("WATCH_DEATH", 3);
 
 function register_watch_op($uid,$cid,$date='',$info='') {
+    global $globals;
     $date = empty($date) ? 'NOW()' : "'$date'";
     $globals->db->query("REPLACE INTO watch_ops (uid,cid,known,date,info) VALUES('$uid','$cid',NOW(),$date,'$info')");
     if($cid == WATCH_FICHE) {
@@ -33,6 +34,60 @@ function register_watch_op($uid,$cid,$date='',$info='') {
     }
 }
 
+class Notifs {
+    var $_uid;
+    var $_cats = Array();
+    var $_data = Array();
+    
+    function Notifs($uid) {
+       global $globals;
+       $this->_uid = $uid;
+       
+       $res = $globals->db->query("SELECT * FROM watch_cat");
+       while($tmp = mysql_fetch_assoc($res)) $this->_cats[$tmp['id']] = $tmp;
+       mysql_free_result($res);
+
+       $res = $globals->db->query("SELECT  u.promo, u.prenom, IF(u.epouse='',u.nom,u.epouse) AS nom, a.alias AS forlife, wo.*
+                                     FROM  auth_user_quick AS q
+                               INNER JOIN  contacts        AS c  ON(q.user_id = c.uid)
+                               INNER JOIN  watch_ops       AS wo ON(wo.uid=c.contact)
+                               INNER JOIN  watch_sub       AS ws ON(wo.cid=ws.cid AND ws.uid=c.uid)
+                               INNER JOIN  auth_user_md5   AS u  ON(u.user_id = wo.uid)
+                                LEFT JOIN  aliases         AS a  ON(u.user_id = a.id AND a.type='a_vie')
+                                    WHERE  q.user_id = '$uid' AND q.watch_contacts=1
+                                 ORDER BY  wo.cid,promo,nom");
+       while($tmp = mysql_fetch_assoc($res)) {
+           $this->_data[$tmp['cid']][$tmp['promo']][$tmp['uid']] = $tmp;
+       }
+       
+       $res = $globals->db->query("SELECT  u.promo, u.prenom, IF(u.epouse='',u.nom,u.epouse) AS nom, a.alias AS forlife, wo.*
+                                     FROM  watch_promo     AS w
+                               INNER JOIN  auth_user_md5   AS u  USING(promo)
+                               INNER JOIN  watch_ops       AS wo ON(wo.uid=u.user_id)
+                               INNER JOIN  watch_sub       AS ws ON(wo.cid=ws.cid)
+                               INNER JOIN  watch_cat       AS wc ON(wc.id=wo.cid AND wc.frequent=0)
+                                LEFT JOIN  aliases         AS a  ON(u.user_id = a.id AND a.type='a_vie')
+                                    WHERE  w.uid = '$uid'
+                                 ORDER BY  wo.cid,promo,nom");
+       while($tmp = mysql_fetch_assoc($res)) {
+           $this->_data[$tmp['cid']][$tmp['promo']][$tmp['uid']] = $tmp;
+       }
+       
+       $res = $globals->db->query("SELECT  u.promo, u.prenom, IF(u.epouse='',u.nom,u.epouse) AS nom, a.alias AS forlife, wo.*
+                                     FROM  watch_nonins    AS w
+                               INNER JOIN  auth_user_md5   AS u  ON(w.ni_id=u.user_id)
+                               INNER JOIN  watch_ops       AS wo ON(wo.uid=u.user_id)
+                               INNER JOIN  watch_sub       AS ws ON(wo.cid=ws.cid)
+                               INNER JOIN  watch_cat       AS wc ON(wc.id=wo.cid)
+                                LEFT JOIN  aliases         AS a  ON(u.user_id = a.id AND a.type='a_vie')
+                                    WHERE  w.uid = '$uid'
+                                 ORDER BY  wo.cid,promo,nom");
+       while($tmp = mysql_fetch_assoc($res)) {
+           $this->_data[$tmp['cid']][$tmp['promo']][$tmp['uid']] = $tmp;
+       }
+    }
+}
+
 class Watch {
     var $_uid;
     var $_promos;
@@ -40,7 +95,6 @@ class Watch {
     var $_cats = Array();
     var $_subs;
     var $watch_contacts;
-    var $watch_last;
     
     function Watch($uid) {
        global $globals;
@@ -48,8 +102,8 @@ class Watch {
        $this->_promos = new PromoNotifs($uid);
        $this->_nonins = new NoninsNotifs($uid);
        $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);
+       $res = $globals->db->query("SELECT watch_contacts FROM auth_user_quick WHERE user_id='$uid'");
+       list($this->watch_contacts) = mysql_fetch_row($res);
        mysql_free_result($res);
        
        $res = $globals->db->query("SELECT * FROM watch_cat");
index 91a3704..c8ad395 100644 (file)
@@ -18,7 +18,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: xorg.session.inc.php,v 1.36 2004-11-06 13:53:52 x2000habouzit Exp $
+        $Id: xorg.session.inc.php,v 1.37 2004-11-06 18:18:44 x2000habouzit Exp $
  ***************************************************************************/
 
 require("diogenes.core.session.inc.php");
@@ -220,8 +220,9 @@ function try_cookie() {
 function start_connexion ($uid, $identified) {
     global $globals;
     $result=$globals->db->query("
-       SELECT  prenom, nom, perms, promo, matricule, UNIX_TIMESTAMP(s.start) AS lastlogin, s.host,
-               a.alias, UNIX_TIMESTAMP(q.lastnewslogin), a2.alias, password, FIND_IN_SET('femme', flags)
+       SELECT  prenom, nom, perms, promo, matricule, UNIX_TIMESTAMP(s.start) AS lastlogin, s.host, a.alias,
+               UNIX_TIMESTAMP(q.lastnewslogin), q.watch_last,
+               a2.alias, password, FIND_IN_SET('femme', flags)
           FROM  auth_user_md5   AS u
     INNER JOIN  auth_user_quick AS q  USING(user_id)
     INNER JOIN aliases         AS a  ON (u.user_id = a.id AND a.type='a_vie')
@@ -230,8 +231,9 @@ function start_connexion ($uid, $identified) {
          WHERE  u.user_id=$uid
       ORDER BY  s.start DESC, a2.type != 'epouse', length(a2.alias)
          LIMIT  1");
-    list($prenom, $nom, $perms, $promo, $matricule, $lastlogin, $host,
-        $forlife, $lastnewslogin, $bestalias, $password, $femme) = mysql_fetch_row($result);
+    list($prenom, $nom, $perms, $promo, $matricule, $lastlogin, $host, $forlife, 
+        $lastnewslogin, $watch_last,
+        $bestalias, $password, $femme) = mysql_fetch_row($result);
     mysql_free_result($result);
    
     // on garde le logger si il existe (pour ne pas casser les sessions lors d'une
@@ -257,6 +259,7 @@ function start_connexion ($uid, $identified) {
     // le login est stocké pour un an
     $_SESSION['lastlogin'] = $lastlogin;
     $_SESSION['lastnewslogin'] = $lastnewslogin;
+    $_SESSION['watch_last'] = $watch_last;
     $_SESSION['host'] = $host;
     $_SESSION['auth'] = ($identified ? AUTH_MDP : AUTH_COOKIE);
     $_SESSION['uid'] = $uid;
index 000b84a..5ec4d50 100644 (file)
@@ -17,7 +17,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: index.tpl,v 1.2 2004-11-04 15:48:45 x2000habouzit Exp $
+        $Id: index.tpl,v 1.3 2004-11-06 18:18:44 x2000habouzit Exp $
  ***************************************************************************}
 
 <h1>Carnet polytechnicien</h1>
@@ -29,7 +29,7 @@
     </th>
   </tr>
   <tr class="impair">
-    <td>
+    <td class='half'>
       <div class="question">
         <a href="{"carnet/mescontacts.php"|url}">Page de tes contacts</a>
       </div>
@@ -37,7 +37,7 @@
         Tu peux ici lister tes contacts, en ajouter et en retirer.
       </div>
     </td>
-    <td>
+    <td class='half'>
       <div class="question">
         <a href="{"carnet/mescontacts.php?trombi=1"|url}">Le trombi de tes contacts</a>
       </div>
       </div>
     </td>
   </tr>
+</table>
+
+<br />
+
+<table class="bicol">
+  <tr>
+    <th colspan="2">
+      Notifications
+    </th>
+  </tr>
   <tr class="pair">
-    <td colspan="2">
+    <td class='half'>
+      <div class="question">
+        <a href="{"carnet/panel.php"|url}">Bilan de tes notifications</a>
+      </div>
+      <div class="explication">
+        Affichage de tous les évenements de camarades/promos
+      </div>
+    </td>
+    <td class='half'>
       <div class="question">
-        <a href="{"carnet/notifs.php"|url}">Notifications hebdomadaires automatiques</a>
+        <a href="{"carnet/notifs.php"|url}">Configurer tes notifications</a>
       </div>
       <div class="explication">
         Être notifié des inscriptions, décès, changement de fiche, ...
diff --git a/templates/carnet/panel.tpl b/templates/carnet/panel.tpl
new file mode 100644 (file)
index 0000000..dee8b4c
--- /dev/null
@@ -0,0 +1,79 @@
+{***************************************************************************
+ *  Copyright (C) 2003-2004 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or      *
+ *  (at your option) any later version.                                    *
+ *                                                                         *
+ *  This program is distributed in the hope that it will be useful,        *
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
+ *  GNU General Public License for more details.                           *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program; if not, write to the Free Software            *
+ *  Foundation, Inc.,                                                      *
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
+ ***************************************************************************
+        $Id: panel.tpl,v 1.1 2004-11-06 18:18:44 x2000habouzit Exp $
+ ***************************************************************************}
+
+<h1>Carnet polytechnicien</h1>
+
+<table class="bicol">
+  <tr>
+    <th colspan="2">
+      Tes contacts
+    </th>
+  </tr>
+  <tr class="impair">
+    <td class='half'>
+      <div class="question">
+        <a href="{"carnet/mescontacts.php"|url}">Page de tes contacts</a>
+      </div>
+      <div class="explication">
+        Tu peux ici lister tes contacts, en ajouter et en retirer.
+      </div>
+    </td>
+    <td class='half'>
+      <div class="question">
+        <a href="{"carnet/mescontacts.php?trombi=1"|url}">Le trombi de tes contacts</a>
+      </div>
+      <div class="explication">
+        La même chose que la page de tes contacts... <strong>en images !</strong>
+      </div>
+    </td>
+  </tr>
+</table>
+
+<br />
+
+<table class="bicol">
+  <tr>
+    <th colspan="2">
+      Notifications
+    </th>
+  </tr>
+  <tr class="pair">
+    <td class='half'>
+      <div class="question">
+        <a href="{"carnet/panel.php"|url}">Bilan de tes notifications</a>
+      </div>
+      <div class="explication">
+        Affichage de tous les évenements de camarades/promos
+      </div>
+    </td>
+    <td class='half'>
+      <div class="question">
+        <a href="{"carnet/notifs.php"|url}">Configurer tes notifications</a>
+      </div>
+      <div class="explication">
+        Être notifié des inscriptions, décès, changement de fiche, ...
+      </div>
+    </td>
+  </tr>
+</table>
+
+{* vim:set et sw=2 sts=2 sws=2: *}