X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;ds=sidebyside;f=include%2Fnotifs.inc.php;h=d48f010a2da3849a283bb35f26fa1dc55e4bc11d;hb=460d8f5533ac4dff9d0df95efe11c399228b8637;hp=74348ebd3a83e9ffdbe87f5b0e71ec311173a47b;hpb=3ebe4a0a4465cd6660a19a6cd688f7c0fb307fee;p=platal.git diff --git a/include/notifs.inc.php b/include/notifs.inc.php index 74348eb..d48f010 100644 --- a/include/notifs.inc.php +++ b/include/notifs.inc.php @@ -1,6 +1,6 @@ Array('wfield' => 'contact', - 'ufield' => 'user_id', - 'freq_sql' => '', - 'where' => 'AND (q.watch_flags=1 OR q.watch_flags=3)' - ), - 'watch_promo' => Array('wfield' => 'promo', - 'ufield' => 'promo', - 'freq_sql' => ' AND ( wc.type = "basic" OR wc.type="near" - AND (u.promo <= v.promo_sortie-2 AND u.promo_sortie >= v.promo+2) )', - 'where' => '', - ), - 'watch_nonins' => Array('wfield' => 'ni_id', - 'ufield' => 'user_id', - 'freq_sql' => '', - 'where' => '', - ) - ); - $our = $cases[$table]; - $sql = " - ( - SELECT COUNT(1) AS count - FROM $table AS w - INNER JOIN auth_user_md5 AS u ON(u.{$our['ufield']} = w.{$our['wfield']}) - INNER JOIN auth_user_quick AS q ON(q.user_id = w.uid) - INNER JOIN auth_user_md5 AS v ON(v.user_id = q.user_id) - INNER JOIN watch_ops AS wo ON(wo.uid = u.user_id AND wo.known > q.watch_last) - INNER JOIN watch_sub AS ws ON(ws.cid = wo.cid AND ws.uid = w.uid) - INNER JOIN watch_cat AS wc ON(wc.id = wo.cid{$our['freq_sql']}) - WHERE w.uid = {?} {$our['where']} - )"; - return $sql; + Platal::session()->updateNbNotifs(); } // }}} @@ -115,7 +81,7 @@ function _select_notifs_base($table, $mail, $where) $sql = " ( SELECT u.promo, u.prenom, IF(u.nom_usage='',u.nom,u.nom_usage) AS nom, - u.deces != 0 AS dcd, + u.deces != 0 AS dcd, (u.flags = 'femme') AS sexe, a.alias AS bestalias, wo.*, {$our['contact_sql']} AS contact, @@ -123,7 +89,7 @@ function _select_notifs_base($table, $mail, $where) if ($mail) { $sql.=", w.uid AS aid, v.prenom AS aprenom, IF(v.nom_usage='',v.nom,v.nom_usage) AS anom, - b.alias AS abestalias, (v.flags='femme') AS sexe, q.core_mail_fmt AS mail_fmt"; + b.alias AS abestalias, (v.flags='femme') AS asexe, q.core_mail_fmt AS mail_fmt"; } $sql .= " @@ -169,29 +135,51 @@ function select_notifs($mail, $uid=null, $last=null, $iterator=true) } // }}} -// {{{ function getNbNotifs - -function getNbNotifs() -{ - if (!S::has('uid')) { - return 0; - } - $uid = S::i('uid'); - - // selectionne les notifs de uid, sans detail sur le watcher, depuis - // $watchlast, meme ceux sans surveillance, non ordonnés - $res = XDB::query(_select_notifs_count('contacts') . ' UNION ' - . _select_notifs_count('watch_promo') . ' UNION ' - . _select_notifs_count('watch_nonins'), $uid, $uid, $uid); - $n = array_sum($res->fetchColumn()); - if ($n == 0) { - return; +// {{{ + +global $prf_desc; +$prf_desc = array('nom' => 'Son patronyme', + 'freetext' => 'Le texte libre', + 'mobile' => 'Son numéro de téléphone portable', + 'nationalite' => 'Sa nationalité', + 'nick' => 'Son surnom', + 'web' => 'L\'adresse de son site web', + 'appli1' => 'Son école d\'application', + 'appli2' => 'Son école de post-application', + 'addresses' => 'Ses adresses', + 'section' => 'Sa section sportive', + 'binets' => 'La liste de ses binets', + 'medals' => 'Ses décorations', + 'cv' => 'Son Curriculum Vitae', + 'jobs' => 'Ses informations professionnelles', + 'photo' => 'Sa photographie'); + +function get_profile_change_details($event, $limit) { + global $prf_desc; + $res = XDB::iterRow("SELECT field + FROM watch_profile + WHERE uid = {?} AND ts > {?} + ORDER BY ts DESC", + $event['uid'], $limit); + if ($res->total() > 0) { + $data = array(); + while (list($field) = $res->next()) { + $data[] .= $prf_desc[$field]; + } + return '