<?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 *
// }}}
// {{{ 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);
}
Platal::session()->updateNbNotifs();
}
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);