Merge commit 'origin/master' into fusionax
[platal.git] / include / notifs.inc.php
index 95ae89c..cf3023d 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
+ *  Copyright (C) 2003-2009 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -34,28 +34,35 @@ function inscription_notifs_base($uid)
 // }}}
 // {{{ function register_watch_op
 
-function register_watch_op($uid, $cid, $date='', $info='')
+function register_watch_op($uid, $cid, $date = '', $info = '')
 {
     if (empty($date)) {
         $date = date('Y-m-d');
-    };
-    XDB::execute('REPLACE INTO  watch_ops (uid,cid,known,date,info)
+    }
+    XDB::execute('REPLACE INTO  watch_ops (uid, cid, known, date, info)
                         VALUES  ({?}, {?}, NOW(), {?}, {?})',
                  $uid, $cid, $date, $info);
-    if($cid == WATCH_FICHE) {
+    if ($cid == WATCH_FICHE) {
         if ($info) {
             register_profile_update($uid, $info);
         }
-        XDB::execute('UPDATE auth_user_md5 SET DATE=NOW() WHERE user_id={?}', $uid);
-    } elseif($cid == WATCH_INSCR) {
-        XDB::execute('REPLACE INTO  contacts (uid,contact)
-                            SELECT  uid,ni_id
+        XDB::execute('UPDATE  auth_user_md5
+                         SET  DATE = NOW()
+                       WHERE  user_id = {?}', $uid);
+    } elseif ($cid == WATCH_INSCR) {
+        XDB::execute('REPLACE INTO  contacts (uid, contact)
+                            SELECT  uid, ni_id
                               FROM  watch_nonins
-                             WHERE  ni_id={?}', $uid);
-        XDB::execute('DELETE FROM watch_nonins WHERE ni_id={?}', $uid);
+                             WHERE  ni_id = {?}', $uid);
+        XDB::execute('DELETE FROM  watch_nonins
+                            WHERE  ni_id = {?}', $uid);
+    } elseif ($cid == WATCH_DEATH) {
+        // We delete nonins watches both for the dead (if non registered), and
+        // for people watched by the dead.
+        XDB::execute('DELETE FROM  watch_nonins
+                            WHERE  ni_id = {?} OR uid = {?}', $uid);
     }
-    require_once 'xorg.misc.inc.php';
-    update_NbNotifs();
+    Platal::session()->updateNbNotifs();
 }
 
 // }}}
@@ -82,7 +89,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,
@@ -90,7 +97,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 .= "
@@ -139,19 +146,21 @@ function select_notifs($mail, $uid=null, $last=null, $iterator=true)
 // {{{
 
 global $prf_desc;
-$prf_desc = array('nom' => 'Son patronyme',
+$prf_desc = array('search_names' => 'L\'un de ses noms',
                   'freetext' => 'Le texte libre',
                   'mobile' => 'Son numéro de téléphone portable',
                   'nationalite' => 'Sa nationalité',
+                  'nationalite2' => 'Sa seconde nationalité',
+                  'nationalite3' => 'Sa troisième nationalité',
                   'nick' => 'Son surnom',
-                  'web' => 'L\'adresse de son site web',
-                  'appli1' => 'Son école d\'application',
-                  'appli2' => 'Son école de post-application',
+                  'networking' => 'La liste de ses adresses de networking',
+                  'edus' => 'Ses formations',
                   'addresses' => 'Ses adresses',
                   'section' => 'Sa section sportive',
                   'binets' => 'La liste de ses binets',
                   'medals' => 'Ses décorations',
                   'cv' => 'Son Curriculum Vitae',
+                  'corps' => 'Son Corps d\'État',
                   'jobs' => 'Ses informations professionnelles',
                   'photo' => 'Sa photographie');
 
@@ -203,10 +212,10 @@ class AllNotifs
             $aid = $tmp['aid'];
             if (empty($this->_data[$aid])) {
                 $this->_data[$aid] = Array("prenom" => $tmp['aprenom'], 'nom' => $tmp['anom'],
-                    'bestalias'=>$tmp['abestalias'], 'sexe' => $tmp['sexe'], 'mail_fmt' => $tmp['mail_fmt'],
+                    'bestalias'=>$tmp['abestalias'], 'sexe' => $tmp['asexe'], 'mail_fmt' => $tmp['mail_fmt'],
                     'dcd'=>$tmp['dcd']);
             }
-            unset($tmp['aprenom'], $tmp['anom'], $tmp['abestalias'], $tmp['aid'], $tmp['sexe'], $tmp['mail_fmt'], $tmp['dcd']);
+            unset($tmp['aprenom'], $tmp['anom'], $tmp['abestalias'], $tmp['aid'], $tmp['asexe'], $tmp['mail_fmt'], $tmp['dcd']);
             $this->_data[$aid]['data'][$tmp['cid']][] = $tmp;
         }
     }
@@ -447,7 +456,7 @@ class NoninsNotifs
 
     public function add($p)
     {
-        XDB::execute('INSERT INTO  watch_nonins (uid,ni_id) VALUES({?},{?})', $this->_uid, $p);
+        XDB::execute('INSERT IGNORE INTO  watch_nonins (uid,ni_id) VALUES({?},{?})', $this->_uid, $p);
         $res = XDB::query('SELECT  prenom,IF(nom_usage="",nom,nom_usage) AS nom,promo,user_id
                              FROM  auth_user_md5
                             WHERE  user_id={?}', $p);