From 0d9c74ba69f3a88989f0ad13d1ee8651ec030423 Mon Sep 17 00:00:00 2001 From: x2000habouzit Date: Sat, 6 Nov 2004 22:34:16 +0000 Subject: [PATCH] now it's quite complete --- htdocs/carnet/panel.php | 12 +++-- include/notifs.inc.php | 82 ++++++++++++++++++++++++++++----- plugins/insert.getNbNotifs.php | 30 +++++++++++++ templates/carnet/panel.tpl | 100 +++++++++++++++++++++-------------------- templates/fiche.tpl | 4 +- templates/skin/default.tpl | 7 ++- templates/skin/espace.tpl | 7 ++- templates/skin/humlinux.tpl | 7 ++- templates/skin/linux.tpl | 7 ++- templates/skin/liteskin.tpl | 7 ++- templates/skin/nbviolet.tpl | 7 ++- templates/skin/newxorg.tpl | 7 ++- templates/skin/noIE.tpl | 5 ++- templates/skin/oldtimes.tpl | 7 ++- templates/skin/sharky.tpl | 7 ++- templates/skin/spectral.tpl | 7 ++- templates/skin/trapped.tpl | 7 ++- 17 files changed, 223 insertions(+), 87 deletions(-) create mode 100644 plugins/insert.getNbNotifs.php diff --git a/htdocs/carnet/panel.php b/htdocs/carnet/panel.php index e12f61b..56ac082 100644 --- a/htdocs/carnet/panel.php +++ b/htdocs/carnet/panel.php @@ -18,14 +18,20 @@ * 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 $ + $Id: panel.php,v 1.2 2004-11-06 22:34:16 x2000habouzit Exp $ ***************************************************************************/ require("auto.prepend.inc.php"); -new_skinned_page('carnet/panel.tpl', AUTH_COOKIE); +new_skinned_page('carnet/panel.tpl', AUTH_COOKIE, true); require('notifs.inc.php'); -$notifs = new Notifs($_SESSION['uid']); +if(isset($_GET['read'])) { + $_SESSION['watch_last'] = $_GET['read']; + header("Location: panel.php"); +} + +$page->assign('now',date('YmdHis')); +$notifs = new Notifs($_SESSION['uid'], true); $page->assign_by_ref('notifs', $notifs); diff --git a/include/notifs.inc.php b/include/notifs.inc.php index 8eb2080..e09854d 100644 --- a/include/notifs.inc.php +++ b/include/notifs.inc.php @@ -18,7 +18,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: notifs.inc.php,v 1.10 2004-11-06 18:29:58 x2000habouzit Exp $ + $Id: notifs.inc.php,v 1.11 2004-11-06 22:34:17 x2000habouzit Exp $ ***************************************************************************/ define("WATCH_FICHE", 1); @@ -34,12 +34,64 @@ function register_watch_op($uid,$cid,$date='',$info='') { } } +function getNbNotifs() { + global $globals; + if(!isset($_SESSION['uid'])) return 0; + $uid = $_SESSION['uid']; + + $res = $globals->db->query(" + ( + SELECT u.promo, u.prenom, IF(u.epouse='',u.nom,u.epouse) AS nom, a.alias AS forlife, + wo.*, 1 AS contact, (u.perms='admin' OR u.perms='user') AS inscrit + 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 AND wo.known > q.watch_last + ) UNION DISTINCT ( + SELECT u.promo, u.prenom, IF(u.epouse='',u.nom,u.epouse) AS nom, a.alias AS forlife, + wo.*, NOT (c.contact IS NULL) AS contact, (u.perms='admin' OR u.perms='user') AS inscrit + FROM watch_promo AS w + INNER JOIN auth_user_md5 AS u USING(promo) + INNER JOIN auth_user_quick AS q ON(q.user_id = w.uid) + LEFT JOIN contacts AS c ON(w.uid = c.uid AND c.contact=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 AND wc.frequent=0) + LEFT JOIN aliases AS a ON(u.user_id = a.id AND a.type='a_vie') + WHERE w.uid = '$uid' AND wo.known > q.watch_last + ) UNION DISTINCT ( + SELECT u.promo, u.prenom, IF(u.epouse='',u.nom,u.epouse) AS nom, a.alias AS forlife, + wo.*, 0 AS contact, (u.perms='admin' OR u.perms='user') AS inscrit + FROM watch_nonins AS w + INNER JOIN auth_user_quick AS q ON(q.user_id = w.uid) + 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' AND wo.known > q.watch_last + )"); + $n = mysql_num_rows($res); + mysql_free_result($res); + $url = smarty_modifier_url('carnet/panel.php'); + if($n==0) { + return; + } + if($n==1) { + return "$n notification !"; + } + return "$n notifications !"; +} + class Notifs { var $_uid; var $_cats = Array(); var $_data = Array(); - function Notifs($uid) { + function Notifs($uid,$up=false) { global $globals; $this->_uid = $uid; @@ -47,38 +99,48 @@ class Notifs { while($tmp = mysql_fetch_assoc($res)) $this->_cats[$tmp['id']] = $tmp; mysql_free_result($res); + $lastweek = date('YmdHis',mktime() - 7*24*60*60); + $res = $globals->db->query(" ( - SELECT u.promo, u.prenom, IF(u.epouse='',u.nom,u.epouse) AS nom, a.alias AS forlife, wo.* + SELECT u.promo, u.prenom, IF(u.epouse='',u.nom,u.epouse) AS nom, a.alias AS forlife, + wo.*, 1 AS contact, (u.perms='admin' OR u.perms='user') AS inscrit 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 + WHERE q.user_id = '$uid' AND q.watch_contacts=1 AND wo.known > $lastweek ) UNION DISTINCT ( - SELECT u.promo, u.prenom, IF(u.epouse='',u.nom,u.epouse) AS nom, a.alias AS forlife, wo.* + SELECT u.promo, u.prenom, IF(u.epouse='',u.nom,u.epouse) AS nom, a.alias AS forlife, + wo.*, NOT (c.contact IS NULL) AS contact, (u.perms='admin' OR u.perms='user') AS inscrit FROM watch_promo AS w INNER JOIN auth_user_md5 AS u USING(promo) + LEFT JOIN contacts AS c ON(w.uid = c.uid AND c.contact=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 AND wc.frequent=0) LEFT JOIN aliases AS a ON(u.user_id = a.id AND a.type='a_vie') - WHERE w.uid = '$uid' + WHERE w.uid = '$uid' AND wo.known > $lastweek ) UNION DISTINCT ( - SELECT u.promo, u.prenom, IF(u.epouse='',u.nom,u.epouse) AS nom, a.alias AS forlife, wo.* + SELECT u.promo, u.prenom, IF(u.epouse='',u.nom,u.epouse) AS nom, a.alias AS forlife, + wo.*, 0 AS contact, (u.perms='admin' OR u.perms='user') AS inscrit 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' + WHERE w.uid = '$uid' AND wo.known > $lastweek ) - ORDER BY wo.cid,promo,nom"); + ORDER BY cid,promo,nom"); while($tmp = mysql_fetch_assoc($res)) { - $this->_data[$tmp['cid']][$tmp['promo']][$tmp['uid']] = $tmp; + $this->_data[$tmp['cid']][$tmp['promo']][] = $tmp; + } + + if($up) { + $globals->db->query("UPDATE auth_user_quick SET watch_last=NOW() WHERE user_id='$uid'"); } } } diff --git a/plugins/insert.getNbNotifs.php b/plugins/insert.getNbNotifs.php new file mode 100644 index 0000000..3b936f3 --- /dev/null +++ b/plugins/insert.getNbNotifs.php @@ -0,0 +1,30 @@ + diff --git a/templates/carnet/panel.tpl b/templates/carnet/panel.tpl index dee8b4c..aabd11e 100644 --- a/templates/carnet/panel.tpl +++ b/templates/carnet/panel.tpl @@ -17,63 +17,67 @@ * 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 $ + $Id: panel.tpl,v 1.2 2004-11-06 22:34:18 x2000habouzit Exp $ ***************************************************************************} -

Carnet polytechnicien

+

Bilan des Notifications

- - - - - - - - -
- Tes contacts -
- -
- Tu peux ici lister tes contacts, en ajouter et en retirer. -
-
- -
- La même chose que la page de tes contacts... en images ! -
-
+

+Cette page récapitule tous les évènements que tu surveilles de la semaine écoulée +

+ +

+Les lignes en gras sont les événements qui ont été porté à notre connaissance +depuis ta dernière connexion sur cette page.
+Tu peux les marquer comme vus sans te déconnecter. +

+ +

+Tu peux choisir plus finement les données affichées sur cette page. +Il faut pour celà se rendre sur la page de configuration des notifications. +

+ +{dynamic} + +{foreach from=$notifs->_data item=c key=cid} +

{$notifs->_cats[$cid].mail} :


- - - - - - - +
- Notifications -
- -
- Affichage de tous les évenements de camarades/promos -
+ + {foreach from=$c key=p item=promo} + {section name=row loop=$promo} + $smarty.session.watch_last}style="font-weight: bold"{/if}> + + - + {/section} + {/foreach}
{if $smarty.section.row.first}{$p}{/if} + {if $promo[row].inscrit} + + {$promo[row].prenom} {$promo[row].nom} + + {if $promo[row].contact} + {* + *}retirer de mes contacts{* + *} + {else} + {* + *}ajouter à mes contacts{* + *} + {/if} + {else} + {$promo[row].prenom} {$promo[row].nom} + {/if} - -
- Être notifié des inscriptions, décès, changement de fiche, ... -
+
+ {$promo[row].date|date_format:"%d %b. %Y"}
+
+{/foreach} + +{/dynamic} + {* vim:set et sw=2 sts=2 sws=2: *} diff --git a/templates/fiche.tpl b/templates/fiche.tpl index 7c65b23..9e36ac2 100644 --- a/templates/fiche.tpl +++ b/templates/fiche.tpl @@ -17,7 +17,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: fiche.tpl,v 1.22 2004-11-04 15:33:28 x2000habouzit Exp $ + $Id: fiche.tpl,v 1.23 2004-11-06 22:34:17 x2000habouzit Exp $ ***************************************************************************} {literal} @@ -37,7 +37,7 @@ function chgMainWinLoc( strPage ) { Afficher la carte de visite {if !$is_contact} - + Ajouter à mes contacts {else} diff --git a/templates/skin/default.tpl b/templates/skin/default.tpl index 7458b1f..7ded052 100644 --- a/templates/skin/default.tpl +++ b/templates/skin/default.tpl @@ -17,7 +17,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: default.tpl,v 1.16 2004-09-02 19:39:21 x2000habouzit Exp $ + $Id: default.tpl,v 1.17 2004-11-06 22:34:18 x2000habouzit Exp $ ***************************************************************************} @@ -73,7 +73,10 @@ //-->
{insert name="getNbIns"} polytechniciens sur le web + {insert name="getNbIns"} polytechniciens sur le web
+ {insert name="getNbNotifs"} +
[LES X SUR LE WEB] diff --git a/templates/skin/espace.tpl b/templates/skin/espace.tpl index 8202cf4..72285ab 100644 --- a/templates/skin/espace.tpl +++ b/templates/skin/espace.tpl @@ -17,7 +17,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: espace.tpl,v 1.1 2004-10-03 13:29:34 x2003bruneau Exp $ + $Id: espace.tpl,v 1.2 2004-11-06 22:34:18 x2000habouzit Exp $ ***************************************************************************} @@ -74,7 +74,10 @@ //--> - {insert name="getNbIns"} polytechniciens sur le web + + {insert name="getNbIns"} polytechniciens sur le web
+ {insert name="getNbNotifs"} + [LES X SUR LE WEB] diff --git a/templates/skin/humlinux.tpl b/templates/skin/humlinux.tpl index 6cd1e05..f3c309c 100644 --- a/templates/skin/humlinux.tpl +++ b/templates/skin/humlinux.tpl @@ -17,7 +17,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: humlinux.tpl,v 1.2 2004-10-03 16:12:53 x2003cortot Exp $ + $Id: humlinux.tpl,v 1.3 2004-11-06 22:34:18 x2000habouzit Exp $ ***************************************************************************} @@ -74,7 +74,10 @@ //--> - {insert name="getNbIns"} polytechniciens sur le web + + {insert name="getNbIns"} polytechniciens sur le web
+ {insert name="getNbNotifs"} + diff --git a/templates/skin/linux.tpl b/templates/skin/linux.tpl index 2b80508..4ccd8e2 100644 --- a/templates/skin/linux.tpl +++ b/templates/skin/linux.tpl @@ -17,7 +17,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: linux.tpl,v 1.1 2004-10-03 15:10:13 x2003cortot Exp $ + $Id: linux.tpl,v 1.2 2004-11-06 22:34:18 x2000habouzit Exp $ ***************************************************************************} @@ -74,7 +74,10 @@ //--> - {insert name="getNbIns"} polytechniciens sur le web + + {insert name="getNbIns"} polytechniciens sur le web
+ {insert name="getNbNotifs"} + [LES X SUR LE WEB] diff --git a/templates/skin/liteskin.tpl b/templates/skin/liteskin.tpl index 2bed41a..f5d8b78 100644 --- a/templates/skin/liteskin.tpl +++ b/templates/skin/liteskin.tpl @@ -17,7 +17,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: liteskin.tpl,v 1.1 2004-10-17 01:29:48 x98ho Exp $ + $Id: liteskin.tpl,v 1.2 2004-11-06 22:34:18 x2000habouzit Exp $ ***************************************************************************} @@ -74,7 +74,10 @@ //--> - {insert name="getNbIns"} polytechniciens sur le web + + {insert name="getNbIns"} polytechniciens sur le web
+ {insert name="getNbNotifs"} + diff --git a/templates/skin/nbviolet.tpl b/templates/skin/nbviolet.tpl index 19ad68d..2a07545 100644 --- a/templates/skin/nbviolet.tpl +++ b/templates/skin/nbviolet.tpl @@ -17,7 +17,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: nbviolet.tpl,v 1.1 2004-10-06 18:41:20 x2003bruneau Exp $ + $Id: nbviolet.tpl,v 1.2 2004-11-06 22:34:18 x2000habouzit Exp $ ***************************************************************************} @@ -74,7 +74,10 @@ //--> - {insert name="getNbIns"} polytechniciens sur le web + + {insert name="getNbIns"} polytechniciens sur le web
+ {insert name="getNbNotifs"} + [LES X SUR LE WEB] diff --git a/templates/skin/newxorg.tpl b/templates/skin/newxorg.tpl index 8f01e51..a7d2a9c 100644 --- a/templates/skin/newxorg.tpl +++ b/templates/skin/newxorg.tpl @@ -17,7 +17,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: newxorg.tpl,v 1.1 2004-10-03 22:32:48 x2003bruneau Exp $ + $Id: newxorg.tpl,v 1.2 2004-11-06 22:34:18 x2000habouzit Exp $ ***************************************************************************} @@ -74,7 +74,10 @@ //--> - {insert name="getNbIns"} polytechniciens sur le web + + {insert name="getNbIns"} polytechniciens sur le web
+ {insert name="getNbNotifs"} + diff --git a/templates/skin/noIE.tpl b/templates/skin/noIE.tpl index beed0f0..e5ef1e9 100644 --- a/templates/skin/noIE.tpl +++ b/templates/skin/noIE.tpl @@ -17,7 +17,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: noIE.tpl,v 1.4 2004-09-02 19:39:21 x2000habouzit Exp $ + $Id: noIE.tpl,v 1.5 2004-11-06 22:34:18 x2000habouzit Exp $ ***************************************************************************} @@ -56,7 +56,8 @@
[ BAN ] - {insert name="getNbIns"} polytechniciens sur le web + {insert name="getNbIns"} polytechniciens sur le web
+ {insert name="getNbNotifs"}
diff --git a/templates/skin/oldtimes.tpl b/templates/skin/oldtimes.tpl index 4f3bac0..f6e8763 100644 --- a/templates/skin/oldtimes.tpl +++ b/templates/skin/oldtimes.tpl @@ -17,7 +17,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: oldtimes.tpl,v 1.1 2004-10-04 22:08:53 x2003bruneau Exp $ + $Id: oldtimes.tpl,v 1.2 2004-11-06 22:34:18 x2000habouzit Exp $ ***************************************************************************} @@ -74,7 +74,10 @@ //--> - {insert name="getNbIns"} polytechniciens sur le web + + {insert name="getNbIns"} polytechniciens sur le web
+ {insert name="getNbNotifs"} + [LES X SUR LE WEB] diff --git a/templates/skin/sharky.tpl b/templates/skin/sharky.tpl index e5f331e..4717064 100644 --- a/templates/skin/sharky.tpl +++ b/templates/skin/sharky.tpl @@ -17,7 +17,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: sharky.tpl,v 1.6 2004-09-02 19:39:21 x2000habouzit Exp $ + $Id: sharky.tpl,v 1.7 2004-11-06 22:34:18 x2000habouzit Exp $ ***************************************************************************} @@ -74,7 +74,10 @@ //--> - {insert name="getNbIns"} polytechniciens sur le web + + {insert name="getNbIns"} polytechniciens sur le web
+ {insert name="getNbNotifs"} + diff --git a/templates/skin/spectral.tpl b/templates/skin/spectral.tpl index cf8d30b..c023411 100644 --- a/templates/skin/spectral.tpl +++ b/templates/skin/spectral.tpl @@ -17,7 +17,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: spectral.tpl,v 1.1 2004-10-03 11:54:41 x2003bruneau Exp $ + $Id: spectral.tpl,v 1.2 2004-11-06 22:34:18 x2000habouzit Exp $ ***************************************************************************} @@ -74,7 +74,10 @@ //--> - {insert name="getNbIns"} polytechniciens sur le web + + {insert name="getNbIns"} polytechniciens sur le web
+ {insert name="getNbNotifs"} + [LES X SUR LE WEB] diff --git a/templates/skin/trapped.tpl b/templates/skin/trapped.tpl index 3bab04b..e9da185 100644 --- a/templates/skin/trapped.tpl +++ b/templates/skin/trapped.tpl @@ -17,7 +17,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: trapped.tpl,v 1.1 2004-10-03 17:07:44 x2003bruneau Exp $ + $Id: trapped.tpl,v 1.2 2004-11-06 22:34:18 x2000habouzit Exp $ ***************************************************************************} @@ -74,7 +74,10 @@ //--> - {insert name="getNbIns"} polytechniciens sur le web + + {insert name="getNbIns"} polytechniciens sur le web
+ {insert name="getNbNotifs"} + [LES X SUR LE WEB] -- 2.1.4