Fix many small issues with the "carnet"
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Sat, 6 Oct 2007 20:38:59 +0000 (22:38 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Sat, 6 Oct 2007 20:38:59 +0000 (22:38 +0200)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
include/notifs.inc.php
modules/admin.php
modules/profile/page.inc.php

index c74a0d6..74348eb 100644 (file)
@@ -103,11 +103,11 @@ function _select_notifs_base($table, $mail, $where)
         ),
         'watch_promo'  => Array('wfield' => 'promo',   'ufield' => 'promo',   'need_contact' => true,
             'freq_sql' => ' AND ( wc.type = "basic" OR wc.type="near" AND (u.promo <= v.promo_sortie-2 AND u.promo_sortie >= v.promo+2) )',
-            'contact_sql' => 'NOT (c.contact IS NULL)'
+            'contact_sql' => 'IF(c.contact IS NULL, 0, 1)'
         ),
-        'watch_nonins' => Array('wfield' => 'ni_id',   'ufield' => 'user_id', 'need_contact' => false,
+        'watch_nonins' => Array('wfield' => 'ni_id',   'ufield' => 'user_id', 'need_contact' => true,
             'freq_sql' => '',
-            'contact_sql' => '0'
+            'contact_sql' => 'IF(c.contact IS NULL, 0, 1)'
         )
     );
 
@@ -276,8 +276,8 @@ class Watch
         $this->_nonins = new NoninsNotifs($uid);
         $this->_subs = new WatchSub($uid);
         $res = XDB::query("SELECT  FIND_IN_SET('contacts',watch_flags),FIND_IN_SET('mail',watch_flags)
-            FROM  auth_user_quick
-            WHERE  user_id={?}", $uid);
+                             FROM  auth_user_quick
+                            WHERE  user_id={?}", $uid);
         list($this->watch_contacts,$this->watch_mail) = $res->fetchOneRow();
 
         $res = XDB::iterator("SELECT * FROM watch_cat");
@@ -450,12 +450,12 @@ class NoninsNotifs
     public function del($p)
     {
         unset($this->_data["$p"]);
-        XDB::execute('DELETE FROM watch_nonins WHERE uid={?} AND ni_id={?}', $this->_uid, $p);
+        XDB::execute('DELETE FROM  watch_nonins WHERE uid={?} AND ni_id={?}', $this->_uid, $p);
     }
 
     public function add($p)
     {
-        XDB::execute('INSERT INTO watch_nonins (uid,ni_id) VALUES({?},{?})', $this->_uid, $p);
+        XDB::execute('INSERT 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);
index 99e594a..7b97b37 100644 (file)
@@ -566,6 +566,8 @@ class AdminModule extends PLModule
                             set_new_usage($mr['user_id'], Env::v('nomusageN'), make_username(Env::v('prenomN'), Env::v('nomusageN')));
                         }
                         if (Env::v('decesN') != $mr['deces']) {
+                            require_once 'notifs.inc.php';
+                            register_watch_op($mr['user_id'], WATCH_DEATH, $mr['deces']);
                             user_clear_all_subs($mr['user_id'], false);
                         }
                         $r = XDB::query("SELECT *, a.alias AS forlife,
index a7dada8..74b3560 100644 (file)
@@ -248,6 +248,10 @@ abstract class ProfilePage implements PlWizardPage
         // Update the last modification date
         XDB::execute('REPLACE INTO  user_changes
                                SET  user_id = {?}', S::v('uid'));
+        if (!S::has('suid')) {
+            require_once 'notifs.inc.php';
+            register_watch_op(S::i('uid'), WATCH_FICHE);
+        }
         global $platal;
         $log =& $_SESSION['log'];
         $log->log('profil', $platal->pl_self(1));