* 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);
* 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);
}
}
+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 "<a href='$url'>$n notification !</a>";
+ }
+ return "<a href='$url'>$n notifications !</a>";
+}
+
class Notifs {
var $_uid;
var $_cats = Array();
var $_data = Array();
- function Notifs($uid) {
+ function Notifs($uid,$up=false) {
global $globals;
$this->_uid = $uid;
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'");
}
}
}
--- /dev/null
+<?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: insert.getNbNotifs.php,v 1.1 2004-11-06 22:34:17 x2000habouzit Exp $
+ ***************************************************************************/
+
+
+function smarty_insert_getNbNotifs($params, &$smarty)
+{
+ require_once('notifs.inc.php');
+ return getNbNotifs();
+}
+?>
* 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 $
***************************************************************************}
-<h1>Carnet polytechnicien</h1>
+<h1>Bilan des Notifications</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>
+<p>
+Cette page récapitule tous les évènements que tu surveilles de la semaine écoulée
+</p>
+
+<p>
+Les lignes en gras sont les événements qui ont été porté à notre connaissance
+depuis ta dernière connexion sur cette page.<br />
+Tu peux les <a href="?read={$now}">marquer comme vus</a> sans te déconnecter.
+</p>
+
+<p>
+Tu peux choisir plus finement les données affichées sur cette page.
+Il faut pour celà se rendre sur la page de <a href='notifs.php'>configuration des notifications</a>.
+</p>
+
+{dynamic}
+
+{foreach from=$notifs->_data item=c key=cid}
+<h2>{$notifs->_cats[$cid].mail} :</h2>
<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>
+<table class='tinybicol'>
+ {foreach from=$c key=p item=promo}
+ {section name=row loop=$promo}
+ <tr {if $promo[row].known > $smarty.session.watch_last}style="font-weight: bold"{/if}>
+ <td class='titre' style="width:15%">{if $smarty.section.row.first}{$p}{/if}</td>
+ <td>
+ {if $promo[row].inscrit}
+ <a href="javascript:x()" onclick="popupWin('fiche.php?user={$promo[row].forlife}','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=800,height=500')">
+ {$promo[row].prenom} {$promo[row].nom}
+ </a>
+ {if $promo[row].contact}
+ <a href="{"carnet/mescontacts.php"|url}?action=retirer&user={$promo[row].forlife}">{*
+ *}<img src="{"images/retirer.gif"|url}" alt="retirer de mes contacts" />{*
+ *}</a>
+ {else}
+ <a href="{"carnet/mescontacts.php"|url}?action=ajouter&user={$promo[row].forlife}">{*
+ *}<img src="{"images/ajouter.gif"|url}" alt="ajouter à mes contacts" />{*
+ *}</a>
+ {/if}
+ {else}
+ {$promo[row].prenom} {$promo[row].nom}
+ {/if}
</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 style="width:25%">
+ {$promo[row].date|date_format:"%d %b. %Y"}
</td>
</tr>
+ {/section}
+ {/foreach}
</table>
+<br />
+{/foreach}
+
+{/dynamic}
+
{* vim:set et sw=2 sts=2 sws=2: *}
* 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}
<img src="images/vcard.png" alt="Afficher la carte de visite" title="Afficher la carte de visite"/>
</a>
{if !$is_contact}
- <a href="javascript:x()" onclick="chgMainWinLoc('{"carnet/mescontacts.php|"url}?action=ajouter&user={$forlife}')">
+ <a href="javascript:x()" onclick="chgMainWinLoc('{"carnet/mescontacts.php"|url}?action=ajouter&user={$forlife}')">
<img src="images/ajouter.gif" alt="Ajouter à mes contacts" title="Ajouter à mes contacts" />
</a>
{else}
* 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 $
***************************************************************************}
<?xml version="1.0" encoding="iso-8859-1"?>
//-->
</script>
</td>
- <td class="inscrits">{insert name="getNbIns"} polytechniciens sur le web</td>
+ <td class="inscrits">
+ {insert name="getNbIns"} polytechniciens sur le web<br />
+ {insert name="getNbNotifs"}
+ </td>
</tr>
</table>
<img src="{"images/sk_default_lesX.gif"|url}" alt="[LES X SUR LE WEB]" />
* 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 $
***************************************************************************}
<?xml version="1.0" encoding="iso-8859-1"?>
//-->
</script>
</td>
- <td class="inscrits">{insert name="getNbIns"} polytechniciens sur le web</td>
+ <td class="inscrits">
+ {insert name="getNbIns"} polytechniciens sur le web<br />
+ {insert name="getNbNotifs"}
+ </td>
</tr>
</table>
<img src="{"images/sk_espace_lesX.gif"|url}" alt="[LES X SUR LE WEB]" />
* 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 $
***************************************************************************}
<?xml version="1.0" encoding="iso-8859-1"?>
//-->
</script>
</td>
- <td class="inscrits">{insert name="getNbIns"} polytechniciens sur le web</td>
+ <td class="inscrits">
+ {insert name="getNbIns"} polytechniciens sur le web<br />
+ {insert name="getNbNotifs"}
+ </td>
</tr>
</table>
</td>
* 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 $
***************************************************************************}
<?xml version="1.0" encoding="iso-8859-1"?>
//-->
</script>
</td>
- <td class="inscrits">{insert name="getNbIns"} polytechniciens sur le web</td>
+ <td class="inscrits">
+ {insert name="getNbIns"} polytechniciens sur le web<br />
+ {insert name="getNbNotifs"}
+ </td>
</tr>
</table>
<img src="{"images/sk_linux_lesX.jpg"|url}" alt="[LES X SUR LE WEB]" />
* 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 $
***************************************************************************}
<?xml version="1.0" encoding="iso-8859-1"?>
//-->
</script>
</td>
- <td class="inscrits">{insert name="getNbIns"} polytechniciens sur le web</td>
+ <td class="inscrits">
+ {insert name="getNbIns"} polytechniciens sur le web<br />
+ {insert name="getNbNotifs"}
+ </td>
</tr>
</table>
</td>
* 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 $
***************************************************************************}
<?xml version="1.0" encoding="iso-8859-1"?>
//-->
</script>
</td>
- <td class="inscrits">{insert name="getNbIns"} polytechniciens sur le web</td>
+ <td class="inscrits">
+ {insert name="getNbIns"} polytechniciens sur le web<br />
+ {insert name="getNbNotifs"}
+ </td>
</tr>
</table>
<img src="{"images/sk_nbviolet_lesX.gif"|url}" alt="[LES X SUR LE WEB]" />
* 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 $
***************************************************************************}
<?xml version="1.0" encoding="iso-8859-1"?>
//-->
</script>
</td>
- <td class="inscrits">{insert name="getNbIns"} polytechniciens sur le web</td>
+ <td class="inscrits">
+ {insert name="getNbIns"} polytechniciens sur le web<br />
+ {insert name="getNbNotifs"}
+ </td>
</tr>
</table>
</td>
* 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 $
***************************************************************************}
<?xml version="1.0" encoding="iso-8859-1"?>
<div class="center">
<img src="{"images/sk_sharky_ban.png"|url}" alt="[ BAN ]" />
<span>
- {insert name="getNbIns"} polytechniciens sur le web
+ {insert name="getNbIns"} polytechniciens sur le web<br />
+ {insert name="getNbNotifs"}
</span>
</div>
* 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 $
***************************************************************************}
<?xml version="1.0" encoding="iso-8859-1"?>
//-->
</script>
</td>
- <td class="inscrits">{insert name="getNbIns"} polytechniciens sur le web</td>
+ <td class="inscrits">
+ {insert name="getNbIns"} polytechniciens sur le web<br />
+ {insert name="getNbNotifs"}
+ </td>
</tr>
</table>
<img src="{"images/sk_oldtimes_lesX.gif"|url}" alt="[LES X SUR LE WEB]" />
* 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 $
***************************************************************************}
<?xml version="1.0" encoding="iso-8859-1"?>
//-->
</script>
</td>
- <td class="inscrits">{insert name="getNbIns"} polytechniciens sur le web</td>
+ <td class="inscrits">
+ {insert name="getNbIns"} polytechniciens sur le web<br />
+ {insert name="getNbNotifs"}
+ </td>
</tr>
</table>
</td>
* 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 $
***************************************************************************}
<?xml version="1.0" encoding="iso-8859-1"?>
//-->
</script>
</td>
- <td class="inscrits">{insert name="getNbIns"} polytechniciens sur le web</td>
+ <td class="inscrits">
+ {insert name="getNbIns"} polytechniciens sur le web<br />
+ {insert name="getNbNotifs"}
+ </td>
</tr>
</table>
<img src="{"images/sk_spectral_lesX.jpg"|url}" alt="[LES X SUR LE WEB]" />
* 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 $
***************************************************************************}
<?xml version="1.0" encoding="iso-8859-1"?>
//-->
</script>
</td>
- <td class="inscrits">{insert name="getNbIns"} polytechniciens sur le web</td>
+ <td class="inscrits">
+ {insert name="getNbIns"} polytechniciens sur le web<br />
+ {insert name="getNbNotifs"}
+ </td>
</tr>
</table>
<img src="{"images/sk_trapped_lesX.gif"|url}" alt="[LES X SUR LE WEB]" />